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

compiler doesn't create class file for inner class inside of a block

XMLWordPrintable

    • x86, sparc
    • solaris_2.5.1



      Name: laC46010 Date: 06/18/97



      Compiler doesn't create class file for inner class, declared inside of
      another inner class, which, in turn, is declared within a block. Doing so,
      it does not report any errors and succeeds in compilation. As a result of
      this, JVM throws java.lang.NoClassDefFoundError exception during execution
      of such a program.

      Example 'Test.java' demonstrates this behaviour. After successful
      compilation of 'Test.java', we have the following classes in output
      directory:
      Test$1$A.class
      Test.class

      As we try to run the program, java interpreter says (see console output
      below):
      java.lang.NoClassDefFoundError: Test$1$A$B
      at java.lang.Thread.init(Thread.java)

      Note, that all compilers from JDK1.1_Final thru JDK1.1.3B produce no
      class file for class Test$1$A$B that way.


      --------------------Test.java----------------------
      public class Test {
      public static void main(String argv[]) {
      class A {
      class B {}
      }
      new A().new B();
      }
      }
      --------------------console output-----------------
      46 > ls -al
      total 6
      drwxrwxr-x 2 oul java 512 Jun 18 17:08 .
      drwxrwxr-x 4 oul java 512 Jun 18 14:46 ..
      -rw-rw-r-- 1 oul java 116 Jun 18 17:07 Test.java
      47 > /export/ld14/java/dest/jdk1.1.3B/solaris/bin/javac -d . Test.java
      48 ls -al
      total 10
      drwxrwxr-x 2 oul java 512 Jun 18 17:08 .
      drwxrwxr-x 4 oul java 512 Jun 18 14:46 ..
      -rw-rw-r-- 1 oul java 305 Jun 18 17:08 Test$1$A.class
      -rw-rw-r-- 1 oul java 460 Jun 18 17:08 Test.class
      -rw-rw-r-- 1 oul java 116 Jun 18 17:07 Test.java
      49 > /export/ld14/java/dest/jdk1.1.3B/solaris/bin/java Test
      java.lang.NoClassDefFoundError: Test$1$A$B
      at java.lang.Thread.init(Thread.java)
      50 >
      ---------------------------------------------------


      ======================================================================

            wmaddoxsunw William Maddox (Inactive)
            leosunw Leo Leo (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: