-
Bug
-
Resolution: Unresolved
-
P4
-
21
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.
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.
- relates to
-
JDK-8323432 2.9: Revise special method description
-
- Open
-