Skip to content

Support anonymous, local and JDK nested classes in TOOLING.jsh's javap function #26864

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

altrisi
Copy link
Contributor

@altrisi altrisi commented Aug 20, 2025

This PR makes TOOLING.jsh's javap function support anonymous, local and built-in nested classes.

Note that nested classes created in jshell would previously work, but not JDK ones as they'd miss the is built-in check (wrong name for Class.forName) and later throw an exception because of a null classloader.

The rest of classes would fail the canonical name check, which wouldn't allow them to be disassembled.

This change makes them work by changing the check from canonicalName != null to specific checks for unsupported types of classes, and doing Class.forName using the result of getName(), not the canonical name, for the built-in check.


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

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 26864

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 20, 2025

👋 Welcome back altrisi! 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
Copy link

openjdk bot commented Aug 20, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk
Copy link

openjdk bot commented Aug 20, 2025

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

  • compiler

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.

@@ -9,8 +9,8 @@ void jpackage(String... args) { run("jpackage", args); }

void javap(Class<?> type) throws Exception {
try {
var name = type.getCanonicalName();
if (name == null) throw new IllegalArgumentException("Type not supported: " + type);
if (type.isPrimitive() || type.isHidden() || type.isArray()) throw new IllegalArgumentException("Type not supported: " + type);
Copy link
Member

@liach liach Aug 20, 2025

Choose a reason for hiding this comment

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

The message should say the given class has no class file. And this check should be hoisted out of the try-catch.

It's enough with just the user-created one, which is reliable and won't cause failures if the class being targeted is refactored
@liach
Copy link
Member

liach commented Aug 20, 2025

Created https://bugs.openjdk.org/browse/JDK-8365878 for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants