JDK-8288976 : classfile parser 'wrong name' error message has the names the wrong way around
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 20
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2022-06-22
  • Updated: 2024-10-05
  • Resolved: 2022-06-24
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 17 JDK 20
17.0.14Fixed 20 b04Fixed
Related Reports
Relates :  
Description
Spotted in an erroneous bug report. Consider a class:

package circular;
public class I {
} 

which gets compiled into ./circular/I.class

You then incorrectly invoke it as:

java -cp circular I

the error is:

Error: Could not find or load main class I
Caused by: java.lang.NoClassDefFoundError: circular/I (wrong name: I) 

but it should be:

Error: Could not find or load main class I
Caused by: java.lang.NoClassDefFoundError: I (wrong name: circular/I) 

because the VM was asked to load class I but couldn't find I; it found a classfile I.class, but that classfile identified the class in it as circular.I which is the wrong name.

There is obviously a matter of perspective on this but the error should reflect things from the user's perspective:

User: Hey JVM please load class I
JVM: Where should I look for it?
User: in the circular directory
JVM: NoClassDefFoundError: I
User: Hey it is in file I.class
JVM: No the class in that file has the wrong name: circular.I

Comments
Fix request [17u] I backport this so that the message of this new exception reads the same in all releases. Low risk, changes only message text. Clean backport. Test passes and fails without the fix. SAP nightly testing passed.
02-10-2024

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk17u-dev/pull/2925 Date: 2024-10-01 11:20:19 +0000
01-10-2024

The exception message fixed here was introduced by JDK-8238358
01-10-2024

Changeset: 925084c4 Author: Harold Seigel <hseigel@openjdk.org> Date: 2022-06-24 12:03:09 +0000 URL: https://git.openjdk.org/jdk/commit/925084c496113c9d8e860ded0b8645fd584380bc
24-06-2022

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/9264 Date: 2022-06-23 21:23:00 +0000
23-06-2022