author | aeremeev |
Mon, 28 Sep 2015 13:23:35 +0300 | |
changeset 32908 | bef9744cf56f |
parent 31750 | c65c37c0c691 |
permissions | -rw-r--r-- |
31750
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
1 |
/* |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
2 |
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
4 |
* |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
8 |
* |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
13 |
* accompanied this code). |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
14 |
* |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
18 |
* |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
21 |
* questions. |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
22 |
*/ |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
23 |
|
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
24 |
import com.sun.tools.classfile.Attribute; |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
25 |
import com.sun.tools.classfile.ConstantPoolException; |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
26 |
import com.sun.tools.classfile.Descriptor; |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
27 |
|
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
28 |
import javax.tools.JavaFileObject; |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
29 |
import java.io.IOException; |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
30 |
import java.lang.annotation.RetentionPolicy; |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
31 |
import java.nio.file.Path; |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
32 |
import java.nio.file.Paths; |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
33 |
import java.util.*; |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
34 |
import java.util.stream.Collectors; |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
35 |
import java.util.stream.IntStream; |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
36 |
import java.util.stream.Stream; |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
37 |
|
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
38 |
public abstract class AnnotationsTestBase extends TestResult { |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
39 |
|
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
40 |
/** |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
41 |
* Element values which are used in generation of annotations. |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
42 |
*/ |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
43 |
private static final TestAnnotationInfo.Pair[] elementValues = { |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
44 |
new TestAnnotationInfo.Pair("booleanValue", new TestAnnotationInfo.TestBooleanElementValue(true)), |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
45 |
new TestAnnotationInfo.Pair("byteValue", new TestAnnotationInfo.TestIntegerElementValue('B', 83)), |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
46 |
new TestAnnotationInfo.Pair("charValue", new TestAnnotationInfo.TestCharElementValue('H')), |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
47 |
new TestAnnotationInfo.Pair("shortValue", new TestAnnotationInfo.TestIntegerElementValue('S', 14)), |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
48 |
new TestAnnotationInfo.Pair("intValue", new TestAnnotationInfo.TestIntegerElementValue('I', 18)), |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
49 |
new TestAnnotationInfo.Pair("longValue", new TestAnnotationInfo.TestLongElementValue(14)), |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
50 |
new TestAnnotationInfo.Pair("floatValue", new TestAnnotationInfo.TestFloatElementValue(-1)), |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
51 |
new TestAnnotationInfo.Pair("doubleValue", new TestAnnotationInfo.TestDoubleElementValue(-83)), |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
52 |
new TestAnnotationInfo.Pair("stringValue", new TestAnnotationInfo.TestStringElementValue("///")), |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
53 |
new TestAnnotationInfo.Pair("arrayValue1", new TestAnnotationInfo.TestArrayElementValue( |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
54 |
new TestAnnotationInfo.TestIntegerElementValue('I', 1), |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
55 |
new TestAnnotationInfo.TestIntegerElementValue('I', 4), |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
56 |
new TestAnnotationInfo.TestIntegerElementValue('I', 8), |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
57 |
new TestAnnotationInfo.TestIntegerElementValue('I', 3))), |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
58 |
new TestAnnotationInfo.Pair("arrayValue2", new TestAnnotationInfo.TestArrayElementValue( |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
59 |
new TestAnnotationInfo.TestStringElementValue("AAA"), |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
60 |
new TestAnnotationInfo.TestStringElementValue("BBB"))), |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
61 |
new TestAnnotationInfo.Pair("enumValue", new TestAnnotationInfo.TestEnumElementValue("EnumValue", "VALUE2")), |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
62 |
new TestAnnotationInfo.Pair("classValue1", new TestAnnotationInfo.TestClassElementValue("void.class")), |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
63 |
new TestAnnotationInfo.Pair("classValue2", new TestAnnotationInfo.TestClassElementValue("Character.class")), |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
64 |
new TestAnnotationInfo.Pair("annoValue", new TestAnnotationInfo.TestAnnotationElementValue("AnnotationValue", |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
65 |
new TestAnnotationInfo("AnnotationValue", RetentionPolicy.CLASS, |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
66 |
new TestAnnotationInfo.Pair("stringValue", |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
67 |
new TestAnnotationInfo.TestStringElementValue("StringValue1"))))), |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
68 |
new TestAnnotationInfo.Pair("annoArrayValue", new TestAnnotationInfo.TestArrayElementValue( |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
69 |
new TestAnnotationInfo.TestAnnotationElementValue("AnnotationValue", |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
70 |
new TestAnnotationInfo("AnnotationValue", RetentionPolicy.CLASS, |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
71 |
new TestAnnotationInfo.Pair("stringValue", |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
72 |
new TestAnnotationInfo.TestStringElementValue("StringValue1")))), |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
73 |
new TestAnnotationInfo.TestAnnotationElementValue("AnnotationValue", |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
74 |
new TestAnnotationInfo("AnnotationValue", RetentionPolicy.CLASS, |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
75 |
new TestAnnotationInfo.Pair("stringValue", |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
76 |
new TestAnnotationInfo.TestStringElementValue("StringValue1")))))) |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
77 |
}; |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
78 |
|
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
79 |
/** |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
80 |
* Masks which are used in generation of annotations. |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
81 |
* E.g. mask 0 corresponds to an annotation without element values. |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
82 |
*/ |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
83 |
private static final int[] elementValuesCombinations; |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
84 |
|
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
85 |
static { |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
86 |
List<Integer> combinations = new ArrayList<>(); |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
87 |
combinations.add(0); |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
88 |
for (int i = 0; i < elementValues.length; ++i) { |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
89 |
combinations.add(1 << i); |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
90 |
} |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
91 |
// pairs int value and another value |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
92 |
for (int i = 0; i < elementValues.length; ++i) { |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
93 |
combinations.add((1 << 5) | (1 << i)); |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
94 |
} |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
95 |
combinations.add((1 << elementValues.length) - 1); |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
96 |
elementValuesCombinations = combinations.stream().mapToInt(Integer::intValue).toArray(); |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
97 |
} |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
98 |
|
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
99 |
/** |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
100 |
* Method generates a list of test cases. |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
101 |
* Method is called in the method {@code call()}. |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
102 |
* |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
103 |
* @return a list of test cases |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
104 |
*/ |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
105 |
public abstract List<TestCase> generateTestCases(); |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
106 |
|
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
107 |
public abstract void test(TestCase testCase, Map<String, ? extends JavaFileObject> classes) |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
108 |
throws IOException, ConstantPoolException, Descriptor.InvalidDescriptor; |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
109 |
|
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
110 |
/** |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
111 |
* The method is used to create a repeatable annotation. |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
112 |
*/ |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
113 |
private TestAnnotationInfo createSomeAnnotation(String annotationName) { |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
114 |
return new TestAnnotationInfo(annotationName, getRetentionPolicy(annotationName), |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
115 |
new TestAnnotationInfo.Pair("booleanValue", |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
116 |
new TestAnnotationInfo.TestBooleanElementValue(true)), |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
117 |
new TestAnnotationInfo.Pair("intValue", |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
118 |
new TestAnnotationInfo.TestIntegerElementValue('I', 1)), |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
119 |
new TestAnnotationInfo.Pair("enumValue", |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
120 |
new TestAnnotationInfo.TestEnumElementValue("EnumValue", "VALUE1"))); |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
121 |
} |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
122 |
|
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
123 |
private TestAnnotationInfo getAnnotationByMask(String annotationName, int mask) { |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
124 |
List<TestAnnotationInfo.Pair> pairs = new ArrayList<>(); |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
125 |
for (int i = 0; i < elementValues.length; ++i) { |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
126 |
if ((mask & (1 << i)) != 0) { |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
127 |
pairs.add(elementValues[i]); |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
128 |
} |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
129 |
} |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
130 |
return new TestAnnotationInfo( |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
131 |
annotationName, |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
132 |
getRetentionPolicy(annotationName), |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
133 |
pairs.toArray(new TestAnnotationInfo.Pair[pairs.size()])); |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
134 |
} |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
135 |
|
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
136 |
/** |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
137 |
* Class represents annotations which will be applied to one method. |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
138 |
*/ |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
139 |
public static class TestAnnotationInfos { |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
140 |
public final List<TestAnnotationInfo> annotations; |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
141 |
|
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
142 |
public TestAnnotationInfos(List<TestAnnotationInfo> a) { |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
143 |
this.annotations = a; |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
144 |
} |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
145 |
|
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
146 |
public void annotate(TestCase.TestMemberInfo memberInfo) { |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
147 |
annotations.forEach(memberInfo::addAnnotation); |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
148 |
} |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
149 |
} |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
150 |
|
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
151 |
/** |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
152 |
* Convenience method to group test cases. |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
153 |
* Increases speed of tests. |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
154 |
*/ |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
155 |
public List<List<TestAnnotationInfos>> groupAnnotations(List<TestAnnotationInfos> annotations) { |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
156 |
List<List<TestAnnotationInfos>> groupedAnnotations = new ArrayList<>(); |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
157 |
int size = 32; |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
158 |
List<TestAnnotationInfos> current = null; |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
159 |
for (TestAnnotationInfos infos : annotations) { |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
160 |
if (current == null || current.size() == size) { |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
161 |
current = new ArrayList<>(); |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
162 |
groupedAnnotations.add(current); |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
163 |
} |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
164 |
current.add(infos); |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
165 |
} |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
166 |
return groupedAnnotations; |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
167 |
} |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
168 |
|
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
169 |
public List<TestAnnotationInfos> getAllCombinationsOfAnnotations() { |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
170 |
List<TestAnnotationInfos> combinations = new ArrayList<>(); |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
171 |
for (Annotations annotationName1 : Annotations.values()) { |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
172 |
List<TestAnnotationInfo> list = IntStream.of(elementValuesCombinations) |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
173 |
.mapToObj(e -> getAnnotationByMask(annotationName1.getAnnotationName(), e)) |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
174 |
.collect(Collectors.toList()); |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
175 |
// add cases with a single annotation |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
176 |
combinations.addAll(list.stream() |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
177 |
.map(Collections::singletonList) |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
178 |
.map(TestAnnotationInfos::new) |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
179 |
.collect(Collectors.toList())); |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
180 |
|
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
181 |
// add cases with a repeatable annotation |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
182 |
for (Annotations annotationName2 : Annotations.values()) { |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
183 |
if (annotationName1 == annotationName2 && !annotationName1.isRepeatable()) { |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
184 |
continue; |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
185 |
} |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
186 |
TestAnnotationInfo annotation2 = createSomeAnnotation(annotationName2.getAnnotationName()); |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
187 |
for (TestAnnotationInfo annotation1 : list) { |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
188 |
List<TestAnnotationInfo> list1 = new ArrayList<>(); |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
189 |
Collections.addAll(list1, annotation1, annotation2); |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
190 |
combinations.add(new TestAnnotationInfos(list1)); |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
191 |
} |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
192 |
} |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
193 |
} |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
194 |
return combinations; |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
195 |
} |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
196 |
|
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
197 |
protected RetentionPolicy getRetentionPolicy(String name) { |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
198 |
if (name.contains("Visible")) { |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
199 |
return RetentionPolicy.RUNTIME; |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
200 |
} else if (name.contains("Invisible")) { |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
201 |
return RetentionPolicy.CLASS; |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
202 |
} |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
203 |
throw new IllegalArgumentException(name); |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
204 |
} |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
205 |
|
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
206 |
protected long countNumberOfAttributes(Attribute[] attrs, |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
207 |
Class<? extends Attribute> clazz) { |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
208 |
return Stream.of(attrs) |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
209 |
.filter(clazz::isInstance) |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
210 |
.count(); |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
211 |
} |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
212 |
|
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
213 |
public void test() throws TestFailedException { |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
214 |
try { |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
215 |
List<TestCase> testCases = generateTestCases(); |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
216 |
for (int i = 0; i < testCases.size(); ++i) { |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
217 |
TestCase testCase = testCases.get(i); |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
218 |
String source = testCase.generateSource(); |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
219 |
Path sourceFile = Paths.get(getClass().getSimpleName() + i + ".java"); |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
220 |
addTestCase(sourceFile.toAbsolutePath().toString()); |
32908
bef9744cf56f
8081472: Add a mode to the tests for class-file attributes which dumps in-memory sources to disk
aeremeev
parents:
31750
diff
changeset
|
221 |
writeToFileIfEnabled(sourceFile, source); |
31750
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
222 |
echo("Testing: " + sourceFile.toString()); |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
223 |
try { |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
224 |
test(testCase, compile(source).getClasses()); |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
225 |
} catch (Exception e) { |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
226 |
addFailure(e); |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
227 |
} |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
228 |
} |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
229 |
} catch (RuntimeException | IOException e) { |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
230 |
addFailure(e); |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
231 |
} finally { |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
232 |
checkStatus(); |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
233 |
} |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
234 |
} |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
235 |
|
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
236 |
public enum Annotations { |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
237 |
RUNTIME_INVISIBLE_REPEATABLE("RuntimeInvisibleRepeatable", true), |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
238 |
RUNTIME_INVISIBLE_NOT_REPEATABLE("RuntimeInvisibleNotRepeatable", false), |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
239 |
RUNTIME_VISIBLE_REPEATABLE("RuntimeVisibleRepeatable", true), |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
240 |
RUNTIME_VISIBLE_NOT_REPEATABLE("RuntimeVisibleNotRepeatable", false); |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
241 |
|
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
242 |
private final String annotationName; |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
243 |
private final boolean isRepeatable; |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
244 |
|
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
245 |
Annotations(String annotationName, boolean isRepeatable) { |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
246 |
this.annotationName = annotationName; |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
247 |
this.isRepeatable = isRepeatable; |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
248 |
} |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
249 |
|
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
250 |
public String getAnnotationName() { |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
251 |
return annotationName; |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
252 |
} |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
253 |
|
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
254 |
public boolean isRepeatable() { |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
255 |
return isRepeatable; |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
256 |
} |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
257 |
} |
c65c37c0c691
8044411: Implement classfile tests for RuntimeAnnotations and RuntimeParameterAnnotations attribute.
aeremeev
parents:
diff
changeset
|
258 |
} |