Repository navigation
Initialize a class before reflective access to its static fields - #26
Merged
Merged
Conversation
OpenLDK replaces Field.get/set with a direct slot access, which never initialized the declaring class. A static field read by reflection before anything else touched its class came back with its default (null, 0), and a value written by Field.set was overwritten when <clinit> ran later. Initialize the declaring class first, as the JVM does. Co-Authored-By: Claude Opus 5.5 <[email protected]>
atgreen
added a commit
that referenced
this pull request
Oct 20, 2026
It was not a class loader bug: Field.get never initialized the declaring class, which #26 fixes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
JDK 25 routes
Field.get/Field.setthrough a method-handle accessor, which OpenLDK can't run, so OpenLDK replaces both with a direct slot access (src/native/reflection.lisp). That replacement never initialized the declaring class, while the JVM always runs<clinit>before reflective access to a static.So a static field read by reflection before anything else touched its class came back with its default value. A plain app class:
Field.sethad the mirror problem: the written value was overwritten when<clinit>ran later.This was listed in #25 and
docs/ABCL.mdas a custom-class-loader bug. It isn't one: the repro just read the field before anything else had initialized the class.Fix:
%field-slot-storage, which both overrides use, now initializes the declaring class (%clinit) before returning a static field's storage.Test: new
aaa/reflstatic.javareads two statics by reflection first, and writes one withField.setbefore its class is initialized.OKFAIL: null 0 1 1OKmake check-regressioncouldn't run locally (no DejaGnu), so CI's gate is the full check. Once #25 merges, the "reflective static field reads" known issue indocs/ABCL.mdcan go; I'll remove it in the follow-up loader PR.🤖 Generated with Claude Code