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

static void main(String args[]) works without public

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.2.1
    • hotspot
    • x86
    • windows_nt



      Name: vi73552 Date: 05/04/99


      This compiles and runs without any error at runtime on JDK1.2.1
      class L2 extends Object {
              static void main(String args[]) {
                      System.out.println("L1 - main");
              }
      }

      In JDK 1.1, we get runtime error
      In class L2: main must be public and static.

      1.2.1 documentation says

      12.1.4 Invoke Test.main

      Finally, after completion of the initialization for class Test (during which other
      consequential loading, linking, and initializing may have occurred), the method
      main of Test is invoked.

      The method main must be declared public, static, and void. It must accept a
      single argument that is an array of strings.
      (Review ID: 57782)
      ======================================================================

            apalanissunw Anand Palaniswamy (Inactive)
            vasya Vassili Igouchkine (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: