author | robm |
Tue, 13 Sep 2016 14:47:29 +0100 | |
changeset 40938 | 5b0977acc842 |
parent 40308 | 274367a99f98 |
permissions | -rw-r--r-- |
26991
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
1 |
/* |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
32337
diff
changeset
|
2 |
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. |
26991
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
4 |
* |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
32337 | 7 |
* published by the Free Software Foundation. |
26991
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
8 |
* |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
13 |
* accompanied this code). |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
14 |
* |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
18 |
* |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
21 |
* questions. |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
22 |
*/ |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
23 |
|
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
24 |
import java.lang.reflect.Method; |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
25 |
import java.util.Arrays; |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
26 |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
32337
diff
changeset
|
27 |
import toolbox.ToolBox; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
32337
diff
changeset
|
28 |
|
26991
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
29 |
public class SjavacBase { |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
30 |
|
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
31 |
protected final static ToolBox toolbox = new ToolBox(); |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
32 |
|
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
33 |
/** |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
34 |
* Utility method for invoking sjavac. Method accepts Objects as arguments |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
35 |
* (which are turned into Strings through Object::toString) to allow clients |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
36 |
* to pass for instance Path objects. |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
37 |
*/ |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
38 |
public static int compile(Object... args) throws ReflectiveOperationException { |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
39 |
// Use reflection to avoid a compile-time dependency on sjavac Main |
31115
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
26991
diff
changeset
|
40 |
System.out.println("compile: " + Arrays.toString(args)); |
26991
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
41 |
Class<?> c = Class.forName("com.sun.tools.sjavac.Main"); |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
42 |
Method m = c.getDeclaredMethod("go", String[].class); |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
43 |
String[] strArgs = new String[args.length]; |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
44 |
for (int i = 0; i < args.length; i++) |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
45 |
strArgs[i] = args[i].toString(); |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
46 |
int rc = (Integer) m.invoke(null, (Object) strArgs); |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
47 |
return rc; |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
48 |
} |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
49 |
} |