Add XS fallback mechanism and DateTime Java implementation#337
Merged
Conversation
This enables CPAN modules with XS code to work on PerlOnJava: 1. XSLoader: Error message now matches /loadable object/ pattern - Modules like DateTime catch this and use their PP fallback - Unmodified .pm files work correctly 2. MakeMaker: Always installs .pm files for XS modules - Prints warning that XS cannot be compiled - Runtime decides: Java XS → PP fallback → error 3. DateTime.java: Full Java XS implementation - Uses java.time.JulianFields.RATA_DIE for Rata Die calculations - Uses java.time.Year.isLeap() for leap year checking - Custom leap seconds table for _day_length functions - All 10 XS functions implemented Design document: dev/design/xs_fallback.md Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
- Add jcpan as the primary installation method - Document the XS fallback mechanism (Java XS -> PP fallback -> error) - Update built-in Java implementations table - Clarify module compatibility and troubleshooting - Remove outdated XS handling information Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
- Add XS_VERSION constant to DateTime.java (1.65) - XSLoader::load now checks version if provided as second argument - Warns (to stderr) if major versions differ, but continues loading - Modules without XS_VERSION skip the check silently - Compatible versions (same major) produce no warning Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
- Create docs/reference/xs-compatibility.md with: - Modules with Java XS implementations - Modules with built-in PP fallbacks - Guide for adding new Java XS implementations - Update using-cpan-modules.md to reference the new doc - Add DateTime to built-in Java implementations table Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
- docs/README.md: Add XS Compatibility to Reference section - docs/guides/using-cpan-modules.md: Add See Also section - docs/guides/module-porting.md: Add See Also section - docs/reference/feature-matrix.md: Link to xs-compatibility.md - docs/reference/xs-compatibility.md: Expand See Also section Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Socket.java: - Add SO_ERROR, IPPROTO_IP, IPPROTO_IPV6, IP_TOS, IP_TTL constants - Add getnameinfo() function - Use empty prototype '' for constants (fixes parser issue with ternary) Socket.pm: - Export new constants and getnameinfo Net/Ping.pm: - Import from perl5 core (required by CPAN::Mirrors) - Added to dev/import-perl5/config.yaml CPAN/Config.pm (new): - Default CPAN configuration for PerlOnJava - Uses ~/.perlonjava/cpan for CPAN home (consistent with other paths) - Works cross-platform (Windows/Unix) - No first-time configuration required Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
These modules already have pure Perl fallback when XS is unavailable, so they do not need protection - they work unmodified in PerlOnJava: - Unicode/Normalize.pm - Data/Dumper.pm - Sys/Hostname.pm Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
eada4c6 to
1db8a80
Compare
Create Unix.pm.patch to add jar: path recognition in file_name_is_absolute(). This allows sync.pl to keep the file in sync with upstream while applying the PerlOnJava-specific modification. Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Phase 11 investigation found:
- DateTime fails due to dependency chain issues
- Root cause: ${ $Package::{NAME} } returns empty instead of value
- This blocks Module::Implementation -> Specio -> DateTime
- Also B::Hooks::EndOfScope (XS) blocks namespace::autoclean
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Bug: ${ $Foo::{NAME} } returned empty instead of the variable value.
This blocked Module::Implementation, Specio, and DateTime dependency chain.
Fix: Added GLOB case to scalarDeref() and scalarDerefNonStrict() in
RuntimeScalar.java to return the scalar slot when dereferencing a glob.
Now working:
- Module::Implementation
- Specio
- Params::ValidationCompiler
Still blocked (documented in xsloader.md):
- B::Hooks::EndOfScope (XS module, needs stub)
- namespace::autoclean (depends on B::Hooks::EndOfScope)
- DateTime full install (depends on namespace::autoclean)
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Uses PerlOnJava's existing defer infrastructure:
- DeferBlock wraps callback for scope-exit execution
- DynamicVariableManager manages deferred block stack
- Callbacks execute in LIFO order (same as Perl)
Files added:
- BHooksEndOfScope.java - Java XS implementation
- B/Hooks/EndOfScope.pm - Perl wrapper with XSLoader
Limitation: requires on_scope_end(sub { }) syntax instead of
on_scope_end { } bare block. Parser special-case could fix this.
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
on_scope_end { BLOCK } now works correctly with the & prototype.
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
This PR enables CPAN modules with XS code to work on PerlOnJava through automatic fallback mechanisms.
Core Changes
/loadable object/pattern that modules expect for PP fallbackDateTime Java Implementation
Full Java XS implementation using
java.timeAPIs:JulianFields.RATA_DIEfor Rata Die calculationsYear.isLeap()for leap year checkingDocumentation
docs/reference/xs-compatibility.md- Central reference for XS module compatibilitydocs/guides/using-cpan-modules.md- Added jcpan, XS fallback mechanismFiles Changed
Java:
XSLoader.java- Error message + version checkingDateTime.java- New Java XS implementationPerl:
MakeMaker.pm- Simplified XS module handlingDocs:
docs/reference/xs-compatibility.md(new)docs/guides/using-cpan-modules.mddocs/guides/module-porting.mddocs/reference/feature-matrix.mddocs/README.mdHow It Works
Test Plan
make)Generated with Devin