-
Bug
-
Resolution: Fixed
-
P2
-
8, 9
-
b172
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8181548 | 10 | Joe Darcy | P2 | Resolved | Fixed | b11 |
JDK-8181267 | 9.0.4 | Joe Darcy | P2 | Resolved | Fixed | b01 |
---------------------------------------------------------------------------
public class MinimizedTest {
public static void main(String[] args) throws NoSuchMethodException {
Constructor constructor = Inner.class.getConstructor(MinimizedTest.class, Object.class);
for (AnnotatedType at : constructor.getAnnotatedParameterTypes()) {
System.out.println(at.getType());
System.out.println(Arrays.toString(at.getAnnotations()));
System.out.println();
}
}
class Inner {
public Inner(@Anno Object param) {}
}
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE_USE)
@interface Anno {
}
}
---------------------------------------------------------------------------
The output will be:
---------------------------------------------------------------------------
class MinimizedTest
[@MinimizedTest$Anno()]
class java.lang.Object
[]
---------------------------------------------------------------------------
As we can see, the first annotated parameter type has a type MinimizedTest (this is receiver) and has one annotation, but the receiver parameter is not annotated. The second parameter type doesn't has annotation, but it should.
Receiver parameter is not a formal parameter, so it's annotated type should not be presented here.
The spec of j.l.r.Executable.getAnnotatedParameterTypes says:
"Returns an array of AnnotatedType objects that represent the use of types to specify formal parameter types of the method/constructor represented by this Executable. "
Checked with JDK9 b53.
Failed JCK tests is under development.
- backported by
-
JDK-8181267 Constructor.getAnnotatedParameterTypes returns wrong value
-
- Resolved
-
-
JDK-8181548 Constructor.getAnnotatedParameterTypes returns wrong value
-
- Resolved
-
- duplicates
-
JDK-8225470 Constructor.getParameterAnnotations does not include implicit enclosing param
-
- Closed
-
- relates to
-
JDK-8180892 Correct handling of annotations on parameters
-
- Open
-
-
JDK-8024694 javac always expects signature attribute for enum constructors
-
- Closed
-
-
JDK-8262807 Note assumptions of core reflection modeling and parameter handling
-
- Resolved
-
-
JDK-8274617 annotations in the super class constructor are not propagated to the anonymous class constructor
-
- Closed
-
-
JDK-8181869 getAnnotatedParameterTypes() specification should be clarified
-
- Closed
-
-
JDK-8284333 Constructor.getAnnotatedParameterTypes returns wrong value for Enums
-
- Closed
-