Skip to content

Fix: PerlLanguageProvider.executePerlCode terminates JVM on exit()#294

Merged
fglock merged 1 commit intomasterfrom
fix-exit-terminates-jvm
Mar 10, 2026
Merged

Fix: PerlLanguageProvider.executePerlCode terminates JVM on exit()#294
fglock merged 1 commit intomasterfrom
fix-exit-terminates-jvm

Conversation

@fglock
Copy link
Owner

@fglock fglock commented Mar 10, 2026

Summary

Fixes #291 - PerlLanguageProvider.executePerlCode was terminating the entire JVM when Perl code called exit(), preventing library/embedded use.

Changes:

  • Add PerlExitException class for Perl's exit() semantics
  • WarnDie.exit() now throws PerlExitException instead of System.exit()
  • Main.main() catches PerlExitException and converts to System.exit() for CLI use
  • exit() is never caught by Perl's eval{} (matching standard Perl behavior)
  • Both JVM compiler and interpreter backends handle this correctly
  • END blocks still run before exit (matching standard Perl)

Documentation:

  • Updated docs/guides/java-integration.md with "Handling Script Exit" section

Test plan

  • Unit tests for PerlExitException (exit 0, exit N, exit inside eval)
  • CLI exit still works with correct exit codes
  • END blocks run before exit
  • Both JVM and interpreter backends tested

Generated with Devin

Previously, when Perl code called exit(), it would call System.exit()
and terminate the entire JVM. This prevented library/embedded use where
the caller wants to continue execution after the script completes.

Changes:
- Add PerlExitException class for Perl's exit() semantics
- WarnDie.exit() now throws PerlExitException instead of System.exit()
- Main.main() catches PerlExitException and converts to System.exit()
- exit() is never caught by Perl's eval{} (matching standard Perl)
- Both JVM compiler and interpreter backends handle this correctly
- END blocks still run before exit (matching standard Perl)

Documentation:
- Updated docs/guides/java-integration.md with "Handling Script Exit" section

Fixes #291

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <noreply@cognition.ai>
@fglock fglock merged commit 2560cf7 into master Mar 10, 2026
2 checks passed
@fglock fglock deleted the fix-exit-terminates-jvm branch March 10, 2026 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PerlLanguageProvider.executePerlCode terminates program

1 participant