Skip to content

Commit 4495e32

Browse files
committed
Eliminated some code supporting legacy versions of Java (5,6,7)
Patched support for the bundled compiler by add the Java library jar (rt.jar) to the lib directory of the drjava branch. On branch master Your branch is up to date with 'origin/master'. Changes to be committed: new file: lib/rt.jar modified: lib/tools.jar modified: src/edu/rice/cs/drjava/model/AbstractGlobalModel.java modified: src/edu/rice/cs/drjava/model/DefaultGlobalModel.java modified: src/edu/rice/cs/drjava/model/JDKDescriptor.java modified: src/edu/rice/cs/drjava/model/JDKToolsLibrary.java modified: src/edu/rice/cs/drjava/model/JarJDKToolsLibrary.java modified: src/edu/rice/cs/drjava/model/repl/newjvm/MainJVM.java modified: src/edu/rice/cs/drjava/ui/MainFrame.java modified: src/edu/rice/cs/drjava/ui/config/ConfigFrame.java
1 parent 3283654 commit 4495e32

10 files changed

Lines changed: 232 additions & 213 deletions

File tree

drjava/lib/rt.jar

60.3 MB
Binary file not shown.

drjava/lib/tools.jar

15 KB
Binary file not shown.

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

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,8 @@ public void optionChanged(OptionEvent<Integer> oce) {
364364

365365
// ----- STATE -----
366366

367-
/** Specifies the state of the navigator pane. The global model delegates the compileAll command to the _state.
367+
/** Specifies the state of the navigator pane.
368+
* The global model delegates the compileAll command to the _state.
368369
* FileGroupingState synchronization is handled by the compilerModel (??).
369370
*/
370371
protected volatile FileGroupingState _state;
@@ -3474,52 +3475,56 @@ private File _locateClassFile() {
34743475
_log.log("_locateClassFile() failed for " + this + " because getQualifedClassName returned ClassNotFound");
34753476
return FileOps.NULL_FILE; /* No source class name */
34763477
}
3477-
// _log.log("In _locateClassFile, className = " + className);
3478+
_log.log("In _locateClassFile, className = " + className);
34783479
String ps = System.getProperty("file.separator");
34793480
// replace periods with the System's file separator
34803481
className = StringOps.replace(className, ".", ps);
34813482
String fileName = className + ".class";
34823483

3483-
// _log.log("In _locateClassFile, classfileName = " + fileName);
3484+
_log.log("In _locateClassFile, classfileName = " + fileName);
34843485

34853486
// Check source root set (open files)
34863487
ArrayList<File> roots = new ArrayList<File>();
34873488

3488-
// _log.log("build directory = " + getBuildDirectory());
3489+
File bd = getBuildDirectory();
34893490

3490-
if (getBuildDirectory() != FileOps.NULL_FILE) roots.add(getBuildDirectory());
3491+
_log.log("build directory = " + bd);
34913492

3492-
// Add the current document to the beginning of the roots list
3493+
// Place the build directory at the front of the roots list
3494+
if (bd != FileOps.NULL_FILE) roots.add(getBuildDirectory());
3495+
3496+
// Add the current document to the end (formerly beginning) of the roots list; in the command line class file
3497+
// layout, class files reside in same directory as corresponding source files.
34933498
try {
34943499
File root = getSourceRoot();
3495-
// _log.log("Directory " + root + " added to list of source roots");
3496-
roots.add(root);
3500+
_log.log("Directory " + root + " added to list of class file roots");
3501+
if (! roots.contains(root)) roots.add(root);
34973502
}
34983503
catch (InvalidPackageException ipe) {
34993504
try {
3500-
// _log.log(this + " has no source root, using parent directory instead");
3505+
_log.log(this + " has no source root, using parent directory of this source document instead");
35013506
File root = getFile().getParentFile();
35023507
if (root != FileOps.NULL_FILE) {
35033508
roots.add(root);
3504-
// _log.log("Added parent directory " + root + " to list of source roots");
3509+
_log.log("Added parent directory " + root + " to list of class file roots");
35053510
}
35063511
}
35073512
catch(NullPointerException e) { throw new UnexpectedException(e); }
35083513
catch(FileMovedException fme) {
35093514
// Moved, but we'll add the old file to the set anyway
3510-
_log.log("File for " + this + "has moved; adding parent directory to list of roots");
3515+
_log.log("File for " + this + "has moved; adding parent directory of this source document instead");
35113516
File root = fme.getFile().getParentFile();
35123517
if (root != FileOps.NULL_FILE) roots.add(root);
35133518
}
35143519
}
35153520

35163521
File classFile = findFileInPaths(fileName, roots);
35173522
if (classFile != FileOps.NULL_FILE) {
3518-
// _log.log("Found source file " + classFile + " for " + this);
3523+
_log.log("Found class file " + classFile + " for " + this);
35193524
return classFile;
35203525
}
35213526

3522-
// _log.log(this + " not found on path of source roots");
3527+
_log.log(fileName + " not found on list of class file roots");
35233528
// Class not on source root set, check system classpath
35243529
classFile = findFileInPaths(fileName, ReflectUtil.SYSTEM_CLASS_PATH);
35253530

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@
4545
import edu.rice.cs.drjava.model.FileSaveSelector;
4646
import edu.rice.cs.drjava.model.JDKDescriptor;
4747
import edu.rice.cs.drjava.model.compiler.DummyCompilerListener;
48-
//import edu.rice.cs.drjava.model.compiler.EclipseCompiler;
49-
//import edu.rice.cs.drjava.model.compiler.descriptors.EclipseDescriptor;
5048
import edu.rice.cs.drjava.model.definitions.ClassNameNotFoundException;
5149
import edu.rice.cs.drjava.model.definitions.InvalidPackageException;
5250
import edu.rice.cs.drjava.model.debug.Breakpoint;
@@ -79,10 +77,10 @@
7977
import edu.rice.cs.plt.reflect.ReflectUtil;
8078
import edu.rice.cs.plt.tuple.Pair;
8179

80+
import edu.rice.cs.util.AbsRelFile;
8281
import edu.rice.cs.util.FileOpenSelector;
8382
import edu.rice.cs.util.FileOps;
8483
import edu.rice.cs.util.NullFile;
85-
import edu.rice.cs.util.AbsRelFile;
8684
import edu.rice.cs.util.OperationCanceledException;
8785
import edu.rice.cs.util.UnexpectedException;
8886
import edu.rice.cs.util.swing.Utilities;
@@ -185,7 +183,7 @@ public void activeCompilerChanged() {
185183
/* CONSTRUCTORS */
186184
/** Constructs a new GlobalModel. Creates a new MainJVM and starts its Interpreter JVM. */
187185
public DefaultGlobalModel() {
188-
Iterable<? extends JDKToolsLibrary> tools = findLibraries();
186+
Iterable<? extends JDKToolsLibrary> tools = findLibraries(); // findLibraries should be called findTools
189187
List<CompilerInterface> compilers = new LinkedList<CompilerInterface>();
190188

191189
/* Note: the only debugger used in DrJava is JPDADebugger in the DrJava code base which relies
@@ -194,9 +192,10 @@ public DefaultGlobalModel() {
194192
*/
195193
_debugger = null;
196194
_javadocModel = null;
195+
/* Gather tools: a list compilers, a debugger, and a javadoc tool. */
197196
for (JDKToolsLibrary t : tools) {
198197
// Utilities.show("Found tools.jar library: " + t);
199-
if (t.compiler().isAvailable() && t.version().supports(JavaVersion.JAVA_7)) compilers.add(t.compiler());
198+
if (t.compiler().isAvailable() && t.version().supports(JavaVersion.JAVA_8)) compilers.add(t.compiler());
200199
if (_debugger == null && t.debugger().isAvailable()) { _debugger = t.debugger(); }
201200
if (_javadocModel == null && t.javadoc().isAvailable()) { _javadocModel = t.javadoc(); }
202201
}
@@ -205,7 +204,7 @@ public DefaultGlobalModel() {
205204

206205
File workDir = Utilities.TEST_MODE ? new File(System.getProperty("user.home")) : getWorkingDirectory();
207206
_jvm = new MainJVM(workDir);
208-
// AbstractMasterJVM._log.log(this + " has created a new MainJVM");
207+
_log.log(this + " has created a new MainJVM");
209208
_compilerModel = new DefaultCompilerModel(this, compilers);
210209
_junitModel = new DefaultJUnitModel(_jvm, _compilerModel, this);
211210
_interactionsDocument = new InteractionsDJDocument(_notifier);

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@
4040
import edu.rice.cs.plt.iter.IterUtil;
4141

4242
/** A description of a JDK.
43-
* Put subclasses of JDKDescriptor in the edu.rice.cs.drjava.model.compiler.descriptors package for DrJava
44-
* to find. */
43+
* Put subclasses of JDKDescriptor in the edu.rice.cs.drjava.model.compiler.descriptors package for DrJava to find. */
4544
public abstract class JDKDescriptor {
4645
/** Return the name of this JDK.
4746
* @return name */
@@ -181,7 +180,7 @@ public String getAdapterForDebugger(JavaVersion.FullVersion guessedVersion) {
181180
return JDKToolsLibrary.adapterForDebugger(guessedVersion);
182181
}
183182
public boolean containsCompiler(File f) { return true; }
184-
public JavaVersion getMinimumMajorVersion() { return JavaVersion.JAVA_7; }
183+
public JavaVersion getMinimumMajorVersion() { return JavaVersion.JAVA_8; }
185184
public Iterable<File> getAdditionalCompilerFiles(File compiler) throws FileNotFoundException {
186185
return IterUtil.empty();
187186
}

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

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -94,32 +94,36 @@ public boolean isValid() {
9494

9595
public String toString() { return _jdkDescriptor.getDescription(_version); }
9696

97-
public static String adapterForCompiler(JavaVersion.FullVersion version) {
98-
switch (version.majorVersion()) {
99-
case FUTURE: return "edu.rice.cs.drjava.model.compiler.Javac170Compiler";
100-
case JAVA_8: return "edu.rice.cs.drjava.model.compiler.Javac170Compiler";
101-
case JAVA_7: return "edu.rice.cs.drjava.model.compiler.Javac170Compiler";
102-
case JAVA_6: {
103-
switch (version.vendor()) {
104-
case OPENJDK: return "edu.rice.cs.drjava.model.compiler.Javac160OpenJDKCompiler";
105-
case UNKNOWN: return null;
106-
default: return "edu.rice.cs.drjava.model.compiler.Javac160Compiler";
107-
}
108-
}
109-
case JAVA_5: return "edu.rice.cs.drjava.model.compiler.Javac150Compiler";
110-
default: return null;
111-
}
97+
public static String adapterForCompiler(JavaVersion.FullVersion version) {
98+
return "edu.rice.cs.drjava.model.compiler.Javac170Compiler";
99+
/* formerly the following */
100+
// switch (version.majorVersion()) {
101+
// case FUTURE: return "edu.rice.cs.drjava.model.compiler.Javac170Compiler";
102+
// case JAVA_8: return "edu.rice.cs.drjava.model.compiler.Javac170Compiler";
103+
// case JAVA_7: return "edu.rice.cs.drjava.model.compiler.Javac170Compiler";
104+
// case JAVA_6: {
105+
// switch (version.vendor()) {
106+
// case OPENJDK: return "edu.rice.cs.drjava.model.compiler.Javac160OpenJDKCompiler";
107+
// case UNKNOWN: return null;
108+
// default: return "edu.rice.cs.drjava.model.compiler.Javac160Compiler";
109+
// }
110+
// }
111+
// case JAVA_5: return "edu.rice.cs.drjava.model.compiler.Javac150Compiler";
112+
// default: return null;
113+
// }
112114
}
113115

114-
public static String adapterForDebugger(JavaVersion.FullVersion version) {
115-
switch (version.majorVersion()) {
116-
case FUTURE:
117-
case JAVA_8:
118-
case JAVA_7:
119-
case JAVA_6:
120-
case JAVA_5: return "edu.rice.cs.drjava.model.debug.jpda.JPDADebugger";
121-
default: return null;
122-
}
116+
public static String adapterForDebugger(JavaVersion.FullVersion version) {
117+
return "edu.rice.cs.drjava.model.debug.jpda.JPDADebugger";
118+
/* formerly */
119+
// switch (version.majorVersion()) {
120+
// case FUTURE:
121+
// case JAVA_8:
122+
// case JAVA_7:
123+
// case JAVA_6:
124+
// case JAVA_5: return "edu.rice.cs.drjava.model.debug.jpda.JPDADebugger";
125+
// default: return null;
126+
// }
123127
}
124128

125129
protected static CompilerInterface getCompilerInterface(String className, FullVersion version) {

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ protected static LinkedHashMap<File,Set<JDKDescriptor>> getDefaultSearchRoots()
416416
String envJavaHome = null;
417417
String programFiles = null;
418418
String systemDrive = null;
419-
if (JavaVersion.CURRENT.supports(JavaVersion.JAVA_7)) { /* formerly JavaVersion.JAVA_5 */
419+
if (JavaVersion.CURRENT.supports(JavaVersion.JAVA_8)) { /* formerly JavaVersion.JAVA_5 and later JavaVersion.JAVA_7 */
420420
// System.getenv is deprecated under 1.3 and 1.4, and may throw a java.lang.Error (!),
421421
// which we'd rather not have to catch
422422
envJavaHome = System.getenv("JAVA_HOME");
@@ -446,9 +446,10 @@ protected static LinkedHashMap<File,Set<JDKDescriptor>> getDefaultSearchRoots()
446446
addIfDir(new File(programFiles), roots);
447447
}
448448

449-
/* The following two lines were added to support OpenJDK8 on Windows 10. */
449+
/* The following three lines were added to support OpenJDK8 on Windows 10/11. */
450450
addIfDir(new File("/C:/Program Files/Zulu/zulu-8"), roots);
451451
addIfDir(new File("/C:/Program Files (x86)/Zulu/zulu-8"), roots);
452+
addIfDir(new File("/C:/Program Files/Amazon Corretto"), roots);
452453

453454
addIfDir(new File("/C:/Program Files/Java"), roots);
454455
addIfDir(new File("/C:/Program Files (x86)/Java"), roots);
@@ -479,11 +480,13 @@ protected static LinkedHashMap<File,Set<JDKDescriptor>> getDefaultSearchRoots()
479480
addIfDir(new File("/usr/lib/jvm"), roots);
480481
addIfDir(new File("/usr/lib/jvm/java-8-oracle"), roots);
481482
addIfDir(new File("/usr/lib/jvm/java-8-openjdk"), roots);
482-
addIfDir(new File("/usr/lib/jvm/java-7-oracle"), roots);
483-
addIfDir(new File("/usr/lib/jvm/java-7-openjdk"), roots);
484-
addIfDir(new File("/usr/lib/jvm/java-6-sun"), roots);
485-
addIfDir(new File("/usr/lib/jvm/java-6-openjdk"), roots);
486-
addIfDir(new File("/usr/lib/jvm/java-1.5.0-sun"), roots);
483+
484+
/* Legacy version of Java -- no longer supported */
485+
// addIfDir(new File("/usr/lib/jvm/java-7-oracle"), roots);
486+
// addIfDir(new File("/usr/lib/jvm/java-7-openjdk"), roots);
487+
// addIfDir(new File("/usr/lib/jvm/java-6-sun"), roots);
488+
// addIfDir(new File("/usr/lib/jvm/java-6-openjdk"), roots);
489+
// addIfDir(new File("/usr/lib/jvm/java-1.5.0-sun"), roots);
487490

488491
// addIfDir(new File("/home/javaplt/java/Linux-i686"), roots);
489492

0 commit comments

Comments
 (0)