author | coleenp |
Tue, 31 Oct 2017 11:55:09 -0400 | |
changeset 47765 | b7c7428eaab9 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1 |
/* |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2 |
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
4 |
* |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
8 |
* |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
13 |
* accompanied this code). |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
14 |
* |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
18 |
* |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
21 |
* questions. |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
22 |
*/ |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
23 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
24 |
import java.io.File; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
25 |
import java.io.InputStream; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
26 |
import java.io.Writer; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
27 |
import java.lang.annotation.Retention; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
28 |
import java.lang.annotation.RetentionPolicy; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
29 |
import java.lang.reflect.Method; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
30 |
import java.util.Arrays; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
31 |
import java.util.List; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
32 |
import com.sun.tools.javac.file.ZipFileIndexCache; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
33 |
import java.io.IOException; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
34 |
import java.nio.file.FileVisitResult; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
35 |
import java.nio.file.FileVisitor; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
36 |
import java.nio.file.Files; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
37 |
import java.nio.file.Path; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
38 |
import java.nio.file.Paths; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
39 |
import java.nio.file.attribute.BasicFileAttributes; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
40 |
import java.util.HashSet; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
41 |
import java.util.Set; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
42 |
import java.util.stream.Collectors; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
43 |
import java.util.stream.Stream; |
33551
1cd3c95fb546
8140766: langtools/make/test/sym/CreateSymbolsTest.java contains incorrect paths
jlahoda
parents:
31506
diff
changeset
|
44 |
import build.tools.symbolgenerator.CreateSymbols; |
1cd3c95fb546
8140766: langtools/make/test/sym/CreateSymbolsTest.java contains incorrect paths
jlahoda
parents:
31506
diff
changeset
|
45 |
import build.tools.symbolgenerator.CreateSymbols.ClassDescription; |
1cd3c95fb546
8140766: langtools/make/test/sym/CreateSymbolsTest.java contains incorrect paths
jlahoda
parents:
31506
diff
changeset
|
46 |
import build.tools.symbolgenerator.CreateSymbols.ClassList; |
1cd3c95fb546
8140766: langtools/make/test/sym/CreateSymbolsTest.java contains incorrect paths
jlahoda
parents:
31506
diff
changeset
|
47 |
import build.tools.symbolgenerator.CreateSymbols.CtSymKind; |
1cd3c95fb546
8140766: langtools/make/test/sym/CreateSymbolsTest.java contains incorrect paths
jlahoda
parents:
31506
diff
changeset
|
48 |
import build.tools.symbolgenerator.CreateSymbols.ExcludeIncludeList; |
1cd3c95fb546
8140766: langtools/make/test/sym/CreateSymbolsTest.java contains incorrect paths
jlahoda
parents:
31506
diff
changeset
|
49 |
import build.tools.symbolgenerator.CreateSymbols.VersionDescription; |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
50 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
51 |
public class CreateSymbolsTestImpl { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
52 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
53 |
static final String CREATE_SYMBOLS_NAME = "symbolgenerator.CreateSymbols"; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
54 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
55 |
public static void main(String... args) throws Exception { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
56 |
new CreateSymbolsTestImpl().doTest(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
57 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
58 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
59 |
void doTest() throws Exception { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
60 |
boolean testRun = false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
61 |
for (Method m : CreateSymbolsTestImpl.class.getDeclaredMethods()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
62 |
if (!"testIncluded".equals(m.getName())) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
63 |
continue; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
64 |
if (m.isAnnotationPresent(Test.class)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
65 |
m.invoke(this); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
66 |
testRun = true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
67 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
68 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
69 |
if (!testRun) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
70 |
throw new IllegalStateException("No tests found."); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
71 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
72 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
73 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
74 |
@Test |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
75 |
void testMethodRemoved() throws Exception { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
76 |
doTest("package t; public class T { public void m() { } }", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
77 |
"package t; public class T { }", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
78 |
"package t; public class Test { { T t = null; t.m(); } }", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
79 |
ToolBox.Expect.SUCCESS, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
80 |
ToolBox.Expect.FAIL); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
81 |
doTest("package t; public class T { public void b() { } public void m() { } public void a() { } }", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
82 |
"package t; public class T { public void b() { } public void a() { } }", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
83 |
"package t; public class Test { { T t = null; t.b(); t.a(); } }", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
84 |
ToolBox.Expect.SUCCESS, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
85 |
ToolBox.Expect.SUCCESS); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
86 |
//with additional attribute (need to properly skip the member): |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
87 |
doTest("package t; public class T { public void m() throws IllegalStateException { } public void a() { } }", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
88 |
"package t; public class T { public void a() { } }", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
89 |
"package t; public class Test { { T t = null; t.a(); } }", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
90 |
ToolBox.Expect.SUCCESS, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
91 |
ToolBox.Expect.SUCCESS); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
92 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
93 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
94 |
@Test |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
95 |
void testMethodAdded() throws Exception { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
96 |
doTest("package t; public class T { }", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
97 |
"package t; public class T { public void m() { } }", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
98 |
"package t; public class Test { { T t = null; t.m(); } }", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
99 |
ToolBox.Expect.FAIL, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
100 |
ToolBox.Expect.SUCCESS); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
101 |
doTest("package t; public class T { public void b() { } public void a() { } }", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
102 |
"package t; public class T { public void b() { } public void m() { } public void a() { } }", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
103 |
"package t; public class Test { { T t = null; t.b(); t.a(); } }", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
104 |
ToolBox.Expect.SUCCESS, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
105 |
ToolBox.Expect.SUCCESS); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
106 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
107 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
108 |
//verify fields added/modified/removed |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
109 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
110 |
@Test |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
111 |
void testClassAdded() throws Exception { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
112 |
doTest("class Dummy {}", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
113 |
"package t; public class T { }", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
114 |
"package t; public class Test { { T t = new T(); } }", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
115 |
ToolBox.Expect.FAIL, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
116 |
ToolBox.Expect.SUCCESS); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
117 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
118 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
119 |
@Test |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
120 |
void testClassModified() throws Exception { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
121 |
doTest("package t; public class T { public void m() { } }", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
122 |
"package t; public class T implements java.io.Serializable { public void m() { } }", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
123 |
"package t; public class Test { { java.io.Serializable t = new T(); } }", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
124 |
ToolBox.Expect.FAIL, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
125 |
ToolBox.Expect.SUCCESS); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
126 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
127 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
128 |
@Test |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
129 |
void testClassRemoved() throws Exception { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
130 |
doTest("package t; public class T { }", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
131 |
"class Dummy {}", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
132 |
"package t; public class Test { { T t = new T(); } }", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
133 |
ToolBox.Expect.SUCCESS, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
134 |
ToolBox.Expect.FAIL); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
135 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
136 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
137 |
@Test |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
138 |
void testInnerClassAttributes() throws Exception { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
139 |
doTest("package t; public class T { public static class Inner { } }", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
140 |
"package t; public class T { public static class Inner { } }", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
141 |
"package t; import t.T.Inner; public class Test { Inner i; }", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
142 |
ToolBox.Expect.SUCCESS, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
143 |
ToolBox.Expect.SUCCESS); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
144 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
145 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
146 |
@Test |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
147 |
void testConstantAdded() throws Exception { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
148 |
doTest("package t; public class T { }", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
149 |
"package t; public class T { public static final int A = 0; }", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
150 |
"package t; public class Test { void t(int i) { switch (i) { case T.A: break;} } }", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
151 |
ToolBox.Expect.FAIL, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
152 |
ToolBox.Expect.SUCCESS); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
153 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
154 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
155 |
@Test |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
156 |
void testAnnotationAttributeDefaultvalue() throws Exception { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
157 |
//TODO: this only verifies that there is *some* value, but we should also verify there is a specific value: |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
158 |
doTest("package t; public @interface T { }", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
159 |
"package t;\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
160 |
"public @interface T {\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
161 |
" public boolean booleanValue() default true;\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
162 |
" public byte byteValue() default 1;\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
163 |
" public char charValue() default 2;\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
164 |
" public short shortValue() default 3;\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
165 |
" public int intValue() default 4;\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
166 |
" public long longValue() default 5;\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
167 |
" public float floatValue() default 6;\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
168 |
" public double doubleValue() default 7;\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
169 |
" public String stringValue() default \"8\";\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
170 |
" public java.lang.annotation.RetentionPolicy enumValue() default java.lang.annotation.RetentionPolicy.RUNTIME;\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
171 |
" public Class classValue() default Number.class;\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
172 |
" public int[] arrayValue() default {1, 2};\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
173 |
" public SuppressWarnings annotationValue() default @SuppressWarnings(\"cast\");\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
174 |
"}\n", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
175 |
"package t; public @T class Test { }", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
176 |
ToolBox.Expect.SUCCESS, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
177 |
ToolBox.Expect.SUCCESS); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
178 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
179 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
180 |
@Test |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
181 |
void testConstantTest() throws Exception { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
182 |
//XXX: other constant types (String in particular) - see testStringConstant |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
183 |
doPrintElementTest("package t; public class T { public static final int A = 1; }", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
184 |
"package t; public class T { public static final int A = 2; }", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
185 |
"t.T", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
186 |
"package t;\n\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
187 |
"public class T {\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
188 |
" public static final int A = 1;\n\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
189 |
" public T();\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
190 |
"}\n", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
191 |
"t.T", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
192 |
"package t;\n\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
193 |
"public class T {\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
194 |
" public static final int A = 2;\n\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
195 |
" public T();\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
196 |
"}\n"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
197 |
doPrintElementTest("package t; public class T { public static final boolean A = false; }", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
198 |
"package t; public class T { public static final boolean A = true; }", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
199 |
"t.T", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
200 |
"package t;\n\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
201 |
"public class T {\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
202 |
" public static final boolean A = false;\n\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
203 |
" public T();\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
204 |
"}\n", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
205 |
"t.T", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
206 |
"package t;\n\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
207 |
"public class T {\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
208 |
" public static final boolean A = true;\n\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
209 |
" public T();\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
210 |
"}\n"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
211 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
212 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
213 |
@Test |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
214 |
void testAnnotations() throws Exception { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
215 |
doPrintElementTest("package t;" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
216 |
"import java.lang.annotation.*;" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
217 |
"public @Visible @Invisible class T { }" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
218 |
"@Retention(RetentionPolicy.RUNTIME) @interface Visible { }" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
219 |
"@Retention(RetentionPolicy.CLASS) @interface Invisible { }", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
220 |
"package t;" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
221 |
"import java.lang.annotation.*;" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
222 |
"public @Visible @Invisible class T { }" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
223 |
"@Retention(RetentionPolicy.RUNTIME) @interface Visible { }" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
224 |
"@Retention(RetentionPolicy.CLASS) @interface Invisible { }", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
225 |
"t.T", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
226 |
"package t;\n\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
227 |
"@t.Invisible\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
228 |
"@t.Visible\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
229 |
"public class T {\n\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
230 |
" public T();\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
231 |
"}\n", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
232 |
"t.Visible", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
233 |
"package t;\n\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
234 |
"@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME)\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
235 |
"@interface Visible {\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
236 |
"}\n"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
237 |
doPrintElementTest("package t;" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
238 |
"import java.lang.annotation.*;" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
239 |
"import java.util.*;" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
240 |
"public class T {" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
241 |
" public void test(int h, @Invisible int i, @Visible List<String> j, int k) { }" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
242 |
"}" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
243 |
"@Retention(RetentionPolicy.RUNTIME) @interface Visible { }" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
244 |
"@Retention(RetentionPolicy.CLASS) @interface Invisible { }", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
245 |
"package t;" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
246 |
"import java.lang.annotation.*;" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
247 |
"import java.util.*;" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
248 |
"public class T {" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
249 |
" public void test(int h, @Invisible int i, @Visible List<String> j, int k) { }" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
250 |
"}" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
251 |
"@Retention(RetentionPolicy.RUNTIME) @interface Visible { }" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
252 |
"@Retention(RetentionPolicy.CLASS) @interface Invisible { }", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
253 |
"t.T", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
254 |
"package t;\n\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
255 |
"public class T {\n\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
256 |
" public T();\n\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
257 |
" public void test(int arg0,\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
258 |
" @t.Invisible int arg1,\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
259 |
" @t.Visible java.util.List<java.lang.String> arg2,\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
260 |
" int arg3);\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
261 |
"}\n", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
262 |
"t.Visible", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
263 |
"package t;\n\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
264 |
"@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME)\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
265 |
"@interface Visible {\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
266 |
"}\n"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
267 |
doPrintElementTest("package t;" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
268 |
"import java.lang.annotation.*;" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
269 |
"public class T {" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
270 |
" public void test(@Ann(v=\"url\", dv=\"\\\"\\\"\") String str) { }" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
271 |
"}" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
272 |
"@Retention(RetentionPolicy.RUNTIME) @interface Ann {" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
273 |
" public String v();" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
274 |
" public String dv();" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
275 |
"}", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
276 |
"package t;" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
277 |
"public class T { }", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
278 |
"t.T", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
279 |
"package t;\n\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
280 |
"public class T {\n\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
281 |
" public T();\n\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
282 |
" public void test(@t.Ann(dv=\"\\\"\\\"\", v=\"url\") java.lang.String arg0);\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
283 |
"}\n", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
284 |
"t.T", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
285 |
"package t;\n\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
286 |
"public class T {\n\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
287 |
" public T();\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
288 |
"}\n"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
289 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
290 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
291 |
@Test |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
292 |
void testStringConstant() throws Exception { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
293 |
doTest("package t; public class T { public static final String C = \"\"; }", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
294 |
"package t; public class T { public static final String C = \"\"; }", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
295 |
"package t; public class Test { { System.err.println(T.C); } }", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
296 |
ToolBox.Expect.SUCCESS, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
297 |
ToolBox.Expect.SUCCESS); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
298 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
299 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
300 |
@Test |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
301 |
void testCopyProfileAnnotation() throws Exception { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
302 |
String oldProfileAnnotation = CreateSymbols.PROFILE_ANNOTATION; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
303 |
try { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
304 |
CreateSymbols.PROFILE_ANNOTATION = "Lt/Ann;"; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
305 |
doTestEquivalence("package t; public class T { public void t() {} } @interface Ann { }", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
306 |
"package t; public @Ann class T { public void t() {} } @interface Ann { }", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
307 |
"t.T"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
308 |
} finally { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
309 |
CreateSymbols.PROFILE_ANNOTATION = oldProfileAnnotation; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
310 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
311 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
312 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
313 |
@Test |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
314 |
void testParseAnnotation() throws Exception { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
315 |
CreateSymbols.parseAnnotations("@Lsun/Proprietary+Annotation;@Ljdk/Profile+Annotation;(value=I1)", new int[1]); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
316 |
CreateSymbols.parseAnnotations("@Ltest;(value={\"\"})", new int[1]); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
317 |
CreateSymbols.parseAnnotations("@Ljava/beans/ConstructorProperties;(value={\"path\"})", new int[1]); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
318 |
CreateSymbols.parseAnnotations("@Ljava/beans/ConstructorProperties;(value=I-2)", new int[1]); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
319 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
320 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
321 |
@Test |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
322 |
void testStringCharLiterals() throws Exception { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
323 |
doPrintElementTest("package t;" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
324 |
"public class T {" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
325 |
" public static final String STR = \"\\u0000\\u0001\\uffff\";" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
326 |
" public static final String EMPTY = \"\";" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
327 |
" public static final String AMP = \"&&<<>>''\";" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
328 |
"}", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
329 |
"package t;" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
330 |
" public class T {" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
331 |
" public static final char c = '\\uffff';" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
332 |
"}", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
333 |
"t.T", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
334 |
"package t;\n\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
335 |
"public class T {\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
336 |
" public static final java.lang.String STR = \"\\u0000\\u0001\\uffff\";\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
337 |
" public static final java.lang.String EMPTY = \"\";\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
338 |
" public static final java.lang.String AMP = \"&&<<>>'\\'\";\n\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
339 |
" public T();\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
340 |
"}\n", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
341 |
"t.T", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
342 |
"package t;\n\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
343 |
"public class T {\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
344 |
" public static final char c = '\\uffff';\n\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
345 |
" public T();\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
346 |
"}\n"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
347 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
348 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
349 |
@Test |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
350 |
void testGenerification() throws Exception { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
351 |
doTest("package t; public class T { public class TT { public Object t() { return null; } } }", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
352 |
"package t; public class T<E> { public class TT { public E t() { return null; } } }", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
353 |
"package t; public class Test { { T.TT tt = null; tt.t(); } }", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
354 |
ToolBox.Expect.SUCCESS, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
355 |
ToolBox.Expect.SUCCESS); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
356 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
357 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
358 |
int i = 0; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
359 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
360 |
void doTest(String code7, String code8, String testCode, ToolBox.Expect result7, ToolBox.Expect result8) throws Exception { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
361 |
ToolBox tb = new ToolBox(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
362 |
Path classes = prepareVersionedCTSym(code7, code8); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
363 |
Path output = classes.getParent(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
364 |
Path scratch = output.resolve("scratch"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
365 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
366 |
Files.createDirectories(scratch); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
367 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
368 |
tb.new JavacTask() |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
369 |
.sources(testCode) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
370 |
.options("-d", scratch.toAbsolutePath().toString(), "-classpath", computeClassPath(classes, "7"), "-XDuseOptimizedZip=false") |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
371 |
.run(result7) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
372 |
.writeAll(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
373 |
tb.new JavacTask() |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
374 |
.sources(testCode) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
375 |
.options("-d", scratch.toAbsolutePath().toString(), "-classpath", computeClassPath(classes, "8"), "-XDuseOptimizedZip=false") |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
376 |
.run(result8) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
377 |
.writeAll(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
378 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
379 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
380 |
private static String computeClassPath(Path classes, String version) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
381 |
try (Stream<Path> elements = Files.list(classes)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
382 |
return elements.map(el -> el.toAbsolutePath().toString()) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
383 |
.collect(Collectors.joining(File.pathSeparator)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
384 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
385 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
386 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
387 |
void doPrintElementTest(String code7, String code8, String className7, String printed7, String className8, String printed8) throws Exception { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
388 |
ToolBox tb = new ToolBox(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
389 |
Path classes = prepareVersionedCTSym(code7, code8); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
390 |
Path output = classes.getParent(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
391 |
Path scratch = output.resolve("scratch"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
392 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
393 |
Files.createDirectories(scratch); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
394 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
395 |
String out; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
396 |
out = tb.new JavacTask(ToolBox.Mode.CMDLINE) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
397 |
.options("-d", scratch.toAbsolutePath().toString(), "-classpath", computeClassPath(classes, "7"), "-XDuseOptimizedZip=false", "-Xprint", className7) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
398 |
.run(ToolBox.Expect.SUCCESS) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
399 |
.getOutput(ToolBox.OutputKind.STDOUT); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
400 |
if (!out.equals(printed7)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
401 |
throw new AssertionError("out=" + out + "; printed7=" + printed7); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
402 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
403 |
out = tb.new JavacTask(ToolBox.Mode.CMDLINE) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
404 |
.options("-d", scratch.toAbsolutePath().toString(), "-classpath", computeClassPath(classes, "8"), "-XDuseOptimizedZip=false", "-Xprint", className8) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
405 |
.run(ToolBox.Expect.SUCCESS) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
406 |
.getOutput(ToolBox.OutputKind.STDOUT); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
407 |
if (!out.equals(printed8)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
408 |
throw new AssertionError("out=" + out + "; printed8=" + printed8); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
409 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
410 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
411 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
412 |
void doTestEquivalence(String code7, String code8, String testClass) throws Exception { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
413 |
Path classes = prepareVersionedCTSym(code7, code8); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
414 |
Path classfile = classes.resolve("78").resolve(testClass.replace('.', '/') + ".class"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
415 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
416 |
if (!Files.isReadable(classfile)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
417 |
throw new AssertionError("Cannot find expected class."); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
418 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
419 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
420 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
421 |
@Test |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
422 |
void testIncluded() throws Exception { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
423 |
doTestIncluded("package t;\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
424 |
"public class Test extends PP1<PP2> implements PP3<PP4>, PP5<PP6> {\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
425 |
" public PP7 m1(PP8 p) { return null;}\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
426 |
" public PP9<PPA> m2(PPB<PPC> p) { return null;}\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
427 |
" public PPD f1;\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
428 |
" public PPE<PPF> f2;\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
429 |
" public Test2 aux;\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
430 |
"}\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
431 |
"class Test2 extends PPG implements PPH, PPI {\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
432 |
"}\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
433 |
"class PP1<T> {}\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
434 |
"class PP2 {}\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
435 |
"interface PP3<T> {}\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
436 |
"class PP4 {}\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
437 |
"interface PP5<T> {}\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
438 |
"class PP6 {}\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
439 |
"class PP7 {}\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
440 |
"class PP8 {}\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
441 |
"class PP9<T> {}\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
442 |
"class PPA {}\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
443 |
"class PPB<T> {}\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
444 |
"class PPC {}\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
445 |
"class PPD {}\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
446 |
"class PPE<T> {}\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
447 |
"class PPF {}\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
448 |
"class PPG {}\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
449 |
"interface PPH {}\n" + |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
450 |
"interface PPI {}\n", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
451 |
"t.Test", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
452 |
"t.Test2", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
453 |
"t.PP1", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
454 |
"t.PP2", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
455 |
"t.PP3", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
456 |
"t.PP4", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
457 |
"t.PP5", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
458 |
"t.PP6", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
459 |
"t.PP7", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
460 |
"t.PP8", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
461 |
"t.PP9", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
462 |
"t.PPA", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
463 |
"t.PPB", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
464 |
"t.PPC", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
465 |
"t.PPD", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
466 |
"t.PPE", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
467 |
"t.PPF", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
468 |
"t.PPG", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
469 |
"t.PPH", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
470 |
"t.PPI"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
471 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
472 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
473 |
void doTestIncluded(String code, String... includedClasses) throws Exception { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
474 |
boolean oldIncludeAll = includeAll; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
475 |
try { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
476 |
includeAll = false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
477 |
Path classes = prepareVersionedCTSym(code, "package other; public class Other {}"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
478 |
Path root = classes.resolve("7"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
479 |
try (Stream<Path> classFiles = Files.walk(root)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
480 |
Set<String> names = classFiles.map(p -> root.relativize(p)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
481 |
.map(p -> p.toString()) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
482 |
.map(n -> {System.err.println("n= " + n); return n;}) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
483 |
.filter(n -> n.endsWith(".class")) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
484 |
.map(n -> n.substring(0, n.lastIndexOf('.'))) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
485 |
.map(n -> n.replace(File.separator, ".")) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
486 |
.collect(Collectors.toSet()); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
487 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
488 |
if (!names.equals(new HashSet<>(Arrays.asList(includedClasses)))) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
489 |
throw new AssertionError("Expected classes not included: " + names); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
490 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
491 |
} finally { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
492 |
includeAll = oldIncludeAll; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
493 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
494 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
495 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
496 |
Path prepareVersionedCTSym(String code7, String code8) throws Exception { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
497 |
String testClasses = System.getProperty("test.classes"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
498 |
Path output = Paths.get(testClasses, "test-data" + i++); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
499 |
deleteRecursively(output); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
500 |
Files.createDirectories(output); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
501 |
Path ver7Jar = output.resolve("7.jar"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
502 |
compileAndPack(output, ver7Jar, code7); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
503 |
Path ver8Jar = output.resolve("8.jar"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
504 |
compileAndPack(output, ver8Jar, code8); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
505 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
506 |
ZipFileIndexCache.getSharedInstance().clearCache(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
507 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
508 |
Path classes = output.resolve("classes"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
509 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
510 |
Files.createDirectories(classes); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
511 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
512 |
Path ctSym = output.resolve("ct.sym"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
513 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
514 |
deleteRecursively(ctSym); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
515 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
516 |
CreateSymbols.ALLOW_NON_EXISTING_CLASSES = true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
517 |
CreateSymbols.EXTENSION = ".class"; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
518 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
519 |
testGenerate(ver7Jar, ver8Jar, ctSym, "8", classes.toAbsolutePath().toString()); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
520 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
521 |
return classes; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
522 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
523 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
524 |
boolean includeAll = true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
525 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
526 |
void testGenerate(Path jar7, Path jar8, Path descDest, String version, String classDest) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
527 |
deleteRecursively(descDest); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
528 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
529 |
List<VersionDescription> versions = |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
530 |
Arrays.asList(new VersionDescription(jar7.toAbsolutePath().toString(), "7", null), |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
531 |
new VersionDescription(jar8.toAbsolutePath().toString(), "8", "7")); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
532 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
533 |
ExcludeIncludeList acceptAll = new ExcludeIncludeList(null, null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
534 |
@Override public boolean accepts(String className) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
535 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
536 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
537 |
}; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
538 |
new CreateSymbols() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
539 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
540 |
protected boolean includeEffectiveAccess(ClassList classes, ClassDescription clazz) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
541 |
return includeAll ? true : super.includeEffectiveAccess(classes, clazz); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
542 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
543 |
}.createBaseLine(versions, acceptAll, descDest, null); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
544 |
Path symbolsDesc = descDest.resolve("symbols"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
545 |
try (Writer symbolsFile = Files.newBufferedWriter(symbolsDesc)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
546 |
symbolsFile.write("generate platforms 7:8"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
547 |
symbolsFile.write(System.lineSeparator()); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
548 |
symbolsFile.write("platform version 7 files java.base-7.sym.txt"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
549 |
symbolsFile.write(System.lineSeparator()); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
550 |
symbolsFile.write("platform version 8 base 7 files java.base-8.sym.txt"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
551 |
symbolsFile.write(System.lineSeparator()); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
552 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
553 |
new CreateSymbols().createSymbols(symbolsDesc.toAbsolutePath().toString(), classDest, CtSymKind.JOINED_VERSIONS); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
554 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
555 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
556 |
void compileAndPack(Path output, Path outputFile, String... code) throws Exception { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
557 |
ToolBox tb = new ToolBox(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
558 |
Path scratch = output.resolve("temp"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
559 |
deleteRecursively(scratch); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
560 |
Files.createDirectories(scratch); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
561 |
System.err.println(Arrays.asList(code)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
562 |
tb.new JavacTask().sources(code).options("-d", scratch.toAbsolutePath().toString()).run(ToolBox.Expect.SUCCESS); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
563 |
List<String> classFiles = collectClassFile(scratch); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
564 |
try (Writer out = Files.newBufferedWriter(outputFile)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
565 |
for (String classFile : classFiles) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
566 |
try (InputStream in = Files.newInputStream(scratch.resolve(classFile))) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
567 |
int read; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
568 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
569 |
while ((read = in.read()) != (-1)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
570 |
out.write(String.format("%02x", read)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
571 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
572 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
573 |
out.write("\n"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
574 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
575 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
576 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
577 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
578 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
579 |
List<String> collectClassFile(Path root) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
580 |
try (Stream<Path> files = Files.walk(root)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
581 |
return files.filter(p -> Files.isRegularFile(p)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
582 |
.filter(p -> p.getFileName().toString().endsWith(".class")) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
583 |
.map(p -> root.relativize(p).toString()) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
584 |
.collect(Collectors.toList()); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
585 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
586 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
587 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
588 |
void deleteRecursively(Path dir) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
589 |
Files.walkFileTree(dir, new FileVisitor<Path>() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
590 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
591 |
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
592 |
return FileVisitResult.CONTINUE; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
593 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
594 |
@Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
595 |
Files.delete(file); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
596 |
return FileVisitResult.CONTINUE; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
597 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
598 |
@Override public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
599 |
return FileVisitResult.CONTINUE; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
600 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
601 |
@Override public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
602 |
Files.delete(dir); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
603 |
return FileVisitResult.CONTINUE; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
604 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
605 |
}); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
606 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
607 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
608 |
@Retention(RetentionPolicy.RUNTIME) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
609 |
@interface Test { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
610 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
611 |
} |