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

NoClassDefFoundError instead of VerifyError on the code constraints violation

    XMLWordPrintable

Details

    • vm
    • 1.2fcs
    • sparc
    • solaris_2.5
    • Not verified

    Description



      Name: szC45993 Date: 03/12/97



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

      "3. The class C is linked ($2.16.3), that is, it is verified ($4.9) and prepared.
      ...
      If the class or interface C contained in class file C.class does not satisfy the static or structural constraints on valid class files listed in Section 4.8, "Constraints on Java Virtual Machine Code," class or interface resolution throws a VerifyError."

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

      java.lang.NoClassDefFoundError: javasoft/sqe/tests/vm/constantpool/ClassInterf014/ClassInterf01401/clss
      at
      at javasoft.sqe.tests.vm.constantpool.ClassInterf014.ClassInterf01401.ClassInterf01401.run(ClassInterf01401.java:21)
      at javasoft.sqe.tests.vm.constantpool.ClassInterf014.ClassInterf01401.ClassInterf01401.main(ClassInterf01401.java:45)
      java.lang.NoClassDefFoundError: javasoft/sqe/tests/vm/constantpool/ClassInterf014/ClassInterf01401/clss
      at
      at javasoft.sqe.tests.vm.constantpool.ClassInterf014.ClassInterf01401.ClassInterf01401.run(ClassInterf01401.java:37)
      at javasoft.sqe.tests.vm.constantpool.ClassInterf014.ClassInterf01401.ClassInterf01401.main(ClassInterf01401.java:45)

      --------------------- ClassInterf01401.java
      //File: @(#)ClassInterf01401.java 1.1 97/02/17
      //Copyright 02/17/97 Sun Microsystems, Inc. All Rights Reserved

      package javasoft.sqe.tests.vm.constantpool.ClassInterf014.ClassInterf01401;

      import java.io.PrintStream;
      import java.io.*;
      import java.lang.*;
      import java.util.*;

      interface Inter {
          int intrmdtprc(PrintStream out);
      }

      public class ClassInterf01401 {

        public static int run(String argv[], PrintStream out) {
      Inter i;
      try{

      i = (Inter) ((Class.forName("javasoft.sqe.tests.vm.constantpool.ClassInterf014.ClassInterf01401.Intrmdt")).newInstance());

      } catch (java.lang.ClassNotFoundException e) {
      out.println("CLASS NOT FOUND: " + e);
      return 2;
      }
      catch (java.lang.IllegalAccessException e) {
      out.println(e);
      return 2;
      }
      catch (java.lang.InstantiationException e) {
      out.println(e);
      return 2;
      };

      return i.intrmdtprc(out);
        }

        public static void main(String argv[]) {
      System.exit(run(argv, System.out) + 95/*STATUS_TEMP*/);
        }
      }
      --------------------- Intrmdt.jasm
      package javasoft/sqe/tests/vm/constantpool/ClassInterf014/ClassInterf01401;

      public class Intrmdt
      implements Inter
      {
      // Compiled from Intrmdt.java
      // Compiler version 3.45;

      static Field c:"Ljavasoft/sqe/tests/vm/constantpool/ClassInterf014/ClassInterf01401/clss;";

      public Method intrmdtprc:"(Ljava/io/PrintStream;)I"
      stack 2 locals 2
      {
      try t8;
      getstatic Field c:"Ljavasoft/sqe/tests/vm/constantpool/ClassInterf014/ClassInterf01401/clss;";
      aload_1;
      invokevirtual Method clss.prc:"(Ljava/io/PrintStream;)I";
      ireturn;
      endtry t8;
      catch t8 java/lang/VerifyError;
      //but NoClassDefFoundError is rised !?
      pop;
      iconst_0;
      ireturn;
      }

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

      static Method <clinit>:"()V"
      stack 2 locals 0
      {
      new class clss;
      dup;
      invokespecial Method clss.<init>:"()V";
      putstatic Field c:"Ljavasoft/sqe/tests/vm/constantpool/ClassInterf014/ClassInterf01401/clss;";
      return;
      }

      } // end Class Intrmdt
      --------------------- clss.jasm
      class javasoft/sqe/tests/vm/constantpool/ClassInterf014/ClassInterf01401/clss {
        0xCAFEBABE;
        3; // minor version
        45; // version
        [18] { // Constant Pool
          ; // first element is empty
          class #13; // #1 at 0x0A
          class #15; // #2 at 0x0D
          Method #1 #4; // #3 at 0x10
          NameAndType #14 #17; // #4 at 0x15
          Utf8 "(Ljava/io/PrintStream;)I"; // #5 at 0x1A
          Utf8 "ConstantValue"; // #6 at 0x35
          Utf8 "prc"; // #7 at 0x45
          Utf8 "Exceptions"; // #8 at 0x4B
          Utf8 "LineNumberTable"; // #9 at 0x58
          Utf8 "SourceFile"; // #10 at 0x6A
          Utf8 "LocalVariables"; // #11 at 0x77
          Utf8 "Code"; // #12 at 0x88
          Utf8 "java/lang/Object"; // #13 at 0x8F
          Utf8 "<init>"; // #14 at 0xA2
          Utf8 "javasoft/sqe/tests/vm/constantpool/ClassInterf014/ClassInterf01401/clss"; // #15 at 0xAB
          Utf8 "clss.java"; // #16 at 0xF5
          Utf8 "()V"; // #17 at 0x0101
        } // Constant Pool

        0x0001; // access
        #2;// this_cpx
        #1;// super_cpx

        [0] { // Interfaces
        } // Interfaces

        [0] { // fields
        } // fields

        [2] { // methods
          { // Member at 0x0113
            0x0001; // access
            #7; // name_cpx
            #5; // sig_cpx
            [1] { // Attributes
              Attr(#12, 26) { // Code at 0x011B
                1; // max_stack
                2; // max_locals
      //////////////////////////////////////////////////////////////////////////////
      //////////////////////////// jvm code constraints violation ($4.8.1,"The last byte of the last instruction in the code array must be the byte at index code_length-1"):
      // Bytes[2] { //So it was.
                Bytes[1] {
      //////////////////////////////////////////////////////////////////////////////
                  0x05AC;
                };
                [0] { // Traps
                } // end Traps
                [1] { // Attributes
                  Attr(#9, 6) { // LineNumberTable at 0x012F
                    [1] { // LineNumberTable
                      0 13; // at 0x0137
                    }
                  } // end LineNumberTable
                } // Attributes
              } // end Code
            } // Attributes
          } // Member
          ;
          { // Member at 0x013B
            0x0001; // access
            #14; // name_cpx
            #17; // sig_cpx
            [1] { // Attributes
              Attr(#12, 29) { // Code at 0x0143
                1; // max_stack
                1; // max_locals
                Bytes[5] {
                  0x2AB70003B1;
                };
                [0] { // Traps
                } // end Traps
                [1] { // Attributes
                  Attr(#9, 6) { // LineNumberTable at 0x015A
                    [1] { // LineNumberTable
                      0 9; // at 0x0162
                    }
                  } // end LineNumberTable
                } // Attributes
              } // end Code
            } // Attributes
          } // Member
        } // methods

        [1] { // Attributes
          Attr(#10, 2) { // SourceFile at 0x0168
            #16;
          } // end SourceFile
        } // Attributes
      } // end class javasoft/sqe/tests/vm/constantpool/ClassInterf014/ClassInterf01401/clss
      ---------------------

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

      Attachments

        Activity

          People

            gbrachasunw Gilad Bracha (Inactive)
            zsssunw Zss Zss (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: