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

NoSuchMethodError instead of AbstractMethodError under the method resolution

XMLWordPrintable

    • 1.2fcs
    • sparc
    • solaris_2.5.1
    • Not verified



      Name: szC45993 Date: 07/14/98

      The test below shows that jdk1.2b4K throws wrong exception under the method resolution.
      There is invocation of the method defined only as abstract into the interface
      in the test. Hence, the method lookup must succeed on the third stage of the
      resolution according to 5.4.3c Method Resolution of the vm spec:
      "3. Otherwise, method lookup attempts to locate the referenced method in any of the
         superinterfaces of the specified class C.
            If any superinterface of C declares a method with the name and
            descriptor specified by the
            method reference, method lookup succeeds. "
      However, the next stage of resolution must rise AbstractMethodError according
      to the following assertion of the 5.4.3c:
      "If method lookup succeeds and the method is abstract, but C is not abstract,
      method resolution throws an AbstractMethodError."
      In fact, NoSuchMethodError is wrongly risen by the jvm.
      Apparently, such wrong result is the same for both cases of invocation
      when invokevirtual or invokespecial instruction is used.

      novo7% setenv CLASSPATH /export/home1/JAVA/workdir4/classes:/export/home1/JAVA/tmp/../classes:/export/ld32/sqe/harness_release_new/classes
      novo7% /export/ld14/java/dest/jdk1.2b4K/solaris/bin/javac -d /export/home1/JAVA/workdir4/classes -nowarn invokespecial00601m1.java
      novo7% /export/ld14/java/dest/jdk1.2b4K/solaris/bin/java javasoft.sqe.jasm.Main -d /export/home1/JAVA/workdir4/classes invokespecial00601m1v.jasm
      novo7% /export/ld14/java/dest/jdk1.2b4K/solaris/bin/java -verify javasoft.sqe.tests.vm.invokevirtual.invokespecial006.invokespecial00601m1.invokespecial00601m1
      Failed with unexpected exception: java.lang.NoSuchMethodError: javasoft.sqe.tests.vm.invokevirtual.invokespecial006.invokespecial00601m1.invokespecial00601m10na: method mtd()V not found
      novo7% /export/ld14/java/dest/jdk1.2b4K/solaris/bin/java -version
      java version "1.2beta4"
      Classic VM (build JDK-1.2beta4-K, green threads, sunwjit)

      SOURCES:


      --------------------- invokespecial00601m1.java
      /* Ident: @(#)invokespecial00601m1.java generated from: @(#)invokespecial00601m.jmpp 1.1 98/07/10 */
      /* Copyright 7/13/98 Sun Microsystems, Inc. All Rights Reserved */

      package javasoft.sqe.tests.vm.invokevirtual.invokespecial006.invokespecial00601m1;

      import java.io.PrintStream;

      public class invokespecial00601m1 {

          public static int run(String argv[], PrintStream out) {
      Class badClass = null;
      try {
      badClass = Class.forName("javasoft.sqe.tests.vm.invokevirtual.invokespecial006.invokespecial00601m1.invokespecial00601m10n");
      Object obj=badClass.newInstance();
      } catch (AbstractMethodError e) {
      out.println("Passed with exception: " + e);
      return 0/*STATUS_PASSED*/;
      } catch (ClassNotFoundException e) {
      out.println("Passed with loading exception: " + e);
      return 0/*STATUS_PASSED*/;
      } catch (Throwable e) {
      out.println("Failed with unexpected exception: " + e);
      return 2/*STATUS_FAILED*/;
      }
      out.println("Failed to reject invalid class ");
      return 2/*STATUS_FAILED*/;
          }

          public static void main(String args[]) {
      System.exit(run(args, System.out) + 95/*STATUS_TEMP*/);
          }

      }
      --------------------- invokespecial00601m1v.jasm
      /* Ident: @(#)invokespecial00601m1v.jasm generated from: @(#)invokespecial00601m.jmpp 1.1 98/07/10 */
      /* Copyright 7/13/98 Sun Microsystems, Inc. All Rights Reserved */

      package javasoft/sqe/tests/vm/invokevirtual/invokespecial006/invokespecial00601m1;


      interface invokespecial00601m10ni
      {
      public abstract Method mtd:"()V";

      }


      super class invokespecial00601m10na
      implements invokespecial00601m10ni
      {

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

      super public class invokespecial00601m10n
      extends invokespecial00601m10na
      {
      public Method "<init>":"()V"
      stack 1 locals 1
      {
      aload_0;
      invokespecial Method invokespecial00601m10na."<init>":"()V";
      aload_0;
      //########################################################################
      // invokevirtual Method invokespecial00601m10na.mtd:"()V";
      invokespecial Method invokespecial00601m10na.mtd:"()V";
      //########################################################################
      return;
      }

      }
      ======================================================================

      Hook 5(hook5): test

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

            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: