fix: make DynaLoader::bootstrap delegate to XSLoader::load fallback chain#493
Merged
fix: make DynaLoader::bootstrap delegate to XSLoader::load fallback chain#493
Conversation
…hain DynaLoader::bootstrap() previously always died with "Can't load module", making all DynaLoader-based XS modules (Image::Magick, Tk, etc.) fail immediately at load time. XSLoader::load() already had a sophisticated multi-stage fallback (Java class -> @isa parent -> ::PP companion -> die with detectable error pattern). Changes: - DynaLoader.java: delegate bootstrap() to XSLoader.load() instead of unconditionally dying - DynaLoader.pm: Perl-side fallback also delegates to XSLoader::load - ImageMagick.java: stub Java class with no-op UNLOAD() and constant() so Image::Magick loads cleanly and objects can be created Before: use Image::Magick dies with "Can't load module Image::Magick" After: use Image::Magick succeeds; new() creates objects; eval-based optional dependency checks work correctly Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
6f8edf8 to
6227163
Compare
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
DynaLoader::bootstrap()previously always died with"Can't load module", making all DynaLoader-based XS modules fail immediately at load time. This prevented modules like Image::Magick, Tk, and others that useDynaLoaderinstead ofXSLoaderfrom loading at all.Meanwhile,
XSLoader::load()already had a sophisticated multi-stage fallback:@ISAhas functional parent → return true (inheritance fallback)::PPcompanion loaded → return true"Can't load loadable object..."(matches/loadable object/pattern for CPAN fallback detection)Changes
bootstrap()toXSLoader.load()instead of unconditionally dyingXSLoader::loadUNLOAD()andconstant()so Image::Magick loads cleanlyBefore / After
use Image::Magick"Can't load module Image::Magick"Image::Magick->neweval { require Image::Magick }$@, module unusable$@empty"Can't load module"(non-standard)"Can't load loadable object..."(matches CPAN fallback pattern)Impact
This fix improves CPAN compatibility broadly — any module using
DynaLoaderinstead ofXSLoadernow gets the same fallback behavior. The Image::Magick stub specifically enables the module to load and create objects; actual image operations require a future Java backend (e.g., viajavax.imageio).Test plan
makepasses (all unit tests)use Image::Magickloads without errorImage::Magick->newcreates objectseval { require Image::Magick }works for optional dependency checksjcpan Image::Magickreports "up to date"jcpan -t Image::Magicktests run (fail on missing backend, not on load)Generated with Devin