Skip to content

Commit 37449cb

Browse files
author
rcartwright
committed
This commit partially cleans up the typing to conform with the newly generified Java 7 APIs.
It also adds final/volatile modifiers to some shared field declarations. The following files have been modified: M src/edu/rice/cs/drjava/ui/ProjectPropertiesFrame.java M src/edu/rice/cs/drjava/ui/RegionsTreePanel.java M src/edu/rice/cs/drjava/ui/MainFrame.java M src/edu/rice/cs/drjava/ui/predictive/PredictiveInputFrame.java M src/edu/rice/cs/drjava/ui/MainFrameStatics.java M src/edu/rice/cs/drjava/ui/DefinitionsPane.java M src/edu/rice/cs/drjava/model/compiler/JavacCompiler.java M src/edu/rice/cs/drjava/model/compiler/CompilerModel.java M src/edu/rice/cs/drjava/model/compiler/DefaultCompilerModel.java M src/edu/rice/cs/drjava/model/FileRegion.java M src/edu/rice/cs/drjava/model/JarJDKToolsLibrary.java M src/edu/rice/cs/drjava/model/cache/DocumentCache.java M src/edu/rice/cs/drjava/model/DefaultGlobalModel.java M src/edu/rice/cs/drjava/model/definitions/reducedmodel/BraceReduction.java M src/edu/rice/cs/drjava/model/definitions/DefinitionsDocument.java M src/edu/rice/cs/drjava/model/junit/DefaultJUnitModel.java M src/edu/rice/cs/drjava/model/repl/DefaultInteractionsModel.java M src/edu/rice/cs/drjava/model/GlobalModelJUnitTest.java M src/edu/rice/cs/drjava/model/JDKToolsLibrary.java M src/edu/rice/cs/drjava/model/AbstractDJDocument.java M src/edu/rice/cs/drjava/config/ClassPathOption.java M src/edu/rice/cs/util/GeneralProcessCreator.java M src/edu/rice/cs/util/docnavigation/JListNavigator.java M src/edu/rice/cs/util/swing/FontChooser.java M src/edu/rice/cs/util/swing/CheckBoxJList.java M src/edu/rice/cs/util/swing/DirectoryChooser.java M src/edu/rice/cs/util/swing/BorderlessScrollPane.java M src/edu/rice/cs/util/swing/ScrollableListDialog.java M src/edu/rice/cs/util/FileOps.java M src/edu/rice/cs/util/text/AbstractDocumentInterface.java M src/edu/rice/cs/util/text/EditDocumentInterface.java M src/edu/rice/cs/util/text/SwingDocument.java M src/edu/rice/cs/util/text/SwingDocumentInterface.java M build.xml git-svn-id: file:///tmp/test-svn/trunk@5544 fe72c1cf-3628-48e9-8b72-1c46755d3cff
1 parent 946c982 commit 37449cb

34 files changed

Lines changed: 209 additions & 180 deletions

drjava/build.xml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@
216216
description="Compile all source files (after generating the source)">
217217
</target>
218218

219-
<target name="do-compile" depends="resolve-java5-runtime, resolve-java5-tools">
219+
<target name="do-compile" depends="resolve-java7-runtime, resolve-java7-tools">
220220

221221
<echo message="Compiling src directory to classes/base and classes/test with command 'javac'" />
222222

@@ -229,13 +229,13 @@
229229
</move>
230230

231231
<javac srcdir="src" destdir="classes/base" source="1.5" target="1.5"
232-
bootclasspath="${java5-runtime}" sourcepath="" includeAntRuntime="no"
232+
bootclasspath="${java7-runtime}" sourcepath="" includeAntRuntime="no"
233233
executable="javac" fork="yes" memoryMaximumSize="512M"
234234
debug="on" optimize="off" deprecation="on" >
235235
<classpath>
236236
<!-- TODO: Remove this dependency on tools.jar by refactoring and moving all the dependent
237237
debugger code into the "platform" module -->
238-
<pathelement location="${java5-tools}" />
238+
<pathelement location="${java7-tools}" />
239239
<fileset refid="libs" />
240240
<pathelement location="lib/buildlib/junit.jar" />
241241
<pathelement location="lib/buildlib/netbeans-memory-leak-utils.jar" />
@@ -598,7 +598,7 @@
598598
Documentation Targets
599599
********************* -->
600600

