-
Bug
-
Resolution: Fixed
-
P4
-
8
JVMS7 and 8 specify that annotated parameters in the Runtime[In]VisibleParameterAnnotations attribute are counted against the method descriptor: "Each entry in the parameter_annotations table represents all of the run-time visible annotations on the declaration of a single formal parameter. ***The i'th entry in the table corresponds to the i'th formal parameter in the method descriptor (§4.3.3).***"
The intent was to allow annotations on any parameter physically present for the method, regardless of whether the parameter was explicitly declared in Java source code or generated by a compiler in an implementation-specific manner ("synthetic").
However, javac has never emitted Runtime[In]VisibleParameterAnnotations attributes that follow the method descriptor. Where the method descriptor contains implicitly declared parameters ("mandated"), javac ignores them for the purpose of generating a parameter_annotations table. For example, the <init> method of an inner class has a method descriptor whose first parameter descriptor represents an implicitly declared parameter (see JLS8 8.8.1), so javac generates parameter_annotations[0] to store annotations for the second parameter descriptor, representing the first _explicitly_ declared parameter.
javac takes a similar position in Signature attributes: method signatures denote formal parameters which were explicitly declared or neither-explicitly-nor-implicitly declared, and completely ignore any implicitly declared parameters introduced by the JLS.
The intent was to allow annotations on any parameter physically present for the method, regardless of whether the parameter was explicitly declared in Java source code or generated by a compiler in an implementation-specific manner ("synthetic").
However, javac has never emitted Runtime[In]VisibleParameterAnnotations attributes that follow the method descriptor. Where the method descriptor contains implicitly declared parameters ("mandated"), javac ignores them for the purpose of generating a parameter_annotations table. For example, the <init> method of an inner class has a method descriptor whose first parameter descriptor represents an implicitly declared parameter (see JLS8 8.8.1), so javac generates parameter_annotations[0] to store annotations for the second parameter descriptor, representing the first _explicitly_ declared parameter.
javac takes a similar position in Signature attributes: method signatures denote formal parameters which were explicitly declared or neither-explicitly-nor-implicitly declared, and completely ignore any implicitly declared parameters introduced by the JLS.
- relates to
-
JDK-8213329 Normalize inclusion of non-explicit parameters in JVM attributes
-
- Open
-
-
JDK-8020000 Clarify "optional" attributes like EnclosingMethod and Signature
-
- Closed
-
-
JDK-6559572 Add a special case in JVMS for synthetic parameters of RuntimeVisibleParameterAnnotations
-
- Closed
-