Tue, 22 Jan 2013 19:07:20 -0800
Merge
1.1 --- a/test/tools/sjavac/SJavac.java Tue Jan 22 19:06:05 2013 -0800 1.2 +++ b/test/tools/sjavac/SJavac.java Tue Jan 22 19:07:20 2013 -0800 1.3 @@ -21,16 +21,6 @@ 1.4 * questions. 1.5 */ 1.6 1.7 -/* 1.8 - * @test 1.9 - * @summary Test all aspects of sjavac. 1.10 - * 1.11 - * @bug 8004658 1.12 - * @summary Add internal smart javac wrapper to solve JEP 139 1.13 - * 1.14 - * @run main SJavac 1.15 - */ 1.16 - 1.17 import java.util.*; 1.18 import java.io.*; 1.19 import java.net.*; 1.20 @@ -44,13 +34,6 @@ 1.21 class SJavac { 1.22 1.23 public static void main(String... args) throws Exception { 1.24 - URL url = SJavac.class.getClassLoader().getResource("com/sun/tools/sjavac/Main.class"); 1.25 - if (url == null) { 1.26 - // No sjavac in the classpath. 1.27 - System.out.println("pass by default"); 1.28 - return; 1.29 - } 1.30 - 1.31 SJavac s = new SJavac(); 1.32 s.test(); 1.33 }
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/test/tools/sjavac/SJavacWrapper.java Tue Jan 22 19:07:20 2013 -0800 2.3 @@ -0,0 +1,67 @@ 2.4 +/* 2.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 2.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.7 + * 2.8 + * This code is free software; you can redistribute it and/or modify it 2.9 + * under the terms of the GNU General Public License version 2 only, as 2.10 + * published by the Free Software Foundation. 2.11 + * 2.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 2.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 2.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 2.15 + * version 2 for more details (a copy is included in the LICENSE file that 2.16 + * accompanied this code). 2.17 + * 2.18 + * You should have received a copy of the GNU General Public License version 2.19 + * 2 along with this work; if not, write to the Free Software Foundation, 2.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2.21 + * 2.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2.23 + * or visit www.oracle.com if you need additional information or have any 2.24 + * questions. 2.25 + */ 2.26 + 2.27 +/* 2.28 + * @test 2.29 + * @summary Test all aspects of sjavac. 2.30 + * 2.31 + * @bug 8004658 2.32 + * @summary Add internal smart javac wrapper to solve JEP 139 2.33 + * 2.34 + * @run main SJavacWrapper 2.35 + */ 2.36 + 2.37 +import java.io.*; 2.38 +import java.lang.reflect.Method; 2.39 +import java.net.*; 2.40 + 2.41 + 2.42 +public 2.43 +class SJavacWrapper { 2.44 + 2.45 + public static void main(String... args) throws Exception { 2.46 + URL url = SJavacWrapper.class.getClassLoader().getResource("com/sun/tools/sjavac/Main.class"); 2.47 + if (url == null) { 2.48 + // No sjavac in the classpath. 2.49 + System.out.println("sjavac not available: pass by default"); 2.50 + return; 2.51 + } 2.52 + 2.53 + File testSrc = new File(System.getProperty("test.src")); 2.54 + File sjavac_java = new File(testSrc, "SJavac.java"); 2.55 + File testClasses = new File(System.getProperty("test.classes")); 2.56 + File sjavac_class = new File(testClasses, "SJavac.class"); 2.57 + if (sjavac_class.lastModified() < sjavac_java.lastModified()) { 2.58 + String[] javac_args = { "-d", testClasses.getPath(), sjavac_java.getPath() }; 2.59 + System.err.println("Recompiling SJavac.java"); 2.60 + int rc = com.sun.tools.javac.Main.compile(javac_args); 2.61 + if (rc != 0) 2.62 + throw new Exception("compilation failed"); 2.63 + } 2.64 + 2.65 + Class<?> sjavac = Class.forName("SJavac"); 2.66 + Method sjavac_main = sjavac.getMethod("main", String[].class); 2.67 + sjavac_main.invoke(null, new Object[] { args }); 2.68 + } 2.69 + 2.70 +}