|
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 |
| package edu.rice.cs.drjava.model.repl.newjvm; |
|
38 |
| |
|
39 |
| import java.rmi.*; |
|
40 |
| import java.io.*; |
|
41 |
| import java.net.SocketException; |
|
42 |
| |
|
43 |
| import java.util.List; |
|
44 |
| import java.util.ArrayList; |
|
45 |
| import java.util.Map; |
|
46 |
| import java.util.concurrent.TimeoutException; |
|
47 |
| |
|
48 |
| import edu.rice.cs.drjava.DrJava; |
|
49 |
| import edu.rice.cs.drjava.config.OptionConstants; |
|
50 |
| import edu.rice.cs.drjava.model.repl.*; |
|
51 |
| import edu.rice.cs.drjava.model.junit.JUnitError; |
|
52 |
| import edu.rice.cs.drjava.model.junit.JUnitModelCallback; |
|
53 |
| import edu.rice.cs.drjava.model.debug.DebugModelCallback; |
|
54 |
| import edu.rice.cs.drjava.platform.PlatformFactory; |
|
55 |
| import edu.rice.cs.drjava.ui.DrJavaErrorHandler; |
|
56 |
| |
|
57 |
| import edu.rice.cs.util.ArgumentTokenizer; |
|
58 |
| import edu.rice.cs.util.FileOps; |
|
59 |
| import edu.rice.cs.util.UnexpectedException; |
|
60 |
| import edu.rice.cs.plt.io.IOUtil; |
|
61 |
| import edu.rice.cs.plt.iter.IterUtil; |
|
62 |
| import edu.rice.cs.plt.reflect.ReflectUtil; |
|
63 |
| import edu.rice.cs.plt.reflect.JavaVersion; |
|
64 |
| import edu.rice.cs.plt.tuple.Option; |
|
65 |
| import edu.rice.cs.plt.tuple.Pair; |
|
66 |
| import edu.rice.cs.plt.concurrent.JVMBuilder; |
|
67 |
| import edu.rice.cs.plt.concurrent.StateMonitor; |
|
68 |
| import edu.rice.cs.plt.concurrent.CompletionMonitor; |
|
69 |
| |
|
70 |
| import edu.rice.cs.util.newjvm.*; |
|
71 |
| import edu.rice.cs.util.classloader.ClassFileError; |
|
72 |
| |
|
73 |
| import static edu.rice.cs.plt.debug.DebugUtil.debug; |
|
74 |
| |
|
75 |
| |
|
76 |
| |
|
77 |
| |
|
78 |
| |
|
79 |
| |
|
80 |
| |
|
81 |
| |
|
82 |
| |
|
83 |
| |
|
84 |
| |
|
85 |
| |
|
86 |
| |
|
87 |
| |
|
88 |
| |
|
89 |
| |
|
90 |
| |
|
91 |
| |
|
92 |
| public class MainJVM extends AbstractMasterJVM implements MainJVMRemoteI { |
|
93 |
| |
|
94 |
| |
|
95 |
| private static final int MAX_STARTUP_FAILURES = 3; |
|
96 |
| |
|
97 |
| |
|
98 |
| private static final int STARTUP_TIMEOUT = 10000; |
|
99 |
| |
|
100 |
| |
|
101 |
| private final StateMonitor<State> _state; |
|
102 |
| |
|
103 |
| |
|
104 |
| private final ResultHandler _handler = new ResultHandler(); |
|
105 |
| |
|
106 |
| |
|
107 |
| private volatile InteractionsModelCallback _interactionsModel; |
|
108 |
| |
|
109 |
| |
|
110 |
| private volatile JUnitModelCallback _junitModel; |
|
111 |
| |
|
112 |
| |
|
113 |
| private volatile DebugModelCallback _debugModel; |
|
114 |
| |
|
115 |
| |
|
116 |
| |
|
117 |
| |
|
118 |
| |
|
119 |
| private volatile boolean _allowAssertions = false; |
|
120 |
| |
|
121 |
| |
|
122 |
| private volatile Iterable<File> _startupClassPath; |
|
123 |
| |
|
124 |
| |
|
125 |
| private volatile File _workingDir; |
|
126 |
| |
|
127 |
| |
|
128 |
| |
|
129 |
| |
|
130 |
| |
|
131 |
159
| public MainJVM(File wd) {
|
|
132 |
159
| super(InterpreterJVM.class.getName());
|
|
133 |
159
| _workingDir = wd;
|
|
134 |
159
| _interactionsModel = new DummyInteractionsModel();
|
|
135 |
159
| _junitModel = new DummyJUnitModel();
|
|
136 |
159
| _debugModel = new DummyDebugModel();
|
|
137 |
159
| _state = new StateMonitor<State>(new FreshState());
|
|
138 |
159
| _startupClassPath = ReflectUtil.SYSTEM_CLASS_PATH;
|
|
139 |
| } |
|
140 |
| |
|
141 |
| |
|
142 |
| |
|
143 |
| |
|
144 |
| |
|
145 |
| |
|
146 |
| |
|
147 |
159
| public void startInterpreterJVM() { _state.value().start(); }
|
|
148 |
| |
|
149 |
| |
|
150 |
| |
|
151 |
| |
|
152 |
| |
|
153 |
0
| public void stopInterpreterJVM() { _state.value().stop(); }
|
|
154 |
| |
|
155 |
| |
|
156 |
| |
|
157 |
| |
|
158 |
| |
|
159 |
| |
|
160 |
26
| public void restartInterpreterJVM(boolean force) { _state.value().restart(force); }
|
|
161 |
| |
|
162 |
| |
|
163 |
| |
|
164 |
| |
|
165 |
| |
|
166 |
157
| public void dispose() { _state.value().dispose(); }
|
|
167 |
| |
|
168 |
| |
|
169 |
| |
|
170 |
| |
|
171 |
| |
|
172 |
| |
|
173 |
| |
|
174 |
| |
|
175 |
| |
|
176 |
| |
|
177 |
180
| protected void handleSlaveConnected(SlaveRemote newSlave) {
|
|
178 |
180
| InterpreterJVMRemoteI slaveCast = (InterpreterJVMRemoteI) newSlave;
|
|
179 |
180
| _state.value().started(slaveCast);
|
|
180 |
| } |
|
181 |
| |
|
182 |
| |
|
183 |
| |
|
184 |
| |
|
185 |
| |
|
186 |
156
| protected void handleSlaveQuit(int status) {
|
|
187 |
157
| debug.logValue("Slave quit", "status", status);
|
|
188 |
157
| _state.value().stopped(status);
|
|
189 |
| } |
|
190 |
| |
|
191 |
| |
|
192 |
| |
|
193 |
| |
|
194 |
| |
|
195 |
0
| protected void handleSlaveWontStart(Exception e) {
|
|
196 |
0
| debug.log("Slave won't start", e);
|
|
197 |
0
| _state.value().startFailed(e);
|
|
198 |
| } |
|
199 |
| |
|
200 |
| |
|
201 |
| |
|
202 |
| |
|
203 |
| |
|
204 |
| |
|
205 |
| |
|
206 |
| |
|
207 |
| |
|
208 |
| |
|
209 |
| |
|
210 |
| |
|
211 |
0
| public void systemErrPrint(String s) {
|
|
212 |
0
| debug.logStart();
|
|
213 |
0
| _interactionsModel.replSystemErrPrint(s);
|
|
214 |
| |
|
215 |
0
| debug.logEnd();
|
|
216 |
| } |
|
217 |
| |
|
218 |
| |
|
219 |
| |
|
220 |
| |
|
221 |
8
| public void systemOutPrint(String s) {
|
|
222 |
8
| debug.logStart();
|
|
223 |
8
| _interactionsModel.replSystemOutPrint(s);
|
|
224 |
| |
|
225 |
8
| debug.logEnd();
|
|
226 |
| } |
|
227 |
| |
|
228 |
| |
|
229 |
| |
|
230 |
| |
|
231 |
1
| public String getConsoleInput() {
|
|
232 |
1
| String s = _interactionsModel.getConsoleInput();
|
|
233 |
| |
|
234 |
1
| return s;
|
|
235 |
| } |
|
236 |
| |
|
237 |
| |
|
238 |
| |
|
239 |
| |
|
240 |
| |
|
241 |
0
| public void nonTestCase(boolean isTestAll, boolean didCompileFail) {
|
|
242 |
0
| _junitModel.nonTestCase(isTestAll, didCompileFail);
|
|
243 |
| } |
|
244 |
| |
|
245 |
| |
|
246 |
| |
|
247 |
| |
|
248 |
| |
|
249 |
0
| public void classFileError(ClassFileError e) {
|
|
250 |
0
| _junitModel.classFileError(e);
|
|
251 |
| } |
|
252 |
| |
|
253 |
| |
|
254 |
| |
|
255 |
| |
|
256 |
| |
|
257 |
16
| public void testSuiteStarted(int numTests) {
|
|
258 |
16
| _junitModel.testSuiteStarted(numTests);
|
|
259 |
| } |
|
260 |
| |
|
261 |
| |
|
262 |
| |
|
263 |
| |
|
264 |
25
| public void testStarted(String testName) {
|
|
265 |
25
| _junitModel.testStarted(testName);
|
|
266 |
| } |
|
267 |
| |
|
268 |
| |
|
269 |
| |
|
270 |
| |
|
271 |
| |
|
272 |
| |
|
273 |
24
| public void testEnded(String testName, boolean wasSuccessful, boolean causedError) {
|
|
274 |
24
| _junitModel.testEnded(testName, wasSuccessful, causedError);
|
|
275 |
| } |
|
276 |
| |
|
277 |
| |
|
278 |
| |
|
279 |
| |
|
280 |
15
| public void testSuiteEnded(JUnitError[] errors) {
|
|
281 |
15
| _junitModel.testSuiteEnded(errors);
|
|
282 |
| } |
|
283 |
| |
|
284 |
| |
|
285 |
| |
|
286 |
| |
|
287 |
| |
|
288 |
4
| public File getFileForClassName(String className) {
|
|
289 |
4
| return _junitModel.getFileForClassName(className);
|
|
290 |
| } |
|
291 |
| |
|
292 |
| |
|
293 |
| |
|
294 |
| |
|
295 |
| |
|
296 |
| |
|
297 |
| |
|
298 |
| |
|
299 |
| |
|
300 |
| |
|
301 |
| |
|
302 |
| |
|
303 |
| |
|
304 |
| |
|
305 |
| |
|
306 |
| |
|
307 |
| |
|
308 |
| |
|
309 |
158
| public void setInteractionsModel(InteractionsModelCallback model) { _interactionsModel = model; }
|
|
310 |
| |
|
311 |
| |
|
312 |
157
| public void setJUnitModel(JUnitModelCallback model) { _junitModel = model; }
|
|
313 |
| |
|
314 |
| |
|
315 |
| |
|
316 |
| |
|
317 |
157
| public void setDebugModel(DebugModelCallback model) { _debugModel = model; }
|
|
318 |
| |
|
319 |
| |
|
320 |
157
| public void setAllowAssertions(boolean allow) { _allowAssertions = allow; }
|
|
321 |
| |
|
322 |
| |
|
323 |
| |
|
324 |
| |
|
325 |
| |
|
326 |
0
| public void setStartupClassPath(String classPath) {
|
|
327 |
0
| _startupClassPath = IOUtil.parsePath(classPath);
|
|
328 |
| } |
|
329 |
| |
|
330 |
| |
|
331 |
25
| public void setWorkingDirectory(File dir) {
|
|
332 |
25
| _workingDir = dir;
|
|
333 |
| } |
|
334 |
| |
|
335 |
| |
|
336 |
39
| protected InterpretResult.Visitor<Void> resultHandler() { return _handler; }
|
|
337 |
| |
|
338 |
| |
|
339 |
| |
|
340 |
| |
|
341 |
| |
|
342 |
| |
|
343 |
| |
|
344 |
| |
|
345 |
54
| public boolean interpret(final String s) {
|
|
346 |
54
| InterpreterJVMRemoteI remote = _state.value().interpreter(true);
|
|
347 |
0
| if (remote == null) { return false; }
|
|
348 |
54
| try {
|
|
349 |
54
| debug.logStart("Interpreting " + s);
|
|
350 |
54
| InterpretResult result = remote.interpret(s);
|
|
351 |
52
| result.apply(resultHandler());
|
|
352 |
52
| debug.logEnd("result", result);
|
|
353 |
52
| return true;
|
|
354 |
| } |
|
355 |
2
| catch (RemoteException e) { debug.logEnd(); _handleRemoteException(e); return false; }
|
|
356 |
| } |
|
357 |
| |
|
358 |
| |
|
359 |
| |
|
360 |
| |
|
361 |
| |
|
362 |
| |
|
363 |
0
| public Option<Pair<String,String>> getVariableToString(String var) {
|
|
364 |
0
| InterpreterJVMRemoteI remote = _state.value().interpreter(false);
|
|
365 |
0
| if (remote == null) { return Option.none(); }
|
|
366 |
0
| try { return Option.some(remote.getVariableToString(var)); }
|
|
367 |
0
| catch (RemoteException e) { _handleRemoteException(e); return Option.none(); }
|
|
368 |
| } |
|
369 |
| |
|
370 |
| |
|
371 |
| |
|
372 |
| |
|
373 |
| |
|
374 |
0
| public boolean addProjectClassPath(File f) {
|
|
375 |
0
| InterpreterJVMRemoteI remote = _state.value().interpreter(false);
|
|
376 |
0
| if (remote == null) { return false; }
|
|
377 |
0
| try { remote.addProjectClassPath(f); return true; }
|
|
378 |
0
| catch (RemoteException e) { _handleRemoteException(e); return false; }
|
|
379 |
| } |
|
380 |
| |
|
381 |
| |
|
382 |
| |
|
383 |
| |
|
384 |
| |
|
385 |
25
| public boolean addBuildDirectoryClassPath(File f) {
|
|
386 |
25
| InterpreterJVMRemoteI remote = _state.value().interpreter(false);
|
|
387 |
0
| if (remote == null) { return false; }
|
|
388 |
25
| try { remote.addBuildDirectoryClassPath(f); return true; }
|
|
389 |
0
| catch (RemoteException e) { _handleRemoteException(e); return false; }
|
|
390 |
| } |
|
391 |
| |
|
392 |
| |
|
393 |
| |
|
394 |
| |
|
395 |
| |
|
396 |
183
| public boolean addProjectFilesClassPath(File f) {
|
|
397 |
183
| InterpreterJVMRemoteI remote = _state.value().interpreter(false);
|
|
398 |
1
| if (remote == null) { return false; }
|
|
399 |
182
| try { remote.addProjectFilesClassPath(f); return true; }
|
|
400 |
0
| catch (RemoteException e) { _handleRemoteException(e); return false; }
|
|
401 |
| } |
|
402 |
| |
|
403 |
| |
|
404 |
| |
|
405 |
| |
|
406 |
| |
|
407 |
225
| public boolean addExternalFilesClassPath(File f) {
|
|
408 |
225
| InterpreterJVMRemoteI remote = _state.value().interpreter(false);
|
|
409 |
0
| if (remote == null) { return false; }
|
|
410 |
225
| try { remote.addExternalFilesClassPath(f); return true; }
|
|
411 |
0
| catch (RemoteException e) { _handleRemoteException(e); return false; }
|
|
412 |
| } |
|
413 |
| |
|
414 |
| |
|
415 |
| |
|
416 |
| |
|
417 |
| |
|
418 |
2
| public boolean addExtraClassPath(File f) {
|
|
419 |
2
| InterpreterJVMRemoteI remote = _state.value().interpreter(false);
|
|
420 |
0
| if (remote == null) { return false; }
|
|
421 |
2
| try { remote.addExtraClassPath(f); return true; }
|
|
422 |
0
| catch (RemoteException e) { _handleRemoteException(e); return false; }
|
|
423 |
| } |
|
424 |
| |
|
425 |
| |
|
426 |
| |
|
427 |
| |
|
428 |
0
| public Option<Iterable<File>> getClassPath() {
|
|
429 |
0
| InterpreterJVMRemoteI remote = _state.value().interpreter(false);
|
|
430 |
0
| if (remote == null) { return Option.none(); }
|
|
431 |
0
| try { return Option.some(remote.getClassPath()); }
|
|
432 |
0
| catch (RemoteException e) { _handleRemoteException(e); return Option.none(); }
|
|
433 |
| } |
|
434 |
| |
|
435 |
| |
|
436 |
| |
|
437 |
| |
|
438 |
0
| public boolean setPackageScope(String packageName) {
|
|
439 |
0
| InterpreterJVMRemoteI remote = _state.value().interpreter(false);
|
|
440 |
0
| if (remote == null) { return false; }
|
|
441 |
0
| try { remote.interpret("package " + packageName + ";"); return true; }
|
|
442 |
0
| catch (RemoteException e) { _handleRemoteException(e); return false; }
|
|
443 |
| } |
|
444 |
| |
|
445 |
| |
|
446 |
| |
|
447 |
| |
|
448 |
| |
|
449 |
| |
|
450 |
| |
|
451 |
18
| public Option<List<String>> findTestClasses(List<String> classNames, List<File> files) {
|
|
452 |
18
| InterpreterJVMRemoteI remote = _state.value().interpreter(false);
|
|
453 |
0
| if (remote == null) { return Option.none(); }
|
|
454 |
18
| try { return Option.some(remote.findTestClasses(classNames, files)); }
|
|
455 |
0
| catch (RemoteException e) { _handleRemoteException(e); return Option.none(); }
|
|
456 |
| } |
|
457 |
| |
|
458 |
| |
|
459 |
| |
|
460 |
| |
|
461 |
| |
|
462 |
16
| public boolean runTestSuite() {
|
|
463 |
16
| InterpreterJVMRemoteI remote = _state.value().interpreter(true);
|
|
464 |
0
| if (remote == null) { return false; }
|
|
465 |
16
| try { return remote.runTestSuite(); }
|
|
466 |
1
| catch (RemoteException e) { _handleRemoteException(e); return false; }
|
|
467 |
| } |
|
468 |
| |
|
469 |
| |
|
470 |
| |
|
471 |
| |
|
472 |
| |
|
473 |
| |
|
474 |
| |
|
475 |
| |
|
476 |
| |
|
477 |
| |
|
478 |
| |
|
479 |
| |
|
480 |
| |
|
481 |
| |
|
482 |
| |
|
483 |
| |
|
484 |
| |
|
485 |
| |
|
486 |
2
| public boolean addInterpreter(String name) {
|
|
487 |
2
| InterpreterJVMRemoteI remote = _state.value().interpreter(false);
|
|
488 |
0
| if (remote == null) { return false; }
|
|
489 |
2
| try { remote.addInterpreter(name); return true; }
|
|
490 |
0
| catch (RemoteException e) { _handleRemoteException(e); return false; }
|
|
491 |
| } |
|
492 |
| |
|
493 |
| |
|
494 |
| |
|
495 |
| |
|
496 |
| |
|
497 |
0
| public boolean removeInterpreter(String name) {
|
|
498 |
0
| InterpreterJVMRemoteI remote = _state.value().interpreter(false);
|
|
499 |
0
| if (remote == null) { return false; }
|
|
500 |
0
| try { remote.removeInterpreter(name); return true; }
|
|
501 |
0
| catch (RemoteException e) { _handleRemoteException(e); return false; }
|
|
502 |
| } |
|
503 |
| |
|
504 |
| |
|
505 |
| |
|
506 |
| |
|
507 |
| |
|
508 |
| |
|
509 |
3
| public Option<Pair<Boolean, Boolean>> setActiveInterpreter(String name) {
|
|
510 |
3
| InterpreterJVMRemoteI remote = _state.value().interpreter(false);
|
|
511 |
0
| if (remote == null) { return Option.none(); }
|
|
512 |
3
| try { return Option.some(remote.setActiveInterpreter(name)); }
|
|
513 |
0
| catch (RemoteException e) { _handleRemoteException(e); return Option.none(); }
|
|
514 |
| } |
|
515 |
| |
|
516 |
| |
|
517 |
| |
|
518 |
| |
|
519 |
| |
|
520 |
26
| public Option<Pair<Boolean, Boolean>> setToDefaultInterpreter() {
|
|
521 |
26
| InterpreterJVMRemoteI remote = _state.value().interpreter(false);
|
|
522 |
0
| if (remote == null) { return Option.none(); }
|
|
523 |
26
| try { return Option.some(remote.setToDefaultInterpreter()); }
|
|
524 |
0
| catch (RemoteException e) { _handleRemoteException(e); return Option.none(); }
|
|
525 |
| } |
|
526 |
| |
|
527 |
| |
|
528 |
| |
|
529 |
| |
|
530 |
0
| public boolean setEnforceAllAccess(boolean enforce) {
|
|
531 |
0
| InterpreterJVMRemoteI remote = _state.value().interpreter(false);
|
|
532 |
0
| if (remote == null) { return false; }
|
|
533 |
0
| try { remote.setEnforceAllAccess(enforce); return true; }
|
|
534 |
0
| catch (RemoteException e) { _handleRemoteException(e); return false; }
|
|
535 |
| } |
|
536 |
| |
|
537 |
| |
|
538 |
| |
|
539 |
| |
|
540 |
0
| public boolean setEnforcePrivateAccess(boolean enforce) {
|
|
541 |
0
| InterpreterJVMRemoteI remote = _state.value().interpreter(false);
|
|
542 |
0
| if (remote == null) { return false; }
|
|
543 |
0
| try { remote.setEnforcePrivateAccess(enforce); return true; }
|
|
544 |
0
| catch (RemoteException e) { _handleRemoteException(e); return false; }
|
|
545 |
| } |
|
546 |
| |
|
547 |
| |
|
548 |
| |
|
549 |
| |
|
550 |
0
| public boolean setRequireSemicolon(boolean require) {
|
|
551 |
0
| InterpreterJVMRemoteI remote = _state.value().interpreter(false);
|
|
552 |
0
| if (remote == null) { return false; }
|
|
553 |
0
| try { remote.setRequireSemicolon(require); return true; }
|
|
554 |
0
| catch (RemoteException e) { _handleRemoteException(e); return false; }
|
|
555 |
| } |
|
556 |
| |
|
557 |
| |
|
558 |
| |
|
559 |
| |
|
560 |
0
| public boolean setRequireVariableType(boolean require) {
|
|
561 |
0
| InterpreterJVMRemoteI remote = _state.value().interpreter(false);
|
|
562 |
0
| if (remote == null) { return false; }
|
|
563 |
0
| try { remote.setRequireVariableType(require); return true; }
|
|
564 |
0
| catch (RemoteException e) { _handleRemoteException(e); return false; }
|
|
565 |
| } |
|
566 |
| |
|
567 |
| |
|
568 |
| |
|
569 |
| |
|
570 |
| |
|
571 |
| |
|
572 |
180
| private void _doStartup() {
|
|
573 |
180
| File dir = _workingDir;
|
|
574 |
| |
|
575 |
| |
|
576 |
0
| if (dir == FileOps.NULL_FILE) { dir = IOUtil.WORKING_DIRECTORY; }
|
|
577 |
| |
|
578 |
180
| List<String> jvmArgs = new ArrayList<String>();
|
|
579 |
| |
|
580 |
| |
|
581 |
| |
|
582 |
| |
|
583 |
| |
|
584 |
180
| final CompletionMonitor cm = new CompletionMonitor();
|
|
585 |
180
| boolean repeat;
|
|
586 |
180
| do {
|
|
587 |
180
| repeat = false;
|
|
588 |
180
| File junitLocation = DrJava.getConfig().getSetting(OptionConstants.JUNIT_LOCATION);
|
|
589 |
180
| boolean javaVersion7 = JavaVersion.CURRENT.supports(JavaVersion.JAVA_7);
|
|
590 |
| |
|
591 |
| |
|
592 |
180
| boolean concJUnitAvailable =
|
|
593 |
| !javaVersion7 && |
|
594 |
| (!DrJava.getConfig().getSetting(OptionConstants.JUNIT_LOCATION_ENABLED) || |
|
595 |
| edu.rice.cs.drjava.model.junit.ConcJUnitUtils.isValidConcJUnitFile(junitLocation)); |
|
596 |
| |
|
597 |
180
| File rtLocation = DrJava.getConfig().getSetting(OptionConstants.RT_CONCJUNIT_LOCATION);
|
|
598 |
180
| boolean rtLocationConfigured =
|
|
599 |
| edu.rice.cs.drjava.model.junit.ConcJUnitUtils.isValidRTConcJUnitFile(rtLocation); |
|
600 |
| |
|
601 |
180
| if (DrJava.getConfig().getSetting(OptionConstants.CONCJUNIT_CHECKS_ENABLED).
|
|
602 |
| equals(OptionConstants.ConcJUnitCheckChoices.ALL) && |
|
603 |
| !rtLocationConfigured && |
|
604 |
| (rtLocation != null) && |
|
605 |
| (!FileOps.NULL_FILE.equals(rtLocation)) && |
|
606 |
| (rtLocation.exists())) { |
|
607 |
| |
|
608 |
0
| DrJava.getConfig().setSetting(OptionConstants.CONCJUNIT_CHECKS_ENABLED,
|
|
609 |
| OptionConstants.ConcJUnitCheckChoices.NO_LUCKY); |
|
610 |
0
| rtLocationConfigured = false;
|
|
611 |
0
| javax.swing.JOptionPane.showMessageDialog(null,
|
|
612 |
| "The selected file is invalid and was disabled:\n"+rtLocation, |
|
613 |
| "Invalid ConcJUnit Runtime File", |
|
614 |
| javax.swing.JOptionPane.ERROR_MESSAGE); |
|
615 |
| } |
|
616 |
180
| if (concJUnitAvailable &&
|
|
617 |
| rtLocationConfigured && |
|
618 |
| DrJava.getConfig().getSetting(OptionConstants.CONCJUNIT_CHECKS_ENABLED). |
|
619 |
| equals(OptionConstants.ConcJUnitCheckChoices.ALL)) { |
|
620 |
0
| try {
|
|
621 |
| |
|
622 |
| |
|
623 |
| |
|
624 |
0
| File shortF = FileOps.getShortFile(rtLocation);
|
|
625 |
| |
|
626 |
| |
|
627 |
0
| if (edu.rice.cs.drjava.model.junit.ConcJUnitUtils.isCompatibleRTConcJUnitFile(shortF)) {
|
|
628 |
| |
|
629 |
| |
|
630 |
0
| jvmArgs.add("-Xbootclasspath/p:"+shortF.getAbsolutePath().replace(File.separatorChar, '/'));
|
|
631 |
| } |
|
632 |
| else { |
|
633 |
| |
|
634 |
| |
|
635 |
0
| repeat = true;
|
|
636 |
0
| cm.reset();
|
|
637 |
0
| boolean attempted = edu.rice.cs.drjava.model.junit.ConcJUnitUtils.
|
|
638 |
| showIncompatibleWantToRegenerateDialog(null, |
|
639 |
0
| new Runnable() { public void run() { cm.signal(); } },
|
|
640 |
0
| new Runnable() { public void run() { cm.signal(); } });
|
|
641 |
0
| while(!cm.attemptEnsureSignaled());
|
|
642 |
0
| if (!attempted) { repeat = false; }
|
|
643 |
| } |
|
644 |
| } |
|
645 |
| catch(IOException ioe) { |
|
646 |
| |
|
647 |
0
| DrJava.getConfig().setSetting(OptionConstants.CONCJUNIT_CHECKS_ENABLED,
|
|
648 |
| OptionConstants.ConcJUnitCheckChoices.NO_LUCKY); |
|
649 |
0
| rtLocationConfigured = false;
|
|
650 |
0
| javax.swing.JOptionPane.showMessageDialog(null,
|
|
651 |
| "There was a problem with the selected file, and it was disabled:\n"+rtLocation, |
|
652 |
| "Invalid ConcJUnit Runtime File", |
|
653 |
| javax.swing.JOptionPane.ERROR_MESSAGE); |
|
654 |
| } |
|
655 |
| } |
|
656 |
180
| } while(repeat);
|
|
657 |
| |
|
658 |
| |
|
659 |
| |
|
660 |
177
| if (_allowAssertions) { jvmArgs.add("-ea"); }
|
|
661 |
180
| int debugPort = _getDebugPort();
|
|
662 |
180
| if (debugPort > -1) {
|
|
663 |
178
| jvmArgs.add("-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=" + debugPort);
|
|
664 |
178
| jvmArgs.add("-Xdebug");
|
|
665 |
178
| jvmArgs.add("-Xnoagent");
|
|
666 |
178
| jvmArgs.add("-Djava.compiler=NONE");
|
|
667 |
| } |
|
668 |
180
| String slaveMemory = DrJava.getConfig().getSetting(OptionConstants.SLAVE_JVM_XMX);
|
|
669 |
180
| if (!"".equals(slaveMemory) && !OptionConstants.heapSizeChoices.get(0).equals(slaveMemory)) {
|
|
670 |
0
| jvmArgs.add("-Xmx" + slaveMemory + "M");
|
|
671 |
| } |
|
672 |
180
| String slaveArgs = DrJava.getConfig().getSetting(OptionConstants.SLAVE_JVM_ARGS);
|
|
673 |
180
| if (PlatformFactory.ONLY.isMacPlatform()) {
|
|
674 |
0
| jvmArgs.add("-Xdock:name=Interactions");
|
|
675 |
| } |
|
676 |
| |
|
677 |
| |
|
678 |
180
| for (File f: _interactionsModel.getCompilerBootClassPath()) {
|
|
679 |
0
| try {
|
|
680 |
| |
|
681 |
| |
|
682 |
| |
|
683 |
0
| File shortF = FileOps.getShortFile(f);
|
|
684 |
0
| jvmArgs.add("-Xbootclasspath/a:"+shortF.getAbsolutePath().replace(File.separatorChar, '/'));
|
|
685 |
| } |
|
686 |
| catch(IOException ioe) { |
|
687 |
| |
|
688 |
| } |
|
689 |
| } |
|
690 |
| |
|
691 |
180
| jvmArgs.addAll(ArgumentTokenizer.tokenize(slaveArgs));
|
|
692 |
| |
|
693 |
180
| JVMBuilder jvmb = new JVMBuilder(_startupClassPath).directory(dir).jvmArguments(jvmArgs);
|
|
694 |
| |
|
695 |
| |
|
696 |
180
| File junitLocation = DrJava.getConfig().getSetting(OptionConstants.JUNIT_LOCATION);
|
|
697 |
180
| boolean junitLocationConfigured =
|
|
698 |
| (edu.rice.cs.drjava.model.junit.ConcJUnitUtils.isValidJUnitFile(junitLocation) || |
|
699 |
| edu.rice.cs.drjava.model.junit.ConcJUnitUtils.isValidConcJUnitFile(junitLocation)); |
|
700 |
180
| if (DrJava.getConfig().getSetting(OptionConstants.JUNIT_LOCATION_ENABLED) &&
|
|
701 |
| !junitLocationConfigured && |
|
702 |
| (junitLocation != null) && |
|
703 |
| (!FileOps.NULL_FILE.equals(junitLocation)) && |
|
704 |
| (junitLocation.exists())) { |
|
705 |
| |
|
706 |
0
| DrJava.getConfig().setSetting(OptionConstants.JUNIT_LOCATION_ENABLED, false);
|
|
707 |
0
| junitLocationConfigured = false;
|
|
708 |
| } |
|
709 |
180
| ArrayList<File> extendedClassPath = new ArrayList<File>();
|
|
710 |
180
| if (DrJava.getConfig().getSetting(OptionConstants.JUNIT_LOCATION_ENABLED) &&
|
|
711 |
| junitLocationConfigured) { |
|
712 |
0
| extendedClassPath.add(junitLocation);
|
|
713 |
| } |
|
714 |
1980
| for(File f: jvmb.classPath()) { extendedClassPath.add(f); }
|
|
715 |
180
| jvmb = jvmb.classPath(edu.rice.cs.plt.iter.IterUtil.asSizedIterable(extendedClassPath));
|
|
716 |
| |
|
717 |
| |
|
718 |
180
| Map<String, String> props = jvmb.propertiesCopy();
|
|
719 |
| |
|
720 |
| |
|
721 |
180
| boolean all = DrJava.getConfig().getSetting(OptionConstants.CONCJUNIT_CHECKS_ENABLED).
|
|
722 |
| equals(OptionConstants.ConcJUnitCheckChoices.ALL); |
|
723 |
180
| boolean noLucky = DrJava.getConfig().getSetting(OptionConstants.CONCJUNIT_CHECKS_ENABLED).
|
|
724 |
| equals(OptionConstants.ConcJUnitCheckChoices.NO_LUCKY); |
|
725 |
180
| boolean onlyThreads = DrJava.getConfig().getSetting(OptionConstants.CONCJUNIT_CHECKS_ENABLED).
|
|
726 |
| equals(OptionConstants.ConcJUnitCheckChoices.ONLY_THREADS); |
|
727 |
180
| boolean none = DrJava.getConfig().getSetting(OptionConstants.CONCJUNIT_CHECKS_ENABLED).
|
|
728 |
| equals(OptionConstants.ConcJUnitCheckChoices.NONE); |
|
729 |
| |
|
730 |
180
| props.put("edu.rice.cs.cunit.concJUnit.check.threads.enabled",
|
|
731 |
| new Boolean(!none).toString()); |
|
732 |
| |
|
733 |
180
| props.put("edu.rice.cs.cunit.concJUnit.check.join.enabled",
|
|
734 |
| new Boolean(all || noLucky).toString()); |
|
735 |
| |
|
736 |
180
| props.put("edu.rice.cs.cunit.concJUnit.check.lucky.enabled",
|
|
737 |
| new Boolean(all).toString()); |
|
738 |
| |
|
739 |
180
| jvmb = jvmb.properties(props);
|
|
740 |
| |
|
741 |
180
| invokeSlave(jvmb);
|
|
742 |
| } |
|
743 |
| |
|
744 |
| |
|
745 |
180
| private int _getDebugPort() {
|
|
746 |
180
| int port = -1;
|
|
747 |
180
| try { port = _interactionsModel.getDebugPort(); }
|
|
748 |
| catch (IOException ioe) { |
|
749 |
| |
|
750 |
| } |
|
751 |
180
| return port;
|
|
752 |
| } |
|
753 |
| |
|
754 |
| |
|
755 |
3
| private void _handleRemoteException(RemoteException e) {
|
|
756 |
3
| if (e instanceof UnmarshalException) {
|
|
757 |
| |
|
758 |
3
| if (e.getCause() instanceof EOFException) return;
|
|
759 |
| |
|
760 |
| |
|
761 |
0
| if ((e.getCause() instanceof SocketException) &&
|
|
762 |
0
| (e.getCause().getMessage().equals("Connection reset"))) return;
|
|
763 |
| } |
|
764 |
0
| DrJavaErrorHandler.record(e);
|
|
765 |
| } |
|
766 |
| |
|
767 |
| |
|
768 |
| |
|
769 |
| |
|
770 |
| |
|
771 |
| |
|
772 |
| private abstract class State { |
|
773 |
| |
|
774 |
| |
|
775 |
| |
|
776 |
| |
|
777 |
| public abstract InterpreterJVMRemoteI interpreter(boolean used); |
|
778 |
| |
|
779 |
| public abstract void start(); |
|
780 |
| |
|
781 |
| public abstract void stop(); |
|
782 |
| |
|
783 |
| |
|
784 |
| |
|
785 |
| |
|
786 |
| public abstract void restart(boolean force); |
|
787 |
| public abstract void dispose(); |
|
788 |
| |
|
789 |
0
| public void started(InterpreterJVMRemoteI i) { throw new IllegalStateException("Unexpected started() call"); }
|
|
790 |
| |
|
791 |
0
| public void startFailed(Exception e) { throw new IllegalStateException("Unexpected startFailed() call"); }
|
|
792 |
| |
|
793 |
135
| public void stopped(int status) { throw new IllegalStateException("Unexpected stopped() call"); }
|
|
794 |
| } |
|
795 |
| |
|
796 |
| |
|
797 |
| private class FreshState extends State { |
|
798 |
0
| public InterpreterJVMRemoteI interpreter(boolean used) { return null; }
|
|
799 |
159
| public void start() {
|
|
800 |
159
| if (_state.compareAndSet(this, new StartingState())) { _doStartup(); }
|
|
801 |
0
| else { _state.value().start(); }
|
|
802 |
| } |
|
803 |
0
| public void stop() { }
|
|
804 |
0
| public void restart(boolean force) { start(); }
|
|
805 |
0
| public void dispose() {
|
|
806 |
0
| if (_state.compareAndSet(this, new DisposedState())) { MainJVM.super.dispose(); }
|
|
807 |
0
| else { _state.value().dispose(); }
|
|
808 |
| } |
|
809 |
| } |
|
810 |
| |
|
811 |
| |
|
812 |
| private class StartingState extends State { |
|
813 |
| private final int _failures; |
|
814 |
180
| public StartingState() { _failures = 0; }
|
|
815 |
0
| private StartingState(int failures) { _failures = failures; }
|
|
816 |
| |
|
817 |
10
| public InterpreterJVMRemoteI interpreter(boolean used) {
|
|
818 |
10
| try { return _state.ensureNotState(this, STARTUP_TIMEOUT).interpreter(used); }
|
|
819 |
0
| catch (TimeoutException e) { return null; }
|
|
820 |
0
| catch (InterruptedException e) { throw new UnexpectedException(e); }
|
|
821 |
| } |
|
822 |
| |
|
823 |
0
| public void start() { }
|
|
824 |
| |
|
825 |
0
| public void restart(boolean force) {
|
|
826 |
0
| try { _state.ensureNotState(this, STARTUP_TIMEOUT).restart(force); }
|
|
827 |
0
| catch (Exception e) { throw new UnexpectedException(e); }
|
|
828 |
| } |
|
829 |
| |
|
830 |
0
| public void stop() {
|
|
831 |
0
| try { _state.ensureNotState(this, STARTUP_TIMEOUT).stop(); }
|
|
832 |
0
| catch (Exception e) { throw new UnexpectedException(e); }
|
|
833 |
| } |
|
834 |
| |
|
835 |
0
| public void dispose() { stop(); _state.value().dispose(); }
|
|
836 |
| |
|
837 |
180
| @Override public void started(InterpreterJVMRemoteI i) {
|
|
838 |
180
| if (_state.compareAndSet(this, new FreshRunningState(i))) {
|
|
839 |
180
| boolean enforceAllAccess = DrJava.getConfig().getSetting(OptionConstants.DYNAMICJAVA_ACCESS_CONTROL)
|
|
840 |
| .equals(OptionConstants.DynamicJavaAccessControlChoices.PRIVATE_AND_PACKAGE); |
|
841 |
180
| try { i.setEnforceAllAccess(enforceAllAccess); }
|
|
842 |
0
| catch (RemoteException re) { _handleRemoteException(re); }
|
|
843 |
| |
|
844 |
180
| boolean enforcePrivateAccess = !DrJava.getConfig().getSetting(OptionConstants.DYNAMICJAVA_ACCESS_CONTROL)
|
|
845 |
| .equals(OptionConstants.DynamicJavaAccessControlChoices.DISABLED); |
|
846 |
180
| try { i.setEnforcePrivateAccess(enforcePrivateAccess); }
|
|
847 |
0
| catch (RemoteException re) { _handleRemoteException(re); }
|
|
848 |
| |
|
849 |
180
| Boolean requireSemicolon = DrJava.getConfig().getSetting(OptionConstants.DYNAMICJAVA_REQUIRE_SEMICOLON);
|
|
850 |
180
| try { i.setRequireSemicolon(requireSemicolon); }
|
|
851 |
0
| catch (RemoteException re) { _handleRemoteException(re); }
|
|
852 |
| |
|
853 |
180
| Boolean requireVariableType = DrJava.getConfig().getSetting(OptionConstants.DYNAMICJAVA_REQUIRE_VARIABLE_TYPE);
|
|
854 |
180
| try { i.setRequireVariableType(requireVariableType); }
|
|
855 |
0
| catch (RemoteException re) { _handleRemoteException(re); }
|
|
856 |
| |
|
857 |
| |
|
858 |
| |
|
859 |
180
| _interactionsModel.interpreterReady(_workingDir);
|
|
860 |
180
| _junitModel.junitJVMReady();
|
|
861 |
| } |
|
862 |
0
| else { _state.value().started(i); }
|
|
863 |
| } |
|
864 |
| |
|
865 |
0
| @Override public void startFailed(Exception e) {
|
|
866 |
0
| int count = _failures + 1;
|
|
867 |
0
| if (count < MAX_STARTUP_FAILURES) {
|
|
868 |
0
| if (_state.compareAndSet(this, new StartingState(count))) { _doStartup(); }
|
|
869 |
0
| else { _state.value().startFailed(e); }
|
|
870 |
| } |
|
871 |
| else { |
|
872 |
0
| if (_state.compareAndSet(this, new FreshState())) { _interactionsModel.interpreterWontStart(e); }
|
|
873 |
0
| else { _state.value().startFailed(e); }
|
|
874 |
| } |
|
875 |
| } |
|
876 |
| } |
|
877 |
| |
|
878 |
| |
|
879 |
| private class RunningState extends State { |
|
880 |
| protected final InterpreterJVMRemoteI _interpreter; |
|
881 |
219
| public RunningState(InterpreterJVMRemoteI interpreter) { _interpreter = interpreter; }
|
|
882 |
553
| public InterpreterJVMRemoteI interpreter(boolean used) { return _interpreter; }
|
|
883 |
0
| public void start() { }
|
|
884 |
| |
|
885 |
156
| public void stop() {
|
|
886 |
156
| if (_state.compareAndSet(this, new StoppingState())) { quitSlave(); }
|
|
887 |
0
| else { _state.value().stop(); }
|
|
888 |
| } |
|
889 |
| |
|
890 |
21
| public void restart(boolean force) {
|
|
891 |
21
| if (_state.compareAndSet(this, new RestartingState())) {
|
|
892 |
21
| _interactionsModel.interpreterResetting();
|
|
893 |
21
| quitSlave();
|
|
894 |
| } |
|
895 |
0
| else { _state.value().restart(force); }
|
|
896 |
| } |
|
897 |
| |
|
898 |
156
| public void dispose() { stop(); _state.value().dispose(); }
|
|
899 |
| |
|
900 |
1
| @Override public void stopped(int status) {
|
|
901 |
1
| if (_state.compareAndSet(this, new RestartingState())) {
|
|
902 |
1
| _interactionsModel.replCalledSystemExit(status);
|
|
903 |
1
| _interactionsModel.interpreterResetting();
|
|
904 |
| } |
|
905 |
1
| _state.value().stopped(status);
|
|
906 |
| } |
|
907 |
| } |
|
908 |
| |
|
909 |
| |
|
910 |
| private class FreshRunningState extends RunningState { |
|
911 |
180
| public FreshRunningState(InterpreterJVMRemoteI interpreter) { super(interpreter); }
|
|
912 |
499
| @Override public InterpreterJVMRemoteI interpreter(boolean used) {
|
|
913 |
499
| if (used) {
|
|
914 |
39
| _state.compareAndSet(this, new RunningState(_interpreter));
|
|
915 |
39
| return _state.value().interpreter(used);
|
|
916 |
| } |
|
917 |
460
| else { return super.interpreter(used); }
|
|
918 |
| } |
|
919 |
13
| @Override public void restart(boolean force) {
|
|
920 |
8
| if (force) { super.restart(force); }
|
|
921 |
| else { |
|
922 |
| |
|
923 |
5
| _interactionsModel.interpreterReady(_workingDir);
|
|
924 |
| } |
|
925 |
| } |
|
926 |
| } |
|
927 |
| |
|
928 |
| |
|
929 |
| private class RestartingState extends State { |
|
930 |
| |
|
931 |
8
| public InterpreterJVMRemoteI interpreter(boolean used) {
|
|
932 |
8
| try { return _state.ensureNotState(this, STARTUP_TIMEOUT).interpreter(used); }
|
|
933 |
1
| catch (TimeoutException e) { return null; }
|
|
934 |
0
| catch (InterruptedException e) { throw new UnexpectedException(e); }
|
|
935 |
| } |
|
936 |
| |
|
937 |
0
| public void start() { }
|
|
938 |
| |
|
939 |
0
| public void stop() {
|
|
940 |
0
| if (!_state.compareAndSet(this, new StoppingState())) { _state.value().stop(); }
|
|
941 |
| } |
|
942 |
| |
|
943 |
0
| public void restart(boolean force) { }
|
|
944 |
| |
|
945 |
1
| public void dispose() {
|
|
946 |
1
| if (_state.compareAndSet(this, new DisposedState())) { MainJVM.super.dispose(); }
|
|
947 |
0
| else { _state.value().dispose(); }
|
|
948 |
| } |
|
949 |
| |
|
950 |
21
| @Override public void stopped(int status) {
|
|
951 |
21
| if (_state.compareAndSet(this, new StartingState())) { _doStartup(); }
|
|
952 |
0
| else { _state.value().stopped(status); }
|
|
953 |
| } |
|
954 |
| } |
|
955 |
| |
|
956 |
| |
|
957 |
| private class StoppingState extends State { |
|
958 |
0
| public InterpreterJVMRemoteI interpreter(boolean used) { return null; }
|
|
959 |
| |
|
960 |
0
| public void start() {
|
|
961 |
0
| try { _state.ensureNotState(this, STARTUP_TIMEOUT).start(); }
|
|
962 |
0
| catch (Exception e) { throw new UnexpectedException(e); }
|
|
963 |
| } |
|
964 |
| |
|
965 |
0
| public void stop() { }
|
|
966 |
| |
|
967 |
0
| public void restart(boolean force) {
|
|
968 |
0
| if (!_state.compareAndSet(this, new RestartingState())) { _state.value().restart(force); }
|
|
969 |
| } |
|
970 |
| |
|
971 |
156
| public void dispose() {
|
|
972 |
156
| if (_state.compareAndSet(this, new DisposedState())) { MainJVM.super.dispose(); }
|
|
973 |
0
| else { _state.value().dispose(); }
|
|
974 |
| } |
|
975 |
| |
|
976 |
0
| @Override public void stopped(int status) {
|
|
977 |
0
| if (!_state.compareAndSet(this, new FreshState())) { _state.value().stopped(status); }
|
|
978 |
| } |
|
979 |
| } |
|
980 |
| |
|
981 |
| private class DisposedState extends State { |
|
982 |
0
| public InterpreterJVMRemoteI interpreter(boolean used) { throw new IllegalStateException("MainJVM is disposed"); }
|
|
983 |
0
| public void start() { throw new IllegalStateException("MainJVM is disposed"); }
|
|
984 |
0
| public void stop() { throw new IllegalStateException("MainJVM is disposed"); }
|
|
985 |
0
| public void restart(boolean force) { throw new IllegalStateException("MainJVM is disposed"); }
|
|
986 |
0
| public void dispose() { }
|
|
987 |
0
| public void stopped() { }
|
|
988 |
| } |
|
989 |
| |
|
990 |
| |
|
991 |
| |
|
992 |
| private class ResultHandler implements InterpretResult.Visitor<Void> { |
|
993 |
| |
|
994 |
9
| public Void forNoValue() {
|
|
995 |
9
| _interactionsModel.replReturnedVoid();
|
|
996 |
9
| return null;
|
|
997 |
| } |
|
998 |
| |
|
999 |
| |
|
1000 |
0
| public Void forObjectValue(String objString, String objTypeString) {
|
|
1001 |
0
| _interactionsModel.replReturnedResult(objString, InteractionsDocument.OBJECT_RETURN_STYLE);
|
|
1002 |
0
| return null;
|
|
1003 |
| } |
|
1004 |
| |
|
1005 |
| |
|
1006 |
5
| public Void forStringValue(String s) {
|
|
1007 |
5
| _interactionsModel.replReturnedResult('"' + s + '"', InteractionsDocument.STRING_RETURN_STYLE);
|
|
1008 |
5
| return null;
|
|
1009 |
| } |
|
1010 |
| |
|
1011 |
| |
|
1012 |
0
| public Void forCharValue(Character c) {
|
|
1013 |
0
| _interactionsModel.replReturnedResult("'" + c + "'", InteractionsDocument.CHARACTER_RETURN_STYLE);
|
|
1014 |
0
| return null;
|
|
1015 |
| } |
|
1016 |
| |
|
1017 |
| |
|
1018 |
18
| public Void forNumberValue(Number n) {
|
|
1019 |
18
| _interactionsModel.replReturnedResult(n.toString(), InteractionsDocument.NUMBER_RETURN_STYLE);
|
|
1020 |
18
| return null;
|
|
1021 |
| } |
|
1022 |
| |
|
1023 |
| |
|
1024 |
0
| public Void forBooleanValue(Boolean b) {
|
|
1025 |
0
| _interactionsModel.replReturnedResult(b.toString(), InteractionsDocument.OBJECT_RETURN_STYLE);
|
|
1026 |
0
| return null;
|
|
1027 |
| } |
|
1028 |
| |
|
1029 |
| |
|
1030 |
0
| public Void forEvalException(String message, StackTraceElement[] stackTrace) {
|
|
1031 |
| |
|
1032 |
0
| _interactionsModel.replThrewException(message, stackTrace);
|
|
1033 |
0
| return null;
|
|
1034 |
| } |
|
1035 |
| |
|
1036 |
| |
|
1037 |
7
| public Void forException(String message) {
|
|
1038 |
| |
|
1039 |
7
| _interactionsModel.replThrewException(message);
|
|
1040 |
7
| return null;
|
|
1041 |
| } |
|
1042 |
| |
|
1043 |
0
| public Void forUnexpectedException(Throwable t) {
|
|
1044 |
0
| _interactionsModel.replReturnedVoid();
|
|
1045 |
0
| throw new UnexpectedException(t);
|
|
1046 |
| } |
|
1047 |
| |
|
1048 |
0
| public Void forBusy() {
|
|
1049 |
0
| _interactionsModel.replReturnedVoid();
|
|
1050 |
0
| throw new UnexpectedException("MainJVM.interpret() called when InterpreterJVM was busy!");
|
|
1051 |
| } |
|
1052 |
| } |
|
1053 |
| |
|
1054 |
| |
|
1055 |
| public static class DummyInteractionsModel implements InteractionsModelCallback { |
|
1056 |
2
| public int getDebugPort() throws IOException { return -1; }
|
|
1057 |
0
| public void replSystemOutPrint(String s) { }
|
|
1058 |
0
| public void replSystemErrPrint(String s) { }
|
|
1059 |
0
| public String getConsoleInput() {
|
|
1060 |
0
| throw new IllegalStateException("Cannot request input from dummy interactions model!");
|
|
1061 |
| } |
|
1062 |
0
| public void setInputListener(InputListener il) {
|
|
1063 |
0
| throw new IllegalStateException("Cannot set the input listener of dummy interactions model!");
|
|
1064 |
| } |
|
1065 |
0
| public void changeInputListener(InputListener from, InputListener to) {
|
|
1066 |
0
| throw new IllegalStateException("Cannot change the input listener of dummy interactions model!");
|
|
1067 |
| } |
|
1068 |
0
| public void replReturnedVoid() { }
|
|
1069 |
0
| public void replReturnedResult(String result, String style) { }
|
|
1070 |
0
| public void replThrewException(String message, StackTraceElement[] stackTrace) { }
|
|
1071 |
0
| public void replThrewException(String message) { }
|
|
1072 |
0
| public void replReturnedSyntaxError(String errorMessage, String interaction, int startRow, int startCol, int endRow,
|
|
1073 |
| int endCol) { } |
|
1074 |
0
| public void replCalledSystemExit(int status) { }
|
|
1075 |
1
| public void interpreterResetting() { }
|
|
1076 |
0
| public void interpreterResetFailed(Throwable th) { }
|
|
1077 |
0
| public void interpreterWontStart(Exception e) { }
|
|
1078 |
2
| public void interpreterReady(File wd) { }
|
|
1079 |
2
| public List<File> getCompilerBootClassPath() { return new ArrayList<File>(); }
|
|
1080 |
0
| public String transformCommands(String interactionsString) { return interactionsString; }
|
|
1081 |
| } |
|
1082 |
| |
|
1083 |
| |
|
1084 |
| public static class DummyJUnitModel implements JUnitModelCallback { |
|
1085 |
0
| public void nonTestCase(boolean isTestAll, boolean didCompileFail) { }
|
|
1086 |
0
| public void classFileError(ClassFileError e) { }
|
|
1087 |
0
| public void testSuiteStarted(int numTests) { }
|
|
1088 |
0
| public void testStarted(String testName) { }
|
|
1089 |
0
| public void testEnded(String testName, boolean wasSuccessful, boolean causedError) { }
|
|
1090 |
0
| public void testSuiteEnded(JUnitError[] errors) { }
|
|
1091 |
0
| public File getFileForClassName(String className) { return null; }
|
|
1092 |
0
| public Iterable<File> getClassPath() { return IterUtil.empty(); }
|
|
1093 |
3
| public void junitJVMReady() { }
|
|
1094 |
| } |
|
1095 |
| |
|
1096 |
| |
|
1097 |
| public static class DummyDebugModel implements DebugModelCallback { |
|
1098 |
0
| public void notifyDebugInterpreterAssignment(String name) {
|
|
1099 |
| } |
|
1100 |
| } |
|
1101 |
| } |