Skip to content

Port Variable::Magic for CPAN compatibility #1433

Description

@fglock

Summary

Port Variable::Magic to PerlOnJava or provide a compatible Java-backed implementation so CPAN modules that depend on Perl variable magic can load and run without native XS.

Variable::Magic exposes Perl's low-level variable-magic API, including callbacks for get, set, clear, free, copy, local, and hash fetch/store/exists/delete operations. The current distribution is XS-only and requires a C compiler; PerlOnJava reports:

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

CPAN evidence

In CPAN run 20260918-141920-96054, MooX::LvalueAttribute v0.16 passes completely under system Perl:

Files=6, Tests=33
Result: PASS

Under PerlOnJava, 4/6 test programs fail during loading because Variable::Magic cannot load. The affected downstream tests are:

  • t/00-compile.t
  • t/lvalue.t
  • t/lvalue_in_role.t
  • t/lvalue_in_role_with_xs.t

This prevents the lvalue-attribute implementation from exercising its normal behavior; the failure is in the native dependency rather than in MooX::LvalueAttribute itself.

Ecosystem impact

The current MetaCPAN release index contains 38 unique CPAN distributions with a runtime requires dependency on Variable::Magic, deduplicated across 634 matching release records. Two dependant distributions have releases within the preceding 12 months: Dios and MooseX-Params.

Representative runtime dependants include DBIx-Class, KiokuDB, MRO-Magic, MooX-LvalueAttribute, MooseX-Lexical-Types, MooseX-LvalueAttribute, Type-Alias, warnings-lock, and Variable-Temp.

Source query: https://fastapi.metacpan.org/v1/release/_search?q=dependency.module%3A%22Variable%3A%3AMagic%22&size=1000&from=0

Expected behavior

A supported PerlOnJava implementation should allow modules using the documented Variable::Magic API to load and provide compatible variable-magic behavior, or clearly expose a supported substitute that downstream CPAN modules can use without native code.

Suggested scope

  • Define the supported Variable::Magic API and identify which magic operations can be represented by PerlOnJava runtime hooks.
  • Implement the highest-value operations first, including wizard creation, casting, retrieving data, and dispelling magic.
  • Preserve callback timing and lvalue/hash behavior where the Perl runtime exposes an equivalent operation.
  • Add focused unit tests for the Java-backed implementation on both JVM and interpreter backends.
  • Use MooX::LvalueAttribute as downstream acceptance coverage, followed by other dependants such as MRO::Magic and warnings-lock.
  • Document unsupported operations explicitly if complete parity cannot be achieved in the first port.

Notes

This is a porting/enhancement request for a native CPAN dependency, not a defect in MooX::LvalueAttribute. The reverse-dependency lookup in the local CPAN-priority tool previously failed with MetaCPAN HTTP 599; the count above was independently obtained from the current MetaCPAN release index and filtered to unique runtime dependants.

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