Skip to content

enhancement: port the meta metaprogramming API #1223

Description

@fglock

Summary

Port the CPAN meta distribution to PerlOnJava so Perl modules can inspect and modify package symbol tables without requiring its XS implementation.

Motivation

meta 0.015 provides a Perl metaprogramming API implemented through XS. PerlOnJava currently reports:

Can't load loadable object for module meta: no Java XS implementation available

This blocks Data::Faker::Colour through the dependency chain:

Data::Faker::Colour
  -> Convert::Color::HSLuv
  -> Convert::Color
  -> meta

Convert::Color uses meta to dynamically install color-conversion methods such as as_RGB and as_HSL. The impact extends beyond this module: CPAN metadata currently identifies 21 unique distributions declaring meta as a dependency, including Full, Tangence, Tickit-Widgets, Future-IO-Resolver, Net::Prometheus, Net::Async::WebSocket, several Syntax::Operator::* distributions, and Convert::Color.

Upstream API surface

The port should investigate the complete public API, including:

  • meta::get_package
  • meta::get_this_package
  • meta::for_reference
  • meta::package objects for package inspection and mutation
  • package, glob, symbol, and reference meta-objects
  • symbol and method creation/removal, including add_symbol and add_named_sub
  • package and symbol enumeration
  • class/package detection where supported by the Perl version
  • warning and deprecation behavior, including the meta::experimental category

The upstream module exposes low-level interpreter structures, so behavior should be defined carefully for both ordinary Perl packages and PerlOnJava's runtime representation.

Suggested implementation

  1. Inspect the upstream meta.pm and meta.xs sources and preserve their license and attribution.
  2. Separate the Perl wrapper/API declarations from operations that access Perl's internal symbol tables.
  3. Add a Java-backed implementation using PerlOnJava's package, glob, symbol-table, and callable registration infrastructure.
  4. Preserve Perl calling context, return values, exceptions, warnings, and aliasing semantics.
  5. Keep unsupported low-level operations explicit; do not silently emulate them with copies when the Perl API requires aliases.
  6. Verify behavior on both JVM and interpreter backends.

Acceptance criteria

  • use meta loads without XS under both PerlOnJava backends.
  • meta::get_package and meta::get_this_package return usable package meta-objects.
  • Package symbols and named subs can be inspected, enumerated, added, and removed with Perl-compatible behavior.
  • Aliases and references retain the expected identity and mutation semantics.
  • Convert::Color loads and dynamically installs its color-space conversion methods.
  • Data::Faker::Colour passes its upstream tests without a native dependency failure.
  • Tests cover missing symbols, invalid names, duplicate additions, package isolation, warnings, and both scalar/list/void contexts where applicable.
  • The upstream meta tests, or focused equivalents where an interpreter-internal test is not portable, pass under system Perl and both PerlOnJava backends.

Related compatibility work

This port would unblock Data::Faker::Colour 0.001, whose system-Perl tests pass but whose PerlOnJava test fails at module load because meta contains XS code. It may also reduce the number of CPAN distributions blocked by native metaprogramming dependencies.

References

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:cpan-portCPAN compatibility ports and providersenhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions