author | vasya |
Mon, 14 Dec 2015 20:18:19 +0100 | |
changeset 34752 | 9c262a013456 |
parent 30730 | d3ce7619db2c |
child 36526 | 3b41f1c69604 |
permissions | -rw-r--r-- |
5319
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
1 |
/* |
30730
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
5520
diff
changeset
|
2 |
* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. |
5319
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
4 |
* |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
8 |
* |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
13 |
* accompanied this code). |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
14 |
* |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
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. |
|
5319
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
22 |
*/ |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
23 |
|
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
24 |
/* |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
25 |
* @test |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
26 |
* @bug 6942649 |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
27 |
* @summary add hidden option to identify location and version of javac classes |
30730
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
5520
diff
changeset
|
28 |
* @modules jdk.compiler |
5319
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
29 |
*/ |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
30 |
|
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
31 |
import java.io.*; |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
32 |
|
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
33 |
public class T6942649 { |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
34 |
public static void main(String... args) throws Exception { |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
35 |
new T6942649().run(); |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
36 |
} |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
37 |
|
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
38 |
void run() throws Exception { |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
39 |
test("-XDshowClass", "com.sun.tools.javac.Main"); |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
40 |
test("-XDshowClass=com.sun.tools.javac.util.Log", "com.sun.tools.javac.util.Log"); |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
41 |
} |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
42 |
|
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
43 |
void test(String opt, String clazz) throws Exception { |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
44 |
System.err.println("test " + opt); |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
45 |
StringWriter sw = new StringWriter(); |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
46 |
PrintWriter pw = new PrintWriter(sw); |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
47 |
int rc = com.sun.tools.javac.Main.compile(new String[] { opt }, pw); |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
48 |
pw.close(); |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
49 |
String out = sw.toString(); |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
50 |
System.err.println("javac rc=" + rc + "\n" + out); |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
51 |
if (!out.contains(clazz)) |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
52 |
throw new Exception("class name not found in output"); |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
53 |
int lastDot = clazz.lastIndexOf("."); |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
54 |
if (!out.contains(clazz.substring(lastDot + 1) + ".class")) |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
55 |
throw new Exception("location of class not found in output"); |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
56 |
if (!out.contains("MD5 checksum: ")) |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
57 |
throw new Exception("checksum not found in output"); |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
58 |
} |
63dc7f367a37
6942649: add hidden option to identify location and version of javac classes
jjg
parents:
diff
changeset
|
59 |
} |