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

vm throws VerifyError instead of ClassFormatError if Code is absent

    Details

    • Subcomponent:
    • Resolved In Build:
      hopper
    • CPU:
      generic
    • OS:
      generic

      Description



      Name: vrC94537 Date: 10/11/99



      Non-abstract and non-native method without Code attribute must be rejected
      with ClassFormatError not VerifyError thrown by jdk1.3.0J

      The section "4.1 The ClassFile Structure" of 2nd JVM spec says:
      "If the method is not native or abstract, the Java virtual machine
      instructions implementing the method are also supplied."

      If class contains non-abstract and non-native method without Code attribute,
      this class file is malformed and therefore JVM class format checker must
      reject it with exception ClassFormatError. However, JVM (all jdk version till 1.3.0J)
      throws VerifyError instead of ClassFormatError.

      The following jck1.3-RC1 tests
      (which was modified compared with jck1.2.2)
      vm/classfmt/clf/clfmth003/clfmth00301m1/clfmth00301m1.html
      is failed due to this bug.

      See test sources and log below:
      ----------- test.java ------------
      public class test {
        public static void main(String args[]) {
          try {
            Class badClass = Class.forName("testn");
            System.out.println("test failed to reject bad classfile");
          } catch (Throwable e) {
            System.out.println("loading exception: " + e);
          }
        }
      }
      ----------- testn.jasm ------------
      class testn {
        Method f:"()V"; // non-abstract and non-native method without Code attribute
        public Method <init>:"()V" stack 1 {
          aload_0;
          invokespecial java/lang/Object.<init>:"()V";
          return;
        }
      }
      ----------------------------------
      ---------- Execution -------------
      %jasm testn.jasm

      %javac test.java

      %java -version
      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-J)
      Java HotSpot (TM) Client VM (build 1.3-J, interpreted mode)

      %java -Xfuture test
      loading exception: java.lang.VerifyError: (class: testn, method: f signature: ()V) Empty code
      ----------------------------------

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

        Attachments

          Activity

            People

            • Assignee:
              wtaosunw Wei Tao (Inactive)
              Reporter:
              duke J. Duke (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: