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

NoClassDefFoundError instead of ClassFormatError on the class file which does no

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      1.2alpha2
    • CPU:
      sparc
    • OS:
      solaris_2.5
    • Verification:
      Not verified

      Description



      Name: szC45993 Date: 03/11/97



      The Java Virtual Machine, chapter 5 Constant Pool Resolution,
      section 5.1.1 Current Class or Interface Not Loaded by a Class Loader, claims:

      "1. The class or interface C and its superclasses are first loaded ($2.16.2).
         a. ...

      ...

       Otherwise, if the selected class file does not specify a superclass and is not the class file for class Object, class or interface resolution throws a ClassFormatError."

      Meanwhile, undermentioned test gives the following result (jdk_1.0.2):

      java.lang.NoClassDefFoundError: javasoft/sqe/tests/vm/constantpool/ClassInterf008/ClassInterf00801/clss
      at
      at javasoft.sqe.tests.vm.constantpool.ClassInterf008.ClassInterf00801.ClassInterf00801.main(ClassInterf00801.jasm)

      --------------------- ClassInterf00801.jasm
      package javasoft/sqe/tests/vm/constantpool/ClassInterf008/ClassInterf00801;

      public class ClassInterf00801 {
      // Compiled from ClassInterf00801.java
      // Compiler version 3.45;


      public static Method run:"([Ljava/lang/String;Ljava/io/PrintStream;)I"
      stack 2 locals 3
      {
      try t16;
      new class clss;
      dup;
      invokespecial Method clss.<init>:"()V";
      astore_2;
      aload_2;
      invokevirtual Method clss.mthd:"()I";
      pop;
      endtry t16;
      goto L19;
      catch t16 java/lang/ClassFormatError;
      pop;
      iconst_0;
      ireturn;
      L19: iconst_2;
      ireturn;
      }

      public static Method main:"([Ljava/lang/String;)V"
      stack 2 locals 1
      {
      aload_0;
      getstatic Field java/lang/System.out:"Ljava/io/PrintStream;";
      invokestatic Method run:"([Ljava/lang/String;Ljava/io/PrintStream;)I";
      bipush 95;
      iadd;
      invokestatic Method java/lang/System.exit:"(I)V";
      return;
      }

      public Method <init>:"()V"
      stack 1 locals 1
      {
      aload_0;
      invokespecial Method java/lang/Object.<init>:"()V";
      return;
      }

      } // end Class ClassInterf00801

      --------------------- clss.jcod
      class javasoft/sqe/tests/vm/constantpool/ClassInterf008/ClassInterf00801/clss {
        0xCAFEBABE;
        3; // minor version
        45; // version
        [18] { // Constant Pool
          ; // first element is empty
          class #13; // #1 at 0x0A
          class #12; // #2 at 0x0D
          Method #1 #4; // #3 at 0x10
          NameAndType #15 #17; // #4 at 0x15
          Utf8 "()I"; // #5 at 0x1A
          Utf8 "ConstantValue"; // #6 at 0x20
          Utf8 "Exceptions"; // #7 at 0x30
          Utf8 "LineNumberTable"; // #8 at 0x3D
          Utf8 "SourceFile"; // #9 at 0x4F
          Utf8 "LocalVariables"; // #10 at 0x5C
          Utf8 "Code"; // #11 at 0x6D
          Utf8 "javasoft/sqe/tests/vm/constantpool/ClassInterf008/ClassInterf00801/clss"; // #12 at 0x74
          Utf8 "java/lang/Object"; // #13 at 0xBE
          Utf8 "mthd"; // #14 at 0xD1
          Utf8 "<init>"; // #15 at 0xD8
          Utf8 "clss.java"; // #16 at 0xE1
          Utf8 "()V"; // #17 at 0xED
        } // Constant Pool

        0x0001; // access
        #2;// this_cpx
      //###########################################################################
      //###########################################################################
        #0;// super_cpx // The 0 value of the super_class item to non-Object class.
                        // It must lead to ClassFormatError!
                        // (The 1 value must be here.)
      //###########################################################################
      //###########################################################################

        [0] { // Interfaces
        } // Interfaces

        [0] { // fields
        } // fields

        [2] { // methods
          { // Member at 0xFF
            0x0001; // access
            #14; // name_cpx
            #5; // sig_cpx
            [1] { // Attributes
              Attr(#11, 26) { // Code at 0x0107
                1; // max_stack
                1; // max_locals
                Bytes[2] {
                  0x05AC;
                };
                [0] { // Traps
                } // end Traps
                [1] { // Attributes
                  Attr(#8, 6) { // LineNumberTable at 0x011B
                    [1] { // LineNumberTable
                      0 9; // at 0x0123
                    }
                  } // end LineNumberTable
                } // Attributes
              } // end Code
            } // Attributes
          } // Member
          ;
          { // Member at 0x0127
            0x0001; // access
            #15; // name_cpx
            #17; // sig_cpx
            [1] { // Attributes
              Attr(#11, 29) { // Code at 0x012F
                1; // max_stack
                1; // max_locals
                Bytes[5] {
                  0x2AB70003B1;
                };
                [0] { // Traps
                } // end Traps
                [1] { // Attributes
                  Attr(#8, 6) { // LineNumberTable at 0x0146
                    [1] { // LineNumberTable
                      0 6; // at 0x014E
                    }
                  } // end LineNumberTable
                } // Attributes
              } // end Code
            } // Attributes
          } // Member
        } // methods

        [1] { // Attributes
          Attr(#9, 2) { // SourceFile at 0x0154
            #16;
          } // end SourceFile
        } // Attributes
      } // end class javasoft/sqe/tests/vm/constantpool/ClassInterf008/ClassInterf00801/clss
      ---------------------

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

        Attachments

          Activity

            People

            Assignee:
            sliangsunw Sheng Liang (Inactive)
            Reporter:
            zsssunw Zss Zss (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: