some minor reformatting

This commit is contained in:
akhil 2013-12-05 14:54:12 -08:00
parent 8b86802ac2
commit b0f3c1ca3f
3 changed files with 19 additions and 17 deletions

View File

@ -42,13 +42,13 @@ import java.util.Set;
* An extensible module loader.
*/
public abstract class Loader {
static {
// XXX jfdenise, this could be revisited with other way to find out debug mode
List<String> debug_keys = new ArrayList<>();
debug_keys.add("-Xdebug");
debug_keys.add("-agentlib:jdwp");
String p = "(function (exports, require, module, __filename, __dirname) { ";
boolean debug = false;
try {
Class<?> clazz = Class.forName("java.lang.management.ManagementFactory");
@ -65,27 +65,28 @@ public abstract class Loader {
}
}
}
}catch(Exception ex) {
} catch (Exception ex) {
// XXX OK compact1 or something
}
/*
* If we are in debugging, the runtime source file is exposed to the user.
* So it must be cleanly formatted and a \n is expected. If a stack trace is displayed,
* If we are in debugging, the runtime source file is exposed to the user.
* So it must be cleanly formatted and a \n is expected. If a stack trace is displayed,
* the line numbers must be in sync with the file exposed to the user (The Runtime Source).
* In this case the function signature is postfixed by a \n for proper formatting.
* If we are NOT in debugging, the original source file is exposed to the user.
* No function wrapper visible. If a stack trace is displayed,
* If we are NOT in debugging, the original source file is exposed to the user.
* No function wrapper visible. If a stack trace is displayed,
* the line numbers must be in sync with the file exposed to the user (The original Source).
* In this case the function signature is not postfixed by a \n.
*/
final String p = "(function (exports, require, module, __filename, __dirname) { ";
if (debug) { // Runtime source is exposed.
PREFIX = p +"\n";
PREFIX = p + "\n";
} else { // Not exposed, so hide wrapping.
PREFIX = p;
}
}
public static final String PREFIX;
public static final String SUFFIX = "\n});";

View File

@ -49,7 +49,7 @@ public final class Event {
this.callback = callback;
this.args = new Object[1];
this.args[0] = arg;
if(System.getSecurityManager() != null) {
if (System.getSecurityManager() != null) {
this.ctx = AccessController.getContext();
} else {
this.ctx = null;
@ -61,7 +61,7 @@ public final class Event {
this.domain = null;
this.callback = callback;
this.args = args == null ? null : args.clone();
if(System.getSecurityManager() != null) {
if (System.getSecurityManager() != null) {
this.ctx = AccessController.getContext();
} else {
this.ctx = null;

View File

@ -79,6 +79,7 @@ public final class EventLoop {
private final AtomicInteger hooks;
private final AsyncHandle asyncHandle;
public Handle(final AtomicInteger hooks, final AsyncHandle asyncHandle) {
this.hooks = hooks;
this.asyncHandle = asyncHandle;
@ -92,7 +93,7 @@ public final class EventLoop {
hooks.decrementAndGet();
asyncHandle.send();
}
public void release() {
close();
}
@ -125,7 +126,7 @@ public final class EventLoop {
public void post(final Callback cb, Object... args) {
eventQueue.add(new Event(null, cb, args));
}
public void post(final Event event) {
eventQueue.add(event);
}
@ -243,7 +244,7 @@ public final class EventLoop {
final Map<String, Object> args = new HashMap<>();
if (LOG.enabled()) { LOG.log("uncaught %s", ex.toString()); }
NashornException nex = null;
if (ex instanceof NashornException) {
nex = (NashornException) ex;
@ -259,7 +260,7 @@ public final class EventLoop {
// unknown/unhandled exception - rethrow
return false;
}
// extract exception file, line, column, stack, name and message, if available
args.put(EXCEPTION_FILE, nex.getFileName());
args.put(EXCEPTION_LINE, nex.getLineNumber());
@ -292,7 +293,7 @@ public final class EventLoop {
}
}
}
// dispatch exception to user handler, returning true on success
try {
final Object[] arr = {args};