Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Fix package-stash copy losing methods in Class::Hook

未关闭
#1,523 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
65/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
java, perl
领域
backend, compilers

调研方向

The issue identifies package stash/typeglob assignment and method dispatch as the entry points; start by tracing %{"FOO::"} = %saved through both JVM and interpreter backends. Add the focused project-owned regression described in the issue, validate it against system Perl, and run it on both backends. Done means the blessed value is returned and unchanged Class-Hook 0.06 t/original.t passes.

由索引模型根据 Issue 内容生成。

描述

area:backend area:runtime bug

Summary

PerlOnJava loses a package method after a package stash is copied back through
the standard typeglob/stash assignment pattern. This breaks the pure-Perl
Class::Hook distribution: its hook restores a saved class namespace and then
calls FOO->new, but the call returns undef rather than the blessed FOO
object returned by standard Perl.

The failure reproduces on both execution backends. It is a shared runtime
compatibility defect in package stash/typeglob handling or in method dispatch
after that mutation, not a dependency, XS, service, display, or timeout issue.

CPAN evidence

  • CPAN random tester run: 20260925-103132-20451
  • Distribution: Class-Hook 0.06
  • Failing upstream test: t/original.t
  • PerlOnJava result: 2 of 5 executed subtests fail, then the test aborts with
    Can't call method "bar" on an undefined value; its plan is 11 tests.
  • Both JVM and interpreter backends reproduce the same result.

The unmodified upstream suite passes under the system-Perl oracle:

t/original.t .. ok
All tests successful.
Files=1, Tests=11
Result: PASS

Class::Hook is pure Perl, so no native-module port or reverse-dependency
qualification is involved.

Failing upstream pattern

Class::Hook dynamically loads a class, snapshots its namespace, restores the
saved namespace before dispatch, then removes it again so later calls route
through UNIVERSAL::AUTOLOAD. Its relevant pattern is:

no strict 'refs';

require FOO;
my %saved = %{"FOO::"};
%{"FOO::"} = %saved;

my $object = FOO->new({});

FOO::new is an ordinary Perl subroutine which blesses and returns a hash
reference. Standard Perl retains the method and returns a FOO object.

Minimal reproducer

The following is self-contained apart from a FOO.pm defining an ordinary
FOO::new constructor:

no strict 'refs';
require FOO;
my %saved = %{"FOO::"};
%{"FOO::"} = %saved;
my $object = FOO->new({});
print defined($object) ? ref($object) : "undef", "\n";

Expected with system Perl:

FOO

Actual with PerlOnJava JVM backend:

undef

Actual with PerlOnJava interpreter backend:

undef

Expected behavior

Assigning a saved package stash back through %{"FOO::"} = %saved must retain
the effective CODE slots for later method lookup. FOO->new({}) must invoke
FOO::new and return its blessed object, matching Perl.

The implementation should preserve normal typeglob slot semantics rather than
special-casing Class::Hook; callers may use this pattern for methods, package
variables, and other glob-backed namespace entries.

Related issues

  • #1305 is related typeglob work but is not a duplicate: it covers compilation
    and dynamic-scope restoration for local *$globref; this issue covers runtime
    method loss after a package-stash hash copy.
  • #1473's false CORE::try/CORE::catch warnings appear during the test run,
    but do not cause this failure.

Regression coverage

Add a project-owned focused, system-Perl-validated regression test covering:

  1. A package with a normal constructor or named method.
  2. Snapshotting its stash with %saved = %{"Package::"}.
  3. Restoring it with %{"Package::"} = %saved.
  4. Successful class-method dispatch after restoration, including the returned
    blessed value.
  5. JVM and interpreter backend parity.

After the focused test passes, rerun Class-Hook 0.06's unchanged t/original.t
as integration coverage.

主要语言
Perl
星标
64
派生
6
平均合并
5 小时
30 天内合并 PR
161

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

fglock/PerlOnJava 的其他 Issue

查看 fglock/PerlOnJava 的全部 Issue

相似的 Issue

更多 Perl Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。