Skip to content

Commit e08bf24

Browse files
committed
remove hack that placed sketch path after class name arg
1 parent fa1f497 commit e08bf24

File tree

2 files changed

+57
-56
lines changed

2 files changed

+57
-56
lines changed

core/src/processing/core/PApplet.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9418,16 +9418,16 @@ static public void runSketch(final String[] args, final PApplet constructedApple
94189418
argIndex++;
94199419
}
94209420

9421-
// Now that sketch path is passed in args after the sketch name
9422-
// it's not set in the above loop(the above loop breaks after
9423-
// finding sketch name). So setting sketch path here.
9424-
// https://github.com/processing/processing/commit/0a14835e6f5f4766b022e73a8fe562318636727c
9425-
// TODO this is a hack added for PDE X and needs to be removed [fry 141104]
9426-
for (int i = 0; i < args.length; i++) {
9427-
if (args[i].startsWith(ARGS_SKETCH_FOLDER)){
9428-
folder = args[i].substring(args[i].indexOf('=') + 1);
9429-
}
9430-
}
9421+
// // Now that sketch path is passed in args after the sketch name
9422+
// // it's not set in the above loop(the above loop breaks after
9423+
// // finding sketch name). So setting sketch path here.
9424+
// // https://github.com/processing/processing/commit/0a14835e6f5f4766b022e73a8fe562318636727c
9425+
// // TODO this is a hack added for PDE X and needs to be removed [fry 141104]
9426+
// for (int i = 0; i < args.length; i++) {
9427+
// if (args[i].startsWith(ARGS_SKETCH_FOLDER)){
9428+
// folder = args[i].substring(args[i].indexOf('=') + 1);
9429+
// }
9430+
// }
94319431

94329432
// Set this property before getting into any GUI init code
94339433
//System.setProperty("com.apple.mrj.application.apple.menu.about.name", name);

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

