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

VM allows an abstract method with Code attribute.

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      1.2fcs
    • CPU:
      sparc
    • OS:
      solaris_2.4
    • Verification:
      Verified

      Description



      Name: akC45999 Date: 07/06/98



      The Java VM spec chapter "4.6 Methods" reads:
      ...
      Is abstract; no implementation is provided.

      But the attached test shows that VM doesn't reject a class which contain an abstract method with Code attribute.

      --------------------------------- test.java

      import java.io.PrintStream;

      public class test {
        
        public static void main(String argv[]) {

      try {
      Class.forName("BadClass");
      System.out.println("Very bad");
      } catch (Throwable e) {
      System.out.println("Exception " + e);
      }
        }
      }

      --------------------------------- BadClass.jasm

      abstract class BadClass
      {

      abstract Method "testMethod":"()V"
      {
      return;
      }
      }

      ------------------------------------- dotest

      #!/bin/sh
      TESTCLASSES=/opt/home/testclasses
      CLASSPATH=$TESTCLASSES
      export CLASSPATH

      jasm -d $TESTCLASSES *.jasm
      javac -d $TESTCLASSES *.java
      java -verify test;

      ----------------------------------------
      Running the test:

      novo48% dotest
      Very bad
      novo48%
      ======================================================================

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

      Name: akC45999 Date: 07/07/98



      The Java VM spec chapter "4.6 Methods" reads:
      ...
      If the method is either native or abstract, its method_info structure must not have a Code attribut.

      But the attached test shows that VM doesn't reject a class which contain an abstract method with Code attribute.

      --------------------------------- test.java

      import java.io.PrintStream;

      public class test {
        
        public static void main(String argv[]) {

      try {
      Class.forName("BadClass");
      System.out.println("Very bad");
      } catch (Throwable e) {
      System.out.println("Exception " + e);
      }
        }
      }

      --------------------------------- BadClass.jasm

      abstract class BadClass
      {

      abstract Method "testMethod":"()V"
      {
      return;
      }
      }

      ------------------------------------- dotest

      #!/bin/sh
      TESTCLASSES=/opt/home/testclasses
      CLASSPATH=$TESTCLASSES
      export CLASSPATH

      jasm -d $TESTCLASSES *.jasm
      javac -d $TESTCLASSES *.java
      java -verify test;

      ----------------------------------------
      Running the test:

      novo48% dotest
      Very bad
      novo48%
      ======================================================================

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

      Name: akC45999 Date: 07/07/98



      The Java VM spec chapter "4.6 Methods" reads:
      ...
      If the method is either native or abstract, its method_info structure must not have a Code attribute.

      But the attached test shows that VM doesn't reject a class which contain an abstract method with Code attribute.

      --------------------------------- test.java

      import java.io.PrintStream;

      public class test {
        
        public static void main(String argv[]) {

      try {
      Class.forName("BadClass");
      System.out.println("Very bad");
      } catch (Throwable e) {
      System.out.println("Exception " + e);
      }
        }
      }

      --------------------------------- BadClass.jasm

      abstract class BadClass
      {

      abstract Method "testMethod":"()V"
      {
      return;
      }
      }

      ------------------------------------- dotest

      #!/bin/sh
      TESTCLASSES=/opt/home/testclasses
      CLASSPATH=$TESTCLASSES
      export CLASSPATH

      jasm -d $TESTCLASSES *.jasm
      javac -d $TESTCLASSES *.java
      java -verify test;

      ----------------------------------------
      Running the test:

      novo48% dotest
      Very bad
      novo48%

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

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

        Attachments

          Activity

            People

            Assignee:
            sliangsunw Sheng Liang (Inactive)
            Reporter:
            rfqsunw Rfq Rfq (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: