Skip to content

Commit 6315a2f

Browse files
committed
Make processing-java return an error code if the VM failed
This still doesn't seem to return anything for exceptions inside a sketch, but a start. Error codes could be helpful for automatic regression testing of all examples.
1 parent c5667e7 commit 6315a2f

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

java/src/processing/mode/java/Commander.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ public Commander(String[] args) {
275275
} else {
276276
runner.launch(sketchArgs);
277277
}
278+
success = !runner.vmReturnedError();
278279
}
279280
} else {
280281
success = false;

java/src/processing/mode/java/runner/Runner.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public class Runner implements MessageConsumer {
5959

6060
// Running remote VM
6161
protected VirtualMachine vm;
62+
protected boolean vmReturnedError;
6263

6364
// Thread transferring remote error stream to our error stream
6465
protected Thread errThread = null;
@@ -130,6 +131,14 @@ public VirtualMachine present(String[] args) {
130131
}
131132

132133

134+
/**
135+
* Whether the last invocation of launchJava() was successful or not
136+
*/
137+
public boolean vmReturnedError() {
138+
return vmReturnedError;
139+
}
140+
141+
133142
/**
134143
* Simple non-blocking launch of the virtual machine. VM starts suspended.
135144
* @return debuggee VM or null on failure
@@ -408,6 +417,7 @@ protected void launchJava(final String[] args) {
408417
new Thread(new Runnable() {
409418
public void run() {
410419
// PApplet.println("java starting");
420+
vmReturnedError = false;
411421
process = PApplet.exec(args);
412422
try {
413423
// PApplet.println("java waiting");
@@ -445,6 +455,7 @@ public void run() {
445455
// changing this to separate editor and listener [091124]
446456
//if (editor != null) {
447457
listener.statusError("Could not run the sketch.");
458+
vmReturnedError = true;
448459
//}
449460
// return null;
450461
}

0 commit comments

Comments
 (0)