feat(Class::C3::XS): pure-Perl shim so jcpan -t Class::C3::XS passes#620
Merged
feat(Class::C3::XS): pure-Perl shim so jcpan -t Class::C3::XS passes#620
Conversation
Class::C3::XS is XS-only (the dist's lib/Class/C3/XS.pm is just an
XSLoader::load + a few next:: dispatch subs). Without XS, the test
suite fails 12/13 with "Can't load loadable object". Provide a
pure-Perl shim:
src/main/perl/lib/Class/C3/XS.pm
implementing the four exported subs on top of core mro:
- calculateMRO -> mro::get_linear_isa($class, 'c3')
- _plsubgen -> monotonically increasing counter
- _calculate_method_dispatch_table -> no-op (core mro handles c3)
- _nextcan -> walks caller() up past next::/maybe::next::
frames, then searches the C3 MRO from the
calling package onward.
Also re-define next::can / next::method / maybe::next::method to
delegate to _nextcan, mirroring what the dist's pm does. PerlOnJava's
MakeMaker shim skips installing the dist's pm (it's superseded by the
bundled jar shim), so these definitions have to live here for tests
like t/36_next_goto.t (`goto &next::can`) to work.
In XSLoader.java, when the existing @isa / ::PP fallback paths don't
apply, try loading a bundled jar:PERL5LIB shim of the same name. This
generalises the existing loadJarShimOverrides hook so any future XS
module can be backed by dropping a .pm into src/main/perl/lib/.
loadJarShimOverrides now returns boolean to signal whether a shim was
found.
Result: jcpan -t Class::C3::XS passes 46/46 tests across 13 files.
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
jcpan -t Class::C3::XSwas failing 12/13 test files with:Class::C3::XS is XS-only — the dist's
lib/Class/C3/XS.pmis just anXSLoader::load(...)plus a fewnext::*dispatch subs. The four functions it exports map cleanly onto coremro(5.9.5+), so this PR adds a pure-Perl shim and a generalised XSLoader hook to load it.Changes
New
src/main/perl/lib/Class/C3/XS.pm— pure-Perl shim:calculateMRO→mro::get_linear_isa($class, 'c3')_plsubgen→ monotonic counter (only consulted for cache invalidation)_calculate_method_dispatch_table→ no-op (core mro handles C3 dispatch)_nextcan→ walkscaller()pastnext::/maybe::next::frames, then searches the C3 MRO from the calling package onwardnext::can,next::method,maybe::next::method(PerlOnJava's MakeMaker skips installing the dist's pm because it's superseded by the bundled jar shim, so these have to live here forgoto &next::canint/36_next_goto.t)XSLoader.java— when the existing@ISA/::PPfallback paths don't apply, try loading a bundledjar:PERL5LIBshim of the same name.loadJarShimOverridesnow returnsbooleanto signal whether a shim was actually found. This generalises the existing hook so any future XS-only module can be supported by dropping a.pmintosrc/main/perl/lib/.Test plan
make(full unit suite) — green./jcpan -t Class::C3::XS—Files=13, Tests=46, Result: PASSt/01_MRO.t…t/05_MRO.t,t/30_next_method.t…t/36_next_goto.tGenerated with Devin