JDK-4228581 : JDK 1.2 VM accepts non-public main method as the primary entry (1.1 OK)
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 1.1.7
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 1999-04-11
  • Updated: 1999-04-13
  • Resolved: 1999-04-13
Related Reports
Duplicate :  
Description

Name: krT82822			Date: 04/11/99


Even when the main method in the appliation's main class is non-public (i.e., declared without public keyword,) the Java VM accepts it and invokes it without any error/warning messages.  This behaviour seems a violation against the section 12.1.4 of The Java Language Specification, which says "The method main must be declared public, static, and void."

E.g., when Hello.java is

class Hello {
        static void main ( String [] argv ) {
                System.out.println( "Hello, world" );
        }
}

current java command (or jre command) executes it successfully, although it should report the fact that the main must be declared as public.
(Review ID: 56812) 
======================================================================