Skip to content

Fix: Sync latest Perl5 modules and restore Data::Dumper numified scalar handling#866

Merged
fglock merged 1 commit into
masterfrom
fix/perl5-sync-data-dumper-numified
Jul 9, 2026
Merged

Fix: Sync latest Perl5 modules and restore Data::Dumper numified scalar handling#866
fglock merged 1 commit into
masterfrom
fix/perl5-sync-data-dumper-numified

Conversation

@fglock

@fglock fglock commented Jul 9, 2026

Copy link
Copy Markdown
Owner

Summary

This PR syncs the latest Perl5 modules, updates dependencies, and fixes Data::Dumper's handling of numified scalars to match Perl5's XS behavior.

Changes

1. Perl5 Module Sync

Updated modules to latest versions from perl5/ tree:

  • Archive::Tar and related modules (Tar.pm, Constant.pm, File.pm)
  • IO::Socket::IP - socket handling improvements
  • NEXT - legacy method dispatch updates
  • Pod documentation - perldelta, perlclass, perlclassguts, perldebug, perlexperiment, perlhist, perlinterp, perlintro, perllocale, perlmodinstall, perlpolicy, perlvar
  • Test::Builder - test framework improvements
  • vars.pm - variable declaration pragma updates

2. Dependency Updates

  • ASM: 9.9.1 → 9.10.1
  • BouncyCastle: 1.78.1 → 1.84
  • Commons Compress: 1.27.1 → 1.28.0
  • JUnit Jupiter: 6.1.0-M1 → 6.1.1
  • SQLite JDBC: 3.51.3.0 → 3.53.2.0

3. Data::Dumper Numeric Scalar Detection

The Problem

The test unit/data_dumper_numified.t was failing because Data::Dumper was outputting numeric values as quoted strings:

my $literal = 1556933584;
# Expected: 1556933584
# Got:      "1556933584"

Root Cause Analysis:

  • Perl5's XS Data::Dumper checks internal SV flags (IOK/NOK) to detect numeric scalars
  • Perl5's pure Perl Data::Dumper only uses a regex: /^(?:0|-?[1-9][0-9]{0,8})\z/
  • This regex only matches numbers with 0-8 digits after the first digit (max 9 total digits)
  • 10+ digit numbers are quoted even if they're numeric literals
  • Pure Perl Perl5 has the same limitation - we verified this!
# Perl5 with pure Perl Data::Dumper:
$ perl -MData::Dumper -e '$Data::Dumper::Useperl=1; print Dumper(1556933584)'
$VAR1 = '1556933584';  # QUOTED!

# Perl5 with XS Data::Dumper:
$ perl -MData::Dumper -e 'print Dumper(1556933584)'
$VAR1 = 1556933584;  # Not quoted

The Solution

1. Improved RuntimeScalar.isDataDumperNumifiedSafeDecimal():

  • INTEGER/DOUBLE types immediately return true (mimics Perl5's IOK/NOK flags)
  • No longer restricted to 10-digit numbers
  • Handles any size numeric scalar
  • Properly validates negative numbers and zero
  • Checks numified strings more accurately

2. Data::Dumper patch (Data-Dumper.pm.patch):

  • Adds a check for _perlonjava_numified_safe_decimal() before the regex
  • This method calls the improved RuntimeScalar implementation
  • Bridges the gap between pure Perl limitations and XS capabilities
  • Makes PerlOnJava's pure Perl Data::Dumper behave like Perl5's XS version

Why This Approach Works

PerlOnJava has an advantage: we can expose scalar type information (INTEGER, DOUBLE, STRING) that pure Perl Perl5 cannot access. By adding a hook in Data::Dumper's pure Perl code that calls back to our Java type system, we achieve XS-like behavior without needing actual XS code.

This is the correct solution because:

  • It matches Perl5 XS behavior, not the limited pure Perl behavior
  • The patch is necessary because pure Perl lacks access to internal type flags
  • Future Perl5 syncs will automatically reapply the patch
  • No special cases or workarounds in the numeric detection logic

Test Plan

  • Unit test unit/data_dumper_numified.t passes (all 7 tests)
  • Full test suite passes with make
  • Data::Dumper correctly handles:
    • Numeric literals of any size
    • Strings used in numeric context
    • Assignment preserving numified state
    • int() function marking scalars as numified
    • Strings that haven't been numified (stay quoted)
    • Negative numbers and zero

Generated with

Claude Code

This commit includes:

1. Sync latest Perl5 modules from perl5/ tree:
   - Archive::Tar and related modules
   - IO::Socket::IP updates
   - NEXT module updates
   - Pod documentation updates (perldelta, perlclass, etc.)
   - Test::Builder improvements
   - vars.pm updates

2. Dependency version updates:
   - ASM: 9.9.1 -> 9.10.1
   - BouncyCastle: 1.78.1 -> 1.84
   - Commons Compress: 1.27.1 -> 1.28.0
   - JUnit Jupiter: 6.1.0-M1 -> 6.1.1
   - SQLite JDBC: 3.51.3.0 -> 3.53.2.0

3. Fix Data::Dumper numified scalar handling:
   - Created patch Data-Dumper.pm.patch
   - Adds PerlOnJava-specific check for numified scalars
   - Fixes test failure in unit/data_dumper_numified.t
   - Ensures numeric literals and numified strings dump as numbers, not quoted strings
   - Updated import config to apply patch during sync

The Data::Dumper fix restores behavior that was overwritten during the
Perl5 sync. The _perlonjava_numified_safe_decimal() method checks if
a scalar has been used in numeric context and should be dumped as a
number instead of a quoted string, matching Perl5's internal behavior.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@fglock fglock merged commit 49dc704 into master Jul 9, 2026
2 checks passed
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