JDK-8010737 : javac, known parameter's names should be copied to automatically generated constructors for inner classes
  • Type: Enhancement
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2013-03-25
  • Updated: 2021-11-09
  • Resolved: 2013-06-01
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8 b94Fixed
Related Reports
Relates :  
Description
When generating the method symbol for the anonymous inner class of the example:

    @Target(value = {ElementType.PARAMETER})
    @interface ParamAnnotation {}

    public class initParams {
        public initParams(@ParamAnnotation int i) {}

        public void m() {
            new initParams(2) {};
        }
    }

Javac will create an int parameter for it, named x0 instead of reusing the more logical "i" in this case.
Also the parameter annotation should be copied to the generated parameter.
Comments
Parameter annotations are copied to automatically generated constructors for inner classes This fix implies that now for programs like: @Target(value = {ElementType.PARAMETER}) @interface ParamAnnotation {} public class initParams { public initParams(@ParamAnnotation int i) {} public void m() { new initParams(2) {}; } } The constructor generated for the inner class created in method m() will have a parameter int i with the annotation @ParamAnnotation. This change in the behavior may impact some annotations processor or applications that use the annotations.
21-11-2013

URL: http://hg.openjdk.java.net/jdk8/jdk8/langtools/rev/e9855150c5b0 User: lana Date: 2013-06-11 18:27:02 +0000
11-06-2013

URL: http://hg.openjdk.java.net/jdk8/tl/langtools/rev/e9855150c5b0 User: vromero Date: 2013-06-01 21:00:23 +0000
01-06-2013

webrev sent
20-04-2013

waiting for ccc approval
09-04-2013