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

8278863: Add method ClassDesc::ofInternalName #9201

Closed
wants to merge 6 commits into from

Conversation

asotona
Copy link
Member

@asotona asotona commented Jun 17, 2022

The symbolic constants API (java.lang.constant) was designed, in part, to provide bytecode parsing and generation APIs with a validated, common, symbolic form for constants in Java class files.

There is an easy way to create a ClassDesc from a binary name (ClassDesc::of) or a field descriptor (ClassDesc::ofDescriptor) but not from an internal name. But, the internal name is common in low-level bytecode-manipulation code.

This patch adds ClassDesc::ofInternalName static factory method that creates a ClassDesc from class internal name.
Class internal name validation and extended ClassDescTest are also parts of this patch.

CSR is linked with the issue.

Please review.

Thank you,
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
  • Change requires a CSR request to be approved

Issues

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 9201

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 17, 2022

👋 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 Jun 17, 2022
@openjdk
Copy link

openjdk bot commented Jun 17, 2022

@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 Jun 17, 2022
@asotona
Copy link
Member Author

asotona commented Jun 17, 2022

/csr needed

@openjdk openjdk bot added the csr Pull request needs approved CSR before integration label Jun 17, 2022
@openjdk
Copy link

openjdk bot commented Jun 17, 2022

@asotona this pull request will not be integrated until the CSR request JDK-8288670 for issue JDK-8278863 has been approved.

@mlbridge
Copy link

mlbridge bot commented Jun 17, 2022

Webrevs

Copy link
Member

@JornVernee JornVernee left a comment

Choose a reason for hiding this comment

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

I've worked with ClassDesc quite a bit as well, and often found myself wanting to do the opposite. i.e. if I have a ClassDesc, convert it to an internal name string (to give to ASM).

There are also methods to get the descriptor, as well as display name & package name from a ClassDesc. So, I'd like to suggest adding a method to get the internal name from a ClassDesc as well.

test/jdk/java/lang/constant/ClassDescTest.java Outdated Show resolved Hide resolved
Co-authored-by: Jorn Vernee <JornVernee@users.noreply.github.com>
@asotona
Copy link
Member Author

asotona commented Jun 17, 2022

My initial thoughts were the same. Passing internal class name through the ClassDesc in and out is very frequent when using ASM library or similar.
However the problem here is that not all ClassDesc have internal class name, it can be applied only to non-primitive and non-array descriptors.
Proposed approach to work with class names in various forms (which can be even more tricky with upcoming Valhalla) is to use ClassDesc as the primary class-describing entity (instead of any form of String).

While constructing ClassDesc from various other forms (internal names, binary names, derivation from other ClassDesc, getting it from Class, etc...) is mostly user responsibility.
Different ways of ClassDesc serialization in various contexts (method descriptor, class reference, annotation, etc...) should be always responsibility of the processing library.

For ASM case I would rather recommend a util class directly converting ClassDesc to ASM Type, while passing ClassDesc through String internal name is risky and not covering all cases.

Copy link
Member

@JornVernee JornVernee left a comment

Choose a reason for hiding this comment

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

Thanks for explaining.

@bridgekeeper
Copy link

bridgekeeper bot commented Jul 18, 2022

@asotona This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@asotona
Copy link
Member Author

asotona commented Jul 26, 2022

ping to keep the PR open

@openjdk openjdk bot removed the csr Pull request needs approved CSR before integration label Sep 20, 2022
@openjdk
Copy link

openjdk bot commented Sep 20, 2022

@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:

8278863: Add method ClassDesc::ofInternalName

Reviewed-by: jvernee

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

  • 4020ed5: 8293210: G1: Remove redundant check in G1FreeHumongousRegionClosure
  • 8ff2c26: 8293942: [JVMCI] data section entries must be 4-byte aligned on AArch64
  • 6e23b43: 8293502: (fc) FileChannel::transfer methods fail to copy /proc files on Linux
  • 1f9ff41: 8292297: Fix up loading of override java.security properties file
  • 64b96e5: 8293811: Provide a reason for PassFailJFrame.forceFail
  • f91762f: 8293965: Code signing warnings after JDK-8293550
  • 8082c24: 8054572: [macosx] JComboBox paints the border incorrectly
  • b920d29: 8271328: User is able to choose the color after disabling the color chooser.
  • 5725a93: 8293879: Remove unnecessary castings in jdk.hotspot.agent
  • ab7f58a: 6286501: JTabbedPane throws NPE from its stateChanged listener in particular case
  • ... and 137 more: https://git.openjdk.org/jdk/compare/6a1e98cbf7369745409094e4b209602ac76f8ff3...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 20, 2022
@asotona
Copy link
Member Author

asotona commented Sep 20, 2022

/integrate

@openjdk
Copy link

openjdk bot commented Sep 20, 2022

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

  • 4020ed5: 8293210: G1: Remove redundant check in G1FreeHumongousRegionClosure
  • 8ff2c26: 8293942: [JVMCI] data section entries must be 4-byte aligned on AArch64
  • 6e23b43: 8293502: (fc) FileChannel::transfer methods fail to copy /proc files on Linux
  • 1f9ff41: 8292297: Fix up loading of override java.security properties file
  • 64b96e5: 8293811: Provide a reason for PassFailJFrame.forceFail
  • f91762f: 8293965: Code signing warnings after JDK-8293550
  • 8082c24: 8054572: [macosx] JComboBox paints the border incorrectly
  • b920d29: 8271328: User is able to choose the color after disabling the color chooser.
  • 5725a93: 8293879: Remove unnecessary castings in jdk.hotspot.agent
  • ab7f58a: 6286501: JTabbedPane throws NPE from its stateChanged listener in particular case
  • ... and 137 more: https://git.openjdk.org/jdk/compare/6a1e98cbf7369745409094e4b209602ac76f8ff3...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Sep 20, 2022

@asotona Pushed as commit 0fa7d9e.

💡 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
4 participants