Fix bug 121790

git-svn-id: svn://10.0.0.236/trunk@112957 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
nboyd%atg.com 2002-01-26 19:15:06 +00:00
parent 045cba9433
commit c5eb49df96

View File

@ -76,7 +76,7 @@ public class Main {
public static int exec(String args[]) {
Context cx = Context.enter();
// Create the top-level scope object.
global = new Global(cx);
global = getGlobal();
errorReporter = new ToolErrorReporter(false, global.getErr());
cx.setErrorReporter(errorReporter);
@ -99,6 +99,18 @@ public class Main {
return exitCode;
}
public static Global getGlobal() {
if (global == null) {
try {
global = new Global(Context.enter());
}
finally {
Context.exit();
}
}
return global;
}
/**
* Parse arguments.
*/
@ -174,7 +186,7 @@ public class Main {
if (filename == null || filename.equals("-")) {
if (filename == null) {
// print implementation version
System.out.println(cx.getImplementationVersion());
getOut().println(cx.getImplementationVersion());
}
// Use the interpreter for interactive input
@ -360,27 +372,27 @@ public class Main {
}
public static InputStream getIn() {
return Global.getInstance(global).getIn();
return Global.getInstance(getGlobal()).getIn();
}
public static void setIn(InputStream in) {
Global.getInstance(global).setIn(in);
Global.getInstance(getGlobal()).setIn(in);
}
public static PrintStream getOut() {
return Global.getInstance(global).getOut();
return Global.getInstance(getGlobal()).getOut();
}
public static void setOut(PrintStream out) {
Global.getInstance(global).setOut(out);
Global.getInstance(getGlobal()).setOut(out);
}
public static PrintStream getErr() {
return Global.getInstance(global).getErr();
return Global.getInstance(getGlobal()).getErr();
}
public static void setErr(PrintStream err) {
Global.getInstance(global).setErr(err);
Global.getInstance(getGlobal()).setErr(err);
}
static protected ToolErrorReporter errorReporter;