{
/** Storage for keystrokes.*/
diff --git a/drjava/src/edu/rice/cs/drjava/config/KeyStrokeOptionTest.java b/drjava/src/edu/rice/cs/drjava/config/KeyStrokeOptionTest.java
index f3f7e2903..8b0cc4b3c 100644
--- a/drjava/src/edu/rice/cs/drjava/config/KeyStrokeOptionTest.java
+++ b/drjava/src/edu/rice/cs/drjava/config/KeyStrokeOptionTest.java
@@ -41,6 +41,7 @@
/** Class according to the JUnit protocol. Tests the proper functionality of the class KeyStrokeOption.
* @version $Id$
*/
+@SuppressWarnings("deprecation")
public final class KeyStrokeOptionTest extends DrJavaTestCase {
/** @param name The name of this test case. */
public KeyStrokeOptionTest(String name) { super(name); }
diff --git a/drjava/src/edu/rice/cs/drjava/config/LongOptionTest.java b/drjava/src/edu/rice/cs/drjava/config/LongOptionTest.java
index 6b5eec551..72afd868c 100644
--- a/drjava/src/edu/rice/cs/drjava/config/LongOptionTest.java
+++ b/drjava/src/edu/rice/cs/drjava/config/LongOptionTest.java
@@ -33,6 +33,7 @@
/** Class according to the JUnit protocol. Tests the proper functionality of the class LongOption.
* @version $Id$
*/
+@SuppressWarnings("deprecation")
public final class LongOptionTest extends DrJavaTestCase {
/** @param name The name of this test case. */
@@ -49,8 +50,8 @@ public void testGetName() {
public void testParse() {
LongOption io = new LongOption("max_files",null);
- assertEquals(new Long(Integer.MAX_VALUE+1), io.parse(new Long(Integer.MAX_VALUE+1).toString()));
- assertEquals(new Long(Integer.MIN_VALUE-1), io.parse(new Long(Integer.MIN_VALUE-1).toString()));
+ assertEquals(Long.valueOf(Integer.MAX_VALUE+1), io.parse(Long.valueOf(Integer.MAX_VALUE+1).toString()));
+ assertEquals(Long.valueOf(Integer.MIN_VALUE-1), io.parse(Long.valueOf(Integer.MIN_VALUE-1).toString()));
try { io.parse("true"); fail(); }
catch (OptionParseException e) { }
@@ -63,9 +64,9 @@ public void testFormat() {
LongOption io1 = new LongOption("max_files",null);
LongOption io2 = new LongOption("indent_size",null);
- assertEquals(new Long(Integer.MAX_VALUE+1).toString(), io1.format(new Long(Integer.MAX_VALUE+1)));
- assertEquals(new Long(Integer.MAX_VALUE+1).toString(), io2.format(new Long(Integer.MAX_VALUE+1)));
- assertEquals(new Long(Integer.MIN_VALUE-1).toString(), io1.format(new Long(Integer.MIN_VALUE-1)));
- assertEquals(new Long(Integer.MIN_VALUE-1).toString(), io2.format(new Long(Integer.MIN_VALUE-1)));
+ assertEquals(Long.valueOf(Integer.MAX_VALUE+1).toString(), io1.format(Long.valueOf(Integer.MAX_VALUE+1)));
+ assertEquals(Long.valueOf(Integer.MAX_VALUE+1).toString(), io2.format(Long.valueOf(Integer.MAX_VALUE+1)));
+ assertEquals(Long.valueOf(Integer.MIN_VALUE-1).toString(), io1.format(Long.valueOf(Integer.MIN_VALUE-1)));
+ assertEquals(Long.valueOf(Integer.MIN_VALUE-1).toString(), io2.format(Long.valueOf(Integer.MIN_VALUE-1)));
}
}
diff --git a/drjava/src/edu/rice/cs/drjava/config/Option.java b/drjava/src/edu/rice/cs/drjava/config/Option.java
index 45dfc3694..f0c4d122b 100644
--- a/drjava/src/edu/rice/cs/drjava/config/Option.java
+++ b/drjava/src/edu/rice/cs/drjava/config/Option.java
@@ -42,7 +42,7 @@
*
* Option<Integer> INDENT_INC = new Option<Integer>("indent.level") {
* public Integer parse(String s) {
- * return new Integer(s);
+ * return Integer.valueOf(s);
* }
* };
*
diff --git a/drjava/src/edu/rice/cs/drjava/config/OptionConstants.java b/drjava/src/edu/rice/cs/drjava/config/OptionConstants.java
index 2ba932770..5e51f3b72 100644
--- a/drjava/src/edu/rice/cs/drjava/config/OptionConstants.java
+++ b/drjava/src/edu/rice/cs/drjava/config/OptionConstants.java
@@ -36,6 +36,7 @@
import java.awt.Font;
import java.awt.Frame;
import java.awt.Toolkit;
+import java.awt.Event;
import java.awt.event.KeyEvent;
import javax.swing.KeyStroke;
import javax.swing.LookAndFeel;
@@ -45,12 +46,13 @@
import edu.rice.cs.drjava.platform.PlatformFactory;
import edu.rice.cs.util.FileOps;
-import static java.awt.Event.*;
+//import static java.awt.Event.*;
/** Defines the commonly used Option constants in DrJava config and project profiles.
* @version $Id$
*/
+@SuppressWarnings("deprecation")
public interface OptionConstants {
// STATIC VARIABLES
@@ -382,6 +384,9 @@ public static String getDefaultTheme() {
/* ---------- Key Binding Options ----------- */
public static int MASK = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
+ public static int SHIFT_MASK = Event.SHIFT_MASK;
+ public static int CTRL_MASK = Event.CTRL_MASK;
+ public static int ALT_MASK = Event.ALT_MASK;
static class to {
public static Vector vector(KeyStroke... ks) {
@@ -619,7 +624,7 @@ public static Vector vector(KeyStroke... ks) {
public static final VectorOption KEY_GOTO_FILE =
new VectorOption("key.goto.file",
new KeyStrokeOption("",null),
- to.vector(KeyStroke.getKeyStroke(KeyEvent.VK_G, MASK|KeyEvent.SHIFT_MASK)));
+ to.vector(KeyStroke.getKeyStroke(KeyEvent.VK_G, MASK|SHIFT_MASK)));
/** The key binding for goto this file. */
public static final VectorOption KEY_GOTO_FILE_UNDER_CURSOR =
@@ -631,7 +636,7 @@ public static Vector vector(KeyStroke... ks) {
public static final VectorOption KEY_OPEN_JAVADOC =
new VectorOption("key.open.javadoc",
new KeyStrokeOption("",null),
- to.vector(KeyStroke.getKeyStroke(KeyEvent.VK_F6, KeyEvent.SHIFT_MASK)));
+ to.vector(KeyStroke.getKeyStroke(KeyEvent.VK_F6, SHIFT_MASK)));
/** The key binding for open Javadoc under cursor. */
public static final VectorOption KEY_OPEN_JAVADOC_UNDER_CURSOR =
@@ -643,7 +648,7 @@ public static Vector vector(KeyStroke... ks) {
public static final VectorOption KEY_COMPLETE_FILE =
new VectorOption("key.complete.file",
new KeyStrokeOption("",null),
- to.vector(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, MASK|KeyEvent.SHIFT_MASK)));
+ to.vector(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, MASK|SHIFT_MASK)));
// /** The key binding for indenting */
// public static final VectorOption KEY_INDENT =
diff --git a/drjava/src/edu/rice/cs/drjava/config/UnaryOpProperty.java b/drjava/src/edu/rice/cs/drjava/config/UnaryOpProperty.java
index e772b5593..113d1be9c 100644
--- a/drjava/src/edu/rice/cs/drjava/config/UnaryOpProperty.java
+++ b/drjava/src/edu/rice/cs/drjava/config/UnaryOpProperty.java
@@ -115,13 +115,13 @@ public void resetAttributes() {
/** Lambda to parse a String into a Double. */
public static final Lambda PARSE_DOUBLE =
new Lambda() {
- public Double value(String s) { return new Double(s); }
+ public Double value(String s) { return Double.valueOf(s); }
};
/** Lambda to parse a String into a Boolean. */
public static final Lambda PARSE_BOOL =
new Lambda() {
- public Boolean value(String s) { return new Boolean(s); }
+ public Boolean value(String s) { return Boolean.valueOf(s); }
};
/** Lambda to parse a String into a String. */
diff --git a/drjava/src/edu/rice/cs/drjava/model/AbstractGlobalModel.java b/drjava/src/edu/rice/cs/drjava/model/AbstractGlobalModel.java
index 6f9ffdb70..829345b49 100644
--- a/drjava/src/edu/rice/cs/drjava/model/AbstractGlobalModel.java
+++ b/drjava/src/edu/rice/cs/drjava/model/AbstractGlobalModel.java
@@ -2518,16 +2518,21 @@ public void optionChanged(OptionEvent oce) {
* @param style the style to print with
*/
protected void _docAppend(final ConsoleDocument doc, final String s, final String style) {
- Utilities.invokeLater(new Runnable() {
- public void run() { doc.insertBeforeLastPrompt(s, style); }
- });
+ assert EventQueue.isDispatchThread();
+ doc.insertBeforeLastPrompt(s, style);
}
/** Prints System.out to the DrJava console. This method can safely be run outside the event thread. */
- public void systemOutPrint(final String s) { _docAppend(_consoleDoc, s, EditDocumentInterface.SYSTEM_OUT_STYLE); }
+ public void systemOutPrint(final String s) {
+// Utilities.show("AbstractGlobalModel.systemOutPrint(" + s + ") called");
+ _docAppend(_consoleDoc, s, EditDocumentInterface.SYSTEM_OUT_STYLE);
+ }
/** Prints System.err to the DrJava console. This method can safely be run outside the event thread. */
- public void systemErrPrint(final String s) { _docAppend(_consoleDoc, s, EditDocumentInterface.SYSTEM_ERR_STYLE); }
+ public void systemErrPrint(final String s) {
+// Utilities.show("AbstractGlobalModel.systemErrPrint(" + s + ") called");
+ _docAppend(_consoleDoc, s, EditDocumentInterface.SYSTEM_ERR_STYLE);
+ }
/** Prints to the DrJava console as an echo of System.in. This method can safely be run outside the event thread. */
public void systemInEcho(final String s) { _docAppend(_consoleDoc, s, EditDocumentInterface.SYSTEM_IN_STYLE); }
diff --git a/drjava/src/edu/rice/cs/drjava/model/DefaultGlobalModel.java b/drjava/src/edu/rice/cs/drjava/model/DefaultGlobalModel.java
index 1c7aaca29..c9ba274c5 100644
--- a/drjava/src/edu/rice/cs/drjava/model/DefaultGlobalModel.java
+++ b/drjava/src/edu/rice/cs/drjava/model/DefaultGlobalModel.java
@@ -416,6 +416,8 @@ public void setBuildDirectory(File f) {
/** Prepares this model to be thrown away. Never called in practice outside of quit(), except in tests. */
public void dispose() {
+ /* Disposing this model is performed in test code that does not run in the dispatch thread. */
+// assert EventQueue.isDispatchThread();
ensureJVMStarterFinished();
_jvm.dispose();
_notifier.removeAllListeners(); // removes the global model listeners!
diff --git a/drjava/src/edu/rice/cs/drjava/model/GlobalModelIOTest.java b/drjava/src/edu/rice/cs/drjava/model/GlobalModelIOTest.java
index 08a8e99ef..24b63db01 100644
--- a/drjava/src/edu/rice/cs/drjava/model/GlobalModelIOTest.java
+++ b/drjava/src/edu/rice/cs/drjava/model/GlobalModelIOTest.java
@@ -1095,10 +1095,10 @@ public synchronized boolean shouldRevertFile(OpenDefinitionsDocument doc) {
}
/** Interprets some statements, saves the history, clears the history, then loads the history.
- * @throws EditDocumentException if an error occurs while editing
- * @throws IOException if an IO operation fails
- * @throws InterruptedException if execution is interrupted unexpectedly
- */
+ * @throws EditDocumentException if an error occurs while editing
+ * @throws IOException if an IO operation fails
+ * @throws InterruptedException if execution is interrupted unexpectedly
+ */
public void testSaveClearAndLoadHistory() throws EditDocumentException, IOException, InterruptedException {
String newLine = StringOps.EOL;
final InteractionListener listener = new InteractionListener();
@@ -1126,6 +1126,10 @@ public void testSaveClearAndLoadHistory() throws EditDocumentException, IOExcept
interpretIgnoreResult(s3);
listener.waitInteractionDone();
+ ConsoleDocument con0 = _model.getConsoleDocument();
+// Utilities.show("Length of console document = " + con0.getLength());
+// Utilities.show("History as string = " + _model.getHistoryAsString());
+
// System.err.println("history is '" + _model.getHistoryAsString() + "'");
// check that the history contains the correct value
assertEquals("History and getHistoryAsString should be the same.",
@@ -1142,10 +1146,13 @@ public void testSaveClearAndLoadHistory() throws EditDocumentException, IOExcept
// check that the file contains the correct value
assertEquals("contents of saved file", History.HISTORY_FORMAT_VERSION_2 + s1 + delim + s2 + delim + s3 + delim,
IOUtil.toString(f));
-
+ ConsoleDocument con1 = _model.getConsoleDocument();
+// Utilities.show("Length of loaded history [?] = " + con1.getLength());
+// Utilities.show("Length of history string [?] = " + _model.getHistoryAsString().length());
_model.clearHistory();
// confirm that the history is clear
assertEquals("History is not clear", "", _model.getHistoryAsString());
+// Utilities.show("Length of loaded history [0] = " + con1.getLength());
Utilities.invokeLater(new Runnable() {
public void run() {
@@ -1160,9 +1167,11 @@ public void run() {
listener.waitInteractionDone();
// check that output of loaded history is correct
- ConsoleDocument con = _model.getConsoleDocument();
- debug.log(con.getDocText(0, con.getLength()).trim());
- assertEquals("Output of loaded history is not correct", "x = 5", con.getDocText(0, con.getLength()).trim());
+ ConsoleDocument con2 = _model.getConsoleDocument();
+ Utilities.clearEventQueue();
+// Utilities.show("Length of loaded history = " + con2.getLength());
+ debug.log(con2.getDocText(0, con2.getLength()).trim());
+ assertEquals("Output of loaded history is not correct", "x = 5", con2.getDocText(0, con2.getLength()).trim());
listener.assertInteractionStartCount(4);
listener.assertInteractionEndCount(4);
_model.removeListener(listener);
diff --git a/drjava/src/edu/rice/cs/drjava/model/GlobalModelTestCase.java b/drjava/src/edu/rice/cs/drjava/model/GlobalModelTestCase.java
index 1b5671f3a..6fcce35fe 100644
--- a/drjava/src/edu/rice/cs/drjava/model/GlobalModelTestCase.java
+++ b/drjava/src/edu/rice/cs/drjava/model/GlobalModelTestCase.java
@@ -264,6 +264,7 @@ protected void safeLoadHistory(final FileSelector fs) {
Utilities.invokeAndWait(new Runnable() { public void run() { _model.loadHistory(fs); } });
}
+ /* Only called from GlobalModelIOTest. */
protected void safeSaveHistory(final FileSelector fs) {
Utilities.invokeAndWait(new Runnable() {
public void run() {
diff --git a/drjava/src/edu/rice/cs/drjava/model/JarJDKToolsLibrary.java b/drjava/src/edu/rice/cs/drjava/model/JarJDKToolsLibrary.java
index e0f073ba0..7b0e9376d 100644
--- a/drjava/src/edu/rice/cs/drjava/model/JarJDKToolsLibrary.java
+++ b/drjava/src/edu/rice/cs/drjava/model/JarJDKToolsLibrary.java
@@ -77,6 +77,7 @@
import edu.rice.cs.drjava.model.JDKDescriptor;
/** A JDKToolsLibrary that was loaded from a specific jar file. */
+@SuppressWarnings("deprecation")
public class JarJDKToolsLibrary extends JDKToolsLibrary {
/** Packages to shadow when loading a new tools.jar. If we don't shadow these classes, we won't
diff --git a/drjava/src/edu/rice/cs/drjava/model/compiler/Javac160FilteringCompiler.java b/drjava/src/edu/rice/cs/drjava/model/compiler/Javac160FilteringCompiler.java
index 843dfab7f..15a37a0b3 100644
--- a/drjava/src/edu/rice/cs/drjava/model/compiler/Javac160FilteringCompiler.java
+++ b/drjava/src/edu/rice/cs/drjava/model/compiler/Javac160FilteringCompiler.java
@@ -96,7 +96,7 @@ public boolean accept(File dir, String name) {
if ((!name.startsWith(PREFIX)) || (!name.endsWith(SUFFIX))) return false;
String rest = name.substring(PREFIX.length(), name.length()-SUFFIX.length());
try {
- new Integer(rest);
+ Integer.valueOf(rest);
// we could create an integer from the rest, this is one of our temporary files
return true;
}
diff --git a/drjava/src/edu/rice/cs/drjava/model/compiler/JavacCompiler.java b/drjava/src/edu/rice/cs/drjava/model/compiler/JavacCompiler.java
index 9b6ad5740..135de0901 100644
--- a/drjava/src/edu/rice/cs/drjava/model/compiler/JavacCompiler.java
+++ b/drjava/src/edu/rice/cs/drjava/model/compiler/JavacCompiler.java
@@ -50,6 +50,7 @@
* a matching signature.
* @version $Id$
*/
+@SuppressWarnings("deprecation")
public abstract class JavacCompiler implements CompilerInterface {
protected final JavaVersion.FullVersion _version;
diff --git a/drjava/src/edu/rice/cs/drjava/model/compiler/JavaxToolsCompiler.java b/drjava/src/edu/rice/cs/drjava/model/compiler/JavaxToolsCompiler.java
index 963910832..caa308274 100644
--- a/drjava/src/edu/rice/cs/drjava/model/compiler/JavaxToolsCompiler.java
+++ b/drjava/src/edu/rice/cs/drjava/model/compiler/JavaxToolsCompiler.java
@@ -13,24 +13,27 @@
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.util.*;
-import javax.tools.*; /* including ToolProvider, StandardLocation, DiagnosticCollector */
-
-/** The CompilerInterface for the javax.tools compiler embedded in the executing JVM.
- * Manages the auxiliary naming methods.(?)
- */
+import javax.tools.*;
+@SuppressWarnings("deprecation")
public class JavaxToolsCompiler implements CompilerInterface {
/** The set of class names that are run as ACM Java Task Force library programs. */
protected static final Set ACM_PROGRAM_CLASSES = new HashSet();
static {
- Collections.addAll(ACM_PROGRAM_CLASSES, new String[] {"acm.program.Program", "acm.graphics.GTurtle"});
+ Collections.addAll(ACM_PROGRAM_CLASSES, new String[] {
+ "acm.program.Program",
+ "acm.graphics.GTurtle"
+ });
}
private final JavaCompiler compiler;
- /** Standard Constructor */
- public JavaxToolsCompiler() { this.compiler = ToolProvider.getSystemJavaCompiler(); }
+ public JavaxToolsCompiler() {
+ this.compiler = ToolProvider.getSystemJavaCompiler();
+ }
- public boolean isAvailable() { return this.compiler != null; }
+ public boolean isAvailable() {
+ return this.compiler != null;
+ }
public List extends DJError> compile(List extends File> files, List extends File> classPath,
List extends File> sourcePath, File destination,
@@ -38,7 +41,7 @@ public List extends DJError> compile(List extends File> files, List extend
// Check if compiler is available
if (compiler == null) {
List errors = new ArrayList<>();
- errors.add(new DJError("The SystemJavaCompiler is not available", false));
+ errors.add(new DJError("Compiler is not available", false));
return errors;
}
@@ -66,7 +69,7 @@ public List extends DJError> compile(List extends File> files, List extend
Iterable extends JavaFileObject> compilationUnits = fileManager.getJavaFileObjectsFromFiles(files);
// Prepare the compilation options
- /* Question (by Corky): is the "-source" option necessary? The JavaxTools compiler is part of the executing JVM. */
+
List optionList = new ArrayList<>();
if (sourceVersion != null) {
optionList.add("-source");
@@ -112,11 +115,12 @@ public List extends DJError> compile(List extends File> files, List extend
return errors;
}
- /* Question (Corky): Shouldn't we retreive the version of this System (JVM). */
- public JavaVersion version() { return JavaVersion.JAVA_8; }
+
public String getName() { return "javax.tools"; }
-
+
+ public JavaVersion version() { return JavaVersion.CURRENT; }
+
public String getDescription() { return "Standard compiler in javax.tools"; }
public String toString() { return getName(); }
@@ -364,53 +368,32 @@ protected static String _transformCommand(String s, String command) {
*/
protected static String _deleteSemiColon(String s) { return s.substring(0, s.length() - 1); }
-// public boolean isSourceFileForThisCompiler(File f) {
-// if (f == null) return false;
-// String fileName = f.getName();
-// return fileName.endsWith(".java") || fileName.endsWith(".dj");
-// }
-
- /** .java {@literal -->} true
- * .dj {@literal -->} true
- * .dj0 {@literal -->} true
- * .dj1 {@literal -->} true
- * .dj2 {@literal -->} true
- * otherwise false
- * @return true if the specified file is a source file for this compiler. */
+
+
public boolean isSourceFileForThisCompiler(File f) {
- // by default, use DrJavaFileUtils.isSourceFile
- return DrJavaFileUtils.isSourceFile(f);
+ if (f == null) return false;
+ String fileName = f.getName();
+ return fileName.endsWith(".java");
}
-// public Set getSourceFileExtensions() {
-// HashSet extensions = new HashSet();
-// extensions.add("java");
-// return extensions;
-// }
-
- /** Return the set of source file extensions that this compiler supports.
- * @return the set of source file extensions that this compiler supports. */
- public Set getSourceFileExtensions() { return DrJavaFileUtils.getSourceFileExtensions(); }
+ public Set getSourceFileExtensions() {
+ HashSet extensions = new HashSet();
+ extensions.add("java");
+ return extensions;
+ }
+
+ public String getSuggestedFileExtension() {
+ return ".java";
+ }
+
+ public FileFilter getFileFilter() {
+ // TODO: this might need to be different... (I think smartsourcefilter includes .dj files which idk ab)
+ return new SmartSourceFilter();
+ }
-// public String getSuggestedFileExtension() { return ".java"; }
-
- /** Return the suggested file extension that will be appended to a file without extension.
- * @return the suggested file extension */
- public String getSuggestedFileExtension() { return DrJavaFileUtils.getSuggestedFileExtension(); }
-
- /** Return a file filter that can be used to open files this compiler supports.
- * @return file filter for appropriate source files for this compiler */
- public FileFilter getFileFilter() { return new SmartSourceFilter(); }
-
-// public String getOpenAllFilesInFolderExtension() {
-// // Should we use OptionConstants for this?
-// return ".java";
-// }
-
- /** Return the extension of the files that should be opened with the "Open Folder..." command.
- * @return file extension for the "Open Folder..." command for this compiler. */
public String getOpenAllFilesInFolderExtension() {
- return OptionConstants.LANGUAGE_LEVEL_EXTENSIONS[DrJava.getConfig().getSetting(OptionConstants.LANGUAGE_LEVEL)];
+ // Should we use OptionConstants for this?
+ return ".java";
}
/** Return the set of keywords that should be highlighted in the specified file.
@@ -432,4 +415,4 @@ public String getOpenAllFilesInFolderExtension() {
/** @return true since this compiler can be used in conjunction with the language level facility. */
public boolean supportsLanguageLevels() { return true; }
-}
\ No newline at end of file
+}
diff --git a/drjava/src/edu/rice/cs/drjava/model/compiler/LanguageLevelStackTraceMapper.java b/drjava/src/edu/rice/cs/drjava/model/compiler/LanguageLevelStackTraceMapper.java
index dfdfd83c6..a62ac35e6 100644
--- a/drjava/src/edu/rice/cs/drjava/model/compiler/LanguageLevelStackTraceMapper.java
+++ b/drjava/src/edu/rice/cs/drjava/model/compiler/LanguageLevelStackTraceMapper.java
@@ -209,7 +209,7 @@ public TreeMap readLLLineBlock(File LLFile){
// Process header line of block
LOG.log("rdLine = '" + rdLine + "'");
LOG.log("\tlastIndex = " + rdLine.lastIndexOf(" "));
- Integer mapSize = new Integer (rdLine.substring(rdLine.lastIndexOf(" ") + 1));
+ Integer mapSize = Integer.valueOf(rdLine.substring(rdLine.lastIndexOf(" ") + 1));
try { rdLine = bufReader.readLine(); } catch(java.io.IOException e){ }
@@ -234,8 +234,8 @@ public TreeMap readLLLineBlock(File LLFile){
String numRnum = text.substring(0, firstBlankPos);
text = text.substring(firstBlankPos).trim() + " "; // Only need to trim leading blanks here; String API is clumsy
- djNum = new Integer(numRnum.substring(0, numRnum.indexOf("->")));
- javaNum = new Integer(numRnum.substring(numRnum.indexOf("->") + 2));
+ djNum = Integer.valueOf(numRnum.substring(0, numRnum.indexOf("->")));
+ javaNum = Integer.valueOf(numRnum.substring(numRnum.indexOf("->") + 2));
javaDJMap.put(javaNum,djNum);
}
@@ -264,7 +264,7 @@ public TreeMap readLLBlock(File LLFile) {
LOG.log("rdLine = '" + rdLine + "'");
LOG.log("\tlastIndex = " + rdLine.lastIndexOf(" "));
- Integer mapSize = new Integer (rdLine.substring(rdLine.lastIndexOf(" ") + 1));
+ Integer mapSize = Integer.valueOf(rdLine.substring(rdLine.lastIndexOf(" ") + 1));
try { rdLine = bufReader.readLine(); } catch(java.io.IOException e){ }
diff --git a/drjava/src/edu/rice/cs/drjava/model/debug/jpda/JPDADebugger.java b/drjava/src/edu/rice/cs/drjava/model/debug/jpda/JPDADebugger.java
index fdd72b51c..7b5b68155 100644
--- a/drjava/src/edu/rice/cs/drjava/model/debug/jpda/JPDADebugger.java
+++ b/drjava/src/edu/rice/cs/drjava/model/debug/jpda/JPDADebugger.java
@@ -465,7 +465,7 @@ public static boolean isSimpleVariableOrFieldAccess(String var) {
indexStr = indexStr.trim();
// System.out.println("\t\tindexStr: "+indexStr);
try {
- new Integer(indexStr);
+ Integer.valueOf(indexStr);
// System.out.println("\t\tindex: "+index);
}
catch(NumberFormatException nfe) { return false; }
diff --git a/drjava/src/edu/rice/cs/drjava/model/definitions/ColoringGlyphPainter.java b/drjava/src/edu/rice/cs/drjava/model/definitions/ColoringGlyphPainter.java
index eeebac5c3..db8718946 100644
--- a/drjava/src/edu/rice/cs/drjava/model/definitions/ColoringGlyphPainter.java
+++ b/drjava/src/edu/rice/cs/drjava/model/definitions/ColoringGlyphPainter.java
@@ -43,7 +43,7 @@
// import edu.rice.cs.util.swing.Utilities; // conflicts with javax.swing.text.Utilities
-
+@SuppressWarnings("deprecation")
public class ColoringGlyphPainter extends GlyphView.GlyphPainter implements OptionConstants {
public static Color COMMENTED_COLOR = DrJava.getConfig().getSetting(DEFINITIONS_COMMENT_COLOR);
diff --git a/drjava/src/edu/rice/cs/drjava/model/definitions/ColoringView.java b/drjava/src/edu/rice/cs/drjava/model/definitions/ColoringView.java
index 3c245433e..69af5c814 100644
--- a/drjava/src/edu/rice/cs/drjava/model/definitions/ColoringView.java
+++ b/drjava/src/edu/rice/cs/drjava/model/definitions/ColoringView.java
@@ -50,6 +50,7 @@
*
* @version $Id$
*/
+@SuppressWarnings("deprecation")
public class ColoringView extends PlainView implements OptionConstants {
public static Color COMMENTED_COLOR = DrJava.getConfig().getSetting(DEFINITIONS_COMMENT_COLOR);
diff --git a/drjava/src/edu/rice/cs/drjava/model/definitions/DefinitionsDocument.java b/drjava/src/edu/rice/cs/drjava/model/definitions/DefinitionsDocument.java
index dcd838409..0d0d94e33 100644
--- a/drjava/src/edu/rice/cs/drjava/model/definitions/DefinitionsDocument.java
+++ b/drjava/src/edu/rice/cs/drjava/model/definitions/DefinitionsDocument.java
@@ -60,6 +60,7 @@
/** The document model for the definitions pane; it contains a reduced model since it extends AbstractDJDocument.
* @see AbstractDJDocument
*/
+@SuppressWarnings("deprecation")
public class DefinitionsDocument extends AbstractDJDocument implements Finalizable {
public static final Log _log = new Log("GlobalModel.txt", false);
diff --git a/drjava/src/edu/rice/cs/drjava/model/repl/InteractionsModel.java b/drjava/src/edu/rice/cs/drjava/model/repl/InteractionsModel.java
index 62cdf2e1c..9a8269cf5 100644
--- a/drjava/src/edu/rice/cs/drjava/model/repl/InteractionsModel.java
+++ b/drjava/src/edu/rice/cs/drjava/model/repl/InteractionsModel.java
@@ -57,6 +57,7 @@
* The methods in this class generally can be executed only in the event thread once the model has been constructed.
* @version $Id$
*/
+@SuppressWarnings("deprecation")
public abstract class InteractionsModel implements InteractionsModelCallback {
/** Banner prefix. */
@@ -303,15 +304,12 @@ public final void resetInterpreter(File wd, boolean force) {
*/
protected abstract void _notifySyntaxErrorOccurred(int offset, int length);
-
- /** Interprets the files selected in the FileOpenSelector. Assumes all
- * strings have no trailing whitespace.
- * Interprets the array all at once so if there are any errors, none of the
- * statements after the first erroneous one are processed. Only runs in
- * the event thread.
- * @param selector a FileOpenSelector
- * @throws IOException if an IO operation fails
- */
+ /** Interprets the files selected in the FileOpenSelector. Assumes all strings have no trailing whitespace. Interprets
+ * the array all at once so if there are any errors, none of the statements after the first erroneous one are processed.
+ * Only runs in the event thread.
+ * @param selector a FileOpenSelector
+ * @throws IOException if an IO operation fails
+ */
public void loadHistory(final FileOpenSelector selector) throws IOException {
ArrayList histories;
try { histories = _getHistoryText(selector); }
@@ -332,11 +330,10 @@ public void loadHistory(final FileOpenSelector selector) throws IOException {
}
}
String text = buf.toString().trim();
-// System.err.println("Histtory is: '" + text + "'");
+// Utilities.show("History is: '" + text + "'");
append(text, ConsoleDocument.DEFAULT_STYLE);
interpretCurrentInteraction();
// System.err.println("Interpreting loaded history");
-
}
/** Opens the files chosen in the given file selector, and returns an
diff --git a/drjava/src/edu/rice/cs/drjava/model/repl/JavaInterpreterTest.java b/drjava/src/edu/rice/cs/drjava/model/repl/JavaInterpreterTest.java
index bb759eb64..6d2feefc4 100644
--- a/drjava/src/edu/rice/cs/drjava/model/repl/JavaInterpreterTest.java
+++ b/drjava/src/edu/rice/cs/drjava/model/repl/JavaInterpreterTest.java
@@ -40,6 +40,7 @@
/** Tests the functionality of the repl interpreter.
* @version $Id$
*/
+@SuppressWarnings("deprecation")
public class JavaInterpreterTest extends DrJavaTestCase {
// ***************************
@@ -96,15 +97,15 @@ private Object interpret(String s) throws InterpreterException {
@SuppressWarnings({"unchecked","rawtypes"})
public void testConstants() throws InterpreterException {
Pair[] cases = new Pair[] {
- Pair.make("5", (Object) new Integer(5)),
- Pair.make("1356", (Object) new Integer(1356)),
+ Pair.make("5", (Object) Integer.valueOf(5)),
+ Pair.make("1356", (Object) Integer.valueOf(1356)),
Pair.make("true", (Object) Boolean.TRUE),
Pair.make("false", (Object) Boolean.FALSE),
- Pair.make("\'c\'", (Object) new Character('c')),
- Pair.make("1.345", (Object) new Double(1.345)),
+ Pair.make("\'c\'", (Object) Character.valueOf('c')),
+ Pair.make("1.345", (Object) Double.valueOf(1.345)),
Pair.make("\"buwahahahaha!\"", (Object) "buwahahahaha!"),
Pair.make("\"yah\\\"eh\\\"\"", (Object) "yah\"eh\""),
- Pair.make("'\\''", (Object) new Character('\''))
+ Pair.make("'\\''", (Object) Character.valueOf('\''))
};
tester(cases);
}
@@ -152,33 +153,33 @@ public void testShortCircuit() throws InterpreterException {
public void testIntegerOps() throws InterpreterException {
Pair[] cases = new Pair[] {
// plus
- Pair.make("5+6", (Object) new Integer(5 + 6)),
+ Pair.make("5+6", (Object) Integer.valueOf(5 + 6)),
// minus
- Pair.make("6-5", (Object) new Integer(6 - 5)),
+ Pair.make("6-5", (Object) Integer.valueOf(6 - 5)),
// times
- Pair.make("6*5", (Object) new Integer(6*5)),
+ Pair.make("6*5", (Object) Integer.valueOf(6*5)),
// divide
- Pair.make("6/5", (Object) new Integer(6/5)),
+ Pair.make("6/5", (Object) Integer.valueOf(6/5)),
// modulo
- Pair.make("6%5", (Object) new Integer(6%5)),
+ Pair.make("6%5", (Object) Integer.valueOf(6%5)),
// bit and
- Pair.make("6&5", (Object) new Integer(6 & 5)),
+ Pair.make("6&5", (Object) Integer.valueOf(6 & 5)),
// bit or
- Pair.make("6 | 5", (Object) new Integer(6 | 5)),
+ Pair.make("6 | 5", (Object) Integer.valueOf(6 | 5)),
// bit xor
- Pair.make("6^5", (Object) new Integer(6 ^ 5)),
+ Pair.make("6^5", (Object) Integer.valueOf(6 ^ 5)),
// bit complement
- Pair.make("~6", (Object) new Integer(~6)),
+ Pair.make("~6", (Object) Integer.valueOf(~6)),
// unary plus
- Pair.make(" + 5", (Object) new Integer(+5)),
+ Pair.make(" + 5", (Object) Integer.valueOf(+5)),
// unary minus
- Pair.make("-5", (Object) new Integer(-5)),
+ Pair.make("-5", (Object) Integer.valueOf(-5)),
// left shift
- Pair.make("400 << 5", (Object) new Integer(400 << 5)),
+ Pair.make("400 << 5", (Object) Integer.valueOf(400 << 5)),
// right shift
- Pair.make("400 >> 5", (Object) new Integer(400 >> 5)),
+ Pair.make("400 >> 5", (Object) Integer.valueOf(400 >> 5)),
// unsigned right shift
- Pair.make("400 >>> 5", (Object) new Integer(400 >>> 5)),
+ Pair.make("400 >>> 5", (Object) Integer.valueOf(400 >>> 5)),
// less than
Pair.make("5 < 4", (Object) Boolean.valueOf(5 < 4)),
// less than or equal to
@@ -214,19 +215,19 @@ public void testDoubleOps() throws InterpreterException {
// not equal to
Pair.make("5.5 != 5.5", (Object) Boolean.valueOf(5 != 5)),
// unary plus
- Pair.make(" + 5.6", (Object) new Double(+5.6)),
+ Pair.make(" + 5.6", (Object) Double.valueOf(+5.6)),
// unary minus
- Pair.make("-5.6", (Object) new Double(-5.6)),
+ Pair.make("-5.6", (Object) Double.valueOf(-5.6)),
// times
- Pair.make("5.6 * 4.5", (Object) new Double(5.6*4.5)),
+ Pair.make("5.6 * 4.5", (Object) Double.valueOf(5.6*4.5)),
// divide
- Pair.make("5.6 / 3.4", (Object) new Double(5.6/3.4)),
+ Pair.make("5.6 / 3.4", (Object) Double.valueOf(5.6/3.4)),
// modulo
- Pair.make("5.6 % 3.4", (Object) new Double(5.6%3.4)),
+ Pair.make("5.6 % 3.4", (Object) Double.valueOf(5.6%3.4)),
// plus
- Pair.make("5.6 + 6.7", (Object) new Double(5.6 + 6.7)),
+ Pair.make("5.6 + 6.7", (Object) Double.valueOf(5.6 + 6.7)),
// minus
- Pair.make("4.5 - 3.4", (Object) new Double(4.5 - 3.4)),
+ Pair.make("4.5 - 3.4", (Object) Double.valueOf(4.5 - 3.4)),
};
tester(cases);
}
@@ -270,7 +271,7 @@ public void testSemicolon() throws InterpreterException {
Pair.make("String s = \"hello\"", (Object) null),
Pair.make("String x = \"hello\";", (Object) null),
Pair.make("char c = 'c'", (Object) null),
- Pair.make("Character d = new Character('d')", (Object) null),
+ Pair.make("Character d = Character.valueOf('d')", (Object) null),
Pair.make("s", "hello"), Pair.make("s;", (Object) null),
Pair.make("x", "hello"), Pair.make("x;", (Object) null),
Pair.make("c", (Object) 'c'), Pair.make("d", (Object) 'd')
@@ -318,11 +319,11 @@ public void testVariableDefaultValues() throws InterpreterException {
Pair[] cases = new Pair[] {
Pair.make("b", (Object) new Byte((byte)0)),
Pair.make("s", (Object) new Short((short)0)),
- Pair.make("i", (Object) new Integer(0)),
- Pair.make("l", (Object) new Long(0L)),
- Pair.make("f", (Object) new Float(0.0f)),
- Pair.make("d", (Object) new Double(0.0d)),
- Pair.make("c", (Object) new Character('\u0000')),
+ Pair.make("i", (Object) Integer.valueOf(0)),
+ Pair.make("l", (Object) Long.valueOf(0L)),
+ Pair.make("f", (Object) Float.valueOf(0.0f)),
+ Pair.make("d", (Object) Double.valueOf(0.0d)),
+ Pair.make("c", (Object) Character.valueOf('\u0000')),
Pair.make("bool", (Object) Boolean.valueOf(false)),
Pair.make("str", (Object) null)
};
@@ -412,7 +413,7 @@ public void testIncompatibleAssignment() throws InterpreterException {
}
// Check that a correct assignment doesn't fail
- _interpreter.interpret("Object o = new Integer(3)");
+ _interpreter.interpret("Object o = Integer.valueOf(3)");
}
/** Test the operation of the TypeCheckerExtension by performing the operations ((false) ? 2/0 : 1) and
@@ -454,9 +455,9 @@ public void testEvaluationVisitorExtensionNO_RESULT() {
// "\"ello\"", _interpreter.interpret("foo.substring(1,5)"));
// _interpreter.defineVariable("x", 3);
// assertEquals("externally defined variable x",
-// new Integer(3), _interpreter.interpret("x"));
+// Integer.valueOf(3), _interpreter.interpret("x"));
// assertEquals("incremented externally defined variable x",
-// new Integer(4), _interpreter.interpret(" + +x"));
+// Integer.valueOf(4), _interpreter.interpret(" + +x"));
// }
// /** Test that the value of a variable can be queried externally. */
@@ -464,7 +465,7 @@ public void testEvaluationVisitorExtensionNO_RESULT() {
// _interpreter.defineVariable("x", 7);
//// Get value of variable externally
// assertEquals("external query for x",
-// new Integer(7), _interpreter.getVariable("x"));
+// Integer.valueOf(7), _interpreter.getVariable("x"));
//
//// Undefined variable
// try {
@@ -535,7 +536,7 @@ public void testArrayCloning() throws InterpreterException {
// DrJava.getConfig().setSetting(OptionConstants.ALLOW_PRIVATE_ACCESS, Boolean.valueOf(true));
// Utilities.clearEventQueue();
// assertEquals("Should be able to access private field i whose value should be 0",
-// new Integer(0),
+// Integer.valueOf(0),
// _interpreter.interpret("new A().i"));
// }
diff --git a/drjava/src/edu/rice/cs/drjava/model/repl/newjvm/MainJVM.java b/drjava/src/edu/rice/cs/drjava/model/repl/newjvm/MainJVM.java
index 5b0c29603..762c39fb0 100644
--- a/drjava/src/edu/rice/cs/drjava/model/repl/newjvm/MainJVM.java
+++ b/drjava/src/edu/rice/cs/drjava/model/repl/newjvm/MainJVM.java
@@ -755,13 +755,13 @@ private void _doStartup() {
// equals(OptionConstants.ConcJUnitCheckChoices.NONE);
// // "threads" is enabled as long as the setting isn't NONE
// props.put("edu.rice.cs.cunit.concJUnit.check.threads.enabled",
-// new Boolean(!none).toString());
+// Boolean.valueOf(!none).toString());
// // "join" is enabled for ALL and NO_LUCKY
// props.put("edu.rice.cs.cunit.concJUnit.check.join.enabled",
-// new Boolean(all || noLucky).toString());
+// Boolean.valueOf(all || noLucky).toString());
// // "lucky" is enabled only for ALL
// props.put("edu.rice.cs.cunit.concJUnit.check.lucky.enabled",
-// new Boolean(all).toString());
+// Boolean.valueOf(all).toString());
// jvmb = jvmb.properties(props);
diff --git a/drjava/src/edu/rice/cs/drjava/model/repl/newjvm/jshell-min-set_documentation.md b/drjava/src/edu/rice/cs/drjava/model/repl/newjvm/jshell-min-set_documentation.md
new file mode 100644
index 000000000..a778e3975
--- /dev/null
+++ b/drjava/src/edu/rice/cs/drjava/model/repl/newjvm/jshell-min-set_documentation.md
@@ -0,0 +1,52 @@
+# InterpreterJVM Documentation
+
+## Primary commands
+To build drjava (2 ways):
+1. **`ant build`** (oftentimes doesn’t work)
+2. **`ant compile`, `ant jar`, `java -jar drjava.jar`**
+
+## Current State of jshell-min-set
+
+### Builds
+The current version of the jshell-min-set branch of DrJava as of November 2024 (commit e4a85d6) compiles and builds with Java 9+ with JShell support. For Java 8 and older versions, this branch will not compile because when the JShell is not found, jshell-min-set is not currently set up to default to a DynamicJava interpreter. If you try to compile with Java 9+ using the --release option to specify Java 8 (i.e., **`ant compile -Djavac.release=8`** then **`ant jar`**), it will compile and jar. However, the jar file output from running these commands seems to only build with Java 9+ running. Attempting to build this jar file with Java 8 and older versions results in an error.
+
+### Structure
+Currently, Dr. Java runs on two JVMs: the Main JVM which runs the **`drjava/drjava/src/edu/rice/cs/drjava/model/repl/newjvm/MainJVM.java`** class and the Interpreter JVM which runs the **`drjava/drjava/src/edu/rice/cs/drjava/model/repl/newjvm/InterpreterJVM.java`** class. Note that in the codebase, the Main JVM and its class may be referred to as the Master JVM and the Interpreter JVM and its class is often referred to as the Slave JVM. The Main JVM runs Dr. Java’s GUI, mainframe, and compilation which is, in essence, the primary functions of the application. The Interpreter / Slave JVM runs JUnit and the Interpreter window which are the secondary portions of the application.
+
+These JVMs communicate via Remote Method Invocation (RMI). The Interpreter / Slave JVM also runs a “demon thread” that checks if the Main JVM still acknowledges its existence. If the Main JVM responds in the affirmative, then the Interpreter / Slave JVM stays alive. If the Main JVM responds in the negative, the Interpreter / Slave JVM shuts down. This is done with the `removeInterpreter` method in **`MainJVM.java`**.
+
+In DrJava, from the user’s perspective when we have a hung computation, the current way to handle this issue in the **`jshell-min-set`** branch is to go to **`Tools -> Reset Interactions and Clear Console`**. Doing this results in the message **`”Resetting Interactions and Clearing Console”`** appearing in the console before the console is cleared.
+
+**Behind the scenes, this is what we know**
+
+From our current working understanding of DrJava we believe the current safe way to kill a JVM in DrJava is by use of `quitSlave()`. Currently `quitSlave()` is called in `MainJVM.java` for `stop()` and `restart(boolean force)`. `quitSlave()` transitions state from RUNNING to STOPPING, calls `attemptQuit(_slave)`, sets `_slave` to null, and then sets `_monitor` to FRESH. `dispose()` is called to clean up external resources and release RMI hooks.
+
+**MainFrame.java**: In MainFrame.java, when resetting the interactions pane and clearing the console, a new AbstractActions is created: `_resetInteractionsAction`. Within this new action, `_doResetInteractions()` is called. Within the `_doResetInteractions()` function, a call to `_interactionsPane.discardUndoEdits()` is made, which discards any edits and resets undoManager, and then a new Thread is started. Now, before `.start()` is called on this new thread, three things of note happen. First,` _model.resetConsole()` is called. This resets the console and fires `consoleReset()` event. Second, `_model.resetInteractions(_model.getWorkingDirectory(), true)` is called. This returns the working directory for the slave (interactions pane) JVM. Third, `_closeSystemInAction.setEnabled(true)` is called. This calls `_interactionsController.setEndOfStream(true)` and `_interactionsController.interruptConsoleInput()`, which sets the end of the stream flag and forces console input to complete without the user hitting `Enter` (called by MainFrame when reset is called so that this lock is released; this method is thread safe) respectively.
+
+**Functions of Note and the Files that Define Them**
+* **GlobalModel.java**: `quit()`: exits the program (only quits if all documents are successfully closed). `forcequit()`: halts the program immediately.
+* **DefaultGlobalModel.java**: `dispose()`: prepares the model to be thrown away.
+* **AbstractMasterJVM.java**: `quitSlave()`: Quits Slave JVM. If a slave is not currently started and running, blocks until that state is reached. `attemptQuit()`: Makes an attempt to invoke slave.quit(), logs an error if it fails. `dispose()`: Frees the resources required for this object to respond to RMI invocations and requires the slave to have quit; blocks until that occurs. An object is no longer useful once it has been disposed of.
+* **InteractionsPane.java**: `discardUndoEdits()`: discards edits and resets undoManager.
+* **InteractionsController.java**: `setEndOfStream()`: sets the end of the stream flag. `interruptConsoleInput():` forces console input to complete without the user hitting `Enter` (called by MainFrame when reset is called so that this lock is released; this method is thread safe) respectively.
+* **FileGroupingState.java**: `getWorkingDirectory()`: returns the working directory for the Slave JVM
+* **InteractionsModel.java**: `resetInterpreter()`: Resets the Java interpreter with working directory wd. `_interactionIsOver()`: Performs the common behavior when an interaction ends (adds completed interaction to history, changes progress of document to false, inserts prompt, and notifies that interaction has ended)
+* **ConsoleDocument.java**: `reset(String banner)`: Resets the document to a clean state and only runs in the event thread; the parameter banner is the value to which to set the banner
+* **InteractionsController.java**: `disableInputs()`: Disables all input to the text box, does not change the appearance of the text
+* **MainFrame.java**: . `_enableInteractionsPane()`: Makes Interactions Pane editable, sets cursor to text cursor, and enables navigation actions within the Interactions Pane. `_disableInteractionsPane()`: Makes Interactions Pane uneditable, sets cursor to waiting cursor, and disables navigation actions within the Interactions Pane.
+**Relationships between files**
+* MainFrame.java invokes `discardUndoEdits()` from InteractionsPane.java, `getWorkingDirectory()`, `resetConsole()`, and `resetInteractions()` from AbstractGlobalModel.java, `setEndOfStream()` and `interruptConsoleInput()` from InteractionsController.java, and `getWorkingWorkingDirectory()` from FileGroupingState.java
+* AbstractGlobalModel.java: invokes `quit()` and `forceQuit()`from GlobalModel.java, and `dispose()` from DefaultGlobalModel.java
+* MainJVM.java invokes `quitSlave()`, `attemptQuit()`, and `dispose()` from AbstractMasterJVM.java
+* InteractionsModel.java invokes `reset(String banner)` from ConsoleDocument.java
+* AbstractGlobalModel.java invokes `consoleReset()` from GlobalEventNotifier.java
+
+### Current Challenges
+Our main challenge is stopping the Interactions Pane when an operation is hanging. This idea of killing the interactions pane becomes more complex when the idea of merging the Main and Secondary JVMs is introduced, a concept we will elaborate on in the Future Work section below. Currently, the only way to stop the interpreter is to reset the interactions page (Tools -> Reset Interactions and Clear Console). If this action is taken, the interactions pane is cleared and all operations and outputs are no longer visible. Note that while the pane is visibly cleared, the history is still intact and you can retrieve singular previous operations by pressing the up key in the interactions pane. Currently, the best way to recover the entirety of the cleared information after resetting the pane is to save your interactions pane history through Tools -> History -> Save Interactions History…. This will save the full history (operations but not their outputs pre and post reset) in a text file located in **`drjava/drjava/src/edu/rice/cs/drjava/model/compiler`**. The best way to save a holistic copy of the interactions pane (operations and their outputs) is to save the interactions pane before resetting it. This can be done by choosing Tools -> Interactions and Console -> Save Copy of Interactions in the top task/tool bar. This option will save a complete record of the interactions pane (operations and outputs) as a .txt file in **`drjava/drjava/src/edu/rice/cs/drjava/model/compiler`**.
+
+## Future Work on jshell-min-set
+Long term, the goal is to integrate the two JVMs into a singular JVM. Currently, the JShell Interpreter is spun up in its own JVM. When the “demon” thread that reaches out to the MainJVM indicates that the MainJVM is no longer acknowledging the Interpreter JVM (sometimes triggered by resetting the interactions pane) the entire JShell Interpreter JVM is killed, and a new one is started. Eventually, with a singular JVM, instead of killing the JVM, there should be the ability to kill the thread. Right now, the prevailing way to potentially implement this functionality is to call `thread.stop()`. However, `thread.stop()` presents many safety issues as the objects it may have interacted with could be left damaged with no warning to the rest of the program.
+
+Additionally, we’d like to be able to stop a hanging operation in the Interactions Pane. Traditionally, the user presses Ctrl+C to terminate a hanging operation and return to a ready prompt in JShell and most other CLI applications. As of right now, the Interactions Pane is not set up to receive multi-key keypress actions nor does it allow any keyboard inputs whenever an operation is running. To rectify this, we would need to change what happens when `_disableInteractionsPane` is called such that the pane is still editable, can receive keyboard input, and can call either `interactionEnded` or `interactionErrorOccurred` in order to terminate the operation. The decision to choose one of the two will come down to whether we want to interpret a hanging operation as an error or simply a characteristic of the operation that was interpreted.
+
+Alternatively, given the limited functionality of JShell in the Interactions Pane (/help doesn’t work, CLI is susceptible to human error in bloated Dr. Java codebase, etc.), one could solve this issue by swapping the JShell specific Interactions Pane with a Terminal / PowerShell pane. With a Terminal / Powershell pane all input, error handling, keyboard interrupts, etc. can be handled by applications native to the user’s device. These panes can even be started with JShell running by programmatically running the `jshell` command and erasing all command history from view before that call. This also allows for users to explore their project’s directories, practice various Linux commands (adding more opportunities for students to learn basic programming practices), and run CLI applications similar to JShell for other languages if they’re working on a Java application that runs programs in other languages.
diff --git a/drjava/src/edu/rice/cs/drjava/ui/AbstractConsoleController.java b/drjava/src/edu/rice/cs/drjava/ui/AbstractConsoleController.java
index 04d7ccbc8..654f8a8a9 100644
--- a/drjava/src/edu/rice/cs/drjava/ui/AbstractConsoleController.java
+++ b/drjava/src/edu/rice/cs/drjava/ui/AbstractConsoleController.java
@@ -180,7 +180,7 @@ public void resetView() {
/** Default cut action. */
Action cutAction = new DefaultEditorKit.CutAction() {
public void actionPerformed(ActionEvent e) {
-
+ assert EventQueue.isDispatchThread();
if (_pane.getSelectedText() != null) {
super.actionPerformed(e);
String s = edu.rice.cs.util.swing.Utilities.getClipboardSelection(_pane);
@@ -192,6 +192,7 @@ public void actionPerformed(ActionEvent e) {
/** Default copy action. */
Action copyAction = new DefaultEditorKit.CopyAction() {
public void actionPerformed(ActionEvent e) {
+ assert EventQueue.isDispatchThread();
if (_pane.getSelectedText() != null) {
super.actionPerformed(e);
String s = edu.rice.cs.util.swing.Utilities.getClipboardSelection(_pane);
diff --git a/drjava/src/edu/rice/cs/drjava/ui/AbstractDJPane.java b/drjava/src/edu/rice/cs/drjava/ui/AbstractDJPane.java
index 73594a49e..c2e2f12d1 100644
--- a/drjava/src/edu/rice/cs/drjava/ui/AbstractDJPane.java
+++ b/drjava/src/edu/rice/cs/drjava/ui/AbstractDJPane.java
@@ -47,6 +47,7 @@
import edu.rice.cs.drjava.DrJavaRoot;
/** This pane class for a SwingDocument. */
+@SuppressWarnings("deprecation")
public abstract class AbstractDJPane extends JTextPane implements OptionConstants, DropTargetListener {
// ------------ FIELDS -----------
diff --git a/drjava/src/edu/rice/cs/drjava/ui/DefinitionsPane.java b/drjava/src/edu/rice/cs/drjava/ui/DefinitionsPane.java
index a87f19ea5..4d1d9caff 100644
--- a/drjava/src/edu/rice/cs/drjava/ui/DefinitionsPane.java
+++ b/drjava/src/edu/rice/cs/drjava/ui/DefinitionsPane.java
@@ -59,6 +59,7 @@
* which cannot be changed.
* @version $Id$
*/
+@SuppressWarnings("deprecation")
public class DefinitionsPane extends AbstractDJPane implements Finalizable {
/** This field NEEDS to be set by setEditorKit() BEFORE any DefinitonsPanes are created. */
diff --git a/drjava/src/edu/rice/cs/drjava/ui/DefinitionsPaneMemoryLeakTest.java b/drjava/src/edu/rice/cs/drjava/ui/DefinitionsPaneMemoryLeakTest.java
index bc394e064..cdbd768b6 100644
--- a/drjava/src/edu/rice/cs/drjava/ui/DefinitionsPaneMemoryLeakTest.java
+++ b/drjava/src/edu/rice/cs/drjava/ui/DefinitionsPaneMemoryLeakTest.java
@@ -298,7 +298,7 @@ public static File dumpHeap() throws IOException, InterruptedException {
LOG.log(line);
// find the PID of JUnitTestRunner, i.e. the PID of the current process
if (line.indexOf("JUnitTestRunner")>=0) {
- pid = new Integer(line.substring(0,line.indexOf(' ')));
+ pid = Integer.valueOf(line.substring(0,line.indexOf(' ')));
}
}
if (pid == null) throw new FileNotFoundException("Could not detect PID");
diff --git a/drjava/src/edu/rice/cs/drjava/ui/DefinitionsPaneTest.java b/drjava/src/edu/rice/cs/drjava/ui/DefinitionsPaneTest.java
index 80d8e862f..9c1e0269b 100644
--- a/drjava/src/edu/rice/cs/drjava/ui/DefinitionsPaneTest.java
+++ b/drjava/src/edu/rice/cs/drjava/ui/DefinitionsPaneTest.java
@@ -50,6 +50,7 @@
/** Tests the Definitions Pane
* @version $Id$
*/
+@SuppressWarnings("deprecation")
public final class DefinitionsPaneTest extends MultiThreadedTestCase {
private volatile MainFrame _frame;
diff --git a/drjava/src/edu/rice/cs/drjava/ui/EditExternalDialog.java b/drjava/src/edu/rice/cs/drjava/ui/EditExternalDialog.java
index 079da853e..1536bca5e 100644
--- a/drjava/src/edu/rice/cs/drjava/ui/EditExternalDialog.java
+++ b/drjava/src/edu/rice/cs/drjava/ui/EditExternalDialog.java
@@ -311,6 +311,7 @@ public void setCurrentDirectory(File dir) {
/** Method that handles the OK button */
private void _ok() {
+ assert EventQueue.isDispatchThread();
_lastState = new FrameState(this);
DrJava.getConfig().setSetting(OptionConstants.EXTERNAL_SAVED_COUNT,
DrJava.getConfig().getSetting(OptionConstants.EXTERNAL_SAVED_COUNT));
@@ -319,6 +320,7 @@ private void _ok() {
/** Edit a command. */
private void _edit() {
+ assert EventQueue.isDispatchThread();
final int selectedIndex = _list.getSelectedIndex();
if ((selectedIndex < 0) || (selectedIndex>=DrJava.getConfig().getSetting(OptionConstants.EXTERNAL_SAVED_COUNT))) {
return;
@@ -550,7 +552,7 @@ public void updateList(int selectedIndex) {
/** Toggle visibility of this frame. Warning, it behaves like a modal dialog. */
public void setVisible(boolean vis) {
- assert EventQueue.isDispatchThread();
+ assert ! _mainFrame.isVisible() || EventQueue.isDispatchThread();
validate();
if (vis) {
updateList(0);
diff --git a/drjava/src/edu/rice/cs/drjava/ui/ErrorPanel.java b/drjava/src/edu/rice/cs/drjava/ui/ErrorPanel.java
index 7c6f2b321..2a03465f1 100644
--- a/drjava/src/edu/rice/cs/drjava/ui/ErrorPanel.java
+++ b/drjava/src/edu/rice/cs/drjava/ui/ErrorPanel.java
@@ -37,11 +37,13 @@
import edu.rice.cs.drjava.model.DJError;
import edu.rice.cs.drjava.model.compiler.CompilerErrorModel;
import edu.rice.cs.drjava.model.ClipboardHistoryModel;
+import edu.rice.cs.drjava.model.print.DrJavaBook;
import edu.rice.cs.util.UnexpectedException;
import edu.rice.cs.util.swing.HighlightManager;
import edu.rice.cs.util.swing.BorderlessScrollPane;
+import edu.rice.cs.util.swing.Utilities;
import edu.rice.cs.util.text.SwingDocument;
-import edu.rice.cs.drjava.model.print.DrJavaBook;
+
import edu.rice.cs.util.swing.RightClickMouseAdapter;
@@ -67,6 +69,7 @@
* TODO: parameterize the types of CompilerErrors (which should be called DJErrors) used here
* @version $Id$
*/
+@SuppressWarnings("deprecation")
public abstract class ErrorPanel extends TabbedPanel implements OptionConstants {
protected static final SimpleAttributeSet NORMAL_ATTRIBUTES = _getNormalAttributes();
@@ -115,6 +118,7 @@ protected static final SimpleAttributeSet _getNormalAttributes() {
return s;
}
+ /* Primary constructor for ErrorPanel class */
public ErrorPanel(SingleDisplayModel model, MainFrame frame, String tabString, String labelString) {
super(frame, tabString);
_model = model;
@@ -155,11 +159,10 @@ public ErrorPanel(SingleDisplayModel model, MainFrame frame, String tabString, S
// _mainPanel.setMinimumSize(new Dimension(225,60));
// We make the vertical scrollbar always there.
- // If we don't, when it pops up it cuts away the right edge of the
- // text. Very bad.
+ // If we don't, when it pops up it cuts away the right edge of thetext. Very bad.
_scroller = new BorderlessScrollPane(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
-
+
_leftPanel.add(_scroller, BorderLayout.CENTER);
_leftPanel.add(_errorNavPanel, BorderLayout.EAST);
@@ -174,9 +177,10 @@ public ErrorPanel(SingleDisplayModel model, MainFrame frame, String tabString, S
_mainPanel.add(_leftPanel, BorderLayout.CENTER);
_mainPanel.add(_rightPanel, BorderLayout.EAST);
- /** Default copy action. Returns focus to the correct pane. */
+ /** Default copy action. Returns focus to the correct pane. Executes in dispatch thread. */
final Action copyAction = new AbstractAction("Copy Contents to Clipboard", MainFrame.getIcon("Copy16.gif")) {
public void actionPerformed(ActionEvent e) {
+ assert EventQueue.isDispatchThread();
getErrorListPane().selectAll();
String t = getErrorListPane().getSelectedText();
if (t != null) {
@@ -187,54 +191,68 @@ public void actionPerformed(ActionEvent e) {
ClipboardHistoryModel.singleton().put(t);
}
}
- }
+ };
};
+
addPopupMenu(copyAction);
+
getPopupMenu().add(new AbstractAction("Save Copy of Contents...", MainFrame.getIcon("Save16.gif")) {
+ /* Executes in dispatch thread. */
public void actionPerformed(ActionEvent e) {
+ assert EventQueue.isDispatchThread();
_frame._saveDocumentCopy(getErrorListPane().getErrorDocument());
}
});
+
getPopupMenu().addSeparator();
+
getPopupMenu().add(new AbstractAction("Print...", MainFrame.getIcon("Print16.gif")) {
+ /* Executes in dispatch thread. */
public void actionPerformed(ActionEvent e) {
+ assert EventQueue.isDispatchThread();
getErrorListPane().getErrorDocument().print();
}
});
+
getPopupMenu().add(new AbstractAction("Print Preview...", MainFrame.getIcon("PrintPreview16.gif")) {
+ /* Executes in dispatch thread. */
public void actionPerformed(ActionEvent e) {
+ assert EventQueue.isDispatchThread();
getErrorListPane().getErrorDocument().preparePrintJob();
new PreviewErrorFrame();
}
});
}
-
+
protected void setErrorListPane(final ErrorListPane elp) {
- if (_popupMenuListener!=null) {
- if ((_scroller!=null) && // unnecessary?
- (_scroller.getViewport()!=null) &&
- (_scroller.getViewport().getView()!=null)) {
+ /* Should this action be performed in the dispatch thread? */
+ if (_popupMenuListener != null) {
+ if ((_scroller.getViewport() != null) && (_scroller.getViewport().getView() != null)) {
_scroller.getViewport().getView().removeMouseListener(_popupMenuListener);
}
}
_scroller.setViewportView(elp);
- if (_popupMenuListener!=null) {
- _scroller.getViewport().getView().addMouseListener(_popupMenuListener);
- }
+ if (_popupMenuListener!=null) { _scroller.getViewport().getView().addMouseListener(_popupMenuListener); }
_nextErrorButton.setEnabled(false);
+
_nextErrorButton.addActionListener(new ActionListener() {
+ /* Executes in dispatch thread. */
public void actionPerformed(ActionEvent e) {
+ assert EventQueue.isDispatchThread();
elp.nextError();
// _prevErrorButton.setEnabled(_errorListPane.hasPrevError());
// _nextErrorButton.setEnabled(_errorListPane.hasNextError());
}
});
+
_prevErrorButton.setEnabled(false);
_prevErrorButton.addActionListener(new ActionListener() {
+ /* Executes in dispatch thread. */
public void actionPerformed(ActionEvent e) {
+ assert EventQueue.isDispatchThread();
elp.prevError();
// _prevErrorButton.setEnabled(_errorListPane.hasPrevError());
// _nextErrorButton.setEnabled(_errorListPane.hasNextError());
@@ -300,21 +318,26 @@ public abstract class ErrorListPane extends JEditorPane implements ClipboardOwne
/** Default cut action. */
volatile Action cutAction = new DefaultEditorKit.CutAction() {
+
+ /* Executes in dispatch thread. */
public void actionPerformed(ActionEvent e) {
+ assert EventQueue.isDispatchThread();
if (getSelectedText() != null) {
super.actionPerformed(e);
- String s = edu.rice.cs.util.swing.Utilities.getClipboardSelection(ErrorListPane.this);
+ String s = Utilities.getClipboardSelection(ErrorListPane.this);
if ((s != null) && (s.length() != 0)) { ClipboardHistoryModel.singleton().put(s); }
}
}
};
-
+
/** Default copy action. */
volatile Action copyAction = new DefaultEditorKit.CopyAction() {
+ /* Executes in dispatch thread. */
public void actionPerformed(ActionEvent e) {
+ assert EventQueue.isDispatchThread();
if (getSelectedText() != null) {
super.actionPerformed(e);
- String s = edu.rice.cs.util.swing.Utilities.getClipboardSelection(ErrorListPane.this);
+ String s = Utilities.getClipboardSelection(ErrorListPane.this);
if (s != null && s.length() != 0) { ClipboardHistoryModel.singleton().put(s); }
}
}
@@ -322,6 +345,7 @@ public void actionPerformed(ActionEvent e) {
/** No-op paste action. */
volatile Action pasteAction = new DefaultEditorKit.PasteAction() {
+ /* Executes in any thread. */
public void actionPerformed(ActionEvent e) { }
};
@@ -497,14 +521,13 @@ private int _getIndexForError(DJError error) {
/** @return true if the text selection interval is empty. */
protected boolean _isEmptySelection() { return getSelectionStart() == getSelectionEnd(); }
- /** Update the pane which holds the list of errors for the viewer.
- * @param done boolean
- */
+ /** Update the pane which holds the list of errors for the viewer. Only executes in the dispatch thread.
+ * @param done boolean
+ */
protected void updateListPane(boolean done) {
try {
_errorListPositions = new Position[_numErrors];
_errorTable.clear();
-
if (_numErrors == 0) _updateNoErrors(done);
else _updateWithErrors();
}
@@ -817,9 +840,8 @@ void switchToError(DJError error) {
if (! prevDoc.equals(doc)) {
model.setActiveDocument(doc);
EventQueue.invokeLater(new Runnable() {
- public void run() {
- model.addToBrowserHistory();
- } });
+ public void run() { model.addToBrowserHistory(); }
+ });
}
else model.refreshActiveDocument();
@@ -836,8 +858,7 @@ public void run() {
* is unhighlighted and the new error is not highlighted because the CaretListener does not act because there
* is no change in caret position. (This is the only place where updateHighlight was called from before) */
defPane.getErrorCaretListener().updateHighlight(errPos);
- }
-
+ }
}
// The following line is a brute force hack that fixed a bug plaguing the DefinitionsPane immediately after a compilation
// with errors. In some cases (which were consistently reproducible), the DefinitionsPane editing functions would break
@@ -960,11 +981,10 @@ protected void _popupAction(MouseEvent e) {
}
};
addMouseListener(_popupMenuListener);
- if (_scroller!=null) { // test unnecessary?
- _scroller.addMouseListener(_popupMenuListener);
- if (_scroller.getViewport().getView()!=null) {
- _scroller.getViewport().getView().addMouseListener(_popupMenuListener);
- }
+
+ _scroller.addMouseListener(_popupMenuListener);
+ if (_scroller.getViewport().getView() != null) {
+ _scroller.getViewport().getView().addMouseListener(_popupMenuListener);
}
}
}
diff --git a/drjava/src/edu/rice/cs/drjava/ui/FindReplacePanel.java b/drjava/src/edu/rice/cs/drjava/ui/FindReplacePanel.java
index ae8ff615b..992a66e99 100644
--- a/drjava/src/edu/rice/cs/drjava/ui/FindReplacePanel.java
+++ b/drjava/src/edu/rice/cs/drjava/ui/FindReplacePanel.java
@@ -56,6 +56,7 @@
/** The tabbed panel that handles requests for finding and replacing text.
* @version $Id$
*/
+@SuppressWarnings("deprecation")
class FindReplacePanel extends TabbedPanel implements ClipboardOwner {
/* Other bracketing options:
diff --git a/drjava/src/edu/rice/cs/drjava/ui/GenerateCustomDrJavaJarFrame.java b/drjava/src/edu/rice/cs/drjava/ui/GenerateCustomDrJavaJarFrame.java
index 406cc2cdb..d75a7e4b8 100644
--- a/drjava/src/edu/rice/cs/drjava/ui/GenerateCustomDrJavaJarFrame.java
+++ b/drjava/src/edu/rice/cs/drjava/ui/GenerateCustomDrJavaJarFrame.java
@@ -189,6 +189,7 @@ public boolean validateTextField() {
/** Resets the frame and hides it. */
public void close() {
+ assert EventQueue.isDispatchThread();
setVisible(false);
reset();
}
diff --git a/drjava/src/edu/rice/cs/drjava/ui/InteractionsController.java b/drjava/src/edu/rice/cs/drjava/ui/InteractionsController.java
index 252e0b99b..2d65ad5bd 100644
--- a/drjava/src/edu/rice/cs/drjava/ui/InteractionsController.java
+++ b/drjava/src/edu/rice/cs/drjava/ui/InteractionsController.java
@@ -92,6 +92,7 @@
*
* @version $Id$
*/
+@SuppressWarnings("deprecation")
public class InteractionsController extends AbstractConsoleController {
/* InteractionsDocument _adapter is inherited from AbstractConsoleController. */
diff --git a/drjava/src/edu/rice/cs/drjava/ui/InteractionsPane.java b/drjava/src/edu/rice/cs/drjava/ui/InteractionsPane.java
index 820517fe3..9cd20f197 100644
--- a/drjava/src/edu/rice/cs/drjava/ui/InteractionsPane.java
+++ b/drjava/src/edu/rice/cs/drjava/ui/InteractionsPane.java
@@ -55,6 +55,7 @@
/** The view component for repl interaction.
* @version $Id$
*/
+@SuppressWarnings("deprecation")
public abstract class InteractionsPane extends AbstractDJPane implements OptionConstants, ClipboardOwner {
public static Log LOG = new Log("InteractionsPane.txt", false);
diff --git a/drjava/src/edu/rice/cs/drjava/ui/InteractionsPaneTest.java b/drjava/src/edu/rice/cs/drjava/ui/InteractionsPaneTest.java
index a7cdad32b..5165d357f 100644
--- a/drjava/src/edu/rice/cs/drjava/ui/InteractionsPaneTest.java
+++ b/drjava/src/edu/rice/cs/drjava/ui/InteractionsPaneTest.java
@@ -49,6 +49,7 @@
/** Test functions of InteractionsPane.
* @version $Id$
*/
+@SuppressWarnings("deprecation")
public final class InteractionsPaneTest extends DrJavaTestCase {
private static final char UNDEFINED = KeyEvent.CHAR_UNDEFINED;
diff --git a/drjava/src/edu/rice/cs/drjava/ui/JUnitPanel.java b/drjava/src/edu/rice/cs/drjava/ui/JUnitPanel.java
index 01db9187f..11489cf5a 100644
--- a/drjava/src/edu/rice/cs/drjava/ui/JUnitPanel.java
+++ b/drjava/src/edu/rice/cs/drjava/ui/JUnitPanel.java
@@ -153,6 +153,7 @@ public void setJUnitInProgress() {
/** Closes this panel and resets the corresponding model. */
@Override
protected void _close() {
+ assert EventQueue.isDispatchThread();
super._close();
getModel().getJUnitModel().resetJUnitErrors();
reset();
@@ -160,7 +161,7 @@ protected void _close() {
/** Reset the errors to the current error information. */
public void reset() {
- assert ! _mainFrame.isVisible() || EventQueue.isDispatchThread();
+ assert EventQueue.isDispatchThread();
JUnitErrorModel junitErrorModel = getModel().getJUnitModel().getJUnitErrorModel();
boolean testsHaveRun = false;
if (junitErrorModel != null) {
@@ -176,7 +177,7 @@ public void reset() {
* @param numTests number of tests to be counted
*/
public void progressReset(int numTests) {
- assert ! _mainFrame.isVisible() || EventQueue.isDispatchThread();
+ assert EventQueue.isDispatchThread();
_progressBar.reset();
_progressBar.start(numTests);
_testsSuccessful = true;
@@ -187,7 +188,7 @@ public void progressReset(int numTests) {
* @param successful Whether the last test was successful or not.
*/
public void progressStep(boolean successful) {
- assert ! _mainFrame.isVisible() || EventQueue.isDispatchThread();
+ assert EventQueue.isDispatchThread();
_testCount++;
_testsSuccessful &= successful;
_progressBar.step(_testCount, _testsSuccessful);
@@ -196,7 +197,7 @@ public void progressStep(boolean successful) {
public void testStarted(String className, String testName) { }
private void _displayStackTrace (JUnitError e) {
- assert ! _mainFrame.isVisible() || EventQueue.isDispatchThread();
+ assert EventQueue.isDispatchThread();
_errorLabel.setText((e.isWarning() ? "Error: " : "Failure: ") +
e.message());
_fileLabel.setText("File: " + (new File(e.fileName())).getName());
@@ -254,7 +255,7 @@ private String _getClassFromName(String name) {
* @param name the name of the test being run
*/
public void testStarted(String name) {
- assert ! _mainFrame.isVisible() || EventQueue.isDispatchThread();
+ assert EventQueue.isDispatchThread();
if (name.indexOf('(') < 0) return;
String testName = _getTestFromName(name);
@@ -263,7 +264,7 @@ public void testStarted(String name) {
if (fullName.equals(JUNIT_WARNING)) return;
ErrorDocument doc = getErrorDocument();
- // Converted this GUI operation to a Runnable and use invokeLater
+ // Converted this GUI operation to a Runnable and used invokeLater
Utilities.invokeLater(new Runnable() {
public void run() {
try {
@@ -297,14 +298,14 @@ public void run() {
* @param causedError whether the test caused an error
*/
public void testEnded(String name, boolean wasSuccessful, boolean causedError) {
- assert ! _mainFrame.isVisible() || EventQueue.isDispatchThread();
+ assert EventQueue.isDispatchThread();
if (name.indexOf('(')<0) return;
- String testName = _getTestFromName(name);
- String fullName = _getClassFromName(name) + "." + testName;
+ final String testName = _getTestFromName(name);
+ final String fullName = _getClassFromName(name) + "." + testName;
if (fullName.equals(JUNIT_WARNING)) return;
// TODO: convert this GUI operation to a Runnable and use invokeLater
- ErrorDocument doc = getErrorDocument();
+ final ErrorDocument doc = getErrorDocument();
Utilities.invokeLater(new Runnable() {
public void run() {
Position namePos = _runningTestNamePositions.get(fullName);
@@ -339,7 +340,7 @@ public void setJUnitInProgress() {
/** Used to show that testing was unsuccessful. */
protected void _updateWithErrors() throws BadLocationException {
- assert ! _mainFrame.isVisible() || EventQueue.isDispatchThread();
+ assert EventQueue.isDispatchThread();
//DefaultStyledDocument doc = new DefaultStyledDocument();
ErrorDocument doc = getErrorDocument();
// _checkSync(doc);
@@ -370,8 +371,8 @@ protected String _getNumErrorsMessage(String failureName, String failureMeaning)
return numErrMsg.toString();
}
- protected void _updateWithErrors(String failureName, String failureMeaning, ErrorDocument doc)
- throws BadLocationException {
+ protected void _updateWithErrors(String failureName, String failureMeaning, ErrorDocument doc) throws BadLocationException {
+ assert EventQueue.isDispatchThread();
// Print how many errors
_replaceInProgressText(_getNumErrorsMessage(failureName, failureMeaning));
@@ -386,7 +387,7 @@ protected void _updateWithErrors(String failureName, String failureMeaning, Erro
* @throws BadLocationException if attempts to reference an invalid location
*/
public void _replaceInProgressText(String msg) throws BadLocationException {
- assert ! _mainFrame.isVisible() || EventQueue.isDispatchThread();
+ assert EventQueue.isDispatchThread();
int start = 0;
if (_warnedOutOfSync) { start = TEST_OUT_OF_SYNC.length(); }
int len = START_JUNIT_MSG.length();
@@ -406,6 +407,7 @@ public void _replaceInProgressText(String msg) throws BadLocationException {
/** Updates the list pane with no errors. */
protected void _updateNoErrors(boolean haveTestsRun) throws BadLocationException {
+ assert EventQueue.isDispatchThread();
//DefaultStyledDocument doc = new DefaultStyledDocument();
// _checkSync(getDocument());
_replaceInProgressText(haveTestsRun ? JUNIT_FINISHED_MSG : NO_TESTS_MSG);
@@ -436,7 +438,7 @@ protected void _updateNoErrors(boolean haveTestsRun) throws BadLocationException
private void _setupStackTraceFrame() {
//DrJava.consoleOut().println("Stack Trace for Error: \n" + e.stackTrace());
- assert ! _mainFrame.isVisible() || EventQueue.isDispatchThread();
+ assert EventQueue.isDispatchThread();
JDialog _dialog = new JDialog(_frame,"JUnit Error Stack Trace",false);
_stackFrame = _dialog;
_stackTextArea = new JTextArea();
@@ -475,7 +477,7 @@ public void actionPerformed(ActionEvent e) {
* and enabling the _showStackTraceButton.
*/
public void selectItem(DJError error) {
- assert ! _mainFrame.isVisible() || EventQueue.isDispatchThread();
+ assert EventQueue.isDispatchThread();
super.selectItem(error);
_error = (JUnitError) error;
_showStackTraceButton.setEnabled(true);
@@ -484,7 +486,7 @@ public void selectItem(DJError error) {
/** Overrides _removeListHighlight in ErrorListPane to disable the _showStackTraceButton. */
protected void _removeListHighlight() {
- assert ! _mainFrame.isVisible() || EventQueue.isDispatchThread();
+ assert EventQueue.isDispatchThread();
super._removeListHighlight();
_showStackTraceButton.setEnabled(false);
}
@@ -521,7 +523,7 @@ public void mouseReleased(MouseEvent e) {
* @return true iff the mouse click is over an error
*/
private boolean _selectError(MouseEvent e) {
- assert ! _mainFrame.isVisible() || EventQueue.isDispatchThread();
+ assert EventQueue.isDispatchThread();
//TODO: get rid of cast in the next line, if possible
_error = (JUnitError)_errorAtPoint(e.getPoint());
@@ -539,7 +541,7 @@ private boolean _selectError(MouseEvent e) {
* @param e the MouseEvent correponding to this click
*/
protected void _popupAction(MouseEvent e) {
- assert ! _mainFrame.isVisible() || EventQueue.isDispatchThread();
+ assert EventQueue.isDispatchThread();
_popMenu.show(e.getComponent(), e.getX(), e.getY());
}
}
diff --git a/drjava/src/edu/rice/cs/drjava/ui/JarOptionsDialog.java b/drjava/src/edu/rice/cs/drjava/ui/JarOptionsDialog.java
index c92a6b131..81b03d996 100644
--- a/drjava/src/edu/rice/cs/drjava/ui/JarOptionsDialog.java
+++ b/drjava/src/edu/rice/cs/drjava/ui/JarOptionsDialog.java
@@ -572,7 +572,7 @@ public String convertFileToString(File f) {
private void setEnabled() {
// Utilities.invokeLater(new Runnable() {
// public void run() {
- assert EventQueue.isDispatchThread();
+ assert ! _mainFrame.isVisible() || EventQueue.isDispatchThread();
_okButton.setEnabled(true);
// }
// });
@@ -1044,7 +1044,7 @@ private boolean _saveSettings() {
/** Toggle visibility of this frame. Warning, it behaves like a modal dialog. */
public void setVisible(boolean vis) {
- assert EventQueue.isDispatchThread();
+ assert ! _mainFrame.isVisible() || EventQueue.isDispatchThread();
validate();
if (vis) {
_mainFrame.hourglassOn();
diff --git a/drjava/src/edu/rice/cs/drjava/ui/JavadocErrorPanel.java b/drjava/src/edu/rice/cs/drjava/ui/JavadocErrorPanel.java
index b68b2395a..912b26c03 100644
--- a/drjava/src/edu/rice/cs/drjava/ui/JavadocErrorPanel.java
+++ b/drjava/src/edu/rice/cs/drjava/ui/JavadocErrorPanel.java
@@ -31,6 +31,7 @@
import edu.rice.cs.drjava.model.SingleDisplayModel;
import edu.rice.cs.drjava.model.compiler.CompilerErrorModel;
+import java.awt.EventQueue;
import javax.swing.text.*;
/** * The panel which displays all the Javadoc parsing errors.
@@ -59,6 +60,7 @@ public JavadocErrorListPane getErrorListPane() {
}
protected CompilerErrorModel getErrorModel() {
+ assert EventQueue.isDispatchThread();
return getModel().getJavadocModel().getJavadocErrorModel();
}
@@ -70,6 +72,7 @@ public void setJavadocInProgress() {
/** Closes this panel and resets the corresponding model. */
@Override
protected void _close() {
+ assert EventQueue.isDispatchThread();
super._close();
getModel().getJavadocModel().resetJavadocErrors();
reset();
@@ -77,6 +80,7 @@ protected void _close() {
/** Reset the errors to the current error information. */
public void reset() {
+ assert EventQueue.isDispatchThread();
CompilerErrorModel model = getModel().getJavadocModel().getJavadocErrorModel();
if (model != null) _numErrors = model.getNumErrors();
else _numErrors = 0;
diff --git a/drjava/src/edu/rice/cs/drjava/ui/MainFrame.java b/drjava/src/edu/rice/cs/drjava/ui/MainFrame.java
index e132cfeda..b4f12086d 100644
--- a/drjava/src/edu/rice/cs/drjava/ui/MainFrame.java
+++ b/drjava/src/edu/rice/cs/drjava/ui/MainFrame.java
@@ -142,13 +142,15 @@ public class MainFrame extends SwingFrame implements ClipboardOwner, DropTargetL
// ------ Field Declarations -------
- /** The model which controls all logic in DrJava. */
+ /** The model which controls all logic in DrJava. Cannot be final because it is initialized in dispatch thread. */
private volatile AbstractGlobalModel _model;
- /** The main model listener attached by the main frame to the global model */
+ /** The main model listener attached by the main frame to the global model.
+ * Cannot be final because it is initialized in dispatch thread. */
private volatile ModelListener _mainListener;
- /** Maps an OpenDefDoc to its JScrollPane. Why doesn't OpenDefDoc contain a defScrollPane field? */
+ /** Maps an OpenDefDoc to its JScrollPane. Cannot be final because it is initialized in dispatch thread.
+ * Why doesn't OpenDefDoc contain a defScrollPane field? */
private volatile HashMap _defScrollPanes;
/** The currently displayed DefinitionsPane. */
@@ -1324,30 +1326,35 @@ public void actionPerformed(ActionEvent e) {
};*/
/** Undoes the last change to the active definitions document. */
- private final DelegatingAction _undoAction = new DelegatingAction() {
+ private final DelegatingAction _undoAction = new DelegatingAction() {
+ /* Executes in dispatch thread */
public void actionPerformed(ActionEvent e) {
+ assert EventQueue.isDispatchThread();
// use whether the delegatee is the Interactions Pane's action instead of whether
// _interactionsPane.hasFocus(), because the focus will be lost when the user clicks
// on the menu bar.
final boolean intPaneFocused = (getDelegatee()==_interactionsController.getUndoAction());
if (intPaneFocused) _interactionsPane.endCompoundEdit();
else _currentDefPane.endCompoundEdit();
-
- super.actionPerformed(e);
+ super.actionPerformed(e);
+
if (intPaneFocused) _interactionsPane.requestFocusInWindow();
else {
_currentDefPane.requestFocusInWindow();
OpenDefinitionsDocument doc = _model.getActiveDocument();
_saveAction.setEnabled(doc.isModifiedSinceSave() || doc.isUntitled());
}
- }
+ };
};
/** Redoes the last undo to the active definitions document. */
private final DelegatingAction _redoAction = new DelegatingAction() {
+ /* Execute in dispatch thread */
public void actionPerformed(ActionEvent e) {
- // use whether the delegatee is the Interactions Pane's action instead of whether
+ assert EventQueue.isDispatchThread();
+
+ // use whether the delegatee is the Interactions Pane's action instead of whether
// _interactionsPane.hasFocus(), because the focus will be lost when the user clicks
// on the menu bar.
final boolean intPaneFocused = (getDelegatee()==_interactionsController.getRedoAction());
@@ -1359,7 +1366,7 @@ public void actionPerformed(ActionEvent e) {
OpenDefinitionsDocument doc = _model.getActiveDocument();
_saveAction.setEnabled(doc.isModifiedSinceSave() || doc.isUntitled());
}
- }
+ };
};
/** Quits DrJava. Optionally displays a prompt before quitting. */
@@ -1429,7 +1436,7 @@ public void actionPerformed(ActionEvent ae) {
}
};
- /** Asks the user for a line number and goes there. */
+ /** Asks the user for a line number and goes there. */ /* UNSAFE? */
private final Action _gotoLineAction = new AbstractAction("Go to Line...") {
public void actionPerformed(ActionEvent ae) {
int pos = _gotoLine();
@@ -2759,7 +2766,7 @@ public void actionPerformed(ActionEvent ae) {
/** Toggle a bookmark. */
public void toggleBookmark() {
// _log.log("MainFrame.toggleBookmark called");
- assert EventQueue.isDispatchThread();
+ assert ! MainFrame.this.isVisible() || EventQueue.isDispatchThread();
addToBrowserHistory();
_model._toggleBookmark(_currentDefPane.getSelectionStart(), _currentDefPane.getSelectionEnd());
showTab(_bookmarksPanel, true);
@@ -4589,6 +4596,7 @@ public void updateStatusField(String text) {
/** Updates the status field with the current status of the Definitions Pane. */
public void updateStatusField() {
+ assert EventQueue.isDispatchThread();
OpenDefinitionsDocument doc = _model.getActiveDocument();
String fileName = doc.getCompletePath();
if (! fileName.equals(_fileTitle)) {
@@ -4774,6 +4782,7 @@ private void _processDocs(Collection docs, Runnable1 op = new Runnable1() {
public void run(OpenDefinitionsDocument d) { _model.addAuxiliaryFile(d); }
};
@@ -4782,6 +4791,7 @@ void _moveToAuxiliary() {
/** Removes selected auxiliary files. */
private void _removeAuxiliary() {
+ assert EventQueue.isDispatchThread();
Runnable1 op = new Runnable1() {
public void run(OpenDefinitionsDocument d) { _model.removeAuxiliaryFile(d); }
};
@@ -5572,11 +5582,12 @@ void quit() {
}
}
}
+
_executeExternalDialog.setVisible(false);
// tried passing false here. seemed to help with bug
// [ 1478796 ] DrJava Does Not Shut Down With Project Open
// on HP tc1100 and Toshiba Portege tablet PCs, but did not help in all cases
-
+
if (! _closeProject(true)) { return; /* if user pressed cancel, do not quit */ }
if (!_updateSavedConfiguration()) { return; /* if user pressed cancel, do not quit */ }
@@ -5585,7 +5596,7 @@ void quit() {
dispose(); // Free GUI elements of this frame
_model.quit();
}
-
+
boolean _updateSavedConfiguration() {
_recentFileManager.saveRecentFiles();
_recentProjectManager.saveRecentFiles();
@@ -8782,7 +8793,7 @@ protected void _enableInteractionsPane() {
/** Comment current selection using wing commenting. public for testing purposes only. Runs in event thread. */
public void commentLines() {
- assert EventQueue.isDispatchThread();
+ assert ! MainFrame.this.isVisible() || EventQueue.isDispatchThread();
// Delegate everything to the DefinitionsDocument.
OpenDefinitionsDocument openDoc = _model.getActiveDocument();
diff --git a/drjava/src/edu/rice/cs/drjava/ui/MainFrameTest.java b/drjava/src/edu/rice/cs/drjava/ui/MainFrameTest.java
index d277f4048..a8741b499 100644
--- a/drjava/src/edu/rice/cs/drjava/ui/MainFrameTest.java
+++ b/drjava/src/edu/rice/cs/drjava/ui/MainFrameTest.java
@@ -56,6 +56,7 @@
/** Test functions of MainFrame.
* @version $Id$
*/
+@SuppressWarnings("deprecation")
public final class MainFrameTest extends MultiThreadedTestCase {
private volatile MainFrame _frame;
diff --git a/drjava/src/edu/rice/cs/drjava/ui/NewJavaClassDialog.java b/drjava/src/edu/rice/cs/drjava/ui/NewJavaClassDialog.java
index a92666965..771cf06c9 100644
--- a/drjava/src/edu/rice/cs/drjava/ui/NewJavaClassDialog.java
+++ b/drjava/src/edu/rice/cs/drjava/ui/NewJavaClassDialog.java
@@ -414,7 +414,7 @@ public void actionPerformed(ActionEvent actionEvent) {
* @param vis true if frame should be shown, false if it should be hidden.
*/
public void setVisible(boolean vis) {
- assert EventQueue.isDispatchThread();
+ assert ! _mainFrame.isVisible() || EventQueue.isDispatchThread();
validate();
if (vis) {
_mainFrame.hourglassOn();
diff --git a/drjava/src/edu/rice/cs/drjava/ui/NewVersionPopup.java b/drjava/src/edu/rice/cs/drjava/ui/NewVersionPopup.java
index 30c13d01e..f56130ad8 100644
--- a/drjava/src/edu/rice/cs/drjava/ui/NewVersionPopup.java
+++ b/drjava/src/edu/rice/cs/drjava/ui/NewVersionPopup.java
@@ -655,7 +655,7 @@ public static Date getBuildTime(URL url, Box versionStringRef) {
/** Toggle visibility of this frame. Warning, it behaves like a modal dialog. */
public void setVisible(boolean vis) {
- assert EventQueue.isDispatchThread();
+ assert ! _mainFrame.isVisible() || EventQueue.isDispatchThread();
validate();
if (vis) {
_mainFrame.hourglassOn();
diff --git a/drjava/src/edu/rice/cs/drjava/ui/PreviewFrame.java b/drjava/src/edu/rice/cs/drjava/ui/PreviewFrame.java
index f2dbb240e..0e3163e84 100644
--- a/drjava/src/edu/rice/cs/drjava/ui/PreviewFrame.java
+++ b/drjava/src/edu/rice/cs/drjava/ui/PreviewFrame.java
@@ -47,6 +47,7 @@
/** DrJava's print preview window
* @version $Id$
*/
+@SuppressWarnings("deprecation")
public abstract class PreviewFrame extends SwingFrame {
protected final SingleDisplayModel _model;
diff --git a/drjava/src/edu/rice/cs/drjava/ui/ReverseHighlighter.java b/drjava/src/edu/rice/cs/drjava/ui/ReverseHighlighter.java
index cdf2575f5..af2d0cc4a 100644
--- a/drjava/src/edu/rice/cs/drjava/ui/ReverseHighlighter.java
+++ b/drjava/src/edu/rice/cs/drjava/ui/ReverseHighlighter.java
@@ -35,12 +35,12 @@
/** Implements the Highlighter interfaces. Implements a simple highlight painter, but stores
* the highlights in reverse order. That means that the selection (for copying) is always
- * the foremost hightlight, and after that, the highlights are drawn from most recent
- * to oldest.
+ * the foremost highlight, and after that, the highlights are drawn from most recent to oldest.
* Based on DefaultHighlighter by Timothy Prinzing, version 1.39 12/19/03
- * Unfortunately, as the vector of highlights in DefaultHighlighter was private, there was
+ * Unfortunately, since the vector of highlights in DefaultHighlighter was private, there was
* no efficient way to make use of inheritance.
*/
+@SuppressWarnings("deprecation")
public class ReverseHighlighter extends DefaultHighlighter {
/** Creates a new ReverseHighlighter object. */
diff --git a/drjava/src/edu/rice/cs/drjava/ui/config/BooleanOptionComponentTest.java b/drjava/src/edu/rice/cs/drjava/ui/config/BooleanOptionComponentTest.java
index 0010ef66e..3d3fb8d6f 100644
--- a/drjava/src/edu/rice/cs/drjava/ui/config/BooleanOptionComponentTest.java
+++ b/drjava/src/edu/rice/cs/drjava/ui/config/BooleanOptionComponentTest.java
@@ -53,7 +53,7 @@ protected void setUp() throws Exception {
public void testCancelDoesNotChangeConfig() {
- Boolean testBoolean = new Boolean (!DrJava.getConfig().getSetting(OptionConstants.LINEENUM_ENABLED).booleanValue());
+ Boolean testBoolean = Boolean.valueOf(!DrJava.getConfig().getSetting(OptionConstants.LINEENUM_ENABLED).booleanValue());
_option.setValue(testBoolean);
Utilities.clearEventQueue();
@@ -68,7 +68,7 @@ public void testCancelDoesNotChangeConfig() {
}
public void testApplyDoesChangeConfig() {
- Boolean testBoolean = new Boolean (!DrJava.getConfig().getSetting(OptionConstants.LINEENUM_ENABLED).booleanValue());
+ Boolean testBoolean = Boolean.valueOf(!DrJava.getConfig().getSetting(OptionConstants.LINEENUM_ENABLED).booleanValue());
_option.setValue(testBoolean);
Utilities.clearEventQueue();
@@ -80,7 +80,7 @@ public void testApplyDoesChangeConfig() {
}
public void testApplyThenResetDefault() {
- Boolean testBoolean = new Boolean (!DrJava.getConfig().getSetting(OptionConstants.LINEENUM_ENABLED).booleanValue());
+ Boolean testBoolean = Boolean.valueOf(!DrJava.getConfig().getSetting(OptionConstants.LINEENUM_ENABLED).booleanValue());
_option.setValue(testBoolean);
Utilities.clearEventQueue();
diff --git a/drjava/src/edu/rice/cs/drjava/ui/predictive/PredictiveInputFrame.java b/drjava/src/edu/rice/cs/drjava/ui/predictive/PredictiveInputFrame.java
index fecfff1f0..c78ee7e1c 100644
--- a/drjava/src/edu/rice/cs/drjava/ui/predictive/PredictiveInputFrame.java
+++ b/drjava/src/edu/rice/cs/drjava/ui/predictive/PredictiveInputFrame.java
@@ -695,7 +695,7 @@ public void setOwnerEnabled(boolean b) {
/** Toggle visibility of this frame. Warning, it behaves like a modal dialog. */
public void setVisible(boolean vis) {
- assert EventQueue.isDispatchThread();
+ assert ! EventQueue.isDispatchThread();
validate();
if (vis) {
DrJavaRoot.installModalWindowAdapter(this, LambdaUtil.NO_OP, CANCEL);
diff --git a/drjava/src/edu/rice/cs/util/InputStreamRedirector.java b/drjava/src/edu/rice/cs/util/InputStreamRedirector.java
index 26a78a04d..3b4e82f7c 100644
--- a/drjava/src/edu/rice/cs/util/InputStreamRedirector.java
+++ b/drjava/src/edu/rice/cs/util/InputStreamRedirector.java
@@ -61,7 +61,7 @@ private void _readInputIntoBuffer() throws IOException {
String input = _getInput();
for(int i = 0; i < input.length(); i++) {
- _buffer.add(new Character(input.charAt(i)));
+ _buffer.add(Character.valueOf(input.charAt(i)));
}
}
diff --git a/drjava/src/edu/rice/cs/util/StringOps.java b/drjava/src/edu/rice/cs/util/StringOps.java
index 0d3a2f16f..5a3393da3 100644
--- a/drjava/src/edu/rice/cs/util/StringOps.java
+++ b/drjava/src/edu/rice/cs/util/StringOps.java
@@ -48,7 +48,7 @@
* to provide convenient namespace importation of its methods.
* @version $Id$
*/
-
+@SuppressWarnings("deprecation")
public abstract class StringOps {
public static final String EOL = System.getProperty("line.separator");
@@ -720,16 +720,16 @@ public static List>> commandLineToLists(String cmdline) {
tok.addKeyword(ProcessChain.PIPE_SEPARATOR);
// add whitespace characters as keyword, as per Character.isWhitespace
tok.addKeyword(" ");
- tok.addKeyword(new Character((char)0x09).toString()); // horizontal tab
- tok.addKeyword(new Character((char)0x0A).toString()); // line feed
- tok.addKeyword(new Character((char)0x0B).toString()); // vertical tab
- tok.addKeyword(new Character((char)0x0C).toString()); // form feed / Character.SPACE_SEPARATOR
- tok.addKeyword(new Character((char)0x0D).toString()); // carriage return / Character.LINE_SEPARATOR
- tok.addKeyword(new Character((char)0x0E).toString()); // carriage return / Character.PARAGRAPH_SEPARATOR
- tok.addKeyword(new Character((char)0x1C).toString()); // file separator
- tok.addKeyword(new Character((char)0x1D).toString()); // group separator
- tok.addKeyword(new Character((char)0x1E).toString()); // record separator
- tok.addKeyword(new Character((char)0x1F).toString()); // unit separator
+ tok.addKeyword(Character.valueOf((char)0x09).toString()); // horizontal tab
+ tok.addKeyword(Character.valueOf((char)0x0A).toString()); // line feed
+ tok.addKeyword(Character.valueOf((char)0x0B).toString()); // vertical tab
+ tok.addKeyword(Character.valueOf((char)0x0C).toString()); // form feed / Character.SPACE_SEPARATOR
+ tok.addKeyword(Character.valueOf((char)0x0D).toString()); // carriage return / Character.LINE_SEPARATOR
+ tok.addKeyword(Character.valueOf((char)0x0E).toString()); // carriage return / Character.PARAGRAPH_SEPARATOR
+ tok.addKeyword(Character.valueOf((char)0x1C).toString()); // file separator
+ tok.addKeyword(Character.valueOf((char)0x1D).toString()); // group separator
+ tok.addKeyword(Character.valueOf((char)0x1E).toString()); // record separator
+ tok.addKeyword(Character.valueOf((char)0x1F).toString()); // unit separator
// also add escaped space as keyword, but treat it differently
final String ESCAPE = String.valueOf((char)0x1B);
final String ESCAPED_SPACE = ESCAPE + " ";