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

VM let to declare main() without public keyword.

XMLWordPrintable

    • sparc
    • solaris_2.4



      Name: akC45999 Date: 07/03/98



      The Java VM spec chapter "2.16.1 Virtual Machine Start-up" reads:
      ...
      The method main must be declared public, static, and void.

      But the attached test shows that VM doesn't reject a class containing
      method main() declared without public keyword.

      --------------------------------- execution00201.jasm

      public class execution00201
      {

      static Method main:"([Ljava/lang/String;)V"
      stack 2 locals 1
      {
      bipush 95/*STATUS_TEMP*/;
      invokestatic Method java/lang/System.exit:"(I)V";
      return;
      }
      } // end Class execution00201
       
      ------------------------------------- dotest

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

      jasm -d $TESTCLASSES execution00201.jasm
      java -verify execution00201;
      echo res=$?

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

      novo48% dotest
      res=95
      novo48%

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

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

            Unassigned Unassigned
            rfqsunw Rfq Rfq (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: