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

Reject pre-51.0 classes with <clinit> methods with arguments



    • Bug
    • Resolution: Unresolved
    • P4
    • tbd
    • 21
    • specification
    • vm


      JVMS claims that a pre-51.0 class file is allowed to declare a method named '<clinit>' with a non-empty argument list. This method should be treated like any other, with none of the special treatment given to class initialization methods.

      There is very little utility in such a method, since it can never be invoked. If any such methods exist in the wild, they likely exist because of a bug; it's possible some important logic will not execute due to the bug.

      Meanwhile, HotSpot doesn't actually conform to this model. For example, verification treats a '<clinit>' method with arguments as implicitly static even when ACC_STATIC is unset. This sort of issue is a natural consequence of keying off of the method name, '<clinit>', to determine whether a method is a class initialization method.

      Rather than imposing a complex model on Hotspot, or specifying some ad hoc HotSpot behaviors in JVMS, I propose rejecting these anomalous method declarations during format checking.

      In theory, that change carries some small incompatibility risk, but I imagine the problem almost never exists in practice; and if it does, it's probably useful for the user to be alerted about the bug.


        Issue Links



              dlsmith Dan Smith
              dlsmith Dan Smith
              0 Vote for this issue
              1 Start watching this issue