-
Bug
-
Resolution: Unresolved
-
P4
-
17, 21, 22
-
generic
-
generic
A DESCRIPTION OF THE PROBLEM :
a Receivers is basicly a way to annotate "this" in a method or non static inner class constructor. it is a parameter, but not a formal one. the distinction between parameters and formal parameters is blury and inconsistent in the relfection api.
the doc for java.lang.reflect.Executable#getParameters only mentions parameters and not formal parameters, while returning formal parameters for methods and parameters for constructors.
annotation processing is clear in its doc. javax.lang.model.element.ExecutableElement#getParameters is documented to return formal parameters and it does.
spec:
https://docs.oracle.com/javase/specs/jls/se21/html/jls-8.html#jls-8.8
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
See zip file
run org.example.Main.main
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
warning: Annotation Processing MethodExample
warning: parameter count: 0
warning: Annotation Processing ConstructorExample
warning: parameter count: 0
4 warnings
Reflection MethodExample
parameter count: 0
Reflection ConstructorExample
parameter count: 0
ACTUAL -
warning: Annotation Processing MethodExample
warning: parameter count: 0
warning: Annotation Processing ConstructorExample
warning: parameter count: 0
4 warnings
Reflection MethodExample
parameter count: 0
Reflection ConstructorExample
parameter count: 1
parameters are: [ConstructorExample arg0]
---------- BEGIN SOURCE ----------
See the attached zip file
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
none. the Receiver support is very limited. via reflection it is impossible to know if a receiver is present. its only possible to construct one and see if it is annotated. yes -> receiver is present; no -> receiver is not annotated or not present. therefore it is not reliable possible to add a receiver to the parameters for methods only when it should be present or remove the receiver for construtors when it should not be present.
FREQUENCY : always
a Receivers is basicly a way to annotate "this" in a method or non static inner class constructor. it is a parameter, but not a formal one. the distinction between parameters and formal parameters is blury and inconsistent in the relfection api.
the doc for java.lang.reflect.Executable#getParameters only mentions parameters and not formal parameters, while returning formal parameters for methods and parameters for constructors.
annotation processing is clear in its doc. javax.lang.model.element.ExecutableElement#getParameters is documented to return formal parameters and it does.
spec:
https://docs.oracle.com/javase/specs/jls/se21/html/jls-8.html#jls-8.8
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
See zip file
run org.example.Main.main
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
warning: Annotation Processing MethodExample
warning: parameter count: 0
warning: Annotation Processing ConstructorExample
warning: parameter count: 0
4 warnings
Reflection MethodExample
parameter count: 0
Reflection ConstructorExample
parameter count: 0
ACTUAL -
warning: Annotation Processing MethodExample
warning: parameter count: 0
warning: Annotation Processing ConstructorExample
warning: parameter count: 0
4 warnings
Reflection MethodExample
parameter count: 0
Reflection ConstructorExample
parameter count: 1
parameters are: [ConstructorExample arg0]
---------- BEGIN SOURCE ----------
See the attached zip file
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
none. the Receiver support is very limited. via reflection it is impossible to know if a receiver is present. its only possible to construct one and see if it is annotated. yes -> receiver is present; no -> receiver is not annotated or not present. therefore it is not reliable possible to add a receiver to the parameters for methods only when it should be present or remove the receiver for construtors when it should not be present.
FREQUENCY : always
- relates to
-
JDK-8320941 Discuss receiver type handling
- Resolved