Lines changed: 47 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public class Runner implements MessageConsumer {
7171

7272
protected PrintStream sketchErr;
7373
protected PrintStream sketchOut;
74-
74+
7575

7676
public Runner(JavaBuild build, RunnerListener listener) throws SketchException {
7777
this.listener = listener;
@@ -95,11 +95,11 @@ public Runner(JavaBuild build, RunnerListener listener) throws SketchException {
9595
int opposite = (bits == 32) ? 64 : 32;
9696
if (Base.isMacOS()) {
9797
//if (library.supportsArch(PConstants.MACOSX, opposite)) { // should always be true
98-
throw new SketchException("To use " + library.getName() + ", " +
98+
throw new SketchException("To use " + library.getName() + ", " +
9999
"switch to " + opposite + "-bit mode in Preferences.");
100100
//}
101101
} else {
102-
throw new SketchException(library.getName() + " is only compatible " +
102+
throw new SketchException(library.getName() + " is only compatible " +
103103
"with the " + opposite + "-bit download of Processing.");
104104
//throw new SketchException(library.getName() + " does not run in " + bits + "-bit mode.");
105105
// "To use this library, switch to 32-bit mode in Preferences." (OS X)
@@ -115,8 +115,8 @@ public void launch(boolean presenting) {
115115
generateTrace();
116116
}
117117
}
118-
119-
118+
119+
120120
/**
121121
* Simple non-blocking launch of the virtual machine. VM starts suspended.
122122
* @return debuggee VM or null on failure
@@ -128,7 +128,7 @@ public VirtualMachine launchDebug() {
128128
return vm;
129129
}
130130

131-
131+
132132
/**
133133
* Redirect a VMs output and error streams to System.out and System.err
134134
*/
@@ -140,16 +140,16 @@ protected void redirectStreams(VirtualMachine vm) {
140140
outThread.start();
141141
}
142142

143-
143+
144144
/**
145145
* Additional access to the virtual machine. TODO: may not be needed
146146
* @return debugge VM or null if not running
147147
*/
148148
public VirtualMachine vm() {
149149
return vm;
150150
}
151-
152-
151+
152+
153153
public boolean launchVirtualMachine(boolean presenting) {
154154
String[] vmParams = getMachineParams();
155155
String[] sketchParams = getSketchParams(presenting);
@@ -158,20 +158,20 @@ public boolean launchVirtualMachine(boolean presenting) {
158158

159159
// Older (Java 1.5 and earlier) version, go figure
160160
// String jdwpArg = "-Xrunjdwp:transport=dt_socket,address=" + portStr + ",server=y,suspend=y";
161-
// String debugArg = "-Xdebug";
161+
// String debugArg = "-Xdebug";
162162
// Newer (Java 1.5+) version that uses JVMTI
163163
String jdwpArg = "-agentlib:jdwp=transport=dt_socket,address=" + portStr + ",server=y,suspend=y";
164164

165-
// Everyone works the same under Java 7 (also on OS X)
165+
// Everyone works the same under Java 7 (also on OS X)
166166
String[] commandArgs = new String[] { Base.getJavaPath(), jdwpArg };
167-
167+
168168
commandArgs = PApplet.concat(commandArgs, vmParams);
169169
commandArgs = PApplet.concat(commandArgs, sketchParams);
170170
// PApplet.println(commandArgs);
171171
// commandArg.setValue(commandArgs);
172172
launchJava(commandArgs);
173-
174-
AttachingConnector connector = (AttachingConnector)
173+
174+
AttachingConnector connector = (AttachingConnector)
175175
findConnector("com.sun.jdi.SocketAttach");
176176
//PApplet.println(connector); // gets the defaults
177177

@@ -182,7 +182,7 @@ public boolean launchVirtualMachine(boolean presenting) {
182182
// addressArg.setValue(addr);
183183
Connector.Argument portArg = arguments.get("port");
184184
portArg.setValue(portStr);
185-
185+
186186
// Connector.Argument timeoutArg =
187187
// (Connector.Argument)arguments.get("timeout");
188188
// timeoutArg.setValue("10000");
@@ -193,7 +193,7 @@ public boolean launchVirtualMachine(boolean presenting) {
193193

194194
//System.out.println(PApplet.javaVersion);
195195
// http://java.sun.com/j2se/1.5.0/docs/guide/jpda/conninv.html#sunlaunch
196-
196+
197197
try {
198198
// boolean available = false;
199199
// while (!available) {
@@ -376,7 +376,7 @@ protected String[] getSketchParams(boolean presenting) {
376376
}
377377

378378
params.add(PApplet.ARGS_DISPLAY + "=" + runDisplay);
379-
379+
380380

381381
if (presenting) {
382382
params.add(PApplet.ARGS_FULL_SCREEN);
@@ -389,10 +389,11 @@ protected String[] getSketchParams(boolean presenting) {
389389
Preferences.get("run.present.bgcolor"));
390390
}
391391

392-
params.add(build.getSketchClassName());
392+
// There was a PDE X hack that put this after the class name, but it was
393+
// removed for 3.0a6 because it would break the args passed to sketches.
393394
params.add(PApplet.ARGS_SKETCH_FOLDER + "=" + build.getSketchPath());
394-
// Adding sketch path in the end coz it's likely to
395-
// contain spaces and things go wrong on UNIX systems.
395+
396+
params.add(build.getSketchClassName());
396397
}
397398

398399
// String outgoing[] = new String[params.size()];
@@ -414,12 +415,12 @@ public void run() {
414415
if (result != 0) {
415416
String[] errorStrings = PApplet.loadStrings(process.getErrorStream());
416417
String[] inputStrings = PApplet.loadStrings(process.getInputStream());
417-
418+
418419
// PApplet.println("launchJava stderr:");
419420
// PApplet.println(errorStrings);
420421
// PApplet.println("launchJava stdout:");
421422
PApplet.printArray(inputStrings);
422-
423+
423424
if (errorStrings != null && errorStrings.length > 1) {
424425
if (errorStrings[0].indexOf("Invalid maximum heap size") != -1) {
425426
Base.showWarning("Way Too High",
@@ -464,18 +465,18 @@ protected void generateTrace() {
464465
//vm.setDebugTraceMode(debugTraceMode);
465466
// vm.setDebugTraceMode(VirtualMachine.TRACE_ALL);
466467
// vm.setDebugTraceMode(VirtualMachine.TRACE_NONE); // formerly, seems to have no effect
467-
468-
// Calling this seems to set something internally to make the
468+
469+
// Calling this seems to set something internally to make the
469470
// Eclipse JDI wake up. Without it, an ObjectCollectedException
470-
// is thrown on excReq.enable(). No idea why this works,
471-
// but at least exception handling has returned. (Suspect that it may
472-
// block until all or at least some threads are available, meaning
473-
// that the app has launched and we have legit objects to talk to).
471+
// is thrown on excReq.enable(). No idea why this works,
472+
// but at least exception handling has returned. (Suspect that it may
473+
// block until all or at least some threads are available, meaning
474+
// that the app has launched and we have legit objects to talk to).
474475
vm.allThreads();
475-
// The bug may not have been noticed because the test suite waits for
476-
// a thread to be available, and queries it by calling allThreads().
476+
// The bug may not have been noticed because the test suite waits for
477+
// a thread to be available, and queries it by calling allThreads().
477478
// See org.eclipse.debug.jdi.tests.AbstractJDITest for the example.
478-
479+
479480
EventRequestManager mgr = vm.eventRequestManager();
480481
// get only the uncaught exceptions
481482
ExceptionRequest excReq = mgr.createExceptionRequest(null, false, true);
@@ -487,15 +488,15 @@ protected void generateTrace() {
487488
// excReq.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
488489
// excReq.setSuspendPolicy(EventRequest.SUSPEND_NONE); // another option?
489490
excReq.enable();
490-
491+
491492
Thread eventThread = new Thread() {
492493
public void run() {
493494
try {
494495
boolean connected = true;
495496
while (connected) {
496497
EventQueue eventQueue = vm.eventQueue();
497498
// remove() blocks until event(s) available
498-
EventSet eventSet = eventQueue.remove();
499+
EventSet eventSet = eventQueue.remove();
499500
// listener.vmEvent(eventSet);
500501

501502
for (Event event : eventSet) {
@@ -510,7 +511,7 @@ public void run() {
510511
exceptionEvent((ExceptionEvent) event);
511512
} else if (event instanceof VMDisconnectEvent) {
512513
connected = false;
513-
}
514+
}
514515
}
515516
}
516517
// } catch (VMDisconnectedException e) {
@@ -524,8 +525,8 @@ public void run() {
524525
};
525526
eventThread.start();
526527

527-
528-
errThread =
528+
529+
errThread =
529530
new MessageSiphon(process.getErrorStream(), this).getThread();
530531

531532
outThread = new StreamRedirectThread("JVM stdout Reader",
@@ -537,7 +538,7 @@ public void run() {
537538
// Shutdown begins when event thread terminates
538539
try {
539540
if (eventThread != null) eventThread.join(); // is this the problem?
540-
541+
541542
// System.out.println("in here");
542543
// Bug #852 tracked to this next line in the code.
543544
// http://dev.processing.org/bugs/show_bug.cgi?id=852
@@ -561,7 +562,7 @@ public void run() {
561562

562563

563564
protected Connector findConnector(String connectorName) {
564-
// List connectors =
565+
// List connectors =
565566
// com.sun.jdi.Bootstrap.virtualMachineManager().allConnectors();
566567
List<Connector> connectors =
567568
org.eclipse.jdi.Bootstrap.virtualMachineManager().allConnectors();
@@ -584,8 +585,8 @@ protected Connector findConnector(String connectorName) {
584585
return connector;
585586
}
586587
}
587-
Base.showError("Compiler Error",
588-
"findConnector() failed to find " +
588+
Base.showError("Compiler Error",
589+
"findConnector() failed to find " +
589590
connectorName + " inside Runner", null);
590591
return null; // Not reachable
591592
}
@@ -618,18 +619,18 @@ public void exceptionEvent(ExceptionEvent event) {
618619
reportException(message, or, event.thread());
619620
// Then try to pretty it up with a better message
620621
handleCommonErrors(exceptionName, message, listener, sketchErr);
621-
622+
622623
if (editor != null) {
623624
editor.deactivateRun();
624625
}
625626
}
626627

627628

628629
/**
629-
* Provide more useful explanations of common error messages, perhaps with
630-
* a short message in the status area, and (if necessary) a longer message
630+
* Provide more useful explanations of common error messages, perhaps with
631+
* a short message in the status area, and (if necessary) a longer message
631632
* in the console.
632-
*
633+
*
633634
* @param exceptionClass Class name causing the error (with full package name)
634635
* @param message The message from the exception
635636
* @param listener The Editor or command line interface that's listening for errors
@@ -658,7 +659,7 @@ public static boolean handleCommonErrors(final String exceptionClass,
658659
} else if (exceptionClass.equals("java.lang.UnsatisfiedLinkError")) {
659660
listener.statusError("A library used by this sketch is not installed properly.");
660661
err.println("A library relies on native code that's not available.");
661-
err.println("Or only works properly when the sketch is run as a " +
662+
err.println("Or only works properly when the sketch is run as a " +
662663
((Base.getNativeBits() == 32) ? "64-bit " : "32-bit ") + " application.");
663664

664665
} else if (exceptionClass.equals("java.lang.StackOverflowError")) {
@@ -762,7 +763,7 @@ protected SketchException findException(String message, ObjectReference or, Thre
762763
method = ((ClassType) or.referenceType()).concreteMethodByName("printStackTrace", "()V");
763764
// System.err.println("got method " + method);
764765
or.invokeMethod(thread, method, new ArrayList<Value>(), ObjectReference.INVOKE_SINGLE_THREADED);
765-
766+
766767
} catch (Exception e) {
767768
e.printStackTrace(sketchErr);
768769
}

0 commit comments

Comments
 (0)