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

4.7.18: Specify a mapping from Signature and *Annotations attributes to method descriptors

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 9
    • 8
    • specification
    • vm

      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.

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

              Created:
              Updated:
              Resolved: