Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8288976

classfile parser 'wrong name' error message has the names the wrong way around

XMLWordPrintable

    • b04

        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

              hseigel Harold Seigel (Inactive)
              dholmes David Holmes
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: