Skip to content

feat: add YAML::XS shim that delegates to bundled YAML::PP#642

Merged
fglock merged 1 commit intomasterfrom
feature/yaml-xs-shim
Apr 30, 2026
Merged

feat: add YAML::XS shim that delegates to bundled YAML::PP#642
fglock merged 1 commit intomasterfrom
feature/yaml-xs-shim

Conversation

@fglock
Copy link
Copy Markdown
Owner

@fglock fglock commented Apr 30, 2026

Summary

./jcpan -t YAML::XS previously failed catastrophically. The CPAN distribution YAML::XS (a.k.a. YAML-LibYAML) is an XS wrapper around libyaml, and PerlOnJava cannot load XS, so every test died with:

Can't locate YAML/XS/LibYAML.pm in @INC

We already bundle a JVM-backed YAML::PP (SnakeYAML under the hood), so this PR adds two pure-Perl shims that re-expose YAML::PP under the YAML::XS namespace:

  • src/main/perl/lib/YAML/XS/LibYAML.pm — minimal stub exporting Load/Dump, used by the cpan-installed upstream YAML/XS.pm in ~/.perlonjava/lib.
  • src/main/perl/lib/YAML/XS.pm — bundled fallback so use YAML::XS; works out of the box without first running jcpan. Implements Load / Dump / LoadFile / DumpFile and declares the standard YAML::XS package globals.

Test plan

  • make (full unit test suite) passes.
  • ./jperl -e 'use YAML::XS qw(Load Dump); print Dump(Load("a: 1\nb: [1,2,3]\n"))' round-trips correctly.
  • ./jcpan -t YAML::XS now configures, builds, and runs the test suite. Test programs go from 0/49 running to 17/49 passing (192/283 subtests pass).

Out of scope

The remaining YAML::XS test failures are all YAML::PP / SnakeYAML feature gaps, not shim bugs:

  • booleans ($YAML::XS::Boolean modes, JSON::PP boolean round-tripping)
  • blessed / tied refs
  • !!perl/code, !!perl/regexp, !!perl/glob round-tripping
  • exact alias output formatting and upstream error-message wording
  • $Indent / $QuoteNumericStrings and other config globals (accepted but not honoured by the shim)

Fixing those would require enhancing YAML::PP itself.

Generated with Devin

Before this change `./jcpan -t YAML::XS` failed catastrophically with
"Can't locate YAML/XS/LibYAML.pm in @inc" on every test, because the
upstream YAML::XS distribution (YAML-LibYAML) is XS-only and PerlOnJava
cannot load XS.

We already ship a JVM-backed YAML::PP (SnakeYAML under the hood), so
this commit adds two pure-Perl shims that re-expose YAML::PP under the
YAML::XS namespace:

  - src/main/perl/lib/YAML/XS::LibYAML.pm
      Tiny stub that exports Load/Dump by delegating to YAML::PP. The
      cpan-installed upstream YAML::XS.pm in ~/.perlonjava/lib uses this
      to satisfy `use YAML::XS::LibYAML qw(Load Dump);`.
  - src/main/perl/lib/YAML/XS.pm
      Bundled fallback so `use YAML::XS;` works out of the box without
      first running jcpan. Implements Load/Dump/LoadFile/DumpFile and
      declares the standard YAML::XS package globals.

With the shim in place `jcpan -t YAML::XS` configures, builds and runs
the test suite, going from 0/49 test programs running to 17/49 passing
(192/283 subtests). The remaining failures are YAML::PP/SnakeYAML
semantic limitations (booleans, blessed/tied refs, !!perl/code,
!!perl/regexp, !!perl/glob round-tripping, alias output format,
upstream error message wording) and are not caused by the shim.

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 28f3511 into master Apr 30, 2026
2 checks passed
@fglock fglock deleted the feature/yaml-xs-shim branch April 30, 2026 14:28
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