Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8313258: RuntimeInvisibleTypeAnnotationsAttribute.annotations() API Index out of Bound error #15511

Closed

Conversation

asotona
Copy link
Member

@asotona asotona commented Aug 31, 2023

Classfile API suppose to throw IllegalArgumentException in situations where bytecode offset is out of allowed range. Such situation includes invalid offset parsed from a TypeAnnotation as well as from other CodeAttribute attributes.

This patch throws IAE for invalid bytecode offset when requested Label for the parsed CodeAttribute, so it cover even wider range of cases than mentioned in the bug report.

Please review.

Thanks,
Adam


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8313258: RuntimeInvisibleTypeAnnotationsAttribute.annotations() API Index out of Bound error (Bug - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/15511/head:pull/15511
$ git checkout pull/15511

Update a local copy of the PR:
$ git checkout pull/15511
$ git pull https://git.openjdk.org/jdk.git pull/15511/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 15511

View PR using the GUI difftool:
$ git pr show -t 15511

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/15511.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 31, 2023

👋 Welcome back asotona! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label Aug 31, 2023
@openjdk
Copy link

openjdk bot commented Aug 31, 2023

@asotona The following label will be automatically applied to this pull request:

  • core-libs

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the core-libs core-libs-dev@openjdk.org label Aug 31, 2023
@mlbridge
Copy link

mlbridge bot commented Aug 31, 2023

Webrevs

@@ -97,6 +97,9 @@ public void setLabelTarget(Label label, int bci) {

@Override
public Label getLabel(int bci) {
if (bci < 0 || bci > codeLength)
throw new IllegalArgumentException(String.format("Bytecode offset out of range; bci=%d, codeLength=%d",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we get an IAE formatter in jdk.internal.util.Preconditons for classfile-specific bound checking, so we can do Preconditions.checkIndex(bci, codeLength, Preconditions.IAE_FORMATTER); and share it with other use sites of classfile-specific exceptions.

In addition, we might move the new IllegalArgumentException constructor calls to a utility method in our Util class in case we migrate our exceptions to a new subclass of IAE. Thoughts?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is a bit overkill for this simple fix. We may discuss it as a part of some wider code cleanups.

@openjdk
Copy link

openjdk bot commented Sep 14, 2023

@asotona This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8313258: RuntimeInvisibleTypeAnnotationsAttribute.annotations() API Index out of Bound error

Reviewed-by: briangoetz

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 185 new commits pushed to the master branch:

  • 5cea53d: 8315810: Reimplement sun.reflect.ReflectionFactory::newConstructorForSerialization with method handles
  • eb1f67b: 8315937: Enable parallelism in vmTestbase/nsk/stress/numeric tests
  • a57b9da: 8316242: Opensource SwingGraphics manual test
  • 3abe798: 8316115: Parallel: Fix -Wconversion warnings around NUMA node ID
  • 83dca62: 8313638: Add test for dump of resolved references
  • cfa8901: 8315338: RISC-V: Change flags for stable extensions to non-experimental
  • edd454b: 8315766: Parallelize gc/stress/TestStressIHOPMultiThread.java test
  • de9b971: 8315933: Serial: Remove empty Generation::ensure_parsability
  • b48dbf6: 8316181: Move the fast locking implementation out of the .ad files
  • 8f4dfc4: 8316164: Opensource JMenuBar manual test
  • ... and 175 more: https://git.openjdk.org/jdk/compare/b594f01fe4872d255f0f2fd2b1a908660e39f426...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Sep 14, 2023
@asotona
Copy link
Member Author

asotona commented Sep 14, 2023

/integrate

@openjdk
Copy link

openjdk bot commented Sep 14, 2023

Going to push as commit 6d47fc6.
Since your change was applied there have been 187 commits pushed to the master branch:

  • c7d306c: 8315541: Classfile API TypeAnnotation.TargetInfo factory methods accept null labels
  • c11f835: 8315824: Open source several Swing Text/HTML related tests
  • 5cea53d: 8315810: Reimplement sun.reflect.ReflectionFactory::newConstructorForSerialization with method handles
  • eb1f67b: 8315937: Enable parallelism in vmTestbase/nsk/stress/numeric tests
  • a57b9da: 8316242: Opensource SwingGraphics manual test
  • 3abe798: 8316115: Parallel: Fix -Wconversion warnings around NUMA node ID
  • 83dca62: 8313638: Add test for dump of resolved references
  • cfa8901: 8315338: RISC-V: Change flags for stable extensions to non-experimental
  • edd454b: 8315766: Parallelize gc/stress/TestStressIHOPMultiThread.java test
  • de9b971: 8315933: Serial: Remove empty Generation::ensure_parsability
  • ... and 177 more: https://git.openjdk.org/jdk/compare/b594f01fe4872d255f0f2fd2b1a908660e39f426...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Sep 14, 2023
@openjdk openjdk bot closed this Sep 14, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Sep 14, 2023
@openjdk
Copy link

openjdk bot commented Sep 14, 2023

@asotona Pushed as commit 6d47fc6.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core-libs core-libs-dev@openjdk.org integrated Pull request has been integrated
3 participants