author | akulyakh |
Thu, 21 May 2015 11:41:04 -0700 | |
changeset 30730 | d3ce7619db2c |
parent 18000 | 5d29ce00a7a2 |
child 30846 | 2b3f379840f0 |
permissions | -rw-r--r-- |
18000
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
1 |
/* |
30730
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
18000
diff
changeset
|
2 |
* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. |
18000
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
4 |
* |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
8 |
* |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
13 |
* accompanied this code). |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
14 |
* |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
18 |
* |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
21 |
* questions. |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
22 |
*/ |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
23 |
|
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
24 |
/* |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
25 |
* @test |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
26 |
* @bug 6695379 |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
27 |
* @summary Copy method annotations and parameter annotations to synthetic |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
28 |
* bridge methods |
30730
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
18000
diff
changeset
|
29 |
* @modules jdk.compiler/com.sun.tools.classfile |
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
18000
diff
changeset
|
30 |
* jdk.compiler/com.sun.tools.javac.util |
18000
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
31 |
* @run main AnnotationsAreNotCopiedToBridgeMethodsTest |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
32 |
*/ |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
33 |
|
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
34 |
import java.lang.annotation.ElementType; |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
35 |
import java.lang.annotation.Target; |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
36 |
import java.io.BufferedInputStream; |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
37 |
import java.lang.annotation.Retention; |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
38 |
import java.lang.annotation.RetentionPolicy; |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
39 |
import java.nio.file.Files; |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
40 |
import java.nio.file.Path; |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
41 |
import java.nio.file.Paths; |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
42 |
|
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
43 |
import com.sun.tools.classfile.AccessFlags; |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
44 |
import com.sun.tools.classfile.Attribute; |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
45 |
import com.sun.tools.classfile.Attributes; |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
46 |
import com.sun.tools.classfile.ClassFile; |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
47 |
import com.sun.tools.classfile.Method; |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
48 |
import com.sun.tools.javac.util.Assert; |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
49 |
|
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
50 |
public class AnnotationsAreNotCopiedToBridgeMethodsTest { |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
51 |
|
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
52 |
public static void main(String[] args) throws Exception { |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
53 |
new AnnotationsAreNotCopiedToBridgeMethodsTest().run(); |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
54 |
} |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
55 |
|
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
56 |
void run() throws Exception { |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
57 |
checkClassFile(Paths.get(System.getProperty("test.classes"), |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
58 |
this.getClass().getSimpleName() + "$CovariantReturnType.class")); |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
59 |
checkClassFile(Paths.get(System.getProperty("test.classes"), |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
60 |
this.getClass().getSimpleName() + |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
61 |
"$CovariantReturnType$VisibilityChange.class")); |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
62 |
} |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
63 |
|
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
64 |
void checkClassFile(final Path cfilePath) throws Exception { |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
65 |
ClassFile classFile = ClassFile.read( |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
66 |
new BufferedInputStream(Files.newInputStream(cfilePath))); |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
67 |
for (Method method : classFile.methods) { |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
68 |
if (method.access_flags.is(AccessFlags.ACC_BRIDGE)) { |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
69 |
checkForAttr(method.attributes, |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
70 |
"Annotations hasn't been copied to bridge method", |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
71 |
Attribute.RuntimeVisibleAnnotations, |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
72 |
Attribute.RuntimeVisibleParameterAnnotations); |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
73 |
} |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
74 |
} |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
75 |
} |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
76 |
|
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
77 |
void checkForAttr(Attributes attrs, String errorMsg, String... attrNames) { |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
78 |
for (String attrName : attrNames) { |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
79 |
Assert.checkNonNull(attrs.get(attrName), errorMsg); |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
80 |
} |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
81 |
} |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
82 |
|
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
83 |
@Target(value = {ElementType.PARAMETER}) |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
84 |
@Retention(RetentionPolicy.RUNTIME) |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
85 |
@interface ParamAnnotation {} |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
86 |
|
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
87 |
@Target(value = {ElementType.METHOD}) |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
88 |
@Retention(RetentionPolicy.RUNTIME) |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
89 |
@interface MethodAnnotation {} |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
90 |
|
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
91 |
abstract class T<A,B> { |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
92 |
B m(A a){return null;} |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
93 |
} |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
94 |
|
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
95 |
class CovariantReturnType extends T<Integer, Integer> { |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
96 |
@MethodAnnotation |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
97 |
Integer m(@ParamAnnotation Integer i) { |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
98 |
return i; |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
99 |
} |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
100 |
|
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
101 |
public class VisibilityChange extends CovariantReturnType {} |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
102 |
|
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
103 |
} |
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
104 |
|
5d29ce00a7a2
6695379: Copy method annotations and parameter annotations to synthetic bridge methods
vromero
parents:
diff
changeset
|
105 |
} |