601-
<target name="javadoc" depends="generate-source, resolve-java5-tools, resolve-version-tag"
601+
<target name="javadoc" depends="generate-source, resolve-java6-tools, resolve-version-tag"
602602
description="Generate javadocs from the source folder (after generating the source)"
603603
unless="skip-javadoc">
604604
<antcall target="do-javadoc">
@@ -614,12 +614,12 @@
614614
<javadoc sourcepath="src" packagenames="*" destdir="docs/javadoc" maxmemory="512M"
615615
access="private" Use="yes" Version="yes" Author="yes" Windowtitle="${readable-project-name} API (${version-tag})" linksource="${link-source}">
616616
<classpath>
617-
<pathelement location="${java5-tools}" />
617+
<pathelement location="${java6-tools}" />
618618
<fileset refid="libs" />
619619
<pathelement location="lib/buildlib/junit.jar" />
620620
<pathelement location="lib/buildlib/netbeans-memory-leak-utils.jar" />
621621
</classpath>
622-
<link href="http://java.sun.com/j2se/1.5/docs/api" />
622+
<link href="http://docs.oracle.com/javase/6/docs/api/"/>
623623
<link href="http://junit.org/junit/javadoc/3.8.1" />
624624
<link href="http://drjava.org/javadoc/plt" />
625625
<link href="http://drjava.org/javadoc/javalanglevels" />
@@ -667,7 +667,7 @@
667667
</target>
668668

669669

670-
<target name="findbugs" depends="assert-findbugs-exists, compile, resolve-java5-tools"
670+
<target name="findbugs" depends="assert-findbugs-exists, compile, resolve-java6-tools"
671671
description="Generate a findbugs report (after compiling)">
672672
<taskdef name="findbugs" classpath="lib/buildlib/findbugs-ant.jar"
673673
classname="edu.umd.cs.findbugs.anttask.FindBugsTask" />
@@ -688,7 +688,7 @@
688688
<class location="classes/base" />
689689
<class location="classes/test" />
690690
<auxclasspath>
691-
<pathelement location="${java5-tools}" />
691+
<pathelement location="${java6-tools}" />
692692
<pathelement location="classes/lib" />
693693
<pathelement location="lib/buildlib/junit.jar" />
694694
<pathelement location="lib/buildlib/netbeans-memory-leak-utils.jar" />
@@ -1265,6 +1265,8 @@
12651265
<property name="java7-runtime-3" location="${java7-home}/../Classes/classes.jar" />
12661266
<available property="java7-runtime" value="${java7-runtime-3}" file="${java7-runtime-3}" />
12671267

1268+
<echo message="java7-runtime = ${java7-runtime}" />
1269+
12681270
<fail message="Can't find rt.jar in the Java 7 home: ${java7-home}" unless="java7-runtime" />
12691271
</target>
12701272

@@ -1298,6 +1300,8 @@
12981300
<property name="java6-runtime-3" location="${java6-home}/../Classes/classes.jar" />
12991301
<available property="java6-runtime" value="${java6-runtime-3}" file="${java6-runtime-3}" />
13001302

1303+
<echo message="java6-runtime = ${java6-runtime}" />
1304+
13011305
<fail message="Can't find rt.jar in the Java 6 home: ${java6-home}" unless="java6-runtime" />
13021306
</target>
13031307

@@ -1331,6 +1335,8 @@
13311335
<property name="java5-runtime-3" location="${java5-home}/../Classes/classes.jar" />
13321336
<available property="java5-runtime" value="${java5-runtime-3}" file="${java5-runtime-3}" />
13331337

1338+
<echo message="java5-runtime = ${java5-runtime}" />
1339+
13341340
<fail message="Can't find rt.jar in the Java 5 home: ${java5-home}" unless="java5-runtime" />
13351341
</target>
13361342

