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

jvm does not reject non-abstract class which includes abstract method

    Details

    • Subcomponent:
      vm
    • CPU:
      sparc
    • OS:
      solaris_2.5.1

      Description



      Name: szC45993 Date: 05/24/98



      The revised jvm spec says:
       
      "2.8.2 Class Modifiers

      ...

      An abstract class is a class which is incomplete, or considered incomplete. Only abstract
      classes may have abstract methods (?2.10.3), that is, methods which are declared but not yet
      implemented."

      So, spec forbids the abstract method existence within the non-abstract class.
      Consequently, either jvm spec should allow such existence or jvm implementation
      should reject such class.

      The test below shows that jdk1.2b4G permits abstract method inside abstract
      class:

      novo7% setenv CLASSPATH /export/home/JAVA/workdir/classes:/export/home/JAVA/sqe_my/harness_release/classes
      novo7% /export/ld14/java/dest/jdk1.2b4G/solaris/bin/java -verify javasoft.sqe.tests.vm.invokevirtual.invokevirtual018.invokevirtual01803m1.invokevirtual01803m1n
      novo7% echo $status
      97
      novo7%


      SOURCE:


      --------------------- invokevirtual01803m1n.jasm
      /* Ident: @(#)invokevirtual01803m1n.jasm generated from: @(#)invokevirtual01803m.jmpp 1.1 98/05/23 */
      /* Copyright 5/25/98 Sun Microsystems, Inc. All Rights Reserved */

      package javasoft/sqe/tests/vm/invokevirtual/invokevirtual018/invokevirtual01803m1;

      class invokevirtual01803m1na
      {
      //#################################################
      //Error (see 2.8.2 of revised jvm spec):
      // abstract method inside non-abstract class must not be allowed
      public abstract Method m1:"()I";
      //#################################################

      public Method m2:"()I"
      stack 2 locals 3
      {
      iconst_2/*STATUS_FAILED*/;
      ireturn;
      }

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

      } // end Class invokevirtual01803m1na

      public class invokevirtual01803m1n
      {

      public static Method run:"([Ljava/lang/String;Ljava/io/PrintStream;)I"
      stack 2 locals 3
      {
      new class invokevirtual01803m1na;
      dup;
      invokespecial Method invokevirtual01803m1na.<init>:"()V";
      astore_2;
      aload_2;
      invokevirtual Method invokevirtual01803m1na.m2:"()I";
      ireturn;
      }

      public static Method main:"([Ljava/lang/String;)V"
      stack 2 locals 1
      {
      aload_0;
      getstatic Field java/lang/System.out:"Ljava/io/PrintStream;";
      invokestatic Method run:"([Ljava/lang/String;Ljava/io/PrintStream;)I";
      bipush 95;
      iadd;
      invokestatic Method java/lang/System.exit:"(I)V";
      return;
      }

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

      } // end Class invokevirtual01803m1n
      ======================================================================

      Hook 5(hook5): test

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

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: