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

Provide a way to inject missing parameter names

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P4
    • Resolution: Approved
    • Fix Version/s: 13
    • Component/s: tools
    • Subcomponent:
    • Compatibility Kind:
      source
    • Compatibility Risk:
      minimal
    • Compatibility Risk Description:
      A new method is added to an abstract class. The new method references a newly added type so even existing subclasses won't have a compilation or linkage issue.
    • Interface Kind:
      Java API
    • Scope:
      JDK

      Description

      Summary

      Adding a way to inject better parameter names to method parameters when the names are not available in the classfiles.

      Problem

      Classfiles may record method parameters in two forms: either in the MethodParameters or the LocalVariableTable attribute. But if a method has neither of these attributes, then its parameters get a cryptic synthetic name.

      An important group of methods that typically get the synthetic parameter names are abstract methods - these don't get debugging info (LocalVariableTable), so unless the classfile was compiled with an explicit "-parameters" option, there are not parameter names for the method.

      The parameter names are visible to the API clients using VariableElements.getSimpleName().

      Solution

      The proposal is to augment com.sun.source.util.JavacTask with a way to set a provider of names for the parameters that don't have names in the classfiles.

      Specification

      Proposed is ParameterNameProvider which can be plugged into JavacTask and should provide user-friendly parameter names. A spec diff is attached and is also for convenience here:

      http://cr.openjdk.java.net/~jlahoda/8217047/specdiff.04/overview-summary.html

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jlahoda Jan Lahoda
                Reporter:
                jlahoda Jan Lahoda
                Reviewed By:
                Jonathan Gibbons
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: