-
Bug
-
Resolution: Fixed
-
P4
-
None
-
b05
The fix for JDK-8304446 (javap --system flag doesn't override system APIs) uses `className.indexOf('.') > 0` to check if a class has a named package. javap accepts classes that use `/` as a separate in addition to `.`, so the fix only works for the latter case.
I'm not sure if tolerating `/`-separated internal names is a deliberate feature, so this may be very low priority, but it would be nice to be consistent if possible.
The docs at https://docs.oracle.com/en/java/javase/22/docs/specs/man/javap.html show a few different examples of class specifications:
path/to/MyClass.class
jar:file:///path/to/MyJar.jar!/mypkg/MyClass.class
java.lang.Object
Note that the first two also include a '.' (in the '.class' extension), so the indexOf check would include those inputs.
If the check is an optimization for classes in the default/unnamed package, I wonder if it's worth considering just removing the check. Alternatively if it's necessary, it could perhaps check for `.` or `/` to consistently handle classes like `java/lang/Object`
```
# define JAVA18_HOME and JAVA19_HOME to refer to paths for the corresponding JDKS
# verify the versions
$ $JAVA21_HOME/bin/java -fullversion
openjdk full version "21.0.3+9-LTS"
$ $JAVA22_HOME/bin/java -fullversion
openjdk full version "22.0.1+8"
# using the same javap implementation but configuring --system always shows different definitions of java.util.List
$ diff <($JAVA22_HOME/bin/javap -v --system $JAVA21_HOME java.util.List) <($JAVA22_HOME/bin/javap -v --system $JAVA22_HOME java.util.List) | grep major
< major version: 65
> major version: 66
# configuring --system to different JDKs and shows the same definition of java/util/List
$ diff <($JAVA22_HOME/bin/javap -v --system $JAVA21_HOME java/util/List) <($JAVA22_HOME/bin/javap -v --system $JAVA22_HOME java/util/List) | grep major
...
no change
```
I'm not sure if tolerating `/`-separated internal names is a deliberate feature, so this may be very low priority, but it would be nice to be consistent if possible.
The docs at https://docs.oracle.com/en/java/javase/22/docs/specs/man/javap.html show a few different examples of class specifications:
path/to/MyClass.class
jar:file:///path/to/MyJar.jar!/mypkg/MyClass.class
java.lang.Object
Note that the first two also include a '.' (in the '.class' extension), so the indexOf check would include those inputs.
If the check is an optimization for classes in the default/unnamed package, I wonder if it's worth considering just removing the check. Alternatively if it's necessary, it could perhaps check for `.` or `/` to consistently handle classes like `java/lang/Object`
```
# define JAVA18_HOME and JAVA19_HOME to refer to paths for the corresponding JDKS
# verify the versions
$ $JAVA21_HOME/bin/java -fullversion
openjdk full version "21.0.3+9-LTS"
$ $JAVA22_HOME/bin/java -fullversion
openjdk full version "22.0.1+8"
# using the same javap implementation but configuring --system always shows different definitions of java.util.List
$ diff <($JAVA22_HOME/bin/javap -v --system $JAVA21_HOME java.util.List) <($JAVA22_HOME/bin/javap -v --system $JAVA22_HOME java.util.List) | grep major
< major version: 65
> major version: 66
# configuring --system to different JDKs and shows the same definition of java/util/List
$ diff <($JAVA22_HOME/bin/javap -v --system $JAVA21_HOME java/util/List) <($JAVA22_HOME/bin/javap -v --system $JAVA22_HOME java/util/List) | grep major
...
no change
```
- relates to
-
JDK-8304446 javap --system flag doesn't override system APIs
- Resolved