CLASS v1.1.8 constant returns main in non-main package

Open
#1,405 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
52/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
perl
Domain
compilers

Research direction

Start by running the upstream CLASS.t coverage and the reproducer on both the JVM and interpreter backends. Trace how imported constant subroutines resolve package context, comparing the failing bare CLASS path with the working $CLASS path. Add a project-owned regression test for a constant subroutine imported into a non-main package, then verify CLASS returns Foo and CLASS->bar returns 23 on both backends.

Written by the indexing model from the issue text.

Description

area:backend area:cpan-port area:runtime bug

Summary

CLASS v1.1.8 fails when imported into a non-main package. Its exported
constant subroutine returns main instead of the importing package, causing
class-method calls through CLASS to dispatch incorrectly.

Minimal reproducer

use CLASS;

package Foo;
use CLASS;

sub bar { 23 }

print CLASS, "\\n";
print CLASS->bar, "\\n";

Expected output under Perl:

Foo
23

Actual PerlOnJava behavior:

main
Can't locate object method "bar" via package "main"

The same failure is covered by upstream CLASS.t:

package Foo;
use CLASS;

is( CLASS, __PACKAGE__, 'CLASS is right' );
is( CLASS->bar, 23, 'CLASS->meth' );

Reproduction results

  • CLASS v1.1.8, CPAN run 20260916-111623-23683
  • System Perl 5.42.2: all 22 tests pass
  • PerlOnJava JVM backend: fails at CLASS is right (main vs Foo), then
    aborts at CLASS->bar
  • PerlOnJava interpreter backend: same failure
  • CPAN result: 1/2 test programs failed; 1/3 executed tests failed

The distribution is pure Perl and does not require XS or native libraries.
Because both PerlOnJava backends reproduce the issue while system Perl passes,
this appears to be a shared compiler/runtime bug involving imported constant
subroutines and package context. The $CLASS variable exported by the module
does return Foo; the bare CLASS constant is the failing path.

Acceptance criteria

  • CLASS v1.1.8's upstream test suite passes completely on both PerlOnJava
    backends.
  • The reproducer returns Foo and then 23.
  • A permanent project-owned regression test covers an imported constant
    subroutine in a non-main package.
Dominant language
Perl
Stars
64
Forks
6
Avg merge
5h 25m
Merged PRs (30d)
157

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from fglock/PerlOnJava

All issues in fglock/PerlOnJava

Similar issues

More Perl issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.