Skip to content

Add Sub::Name module and fix @INC hook exception handling#324

Merged
fglock merged 2 commits into
masterfrom
feature/sub-name
Mar 16, 2026
Merged

Add Sub::Name module and fix @INC hook exception handling#324
fglock merged 2 commits into
masterfrom
feature/sub-name

Conversation

@fglock
Copy link
Copy Markdown
Owner

@fglock fglock commented Mar 16, 2026

Summary

  • Add Sub::Name module (Java implementation using XSLoader)
  • Fix @inc hook exception handling to propagate die() errors

Sub::Name Implementation

Sub::Name::subname(NAME, CODEREF) sets the name of a subroutine for debugging/caller purposes. This is equivalent to Sub::Util::set_subname().

Files added:

  • src/main/java/org/perlonjava/runtime/perlmodule/SubName.java - Java implementation
  • src/main/perl/lib/Sub/Name.pm - Perl wrapper using XSLoader

@inc Hook Fix

Before: When an @inc hook threw an exception (via die()), the exception was caught and ignored, continuing to search subsequent @inc entries.

After: Exceptions from @inc hooks are propagated, matching Perl's behavior.

This fix is required for InlineModule (used by Moo tests) which relies on die() in hooks to hide modules during testing.

Test plan

  • make passes (all unit tests)
  • moo-utils-_subname-Sub-Name.t passes (was failing before)
  • moo-utils-_subname.t passes
  • Manual test: ./jperl -e 'use Sub::Name; subname("Foo::bar", sub {})' works

Generated with Devin

fglock and others added 2 commits March 16, 2026 12:00
- Add SubName.java: Java implementation of Sub::Name::subname()
- Add Sub/Name.pm: Perl wrapper using XSLoader
- Fix ModuleOperators.java: Propagate exceptions from @inc hooks

The @inc hook fix is required because InlineModule (used by Moo tests)
relies on die() in hooks to hide modules. Previously, exceptions were
caught and ignored, causing require to continue searching.

Sub::Name::subname(NAME, CODE) is equivalent to Sub::Util::set_subname()
and is used by Moo for debugging/caller information.

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

Co-Authored-By: Devin <noreply@cognition.ai>
- Add Phase 26: Sub::Name module and @inc hook fix
- Remove moo-utils-_subname-Sub-Name.t from expected failures
- Update test counts: 63/71 Moo tests passing

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

Co-Authored-By: Devin <noreply@cognition.ai>
@fglock fglock merged commit e3ea074 into master Mar 16, 2026
2 checks passed
@fglock fglock deleted the feature/sub-name branch March 16, 2026 11:13
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.

1 participant