Object::Pad BUILD blocks fail to parse in bundled compatibility layer
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
Research direction
Start in src/main/java/org/perlonjava/frontend/parser/StatementResolver.java around line 88, where class-adjacent special blocks are dispatched, then inspect CoreOperatorResolver.java around line 262 and the existing parser tests. Run the jperl reproducer on both backends and add project-owned coverage for BUILD parsing, field initialization, and constructor behavior. Done means the focused case and CAD::OpenSCAD tests pass without the misleading method-body error.
Written by the indexing model from the issue text.
Description
Summary
CAD::OpenSCAD 0.14 fails its upstream test suite on PerlOnJava because the bundled Object::Pad compatibility layer does not parse the distribution's BUILD { ... } constructor block. The resulting diagnostic is misleading: Expected '{' after method declaration.
Reproduction
The failure was recorded by CPAN run 20260918-141920-96054, target row:
CAD::OpenSCAD / CAD::OpenSCAD::GearMaker
The target's t/01-OpenSCAD.t and t/02-OpenSCAD-Math.t both fail before running any tests. Loading the dependency directly reproduces it:
jperl -e 'use CAD::OpenSCAD::Math; print "loaded\\n";'
jperl --interpreter -e 'use CAD::OpenSCAD::Math; print "loaded\\n";'
Both backends terminate with:
Expected '{' after method declaration
Compilation failed in require
The smallest relevant source shape is:
use Object::Pad;
class Example {
field $value;
BUILD {
$value = 1;
}
method value { return $value }
}
CAD::OpenSCAD::Math contains this exact pattern at its class body: BUILD { ... }, followed by Object::Pad method declarations.
Investigation
Object::Pad is bundled by PerlOnJava (Object::Pad version 0.66 in the bundled compatibility module), and the CPAN log explicitly reports that Object/Pad.pm is bundled. Therefore this is not merely an unavailable native dependency.
The parser currently recognizes these class-adjacent special blocks in StatementResolver:
CHECK, INIT, UNITCHECK, BEGIN, END, ADJUST
BUILD is absent from that dispatch at src/main/java/org/perlonjava/frontend/parser/StatementResolver.java around line 88. It consequently falls through as an ordinary expression. When parsing continues into the following method, the token is routed through CoreOperatorResolver.parseAnonymousMethodExpression(), which throws Expected '{' after method declaration at the check around line 262. The error points at the recovery path rather than the actual unsupported BUILD construct.
The same failure occurs on the JVM and interpreter backends. The archived CPAN run used the normal JVM backend and reports both upstream test programs failing with zero tests run.
Expected behavior
PerlOnJava's bundled Object::Pad compatibility should accept BUILD { ... } in a class body and execute it during object construction, or emit a clear supported-feature diagnostic if the feature is intentionally unavailable. Since Object::Pad is bundled and advertised as supported class syntax, the compatibility layer should support this constructor form.
Acceptance criteria
- Parse and execute
BUILD { ... }in a bundledObject::Padclass. - Preserve field initialization and constructor parameter behavior.
- Pass the focused reproducer on both JVM and interpreter backends.
- Add permanent project-owned regression coverage.
- Re-run
CAD::OpenSCAD0.14 tests, especiallyt/01-OpenSCAD.tandt/02-OpenSCAD-Math.t. - Improve the diagnostic or parser recovery so malformed/unsupported constructor blocks do not report a misleading method-body error.
Environment note
The archived PerlOnJava run selected Object-Pad-0.825 as the dependency, while PerlOnJava used its bundled compatibility implementation. A clean system-Perl comparison could not be completed in the investigation environment because Object::Pad was not installed and CPAN network access was unavailable. This does not affect attribution: the same source construct reproduces deterministically in both PerlOnJava backends, and the parser source identifies the missing BUILD dispatch.
- Dominant language
- Perl
- Stars
- 64
- Forks
- 6
- Avg merge
- 5h 11m
- Merged PRs (30d)
- 168
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from fglock/PerlOnJava
-
area:cpan-port area:unicode bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
fglock/PerlOnJava#1341 ·
-
area:backend area:runtime enhancement
Difficulty 4/5 3-5 days Newbie friendliness 45/100
fglock/PerlOnJava#1494 ·
-
area:backend area:runtime enhancement
Difficulty 4/5 3-5 days Newbie friendliness 45/100
fglock/PerlOnJava#1492 ·
-
area:parser bug
Difficulty 3/5 1-2 days Newbie friendliness 65/100
fglock/PerlOnJava#1491 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
fglock/PerlOnJava#1487 ·
All issues in fglock/PerlOnJava
Similar issues
-
documentation Needs Triage
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
trizen/youtube-viewer#456 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
connectivity Open
Difficulty 1/5 Under an hour Newbie friendliness 80/100
-
Common US ingredient names are not recognized, so about 12.4k US products miss an allergen warning Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
openfoodfacts/openfoodfacts-server#14657 · 4 comments ·