forked from pquiring/javaforce
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExecGraalAgent.java
More file actions
66 lines (55 loc) · 1.67 KB
/
Copy pathExecGraalAgent.java
File metadata and controls
66 lines (55 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package javaforce.utils;
/** ExecGraalAgent
*
* @author pquiring
*/
import java.io.*;
import java.util.*;
import javaforce.*;
public class ExecGraalAgent implements ShellProcessListener {
private BuildTools tools;
public static void main(String[] args) {
if (args.length != 1) {
System.out.println("ExecGraalAgent : Runs project using Graal agentlib");
System.out.println(" Usage : ExecGraalAgent buildfile");
System.exit(1);
}
try {
new ExecGraalAgent().run(args[0]);
} catch (Exception e) {
JFLog.log(e);
}
}
public void run(String buildfile) throws Exception {
tools = new BuildTools();
if (!tools.loadXML(buildfile)) throw new Exception("error loading " + buildfile);
String app = tools.getProperty("app");
String cfg = tools.getProperty("cfg");
if (cfg.length() == 0) {
cfg = app + ".cfg";
}
Properties props = new Properties();
FileInputStream fis = new FileInputStream(cfg);
props.load(fis);
fis.close();
String classpath = props.getProperty("CLASSPATH");
String mainclass = props.getProperty("MAINCLASS");
new File("META-INF/native-image").mkdirs();
ShellProcess sp = new ShellProcess();
sp.addListener(this);
ArrayList<String> cmd = new ArrayList<String>();
cmd.add("java");
cmd.add("-agentlib:native-image-agent=config-output-dir=META-INF/native-image");
cmd.add("-cp");
if (JF.isWindows()) {
cmd.add(classpath);
} else {
cmd.add(classpath.replaceAll("[;]", ":"));
}
cmd.add(mainclass);
sp.run(cmd.toArray(JF.StringArrayType), true);
}
public void shellProcessOutput(String str) {
System.out.print(str);
}
}