|
46 | 46 |
|
47 | 47 | import edu.rice.cs.plt.lambda.Thunk; |
48 | 48 | import edu.rice.cs.plt.io.IOUtil; |
| 49 | +import edu.rice.cs.plt.concurrent.JVMBuilder; |
49 | 50 | import edu.rice.cs.plt.concurrent.ConcurrentUtil; |
50 | 51 | import edu.rice.cs.plt.iter.IterUtil; |
51 | 52 | import edu.rice.cs.plt.text.TextUtil; |
@@ -79,26 +80,25 @@ public class DefaultJavadocModel implements JavadocModel { |
79 | 80 |
|
80 | 81 | /**Manages listeners to this model. */ |
81 | 82 | private final JavadocEventNotifier _notifier = new JavadocEventNotifier(); |
82 | | - |
83 | | - /** Location of the java command to use (if not the default in {@code java.home}) */ |
84 | | - private final File _javaCommand; |
85 | | - |
86 | | - /** Location of the tools library containing the javadoc code (if not on the javaCommand's boot class path) */ |
87 | | - private final Iterable<File> _toolsPath; |
| 83 | + |
| 84 | + /** Launcher for javadoc process */ |
| 85 | + private final JVMBuilder _jvmBuilder; |
88 | 86 |
|
89 | 87 | /** The error model containing all current Javadoc errors. */ |
90 | 88 | private CompilerErrorModel _javadocErrorModel; |
91 | 89 |
|
92 | 90 | /** Main constructor. |
93 | 91 | * @param model Source of documents for this JavadocModel |
94 | | - * @param javaCommand Location of the java command to use (if not the default in {@code java.home}) |
95 | | - * @param toolsPath Location of the tools library containing the javadoc code (if not on the |
| 92 | + * @param javaCommand Location of the java command to use ({@code null} means the default: {@code java.home}) |
| 93 | + * @param toolsPath Location of the tools library containing the javadoc code ({@code null} means the default: |
96 | 94 | * javaCommand's boot class path) |
97 | 95 | */ |
98 | 96 | public DefaultJavadocModel(GlobalModel model, File javaCommand, Iterable<File> toolsPath) { |
99 | 97 | _model = model; |
100 | | - _javaCommand = javaCommand; |
101 | | - _toolsPath = toolsPath; |
| 98 | + JVMBuilder builder = JVMBuilder.DEFAULT; |
| 99 | + if (javaCommand != null) { builder = builder.javaCommand(javaCommand); } |
| 100 | + if (toolsPath != null) { builder = builder.classPath(toolsPath); } |
| 101 | + _jvmBuilder = builder; |
102 | 102 | _javadocErrorModel = new CompilerErrorModel(); |
103 | 103 | } |
104 | 104 |
|
@@ -312,14 +312,9 @@ private void _runJavadoc(Iterable<String> files, File destDir, Iterable<String> |
312 | 312 | args = IterUtil.compose(args, ArgumentTokenizer.tokenize(custom)); |
313 | 313 | args = IterUtil.compose(args, files); |
314 | 314 |
|
315 | | - File javaCommand = (_javaCommand == null) ? new File(System.getProperty("java.home", "")) : _javaCommand; |
316 | | - Iterable<File> jvmClassPath = (_toolsPath == null) ? IterUtil.<File>empty() : _toolsPath; |
317 | | - |
318 | 315 | List<DJError> errors = new ArrayList<DJError>(); |
319 | 316 | try { |
320 | | - Process p = ConcurrentUtil.runJavaProcess(javaCommand, "com.sun.tools.javadoc.Main", args, |
321 | | - jvmClassPath, new File(System.getProperty("user.dir", "")), |
322 | | - new Properties(), IterUtil.<String>empty()); |
| 317 | + Process p = _jvmBuilder.start("com.sun.tools.javadoc.Main", args); |
323 | 318 | Thunk<String> outputString = ConcurrentUtil.processOutAsString(p); |
324 | 319 | Thunk<String> errorString = ConcurrentUtil.processErrAsString(p); |
325 | 320 | p.waitFor(); |
|
0 commit comments