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

generic type information lost on mandated parameters of record's compact constructors

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P3 P3
    • 21-pool
    • core-libs
    • None
    • behavioral
    • minimal
    • Hide
      The proposed solution affects only programs using core reflection to retrieve generic type information from mandated parameters of record's compact constructors. There is no effect on a compiler's ability to load or produce class files for records with compact constructors. Some programs that were not able to retrieve information from generic parameters of record's compact constructors could be able to do it due to the proposed solution
      Show
      The proposed solution affects only programs using core reflection to retrieve generic type information from mandated parameters of record's compact constructors. There is no effect on a compiler's ability to load or produce class files for records with compact constructors. Some programs that were not able to retrieve information from generic parameters of record's compact constructors could be able to do it due to the proposed solution
    • Java API
    • JDK

      Summary

      Reflection is not retrieving generic type information for mandated parameters. Now that the parameters of compact constructors of record classes are mandated it makes sense to reconsider this decision.

      Problem

      When mapping the generic type information from the Signature classfile attribute to parameters, code reflection is currently ignoring both mandated and synthetic (constructor) parameters. This works well for local classes: for local classes, the parameter holding the enclosing class is mandated, but is not represented in the Signature field.

      It does not work well for records whose components are of generic types, and have compact constructors. The parameters of the compact constructors are marked mandated, and even though they are represented in the Signature attribute, the mapping of the generic type information from Signature to the parameters will ignore them. This is problematic, as the generic parameters of the compact constructor may be useful for core reflection users.

      Solution

      For compact record constructors, the generic type information will be fetched from the Signature attribute for its parameters independently if they are mandated or not. This is a core-reflection only change, the compilation of records with compact constructor is not affected in any way.

      Specification

      No Change.

            wxiao Weibing Xiao
            webbuggrp Webbug Group
            Vicente Arturo Romero Zaldivar
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: