85N/A/*
553N/A * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
85N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
85N/A *
85N/A * This code is free software; you can redistribute it and/or modify it
85N/A * under the terms of the GNU General Public License version 2 only, as
85N/A * published by the Free Software Foundation.
85N/A *
85N/A * This code is distributed in the hope that it will be useful, but WITHOUT
85N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
85N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
85N/A * version 2 for more details (a copy is included in the LICENSE file that
85N/A * accompanied this code).
85N/A *
85N/A * You should have received a copy of the GNU General Public License version
85N/A * 2 along with this work; if not, write to the Free Software Foundation,
85N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
85N/A *
553N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
553N/A * or visit www.oracle.com if you need additional information or have any
553N/A * questions.
85N/A */
85N/A
85N/A/*
85N/A * @test
85N/A * @bug 6627364 6627366
85N/A * @summary Synthesize important classes if they are missing from the (boot)classpath
85N/A */
85N/A
85N/Aimport java.io.*;
85N/Aimport java.util.*;
85N/A
85N/Apublic class Main
85N/A{
85N/A File testSrc = new File(System.getProperty("test.src"));
85N/A
85N/A public static void main(String[] args) throws Exception {
85N/A new Main().run();
85N/A }
85N/A
85N/A public void run() throws Exception {
85N/A
85N/A // compile with standard bootclasspath
85N/A compile(true, "Test.java");
85N/A
85N/A // compile with various missing system classes
85N/A
85N/A List<String> base_files = Arrays.asList(
85N/A "Boolean.java",
85N/A "Byte.java",
85N/A "Character.java",
85N/A "Integer.java",
85N/A "Long.java",
85N/A "Number.java",
85N/A "Object.java",
85N/A "Short.java",
85N/A "Void.java"
85N/A );
85N/A
85N/A List<String> extra_files = Arrays.asList(
85N/A "Double.java",
85N/A "Float.java",
85N/A "Cloneable.java",
85N/A "Serializable.java"
85N/A );
85N/A
85N/A List<String> files = new ArrayList<String>();
85N/A files.addAll(base_files);
85N/A files.add("Test.java");
85N/A
85N/A compile(false, files);
85N/A
85N/A for (String f: extra_files) {
85N/A files = new ArrayList<String>();
85N/A files.addAll(base_files);
85N/A files.addAll(extra_files);
85N/A files.remove(f);
85N/A files.add("Test.java");
85N/A compile(false, files);
85N/A }
85N/A
85N/A if (errors > 0)
85N/A throw new Exception(errors + " errors occurred");
85N/A }
85N/A
85N/A void compile(boolean stdBootClassPath, String... files) {
85N/A compile(stdBootClassPath, Arrays.asList(files));
85N/A }
85N/A
85N/A void compile(boolean stdBootClassPath, List<String> files) {
85N/A File empty = new File("empty");
85N/A empty.mkdirs();
85N/A
85N/A List<String> args = new ArrayList<String>();
85N/A args.add("-classpath");
85N/A args.add("empty");
85N/A
85N/A if (!stdBootClassPath) {
85N/A args.add("-bootclasspath");
85N/A args.add("empty");
85N/A }
85N/A args.add("-d");
85N/A args.add(".");
85N/A for (String f: files)
85N/A args.add(new File(testSrc, f).getPath());
85N/A
85N/A System.out.println("Compile: " + args);
85N/A StringWriter out = new StringWriter();
85N/A int rc = com.sun.tools.javac.Main.compile(args.toArray(new String[args.size()]),
85N/A new PrintWriter(out));
85N/A System.out.println(out.toString());
85N/A System.out.println("result: " + rc);
85N/A System.out.println();
85N/A
85N/A if (rc != 0)
85N/A errors++;
85N/A }
85N/A
85N/A private int errors;
85N/A}
85N/A
85N/A