Skip to content

Commit 2bbdbef

Browse files
author
mgricken
committed
NextGen in DrJava works now.
git-svn-id: file:///tmp/test-svn/branches/drjava-compilers@5335 fe72c1cf-3628-48e9-8b72-1c46755d3cff
1 parent 101c103 commit 2bbdbef

File tree

19 files changed

+43
-36
lines changed

19 files changed

+43
-36
lines changed

drjava/lib/platform.jar

242 Bytes
Binary file not shown.

drjava/src/edu/rice/cs/drjava/model/JDKToolsLibrary.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,13 @@ public static Iterable<JDKToolsLibrary> makeFromRuntime(GlobalModel model) {
221221
protected static final java.io.PrintWriter LOG_PW = new java.io.PrintWriter(LOG_STRINGWRITER);
222222

223223
public static void msg(String s) {
224-
try {
225-
java.io.PrintWriter pw = new java.io.PrintWriter(new java.io.FileWriter(new File(new File(System.getProperty("user.home")),
226-
"mintcompiler.txt").getAbsolutePath(),true));
227-
pw.println(s);
224+
// try {
225+
// java.io.PrintWriter pw = new java.io.PrintWriter(new java.io.FileWriter(new File(new File(System.getProperty("user.home")),
226+
// "mintcompiler.txt").getAbsolutePath(),true));
227+
// pw.println(s);
228228
LOG_PW.println(s);
229-
pw.close();
230-
}
231-
catch(java.io.IOException ioe) { }
229+
// pw.close();
230+
// }
231+
// catch(java.io.IOException ioe) { }
232232
}
233233
}

drjava/src/edu/rice/cs/drjava/model/JarJDKToolsLibrary.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,12 @@ else if (f.getName().equals("tools.jar")) {
204204
File[] jars = IOUtil.attemptListFiles(libDir, IOUtil.extensionFilePredicate("jar"));
205205
if (jars != null) { bootClassPath.addAll(Arrays.asList(jars)); }
206206
}
207+
else {
208+
// could not determine boot classpath because the file was not named classes.jar or tools.jar
209+
// at least put the compiler file itself and the additional compiler files on the boot classpath
210+
bootClassPath.add(f);
211+
for(File acf: additionalCompilerFiles) { bootClassPath.add(acf); };
212+
}
207213
if (additionalBootClassPath!=null) { bootClassPath.addAll(additionalBootClassPath); }
208214
if (bootClassPath.isEmpty()) { bootClassPath = null; } // null defers to the compiler's default behavior
209215

drjava/src/edu/rice/cs/drjava/model/compiler/JavacCompiler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
package edu.rice.cs.drjava.model.compiler;
3838

3939
import java.util.List;
40-
import java.util.ArrayList;
40+
import java.util.Arrays;
4141
import java.io.File;
4242
import edu.rice.cs.drjava.config.OptionConstants;
4343
import edu.rice.cs.drjava.DrJava;
@@ -79,7 +79,7 @@ public abstract List<? extends DJError> compile(List<? extends File> files, List
7979

8080
/** A compiler can instruct DrJava to include additional elements for the boot
8181
* class path of the Interactions JVM. This isn't necessary for the Java compilers, though. */
82-
public List<File> additionalBootClassPathForInteractions() { return new ArrayList<File>(); }
82+
public List<File> additionalBootClassPathForInteractions() { return Arrays.<File>asList(); }
8383

8484
/** Transform the command line to be interpreted into something the Interactions JVM can use.
8585
* This replaces "java MyClass a b c" with Java code to call MyClass.main(new String[]{"a","b","c"}).

drjava/src/edu/rice/cs/drjava/model/repl/newjvm/InterpreterJVM.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ private InterpreterJVM() {
114114
_classPathManager = new ClassPathManager(ReflectUtil.SYSTEM_CLASS_PATH);
115115
_interpreterLoader = _classPathManager.makeClassLoader(null);
116116
_junitTestManager = new JUnitTestManager(this, _classPathManager);
117+
118+
// set the thread context class loader, this way NextGen and Mint can use the interpreter's class loader
119+
Thread.currentThread().setContextClassLoader(_interpreterLoader);
117120

118121
// _interpreterOptions = Options.DEFAULT;
119122
_interpreterOptions = new InteractionsPaneOptions();
@@ -201,6 +204,9 @@ private InterpretResult interpret(String input, Interpreter interpreter) {
201204
boolean available = _busyInterpreters.add(interpreter);
202205
if (!available) { debug.logEnd(); return InterpretResult.busy(); }
203206

207+
// set the thread context class loader, this way NextGen and Mint can use the interpreter's class loader
208+
Thread.currentThread().setContextClassLoader(_interpreterLoader);
209+
204210
Option<Object> result = null;
205211
try { result = interpreter.interpret(input); }
206212
catch (InterpreterException e) { debug.logEnd(); return InterpretResult.exception(e); }

drjava/src/edu/rice/cs/drjava/model/repl/newjvm/MainJVM.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@
7171

7272
import static edu.rice.cs.plt.debug.DebugUtil.debug;
7373

74-
import edu.rice.cs.drjava.model.JarJDKToolsLibrary;
75-
7674
/**
7775
* <p>Manages a remote JVM. Includes methods for communication in both directions: MainJVMRemoteI
7876
* provides callbacks allowing the remote JVM to access the model, and a variety of delegating

drjava/src/edu/rice/cs/drjava/ui/MainFrame.java

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2157,42 +2157,35 @@ public void run() {
21572157

21582158
/** Displays the interactions classpath. */
21592159
public void viewInteractionsClassPath() {
2160-
String cp = IterUtil.multilineToString(_model.getInteractionsClassPath());
2160+
String cp = IterUtil.multilineToString(IterUtil.filter(_model.getInteractionsClassPath(),
2161+
new Predicate<File>() {
2162+
HashSet<File> alreadySeen = new HashSet<File>();
2163+
public boolean contains(File arg) {
2164+
// filter out empty strings and duplicates
2165+
return !("".equals(arg.toString().trim())) && alreadySeen.add(arg);
2166+
}
2167+
}));
21612168
new DrJavaScrollableDialog(this, "Interactions Classpath", "Current Interpreter Classpath", cp).show();
21622169
}
21632170

21642171
/** Action that shows what help documentation is available. Only executes in the event thread. */
21652172
private final Action _helpAction = new AbstractAction("Help") {
21662173
public void actionPerformed(ActionEvent ae) {
2167-
// Create frame if we haven't yet
2168-
// if (_helpFrame == null) {
2169-
// _helpFrame = new HelpFrame();
2170-
// }
21712174
_helpFrame.setVisible(true);
21722175
}
21732176
};
21742177

21752178
/** Action that shows the quick start documentation. Only executes in the event thread. */
21762179
private final Action _quickStartAction = new AbstractAction("QuickStart") {
21772180
public void actionPerformed(ActionEvent ae) {
2178-
// Create frame if we haven't yet
2179-
// if (_quickStartFrame == null) {
2180-
// _quickStartFrame = new QuickStartFrame();
2181-
// }
21822181
_quickStartFrame.setVisible(true);
21832182
}
21842183
};
21852184

21862185
/** Action that pops up an info dialog. Only runs in the event thread. */
21872186
private final Action _aboutAction = new AbstractAction("About") {
21882187
public void actionPerformed(ActionEvent ae) {
2189-
// Create dialog if we haven't yet
2190-
// if (_aboutDialog == null) _aboutDialog = new AboutDialog(MainFrame.this);
2191-
// Point p = MainFrame.this.getLocation();
21922188
_aboutDialog.setVisible(true);
2193-
// _aboutDialog.setLocation(p.x+(MainFrame.this.getWidth() - _aboutDialog.getWidth())/2,
2194-
// p.y+(MainFrame.this.getHeight()-_aboutDialog.getHeight())/2);
2195-
21962189
}
21972190
};
21982191

Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)