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

InstantiationError instead of AbstractMethodError on the abstract method in non-

XMLWordPrintable

    • 1.2alpha2
    • sparc
    • solaris_2.5
    • Not verified



      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.
       ...
         b. ...
       ...
      If a class that is not declared abstract has an abstract method, class resolution throws an AbstractMethodError."

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

      java.lang.InstantiationError: javasoft/sqe/tests/vm/constantpool/ClassInterf016/ClassInterf01601/clss
      at
      at javasoft.sqe.tests.vm.constantpool.ClassInterf016.ClassInterf01601.ClassInterf01601.run(ClassInterf01601.java:21)
      at javasoft.sqe.tests.vm.constantpool.ClassInterf016.ClassInterf01601.ClassInterf01601.main(ClassInterf01601.java:48)
      test result: Failed. unexpected exit code

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

      package javasoft.sqe.tests.vm.constantpool.ClassInterf016.ClassInterf01601;

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

      interface Inter {
          int intrmdtprc(PrintStream out);
      }

      public class ClassInterf01601 {

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

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

      } catch (java.lang.AbstractMethodError e) {
      out.println(e);
      return 0;
      } 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;
      };

      try{
      return i.intrmdtprc(out);
      }
      catch (java.lang.AbstractMethodError e) {
      return 0;
      }
        }

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

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

      static Field c:"Ljavasoft/sqe/tests/vm/constantpool/ClassInterf016/ClassInterf01601/clss;";

      public Method intrmdtprc:"(Ljava/io/PrintStream;)I"
      stack 2 locals 2
      {
      try t8;
      getstatic Field c:"Ljavasoft/sqe/tests/vm/constantpool/ClassInterf016/ClassInterf01601/clss;";
      aload_1;
      invokevirtual Method clss.prc:"(Ljava/io/PrintStream;)I";
      ireturn;
      endtry t8;
      catch t8 java/lang/AbstractMethodError;
      //but InstantiationError 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/ClassInterf016/ClassInterf01601/clss;";
      return;
      }

      } // end Class Intrmdt
      --------------------- clss.jasm
      //File: @(#)clss.jasm 1.1 97/03/12
      //Copyright 03/12/97 Sun Microsystems, Inc. All Rights Reserved

      package javasoft/sqe/tests/vm/constantpool/ClassInterf016/ClassInterf01601;

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


      public Method prc:"(Ljava/io/PrintStream;)I"
      stack 1 locals 2
      {
      iconst_2;
      ireturn;
      }

      public abstract Method intrmdtprc:"(Ljava/io/PrintStream;)I";
      //!!!!!^^^^^^^^!!!!!!!!!!!!!!!!!!!
      //!!!!!^^^^^^^^!!!!!!!!!!!!!!!!!!!
      //!!!!!^^^^^^^^!!!!!!!!!!!!!!!!!!!

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

      } // end Class clss
      ---------------------

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

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: