author | darcy |
Thu, 13 Jun 2019 11:50:45 -0700 | |
changeset 55387 | 761b86d5563d |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
38830
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
1 |
/* |
55387
761b86d5563d
8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. |
38830
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
4 |
* |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
8 |
* |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
13 |
* accompanied this code). |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
14 |
* |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
18 |
* |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
21 |
* questions. |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
22 |
*/ |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
23 |
|
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
24 |
/* |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
25 |
* @test |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
26 |
* @bug 8146167 |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
27 |
* @summary Anonymous type declarations drop supertype type parameter annotations |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
28 |
* @run main AnonymousExtendsTest |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
29 |
*/ |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
30 |
|
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
31 |
import java.lang.annotation.ElementType; |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
32 |
import java.lang.annotation.Retention; |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
33 |
import java.lang.annotation.RetentionPolicy; |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
34 |
import java.lang.annotation.Target; |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
35 |
import java.lang.reflect.AnnotatedParameterizedType; |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
36 |
import java.lang.reflect.AnnotatedType; |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
37 |
import java.util.ArrayList; |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
38 |
import java.util.Arrays; |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
39 |
import java.util.List; |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
40 |
|
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
41 |
@SuppressWarnings({ "javadoc", "serial" }) |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
42 |
public class AnonymousExtendsTest { |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
43 |
|
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
44 |
@Target(ElementType.TYPE_USE) |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
45 |
@Retention(RetentionPolicy.RUNTIME) |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
46 |
public @interface TA { |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
47 |
int value(); |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
48 |
} |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
49 |
|
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
50 |
public class TestClass extends @TA(1) ArrayList<@TA(2) List<Number>> { |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
51 |
} |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
52 |
|
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
53 |
public void testIt() { |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
54 |
checkAnnotations(TestClass.class.getAnnotatedSuperclass(), |
55387
761b86d5563d
8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents:
47216
diff
changeset
|
55 |
"[@AnonymousExtendsTest$TA(1)],[@AnonymousExtendsTest$TA(2)]"); |
38830
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
56 |
checkAnnotations(new @TA(3) ArrayList<@TA(4) List<Number>>() { |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
57 |
}.getClass().getAnnotatedSuperclass(), |
55387
761b86d5563d
8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents:
47216
diff
changeset
|
58 |
"[@AnonymousExtendsTest$TA(3)],[@AnonymousExtendsTest$TA(4)]"); |
38830
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
59 |
} |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
60 |
|
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
61 |
public void checkAnnotations(AnnotatedType type, String expected) { |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
62 |
String actual = Arrays.asList(((AnnotatedParameterizedType) type) |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
63 |
.getAnnotations()) |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
64 |
.toString() |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
65 |
+ "," + |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
66 |
Arrays.asList(((AnnotatedParameterizedType) type) |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
67 |
.getAnnotatedActualTypeArguments()[0].getAnnotations()) |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
68 |
.toString(); |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
69 |
|
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
70 |
if (!actual.equals(expected)) |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
71 |
throw new AssertionError("Unexpected annotations" + actual); |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
72 |
} |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
73 |
|
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
74 |
public static void main(String[] args) { |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
75 |
new AnonymousExtendsTest().testIt(); |
080df8157078
8146167: Anonymous type declarations drop supertype type parameter annotations
sadayapalam
parents:
diff
changeset
|
76 |
} |
55387
761b86d5563d
8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents:
47216
diff
changeset
|
77 |
} |