658N/A/*
658N/A * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
658N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
658N/A *
658N/A * This code is free software; you can redistribute it and/or modify it
658N/A * under the terms of the GNU General Public License version 2 only, as
658N/A * published by the Free Software Foundation.
658N/A *
658N/A * This code is distributed in the hope that it will be useful, but WITHOUT
658N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
658N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
658N/A * version 2 for more details (a copy is included in the LICENSE file that
658N/A * accompanied this code).
658N/A *
658N/A * You should have received a copy of the GNU General Public License version
658N/A * 2 along with this work; if not, write to the Free Software Foundation,
658N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
658N/A *
658N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
658N/A * or visit www.oracle.com if you need additional information or have any
658N/A * questions.
658N/A */
658N/A
658N/A/*
658N/A * @test
658N/A * @bug 6604599
658N/A * @summary ToolProvider should be less compiler-specific
658N/A */
658N/A
658N/Aimport java.io.*;
658N/A
658N/A// verify that running accessing ToolProvider by itself does not
658N/A// trigger loading com.sun.tools.javac.*
658N/Apublic class ToolProviderTest1 {
658N/A public static void main(String... args) throws Exception {
658N/A if (args.length > 0) {
658N/A System.err.println(Class.forName(args[0], true, null));
658N/A return;
658N/A }
658N/A
658N/A new ToolProviderTest1().run();
658N/A }
658N/A
658N/A void run() throws Exception {
658N/A File javaHome = new File(System.getProperty("java.home"));
658N/A if (javaHome.getName().equals("jre"))
658N/A javaHome = javaHome.getParentFile();
658N/A File javaExe = new File(new File(javaHome, "bin"), "java");
658N/A String classpath = System.getProperty("java.class.path");
658N/A
658N/A String[] cmd = {
658N/A javaExe.getPath(),
658N/A "-verbose:class",
658N/A "-classpath", classpath,
658N/A ToolProviderTest1.class.getName(),
658N/A "javax.tools.ToolProvider"
658N/A };
658N/A
658N/A ProcessBuilder pb = new ProcessBuilder(cmd).redirectErrorStream(true);
658N/A Process p = pb.start();
658N/A BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));
658N/A String line;
658N/A while ((line = r.readLine()) != null) {
658N/A System.err.println(line);
658N/A if (line.contains("com.sun.tools.javac."))
658N/A error(">>> " + line);
658N/A }
658N/A int rc = p.waitFor();
658N/A if (rc != 0)
658N/A error("Unexpected exit code: " + rc);
658N/A
658N/A if (errors > 0)
658N/A throw new Exception(errors + " errors occurred");
658N/A }
658N/A
658N/A void error(String msg) {
658N/A System.err.println(msg);
658N/A errors++;
658N/A }
658N/A
658N/A int errors;
658N/A}