JDK-8181869 : getAnnotatedParameterTypes���() specification should be clarified
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang:reflect
  • Affected Version: 9
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2017-06-09
  • Updated: 2019-06-27
  • Resolved: 2019-06-09
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 13 JDK 14
13 b25Fixed 14Fixed
Related Reports
Relates :  
Description
The getAnnotatedParameterTypes���() specification incorrectly defines its behavior in case of no-args constructor for inner classes. 
The specification states:  "Returns an array of length 0 if the method/constructor declares no parameters."
Actual behavior is : 
--------------------------------------------------
class ConsParamData {
    public class Inner {
        public Inner(@Anno(0) ConsParamData ConsParamData.this) {}
        public class InnerInner {
            public InnerInner() {}
        }
    }
}

 params={ConsParamData} ConsParamData.Inner.class.getConstructor(params).getAnnotatedParameterTypes() 
 [ ctor == public Inner(@Anno(0) ConsParamData ConsParamData.this) {} ]
 returns  { ConsParamData }.length() == 1
 
 params={ ConsParamData.Inner} ConsParamData.Inner.InnerInner.class.getConstructor(params).getAnnotatedParameterTypes() 
 [ ctor == public InnerInner() {} ]
 returns  { ConsParamData$Inner }.length() == 1
--------------------------------
Comments
Review thread: https://mail.openjdk.java.net/pipermail/core-libs-dev/2019-June/060771.html
07-06-2019

It is impractical to make a simple sentence like "Returns an array of length 0 if the method/constructor declares no parameters." explicitly cover all the cases like "but of course if there a mandated outer this parameter for a constructor of a non-static member class, that counts as having a declared parameter even if it is not explicitly present in the sources because core reflection presents a JVM-centric view of the world and what else would you expect to happen in that case." However, the specification can be clarified to more accurately cover such situations.
12-06-2017