JDK-4154504 : VM let to declare main() without public keyword.
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 1.2.0
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_2.4
  • CPU: sparc
  • Submitted: 1998-07-03
  • Updated: 1998-07-08
  • Resolved: 1998-07-08
Related Reports
Duplicate :  
Description

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% 

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

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