Repository navigation
InstConstraintVisitor check objectref class in getfield and putfield verification - #547
Merged
garydgregory merged 1 commit intoNov 19, 2026
Conversation
InstConstraintVisitor.visitGETFIELD and visitPUTFIELD only check that the objectref is an ObjectType or null, never that it is an instance of the class named by the field reference. Structural verification thus accepts getfield/putfield of Foo.x applied to a String, which HotSpot rejects with "Incompatible type for getting or setting field". Apply the same Repository.instanceOf check visitINVOKEVIRTUAL and visitINVOKESPECIAL already use for their objectref.
garydgregory
added a commit
that referenced
this pull request
Nov 19, 2026
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.
InstConstraintVisitor.visitGETFIELDandvisitPUTFIELDonly check that the objectref is anObjectTypeornull, never that it is an instance of the class named by the field reference. Pass 3b therefore returnsVERIFIED_OKfor a method doingaload_0; getfield Foo.x:Iwhere local 0 is aString, while HotSpot rejects the same class withVerifyError: Incompatible type for getting or setting field. Found while auditing the objectref checks inInstConstraintVisitor:visitINVOKEVIRTUALandvisitINVOKESPECIALboth enforceRepository.instanceOf(objRefClassName, theClass), the field instructions don't.Apply the same
Repository.instanceOfcheck to the getfield/putfield objectref;null, array and uninitialized objectrefs keep their existing handling.VerifierFieldAccessTestasserts getfield/putfield on aStringis rejected (fails before, passes after) and the same accesses on the declaring class still verify. As a false-positive check I ran Pass 3a/3b over all 2563 methods in BCEL's owntarget/classes: the same 40 pre-existing rejections before and after, none from the new check.mvn; that'smvnon the command line by itself.