Skip to content

fix: support Params::Validate PP backend (glob ref, regex isa, for-loop aliasing)#503

Merged
fglock merged 5 commits intomasterfrom
feature/params-validate-support
Apr 13, 2026
Merged

fix: support Params::Validate PP backend (glob ref, regex isa, for-loop aliasing)#503
fglock merged 5 commits intomasterfrom
feature/params-validate-support

Conversation

@fglock
Copy link
Copy Markdown
Owner

@fglock fglock commented Apr 13, 2026

Summary

Add full Params::Validate 1.31 pure-Perl support to PerlOnJava. Four runtime fixes ensure the PP test suite passes 100%, and CPAN distroprefs automate the pure-Perl build.

Runtime Fixes

  • ref() on GLOB: Returns "" for bare globs (was incorrectly returning slot type like "CODE")
  • RuntimeScalar.createReference() for GLOB: Returns GLOBREFERENCE type so UNIVERSAL::isa(\*glob, 'GLOB') works
  • UNIVERSAL::isa for "REGEXP": Accepts uppercase "REGEXP" in addition to "Regexp"
  • RuntimeScalarReadOnly boolean for "0": String "0" is now correctly falsy (was truthy due to !s.isEmpty() pre-computation)

CPAN Distroprefs

  • Added Params-Validate.yml to pass --pp to Build.PL automatically
  • jcpan -t Params::Validate now works out of the box

Test Results

  • 38/38 test programs pass (3 skipped: require Test::Taint)
  • 2515/2515 subtests pass (100%)
  • All existing PerlOnJava unit tests still pass (make green)

Test plan

  • make passes (no regressions)
  • jcpan -t Params::Validate passes all 2515 subtests
  • Previously failing tests now pass: t/01-validate.t, t/13-taint.t, t/15-case.t, t/32-regex-as-value.t

Generated with Devin

fglock and others added 4 commits April 13, 2026 16:10
Document 4 PerlOnJava issues found while testing Params::Validate 1.31:
- ref() on GLOB-typed scalars returns slot type instead of ""
- RuntimeScalar.createReference() returns REFERENCE instead of GLOBREFERENCE for globs
- UNIVERSAL::isa doesn't match "REGEXP" (uppercase) for regex objects
- for loop variable aliasing treats literal "0" as truthy

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

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
… "0" boolean)

Four fixes to pass the Params::Validate 1.31 PP test suite (2515/2515 subtests):

1. ref() on GLOB-typed RuntimeScalar now returns "" (empty string).
   In Perl 5, ref(*glob) always returns "" because bare globs are not
   references.  Previously PerlOnJava analyzed glob slots and returned
   the slot type (e.g. "CODE"), which broke Params::Validate::PP type
   detection for glob parameters.
   File: ReferenceOperators.java

2. RuntimeScalar.createReference() returns GLOBREFERENCE for GLOB type.
   When a glob is wrapped in a RuntimeScalar (after passing through @_
   or copy operations), creating a reference via \$val now correctly
   produces GLOBREFERENCE instead of REFERENCE.  This makes
   UNIVERSAL::isa(\*glob, 'GLOB') return true.
   File: RuntimeScalar.java

3. UNIVERSAL::isa accepts "REGEXP" (uppercase) for regex objects.
   Perl 5 treats both "Regexp" and "REGEXP" as valid class names.
   Params::Validate::PP uses the uppercase form in its %isas table.
   File: Universal.java

4. RuntimeScalarReadOnly string "0" is now falsy in boolean context.
   The constructor pre-computed boolean as !s.isEmpty() but Perl's rule
   is that both "" and "0" are false.  This broke for-loop variables
   aliased to literal "0" (e.g. for my $v (qw(0 1)) { $v ? ... }),
   which caused Params::Validate's ignore_case test to select the wrong
   expect function.
   File: RuntimeScalarReadOnly.java

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

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
jcpan -t Params::Validate now works out of the box. The distroprefs
automatically pass --pp to Build.PL and set PARAMS_VALIDATE_IMPLEMENTATION=PP,
bypassing XS compilation which PerlOnJava cannot perform.

38/38 test programs pass, 2515/2515 subtests (100%).

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

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
CPAN::Kwalify loads distroprefs.dd and distroprefs.yml schema files
relative to its own module path. These files existed in the source tree
but were excluded from the JAR because the build only included *.pm,
*.pl, *.ph, and *.pod patterns. This also includes CPAN distroprefs
YAML files in the JAR.

Fixes: "Could not open 'jar:PERL5LIB/CPAN/Kwalify/distroprefs.dd'"

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

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@fglock fglock force-pushed the feature/params-validate-support branch from 90e1119 to 7385e79 Compare April 13, 2026 14:11
The previous createReference() fix for Params::Validate changed
\$scalar_holding_glob to produce GLOBREFERENCE type, which stored the
RuntimeGlob directly and lost the reference to the RuntimeScalar
container. This broke Internals::SvREADONLY on glob copies (-2 in
universal.t), open() on \$glob_copy (-1 in open.t), and reading from
glob copies (-1 in perlio.t).

Fix: revert createReference() to always return REFERENCE type (keeping
the RuntimeScalar container accessible). Instead, teach Universal.isa()
to recognize that a REFERENCE pointing to a GLOB-typed RuntimeScalar
should match "GLOB" (not "SCALAR"). ReferenceOperators.ref() already
handled this case correctly (line 135: case GLOB -> "GLOB").

Params::Validate PP test suite still passes 2515/2515.

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

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@fglock fglock merged commit 14a1893 into master Apr 13, 2026
2 checks passed
@fglock fglock deleted the feature/params-validate-support branch April 13, 2026 15:02
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