Added
Link Here
|
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2000, 2006 IBM Corporation and others. |
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
6 |
* http://www.eclipse.org/legal/epl-v10.html |
7 |
* |
8 |
* Contributors: |
9 |
* IBM Corporation - initial API and implementation |
10 |
*******************************************************************************/ |
11 |
package org.eclipse.jdt.core.tests.runtime; |
12 |
|
13 |
import java.io.File; |
14 |
import java.util.Vector; |
15 |
|
16 |
/** |
17 |
* This is a new vm launcher to support Apache Harmony |
18 |
* (http://harmony.apache.org) settings |
19 |
*/ |
20 |
public class DRLVMLauncher extends StandardVMLauncher { |
21 |
|
22 |
/** |
23 |
* @see LocalVMLauncher#getCommandLine |
24 |
*/ |
25 |
public String[] getCommandLine() { |
26 |
Vector commandLine= new Vector(); |
27 |
|
28 |
// VM binary |
29 |
String vmLocation = this.vmPath + |
30 |
(this.vmPath.endsWith(File.separator) ? "" : File.separator) + |
31 |
"bin" + |
32 |
File.separator + |
33 |
"javaw"; |
34 |
final String osName = System.getProperty("os.name"); |
35 |
if (osName.indexOf("win32") == -1 && !new File(vmLocation).exists()) { |
36 |
vmLocation = vmLocation.substring(0, vmLocation.length()-1); |
37 |
} |
38 |
commandLine.addElement(vmLocation); |
39 |
|
40 |
// VM arguments |
41 |
if (this.vmArguments != null) { |
42 |
for (int i = 0; i < this.vmArguments.length; i++) { |
43 |
commandLine.addElement(this.vmArguments[i]); |
44 |
} |
45 |
} |
46 |
|
47 |
// boot classpath |
48 |
commandLine.addElement("-Xbootclasspath/a:" + buildBootClassPath()); |
49 |
|
50 |
// debug mode |
51 |
if (this.debugPort != -1) { |
52 |
commandLine.addElement("-Xdebug"); |
53 |
commandLine.addElement("-Xnoagent"); |
54 |
// commandLine.addElement("-Djava.compiler=NONE"); |
55 |
commandLine.addElement( |
56 |
"-Xrunjdwp:transport=dt_socket,address=" + |
57 |
this.debugPort + |
58 |
",server=y,suspend=n"); |
59 |
} |
60 |
|
61 |
// regular classpath |
62 |
commandLine.addElement("-classpath"); |
63 |
commandLine.addElement(buildClassPath()); |
64 |
|
65 |
// code snippet runner class |
66 |
if (this.evalPort != -1) { |
67 |
commandLine.addElement(CODE_SNIPPET_RUNNER_CLASS_NAME); |
68 |
} |
69 |
|
70 |
// code snippet runner arguments |
71 |
if (this.evalPort != -1) { |
72 |
commandLine.addElement(EVALPORT_ARG); |
73 |
commandLine.addElement(Integer.toString(this.evalPort)); |
74 |
if (TARGET_HAS_FILE_SYSTEM) { |
75 |
commandLine.addElement(CODESNIPPET_CLASSPATH_ARG); |
76 |
commandLine.addElement(this.evalTargetPath + File.separator + REGULAR_CLASSPATH_DIRECTORY); |
77 |
commandLine.addElement(CODESNIPPET_BOOTPATH_ARG); |
78 |
commandLine.addElement(this.evalTargetPath + File.separator + BOOT_CLASSPATH_DIRECTORY); |
79 |
} |
80 |
} |
81 |
|
82 |
// program class |
83 |
if (this.programClass != null) { |
84 |
commandLine.addElement(this.programClass); |
85 |
} |
86 |
|
87 |
// program arguments |
88 |
if (this.programArguments != null) { |
89 |
for (int i=0;i<this.programArguments.length;i++) { |
90 |
commandLine.addElement(this.programArguments[i]); |
91 |
} |
92 |
} |
93 |
|
94 |
String[] result; |
95 |
if (this.batchFileName!= null) { |
96 |
// Write to batch file if specified |
97 |
writeBatchFile(this.batchFileName, commandLine); |
98 |
result = new String[] {this.batchFileName}; |
99 |
} else { |
100 |
result = new String[commandLine.size()]; |
101 |
commandLine.copyInto(result); |
102 |
} |
103 |
|
104 |
// check for spaces in result |
105 |
for (int i = 0; i < result.length; i++) { |
106 |
String argument = result[i]; |
107 |
if (argument.indexOf(' ') != -1) { |
108 |
result[i] = "\"" + argument + "\""; |
109 |
} |
110 |
} |
111 |
|
112 |
return result; |
113 |
} |
114 |
|
115 |
/** |
116 |
* Builds the actual boot class path that is going to be passed to the VM. |
117 |
*/ |
118 |
protected String buildBootClassPath() { |
119 |
StringBuffer bootPathString = new StringBuffer(); |
120 |
char pathSeparator = File.pathSeparatorChar; |
121 |
|
122 |
if (this.bootPath != null) { |
123 |
// Add boot class path given by client |
124 |
int length = this.bootPath.length; |
125 |
for (int i = 0; i < length; i++){ |
126 |
bootPathString.append(this.bootPath[i]); |
127 |
bootPathString.append(pathSeparator); |
128 |
} |
129 |
} |
130 |
|
131 |
// Add boot class path directory if needed |
132 |
if (this.evalTargetPath != null && TARGET_HAS_FILE_SYSTEM) { |
133 |
bootPathString.append(this.evalTargetPath); |
134 |
bootPathString.append(File.separatorChar); |
135 |
bootPathString.append(BOOT_CLASSPATH_DIRECTORY); |
136 |
} |
137 |
|
138 |
return bootPathString.toString(); |
139 |
} |
140 |
} |