-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
base: master
Are you sure you want to change the base?
Conversation
And correctly report actually unsupported classes
👋 Welcome back altrisi! A progress list of the required criteria for merging this PR into |
❗ This change is not yet ready to be integrated. |
@@ -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); |
There was a problem hiding this comment.
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
Created https://bugs.openjdk.org/browse/JDK-8365878 for you. |
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
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