2
* Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
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
26
* @bug 6627364 6627366
27
* @summary Synthesize important classes if they are missing from the (boot)classpath
28
* @modules jdk.compiler
36
File testSrc = new File(System.getProperty("test.src"));
38
public static void main(String[] args) throws Exception {
42
public void run() throws Exception {
44
// compile with standard bootclasspath
45
compile(true, "Test.java");
47
// compile with various missing system classes
49
List<String> base_files = Arrays.asList(
61
List<String> extra_files = Arrays.asList(
68
List<String> files = new ArrayList<String>();
69
files.addAll(base_files);
70
files.add("Test.java");
72
compile(false, files);
74
for (String f: extra_files) {
75
files = new ArrayList<String>();
76
files.addAll(base_files);
77
files.addAll(extra_files);
79
files.add("Test.java");
80
compile(false, files);
84
throw new Exception(errors + " errors occurred");
87
void compile(boolean stdBootClassPath, String... files) {
88
compile(stdBootClassPath, Arrays.asList(files));
91
void compile(boolean stdBootClassPath, List<String> files) {
92
File empty = new File("empty");
95
// files to compile are in a separate directory from test to avoid
97
File src = new File(testSrc, "src");
99
List<String> args = new ArrayList<String>();
100
args.add("-classpath");
103
if (stdBootClassPath) {
104
args.add("--patch-module");
105
args.add("java.base=" + testSrc.getAbsolutePath());
107
args.add("--system");
109
files.add("module-info.java");
116
for (String f: files)
117
args.add(new File(src, f).getPath());
119
System.out.println("Compile: " + args);
120
StringWriter out = new StringWriter();
121
int rc = com.sun.tools.javac.Main.compile(args.toArray(new String[args.size()]),
122
new PrintWriter(out));
123
System.out.println(out.toString());
124
System.out.println("result: " + rc);
125
System.out.println();