drjava/src/edu/rice/cs/drjava/config/ClassPathOption.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ public VectorOption<File> evaluate(String optionName) {
5757
System.out.println(warning);
5858
System.out.println("using '" + ps.charAt(0) + "' for delimiter.");
5959
}
60-
FileOption fop = new FileOption("",FileOps.NULL_FILE);
60+
FileOption fop = new FileOption("", FileOps.NULL_FILE);
6161
//String name = "extra.classpath";
6262
char delim = ps.charAt(0);
63-
return new VectorOption<File>(optionName,fop,"",delim,"",new Vector<File>());
63+
return new VectorOption<File>(optionName, fop, "", delim, "", new Vector<File>());
6464
}
6565
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ public void optionChanged(OptionEvent<Boolean> oce) {
213213
DrJava.getConfig().addOptionListener(AUTO_CLOSE_COMMENTS, _listener2);
214214
}
215215

216-
217216
/** Create a set of normal endings, i.e., semi-colons and braces for the purposes of indenting.
218217
* @return the set of normal endings
219218
*/
@@ -1530,7 +1529,7 @@ private boolean _inParenPhrase() {
15301529
public boolean _inBlockComment(final int pos) {
15311530
final int here = _currentLocation;
15321531
final int distToStart = here - _getLineStartPos(here);
1533-
_reduced.resetLocation();
1532+
_reduced.resetLocation(); // Why is this call necessary?
15341533
ReducedModelState state = stateAtRelLocation(-distToStart);
15351534

15361535
return (state.equals(INSIDE_BLOCK_COMMENT));

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,8 @@ public DefaultGlobalModel() {
194194
_debugger = null;
195195
_javadocModel = null;
196196
for (JDKToolsLibrary t : tools) {
197-
// only add compiler if it supports JAVA_5
198-
if (t.compiler().isAvailable() && t.version().supports(JavaVersion.JAVA_5)) {
197+
// drop testing that the compiler supports JAVA_5; Scala does NOT
198+
if (t.compiler().isAvailable() /* && t.version().supports(JavaVersion.JAVA_5) */) {
199199
compilers.add(t.compiler());
200200
}
201201
if (_debugger == null && t.debugger().isAvailable()) { _debugger = t.debugger(); }

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,12 @@
4444
*/
4545
public interface FileRegion extends Region {
4646

47-
/** @return the start offset */
47+
/** *Copied from Region*.
48+
* @return the start offset */
4849
public int getStartOffset();
49-
50-
/** @return the end offset */
50+
51+
/** *Copied from Region*.
52+
* @return the end offset */
5153
public int getEndOffset();
5254

5355
/** @return the file */

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public final class GlobalModelJUnitTest extends GlobalModelTestCase {
5858
private static Log _log = new Log("GlobalModelJUnit.txt", false);
5959

6060
/** Whether or not to print debugging output. */
61-
static final boolean printMessages = false;
61+
static final boolean printMessages = true;
6262

6363
private static final String ELSPETH_ERROR_TEXT =
6464
"import junit.framework.TestCase;" +
@@ -741,7 +741,7 @@ public void fileSaved(OpenDefinitionsDocument doc) { }
741741
* an error does not pass unit testing (by running correct class files).
742742
*/
743743
public void testCorrectFilesAfterIncorrectChanges_NOJOIN() throws Exception {
744-
// _log.log("Starting testCorrectFilesAfterIncorrectChanges");
744+
if (printMessages) System.err.println("----testCorrectFilesAfterIncorrectChanges-----");
745745

746746
// OpenDefinitionsDocument doc0 = setupDocument(NON_TESTCASE_TEXT);
747747
// JUnitNonTestListener listener0 = new JUnitNonTestListener(true);
@@ -753,7 +753,7 @@ public void testCorrectFilesAfterIncorrectChanges_NOJOIN() throws Exception {
753753
// listener0.checkCompileOccurred();
754754
// _model.removeListener(listener0);
755755
// // What is the preceding code segment supposed to test; it has already been done!
756-
756+
757757
final OpenDefinitionsDocument doc1 = setupDocument(MULTI_CLASSES_IN_FILE_TEXT);
758758
final File file = new File(_tempDir, "DJTest.java");
759759
saveFile(doc1, new FileSelector(file));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ protected static CompilerInterface getCompilerInterface(String className, FullVe
132132
Class<?>[] sig = { FullVersion.class, String.class, List.class };
133133
Object[] args = { version, "the runtime class path", bootClassPath };
134134
CompilerInterface attempt = (CompilerInterface) ReflectUtil.loadObject(className, sig, args);
135-
msg(" attempt = "+attempt+", isAvailable() = "+attempt.isAvailable());
135+
msg(" attempt = " + attempt + ", isAvailable() = "+attempt.isAvailable());
136136
if (attempt.isAvailable()) { return attempt; }
137137
}
138138
catch (ReflectException e) { /* can't load */ }

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@
7777
import edu.rice.cs.drjava.model.javadoc.NoJavadocAvailable;
7878
import edu.rice.cs.drjava.model.JDKDescriptor;
7979

80+
import edu.rice.cs.util.swing.Utilities;
81+
8082
/** A JDKToolsLibrary that was loaded from a specific jar file. */
8183
public class JarJDKToolsLibrary extends JDKToolsLibrary {
8284

@@ -234,7 +236,7 @@ else if (f.getName().equals("tools.jar")) {
234236
// can't use loadLibraryAdapter because we need to preempt the whole package
235237
ClassLoader debugLoader = new PreemptingClassLoader(new PathClassLoader(loader, path), debuggerPackage);
236238
Debugger attempt = (Debugger) ReflectUtil.loadObject(debugLoader, debuggerAdapter, sig, model);
237-
JDKToolsLibrary.msg(" debugger="+attempt.getClass().getName());
239+
JDKToolsLibrary.msg(" debugger=" + attempt.getClass().getName());
238240
if (attempt.isAvailable()) { debugger = attempt; }
239241
}
240242
catch (ReflectException e) {
@@ -467,8 +469,9 @@ protected static void collectValidResults(GlobalModel model,
467469
assert desc != null;
468470

469471
boolean containsCompiler = desc.containsCompiler(jar.getKey());
470-
JDKToolsLibrary.msg("Checking file "+jar.getKey()+" for "+desc);
471-
JDKToolsLibrary.msg(" "+containsCompiler);
472+
// Utilities.show("Checking file " + jar.getKey() + " for " + desc);
473+
JDKToolsLibrary.msg("Checking file " + jar.getKey() + " for " + desc);
474+
JDKToolsLibrary.msg(" " + containsCompiler);
472475
if (!containsCompiler) continue;
473476

474477
JarJDKToolsLibrary lib = makeFromFile(jar.getKey(), model, desc);

drjava/src/edu/rice/cs/drjava/model/cache/DocumentCache.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ public class DocumentCache {
8484
private static final int INIT_CACHE_SIZE = 32;
8585

8686
/** invariant _residentQueue.size() <= CACHE_SIZE */
87-
private int CACHE_SIZE;
87+
private volatile int CACHE_SIZE;
8888

89-
private LinkedHashSet<DocManager> _residentQueue;
89+
private final LinkedHashSet<DocManager> _residentQueue;
9090

91-
private Object _cacheLock = new Object();
91+
private final Object _cacheLock = new Object();
9292

9393
/* General constructor. Not currently used except when called by default constructor. */
9494
public DocumentCache(int size) {

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,9 @@ public interface CompilerModel {
125125
*/
126126
public void setActiveCompiler(CompilerInterface compiler);
127127

128-
/** Add a compiler to the active list */
129-
public void addCompiler(CompilerInterface compiler);
128+
/* This method is no longer used. */
129+
// /** Add a compiler to the active list */
130+
// public void addCompiler(CompilerInterface compiler);
130131

131132
/** Gets the LanguageLevelStackTraceMapper from the model */
132133
public LanguageLevelStackTraceMapper getLLSTM();

0 commit comments

Comments
 (0)