author | sogoel |
Thu, 05 Jun 2014 10:57:10 -0700 | |
changeset 24797 | 850ebd4d80a7 |
parent 5520 | 86e4b9a9da40 |
child 30730 | d3ce7619db2c |
permissions | -rw-r--r-- |
1037
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
1 |
/* |
5520 | 2 |
* Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. |
1037
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
4 |
* |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
8 |
* |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
13 |
* accompanied this code). |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
14 |
* |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
18 |
* |
5520 | 19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
1037
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
22 |
*/ |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
23 |
|
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
24 |
/* |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
25 |
* @test |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
26 |
* @bug 6627364 6627366 |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
27 |
* @summary Synthesize important classes if they are missing from the (boot)classpath |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
28 |
*/ |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
29 |
|
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
30 |
import java.io.*; |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
31 |
import java.util.*; |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
32 |
|
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
33 |
public class Main |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
34 |
{ |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
35 |
File testSrc = new File(System.getProperty("test.src")); |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
36 |
|
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
37 |
public static void main(String[] args) throws Exception { |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
38 |
new Main().run(); |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
39 |
} |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
40 |
|
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
41 |
public void run() throws Exception { |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
42 |
|
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
43 |
// compile with standard bootclasspath |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
44 |
compile(true, "Test.java"); |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
45 |
|
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
46 |
// compile with various missing system classes |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
47 |
|
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
48 |
List<String> base_files = Arrays.asList( |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
49 |
"Boolean.java", |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
50 |
"Byte.java", |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
51 |
"Character.java", |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
52 |
"Integer.java", |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
53 |
"Long.java", |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
54 |
"Number.java", |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
55 |
"Object.java", |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
56 |
"Short.java", |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
57 |
"Void.java" |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
58 |
); |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
59 |
|
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
60 |
List<String> extra_files = Arrays.asList( |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
61 |
"Double.java", |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
62 |
"Float.java", |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
63 |
"Cloneable.java", |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
64 |
"Serializable.java" |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
65 |
); |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
66 |
|
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
67 |
List<String> files = new ArrayList<String>(); |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
68 |
files.addAll(base_files); |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
69 |
files.add("Test.java"); |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
70 |
|
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
71 |
compile(false, files); |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
72 |
|
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
73 |
for (String f: extra_files) { |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
74 |
files = new ArrayList<String>(); |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
75 |
files.addAll(base_files); |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
76 |
files.addAll(extra_files); |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
77 |
files.remove(f); |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
78 |
files.add("Test.java"); |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
79 |
compile(false, files); |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
80 |
} |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
81 |
|
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
82 |
if (errors > 0) |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
83 |
throw new Exception(errors + " errors occurred"); |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
84 |
} |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
85 |
|
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
86 |
void compile(boolean stdBootClassPath, String... files) { |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
87 |
compile(stdBootClassPath, Arrays.asList(files)); |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
88 |
} |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
89 |
|
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
90 |
void compile(boolean stdBootClassPath, List<String> files) { |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
91 |
File empty = new File("empty"); |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
92 |
empty.mkdirs(); |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
93 |
|
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
94 |
List<String> args = new ArrayList<String>(); |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
95 |
args.add("-classpath"); |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
96 |
args.add("empty"); |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
97 |
|
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
98 |
if (!stdBootClassPath) { |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
99 |
args.add("-bootclasspath"); |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
100 |
args.add("empty"); |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
101 |
} |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
102 |
args.add("-d"); |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
103 |
args.add("."); |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
104 |
for (String f: files) |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
105 |
args.add(new File(testSrc, f).getPath()); |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
106 |
|
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
107 |
System.out.println("Compile: " + args); |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
108 |
StringWriter out = new StringWriter(); |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
109 |
int rc = com.sun.tools.javac.Main.compile(args.toArray(new String[args.size()]), |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
110 |
new PrintWriter(out)); |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
111 |
System.out.println(out.toString()); |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
112 |
System.out.println("result: " + rc); |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
113 |
System.out.println(); |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
114 |
|
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
115 |
if (rc != 0) |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
116 |
errors++; |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
117 |
} |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
118 |
|
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
119 |
private int errors; |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
120 |
} |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
121 |
|
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
diff
changeset
|
122 |