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

Inner classes with identical names, but in different case, fails during runtime.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 1.4.2
    • Fix Version/s: None
    • Component/s: specification
    • Labels:
    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_2000

      Description

      Name: rmT116609 Date: 02/04/2004


      FULL PRODUCT VERSION :
      java version "1.4.2"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
      Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)

      FULL OS VERSION :
      Microsoft Windows 2000 [Version 5.00.2195]

      A DESCRIPTION OF THE PROBLEM :
      Having multiple inner classes with the same name but in a different case, like 'a' and 'A', compiles, but fails during runtime, with a NoClassDefFoundError.

      For eg, consider the following code,

      public class test2{

      public class d{
      public void f(){
      System.out.println("fff");
      }
      }

      public class D{
      public void f1(){
      System.out.println("ggg");
      }
      }

      public static void main(String args[]){
      test2 t2 = new test2();
      t2.testthis();
      }

      public void testthis(){
      D dd = new D();
      d dd1 = new d();
      dd.f1();
      dd1.f();
      }

      }

      this compiles fine and the class files generated are test2$d.class and test2.class.

      When this is run, the following error is received.

      Exception in thread "main" java.lang.NoClassDefFoundError: test2$d (wrong name:
      test2$D)
              at java.lang.ClassLoader.defineClass0(Native Method)
              at java.lang.ClassLoader.defineClass(ClassLoader.java:502)
              at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
      3)
              at java.net.URLClassLoader.defineClass(URLClassLoader.java:250)
              at java.net.URLClassLoader.access$100(URLClassLoader.java:54)
              at java.net.URLClassLoader$1.run(URLClassLoader.java:193)
              at java.security.AccessController.doPrivileged(Native Method)
              at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
              at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
              at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265)
              at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
              at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
              at test2.testthis(test2.java:22)
              at test2.main(test2.java:17)



      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Compile the following program, test2.java
      2. run it.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      In the console, the following should be seen.

      ggg
      fff
      D:\test>java test2
      Exception in thread "main" java.lang.NoClassDefFoundError: test2$d (wrong name:
      test2$D)
              at java.lang.ClassLoader.defineClass0(Native Method)
              at java.lang.ClassLoader.defineClass(ClassLoader.java:502)
              at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
      3)
              at java.net.URLClassLoader.defineClass(URLClassLoader.java:250)
              at java.net.URLClassLoader.access$100(URLClassLoader.java:54)
              at java.net.URLClassLoader$1.run(URLClassLoader.java:193)
              at java.security.AccessController.doPrivileged(Native Method)
              at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
              at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
              at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265)
              at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
              at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
              at test2.testthis(test2.java:22)
              at test2.main(test2.java:17)


      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      D:\test>java test2
      Exception in thread "main" java.lang.NoClassDefFoundError: test2$d (wrong name:
      test2$D)
              at java.lang.ClassLoader.defineClass0(Native Method)
              at java.lang.ClassLoader.defineClass(ClassLoader.java:502)
              at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
      3)
              at java.net.URLClassLoader.defineClass(URLClassLoader.java:250)
              at java.net.URLClassLoader.access$100(URLClassLoader.java:54)
              at java.net.URLClassLoader$1.run(URLClassLoader.java:193)
              at java.security.AccessController.doPrivileged(Native Method)
              at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
              at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
              at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265)
              at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
              at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
              at test2.testthis(test2.java:22)
              at test2.main(test2.java:17)


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public class test2{

      public class d{
      public void f(){
      System.out.println("fff");
      }
      }

      public class D{
      public void f1(){
      System.out.println("ggg");
      }
      }

      public static void main(String args[]){
      test2 t2 = new test2();
      t2.testthis();
      }

      public void testthis(){
      D dd = new D();
      d dd1 = new d();
      dd.f1();
      dd1.f();
      }

      }
      ---------- END SOURCE ----------
      (Incident Review ID: 185004)
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              abuckley Alex Buckley
              Reporter:
              rmandalasunw Ranjith Mandala (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: