Skip to content

Use array element type not basic type for primitive array access#520

Merged
garydgregory merged 1 commit into
apache:masterfrom
rootvector2:verifier-array-element-type
Jul 12, 2026
Merged

Use array element type not basic type for primitive array access#520
garydgregory merged 1 commit into
apache:masterfrom
rootvector2:verifier-array-element-type

Conversation

@rootvector2

Copy link
Copy Markdown
Contributor

InstConstraintVisitor checks the primitive array load/store instructions with ArrayType.getBasicType(), which returns the innermost basic type and drops the dimension count, so iaload/iastore (and the long/float/double/short variants) applied directly to a multidimensional primitive array such as int[][] pass Pass3b even though the component type is int[], a reference. The reference/byte/char siblings (aaload/aastore, baload/bastore, castore) already use getElementType(); this switches the ten primitive *aload/*astore checks to match. For a one-dimensional array getElementType() returns the same object as getBasicType(), so valid code verifies exactly as before. Found while auditing the *ALOAD/*ASTORE element-type checks against ArrayType.

  • Read the contribution guidelines for this project.
  • Read the ASF Generative Tooling Guidance if you use Artificial Intelligence (AI).
  • I used AI to create any part of, or all of, this pull request. Which AI tool was used to create this pull request, and to what extent did it contribute?
  • Run a successful build using the default Maven goal with mvn; that's mvn on the command line by itself.
  • Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Each commit in the pull request should have a meaningful subject line and body.

getBasicType() drops the dimension count, so iaload on int[][] passed structural verification even though its component type is a reference; the ten primitive *aload/*astore constraints in InstConstraintVisitor now use getElementType() like the reference and byte/char siblings.
@garydgregory garydgregory changed the title use array element type not basic type for primitive array access Use array element type not basic type for primitive array access Jul 11, 2026
@garydgregory garydgregory merged commit 2aef1be into apache:master Jul 12, 2026
21 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants