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

4.6: Enforce ACC_STATIC for a <clinit> method

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 10
    • 9
    • specification
    • vm

    Description

      2.9.2 specifies that a void method named <clinit> in a 51.0 class file must be static and no-args in order to be a class or interface initialization method. If the static test or the no-args test fails, then it is not a class or interface initialization method and should be rejected by 4.6. 4.6 performs the no-args test on descriptor_index (though fails to make it version-specific), but does not perform the static test on access_flags. Say:

      - access_flags: "In a class file whose version number is 51.0 or above, a method whose name is <clinit> must have its ACC_STATIC flag set (§2.9.2)."

      - descriptor_index: "If the name of the method is <clinit>, then the descriptor must denote a void method, and, in a class file whose version number is 51.0 or above, a method that takes no arguments."

      Returning to access_flags, the paragraph about the JVM ignoring the flags of a "successful" <clinit> method (i.e. one which meets the reqs for a class or interface initialization method) should be less strident. Saying that all access_flags are "ignored" except for ACC_STRICT is improper, because the static-ness of the method is important to verification and execution. Say:

      "A class or interface initialization method (§2.9.2) is called implicitly by the Java Virtual Machine. The value of its access_flags item is ignored except for the setting of the ACC_STATIC and ACC_STRICT flags, and the method is exempt from the preceding rules about legal combinations of flags."

      Attachments

        Issue Links

          Activity

            People

              abuckley Alex Buckley
              abuckley Alex Buckley
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: