From 0970b8c812971181a637f978d0f2239785c37a60 Mon Sep 17 00:00:00 2001 From: "Flavio S. Glock" Date: Wed, 11 Mar 2026 22:29:04 +0100 Subject: [PATCH 1/2] Add POSIX::strftime and POSIX::mktime Perl wrappers The Java implementations for strftime and mktime already exist in POSIX.java (registered as _strftime and _mktime), but the Perl wrapper functions were missing from POSIX.pm, causing "Undefined subroutine" errors when calling these functions. This fixes ExifTool Writer test 23 which uses DateFormat option (internally calls POSIX::strftime for date formatting). Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin --- src/main/perl/lib/POSIX.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/perl/lib/POSIX.pm b/src/main/perl/lib/POSIX.pm index 1a13dde1c..c93821e4d 100644 --- a/src/main/perl/lib/POSIX.pm +++ b/src/main/perl/lib/POSIX.pm @@ -232,6 +232,8 @@ sub chdir { POSIX::_chdir(@_) } sub time { POSIX::_time() } sub sleep { POSIX::_sleep(@_) } sub alarm { POSIX::_alarm(@_) } +sub strftime { POSIX::_strftime(@_) } +sub mktime { POSIX::_mktime(@_) } # Math functions (many can use Perl builtins) sub abs { CORE::abs($_[0]) } From d205d4039c73c6b14df29438108ea22fa25850b8 Mon Sep 17 00:00:00 2001 From: "Flavio S. Glock" Date: Wed, 11 Mar 2026 22:37:21 +0100 Subject: [PATCH 2/2] Handle InterpreterFallbackException in createRuntimeCode When ASM frame computation crashes during JVM bytecode generation, getBytecode() throws InterpreterFallbackException with the already- compiled InterpretedCode. Previously, createRuntimeCode() did not catch this exception specifically, so it propagated up to eval STRING handlers which treated it as a compilation error. This fix catches InterpreterFallbackException and returns its interpretedCode directly, allowing subroutines like IPTC::IptcTime to work correctly even when they trigger ASM crashes. Fixes ExifTool MWG test 3 (IPTC:TimeCreated was retaining original value instead of being updated because SetNewValue was failing). Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin --- .../org/perlonjava/backend/jvm/EmitterMethodCreator.java | 6 ++++++ .../org/perlonjava/runtime/runtimetypes/RuntimeCode.java | 1 + 2 files changed, 7 insertions(+) diff --git a/src/main/java/org/perlonjava/backend/jvm/EmitterMethodCreator.java b/src/main/java/org/perlonjava/backend/jvm/EmitterMethodCreator.java index 915eb8aec..42626fe7d 100644 --- a/src/main/java/org/perlonjava/backend/jvm/EmitterMethodCreator.java +++ b/src/main/java/org/perlonjava/backend/jvm/EmitterMethodCreator.java @@ -1480,6 +1480,12 @@ public static RuntimeCode createRuntimeCode( return compileToInterpreter(ast, ctx, useTryCatch); } throw e; + } catch (InterpreterFallbackException e) { + // InterpreterFallbackException already carries the InterpretedCode + if (SHOW_FALLBACK) { + System.err.println("Note: Using interpreter fallback (ASM frame compute crash)."); + } + return e.interpretedCode; } catch (RuntimeException e) { if (USE_INTERPRETER_FALLBACK && needsInterpreterFallback(e)) { if (SHOW_FALLBACK) { diff --git a/src/main/java/org/perlonjava/runtime/runtimetypes/RuntimeCode.java b/src/main/java/org/perlonjava/runtime/runtimetypes/RuntimeCode.java index db229846b..619e8b3a8 100644 --- a/src/main/java/org/perlonjava/runtime/runtimetypes/RuntimeCode.java +++ b/src/main/java/org/perlonjava/runtime/runtimetypes/RuntimeCode.java @@ -7,6 +7,7 @@ import org.perlonjava.backend.bytecode.InterpreterState; import org.perlonjava.backend.jvm.EmitterContext; import org.perlonjava.backend.jvm.EmitterMethodCreator; +import org.perlonjava.backend.jvm.InterpreterFallbackException; import org.perlonjava.backend.jvm.JavaClassInfo; import org.perlonjava.frontend.astnode.Node; import org.perlonjava.frontend.astnode.OperatorNode;