Skip to content

8308842: Consolidate exceptions thrown from Class-File API #14143

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

Closed
wants to merge 5 commits into from

Conversation

asotona
Copy link
Member

@asotona asotona commented May 25, 2023

Class-File API actually throws wide variety of exceptions based on the actual situation. Complete error handling code must cover IndexOutOfBoundsException, IllegalStateException and IllegalArgumentException.

Based on previous discussions we decided to consolidate on IllegalArgumentException with possible sub-classes.

It allows easy common error handling in majority of use case, however it allows also to distinguish source of the error when needed (for example javap needs to know if the exception comes from constant poll or not).

Newly introduced ConstantPoolException extends IllegalArgumentException to indicate the source of the problem is in constant pool.

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-8308842: Consolidate exceptions thrown from Class-File API

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 14143

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

Using diff file

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

Webrev

Link to Webrev Comment

Sorry, something went wrong.

@bridgekeeper
Copy link

bridgekeeper bot commented May 25, 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 May 25, 2023
@openjdk
Copy link

openjdk bot commented May 25, 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 May 25, 2023
@mlbridge
Copy link

mlbridge bot commented May 25, 2023

Webrevs

@liach
Copy link
Member

liach commented May 25, 2023

What other types of exceptions does javap distinguish, and should Classfile API distinguish them as well?

@asotona
Copy link
Member Author

asotona commented May 25, 2023

What other types of exceptions does javap distinguish, and should Classfile API distinguish them as well?

Invalid CP index or content are cases where javap tries to recover, replace the value with '???' and print the rest.
This PR is extracted Classfile API - related part of #11411

@liach
Copy link
Member

liach commented May 25, 2023

Then this should suffice for now. We can create specific subtypes if we wish to expose specific exceptions in the future.

public ConstantPoolException() {
super();
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Exception classes in the JDK generally have four constructors: (), (Throwable), (String), and (String, Throwable).

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'll add missing constructors, thanks.

Copy link
Contributor

@briangoetz briangoetz left a comment

Choose a reason for hiding this comment

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

Reviewed, only minor comment is the one about constructors in the new exception class.

@openjdk
Copy link

openjdk bot commented Jun 5, 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:

8308842: Consolidate exceptions thrown from Class-File API

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 4 new commits pushed to the master branch:

  • 2b38343: 8309416: Misstatement in semantics of methods in javax.lang.model.ElementFilter
  • 73352b6: 8280994: [XWayland] Drag and Drop does not work in java -> wayland app direction
  • 5cd8af7: 8308726: RISC-V: avoid unnecessary slli in the vectorized arraycopy stubs for bytes
  • 80232b7: 8308969: make test-prebuilt doesn't return the correct exit code

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
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 Jun 5, 2023
@asotona
Copy link
Member Author

asotona commented Jun 5, 2023

/integrate

@openjdk
Copy link

openjdk bot commented Jun 5, 2023

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

  • 2b38343: 8309416: Misstatement in semantics of methods in javax.lang.model.ElementFilter
  • 73352b6: 8280994: [XWayland] Drag and Drop does not work in java -> wayland app direction
  • 5cd8af7: 8308726: RISC-V: avoid unnecessary slli in the vectorized arraycopy stubs for bytes
  • 80232b7: 8308969: make test-prebuilt doesn't return the correct exit code

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Jun 5, 2023

@asotona Pushed as commit 4b8922f.

💡 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
Development

Successfully merging this pull request may close these issues.

None yet

4 participants