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

JDK 1.2 VM accepts non-public main method as the primary entry (1.1 OK)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.1.7
    • hotspot
    • generic
    • generic



      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)
      ======================================================================

            apalanissunw Anand Palaniswamy (Inactive)
            kryansunw Kevin Ryan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: