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