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

NoSuchMethodError instead of AbstractMethodError

    Details

    • Subcomponent:
    • CPU:
      generic, sparc
    • OS:
      generic, solaris_2.5.1

      Description



      Name: ipC94532 Date: 01/21/2000



      The test below shows that throws wrong exception NoSuchMethodError instead of
      AbstractMethodError according to the following assertion of the JVMS 2nd edition
      CHAPTER 6 "The Java Virtual Machine Instruction Set", invokevirtual instruction):

      "Runtime Exceptions
          ...
          Otherwise, if no method matching the resolved name and descriptor is selected,
          invokevirtual throws an AbstractMethodError. "


      Similar result for invokespecial instruction was described in bug report #4156956.
      This bug is reproduced on different version of JDK (1.2, 1.2.2, 1.3.0A-S)
      on classic machine and HotSpot VM.
      ---------------------------------------------------------------
      Logs:

      > jasm invokevirtual02401m1v.jasm
      > jasm invokevirtual02401m1vf.jasm
      ## good superclass invokevirtual02401m10n_dad is changed by corrupted one (without method mtd)

      > javac invokevirtual02401m1.java
      >
      >java -version
      java version "1.3.0rc1"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0rc1-S)
      Java HotSpot(TM) Client VM (build 1.3.0rc1-S, interpreted mode)

      >java -Xfuture invokevirtual02401m1/invokevirtual02401m1
      Failed with unexpected runtime exception: java.lang.NoSuchMethodError

      >java -classic -version
      java version "1.3.0rc1"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0rc1-S)
      Classic VM (build 1.3.0rc1-S, green threads, nojit)

      >java -classic -Xfuture invokevirtual02401m1/invokevirtual02401m1
      Failed with unexpected runtime exception: java.lang.NoSuchMethodError:
      invokevirtual02401m1.invokevirtual02401m10n: method mtd()I not found

      ---------------------------------------------------------------
      Sources:

      ---- invokevirtual02401m1v.jasm

      package invokevirtual02401m1;

      public class invokevirtual02401m10n_dad {

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

      public Method mtd:"()I"
      stack 1 locals 2
      {
      iconst_0;
      ireturn;
      }


      } // end Class invokevirtual02401m10n_dad


      public class invokevirtual02401m10n extends invokevirtual02401m10n_dad {

      public Method <init>:"()V"
      stack 1 locals 2
      {
      aload_0;
      invokespecial Method invokevirtual02401m10n_dad.<init>:"()V";
      aload_0;
      invokevirtual Method invokevirtual02401m10n.mtd:"()I";
      return;
      }

      } // end Class invokevirtual02401m10n


      ----- invokevirtual02401m1vf.jasm with corrupt superclass invokevirtual02401m10n_dad

      package invokevirtual02401m1;

      public class invokevirtual02401m10n_dad {

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

      } // end Class invokevirtual02401m10n_dad

      ---- invokevirtual02401m1.java - wrapper
      package invokevirtual02401m1;

      import java.io.PrintStream;

      public class invokevirtual02401m1 {


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


          public static int run(String argv[], PrintStream out) {
          
      Class badClass = null;

      try {
      badClass = Class.forName("invokevirtual02401m1.invokevirtual02401m10n");
      try {
      Object obj=badClass.newInstance();
      } catch (AbstractMethodError e) {
      out.println("Passed with runtime exception: " + e);
      return 0/*STATUS_PASSED*/;
      }
      } catch (Throwable e) {
      out.println("Failed with unexpected loading exception: " + e);
      return 2/*STATUS_FAILED*/;
      }
      out.println("Failed to reject invalid class ");
      return 2/*STATUS_FAILED*/;
          }

      }

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

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

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                rgottliesunw Robert Gottlieb (Inactive)
                Reporter:
                duke J. Duke (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: