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

ExecutableElement.getReceiverType doesn't return receiver types for methods loaded from bytecode

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 22
    • tools
    • None
    • behavioral
    • low
    • Existing users of the API may have workarounds to the old, buggy, behavior that could need updating.
    • Java API
    • Implementation

      Summary

      Update javac's implementation of ExecutableElement.getReceiverType() and ExecutableType.getReceiverType() to allow accessing type use annotations on receiver types for methods loaded from bytecode.

      Problem

      The implementation currently returns a NoType type mirror with kind NONE whenever the receiver parameter syntax is not present in source.

      The receiver parameter syntax is not recoverable from the class file, and it is currently never filled in for methods loaded from bytecode. This means that there is no type to host type annotations, and annotation processors are unable to access type annotations on receiver parameters loaded from bytecode.

      Solution

      If a type annotation is present on the receiver type of a method read from bytecode, the implementation should infer that a receiver parameter was present in source, and fill in the receiver type of that method to host the type annotation.

      Specification

      No specification change; behavioral change only.

      Prompted by discussion in an earlier version of this CSR, JDK-8319843 tracks updating the specification to clarify the existing behavior of getReceiverType().

            cushon Liam Miller-Cushon
            cushon Liam Miller-Cushon
            Vicente Arturo Romero Zaldivar
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: