Skip to content

Commit 72f1881

Browse files
committed
This revision cleans up the javalanglevels code base so that all unit
tests pass and that a broad subset of Java is allowed in functional level files.
1 parent 67f28dd commit 72f1881

53 files changed

Lines changed: 1350 additions & 1952 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

drjava/lib/javalanglevels-base.jar

-2.22 KB
Binary file not shown.

drjava/lib/platform.jar

86 Bytes
Binary file not shown.

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,14 +1249,15 @@ public static ArrayList<String> evaluate() {
12491249
static final String JAVADOC_1_5_TEXT = "1.5";
12501250
static final String JAVADOC_1_6_TEXT = "1.6";
12511251
static final String JAVADOC_1_7_TEXT = "1.7";
1252+
static final String JAVADOC_1_8_TEXT = "1.8";
12521253
static final String JAVADOC_AUTO_TEXT = "use compiler version"; // for "Open Java API Javadoc"
12531254

12541255
static final String[] linkChoices = new String[]{
1255-
JAVADOC_NONE_TEXT, JAVADOC_1_5_TEXT, JAVADOC_1_6_TEXT, JAVADOC_1_7_TEXT };
1256+
JAVADOC_NONE_TEXT, JAVADOC_1_5_TEXT, JAVADOC_1_6_TEXT, JAVADOC_1_7_TEXT, JAVADOC_1_8_TEXT };
12561257
static final ArrayList<String> linkVersionChoices = new ArrayList<String>(Arrays.asList(linkChoices));
12571258

12581259
static final String[] linkDeprecated = new String[]{
1259-
JAVADOC_1_3_TEXT, JAVADOC_1_4_TEXT };
1260+
JAVADOC_1_3_TEXT, JAVADOC_1_4_TEXT, JAVADOC_1_5_TEXT };
12601261
static final ArrayList<String> linkVersionDeprecated = new ArrayList<String>(Arrays.asList(linkDeprecated));
12611262

12621263
/** Constants for the URLs of Sun's system class documentation for different versions of Java. */
@@ -1270,21 +1271,26 @@ public static ArrayList<String> evaluate() {
12701271
new StringOption("javadoc.1.6.link", "http://download.oracle.com/javase/6/docs/api");
12711272
public static final StringOption JAVADOC_1_7_LINK =
12721273
new StringOption("javadoc.1.7.link", "http://download.oracle.com/javase/7/docs/api/");
1274+
public static final StringOption JAVADOC_1_8_LINK =
1275+
new StringOption("javadoc.1.8.link", "http://download.oracle.com/javase/8/docs/api/");
12731276

12741277
/** The version of Java to use for links to Javadoc for system classes. */
12751278
public static final ForcedChoiceOption JAVADOC_LINK_VERSION =
12761279
new ForcedChoiceOption("javadoc.link.version",
12771280
(System.getProperty("java.specification.version").startsWith("1.5") ? JAVADOC_1_5_TEXT :
12781281
(System.getProperty("java.specification.version").startsWith("1.6") ? JAVADOC_1_6_TEXT :
1279-
JAVADOC_1_7_TEXT)),
1282+
(System.getProperty("java.specification.version").startsWith("1.7") ? JAVADOC_1_7_TEXT :
1283+
JAVADOC_1_8_TEXT))),
12801284
linkVersionChoices, linkVersionDeprecated);
12811285

12821286
static final String[] apiJavadocChoices = new String[] {
1283-
JAVADOC_1_5_TEXT, JAVADOC_1_6_TEXT, JAVADOC_1_7_TEXT, JAVADOC_AUTO_TEXT};
1287+
JAVADOC_1_5_TEXT, JAVADOC_1_6_TEXT, JAVADOC_1_7_TEXT, JAVADOC_1_8_TEXT, JAVADOC_AUTO_TEXT};
1288+
12841289
static final ArrayList<String> apiJavadocVersionChoices = new ArrayList<String>(Arrays.asList(apiJavadocChoices));
12851290

12861291
static final String[] apiJavadocDeprecated = new String[] {
1287-
JAVADOC_1_3_TEXT, JAVADOC_1_4_TEXT}; // deprecated, will be changed to JAVADOC_AUTO_TEXT
1292+
JAVADOC_1_3_TEXT, JAVADOC_1_4_TEXT, JAVADOC_1_5_TEXT}; // deprecated, will be changed to JAVADOC_AUTO_TEXT
1293+
12881294
static final ArrayList<String> apiJavadocVersionDeprecated = new ArrayList<String>(Arrays.asList(apiJavadocDeprecated));
12891295

12901296
/** The version of Java to use for the "Open Java API Javadoc" feature. */

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public <T> T getOption(OptionParser<T> o) {
7979
}
8080

8181
public <T> T setOption(Option<T> o, T val) {
82-
if (o==null) return _shadowed.getOptionMap().setOption(o, val);
82+
if (o == null) return _shadowed.getOptionMap().setOption(o, val);
8383
try {
8484
String str = _bundle.getString(o.getName());
8585
return null; // defined in resource bundle, can't be set

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public DJError(File file, int lineNumber, int startColumn, String message, boole
7171
// System.err.println("instance of DJError (or subclass) constructed; file = " + file + "; message = " + message);
7272
// need to precisely match the CompilerError message, otherwise a file name containing
7373
// "CompilerError" may trigger an UnexpectedException (see bug 2872797)
74-
if (message != null && message.startsWith("Compile exception: sun.tools.java.CompilerError"))
74+
if (message != null && message.startsWith("Compile exception: "))
7575
throw new UnexpectedException(message);
7676
_file = file;
7777
_lineNumber = lineNumber;

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

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

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,12 @@ public CompilerErrorModel(DJError[] errors, GlobalModel model) {
141141
// .dj2 file anymore. When we get a compiler error in a .java file, and we have a corresponding
142142
// .dj2 file open, but not the .java file, then we change the error to refer to the .dj2 file
143143
// instead.
144-
if (model!=null) {
144+
if (model != null) {
145145
HashSet<File> odds = new HashSet<File>();
146146
for(OpenDefinitionsDocument odd: model.getOpenDefinitionsDocuments()) {
147147
odds.add(odd.getRawFile());
148148
}
149-
for(int i=0; i<errors.length; ++i) {
149+
for(int i = 0; i < errors.length; ++i) {
150150
DJError e = errors[i];
151151
if (e.fileName().endsWith(edu.rice.cs.drjava.config.OptionConstants.JAVA_FILE_EXTENSION)) {
152152
// only needs to be done for .java files
@@ -172,7 +172,7 @@ public CompilerErrorModel(DJError[] errors, GlobalModel model) {
172172

173173
_numWarnings = 0;
174174
_numCompilerErrors = 0;
175-
for (int i =0; i < errors.length; i++) {
175+
for (int i = 0; i < errors.length; i++) {
176176
if (errors[i].isWarning()) _numWarnings++;
177177
else _numCompilerErrors++;
178178
}

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ private void _compileFiles(List<File> files, File buildDir) throws IOException {
343343

344344
List<? extends File> preprocessedFiles = _compileLanguageLevelsFiles(files, errors, classPath, bootClassPath);
345345

346+
System.err.println("Performed Language Level Translation of " + preprocessedFiles);
346347
if (errors.isEmpty()) {
347348
CompilerInterface compiler = getActiveCompiler();
348349

@@ -382,8 +383,8 @@ private static List<File> _testFileSort(List<File> files) {
382383
* @return An updated list for compilation containing no Language Levels files, or @code{null}
383384
* if there were no Language Levels files to process.
384385
*/
385-
private List<File> _compileLanguageLevelsFiles(List<File> files, List<DJError> errors,
386-
Iterable<File> classPath, Iterable<File> bootClassPath) {
386+
private List<File> _compileLanguageLevelsFiles(List<File> files, List<DJError> errors, Iterable<File> classPath,
387+
Iterable<File> bootClassPath) {
387388
/* Construct the collection of files to be compild by javac, renaming any language levels (.dj*) files to the
388389
* corresponding java (.java) files. By using a HashSet, we avoid creating duplicates in this collection.
389390
*/
@@ -535,7 +536,7 @@ public boolean accept(File dir, String name) {
535536

536537
/* Perform language levels conversion, creating corresponding .java files. */
537538
LanguageLevelConverter llc = new LanguageLevelConverter();
538-
Options llOpts;
539+
Options llOpts; /* Options passed as arguments to LLConverter */
539540
if (bootClassPath == null) { llOpts = new Options(getActiveCompiler().version(), classPath); }
540541
else { llOpts = new Options(getActiveCompiler().version(), classPath, bootClassPath); }
541542

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,14 @@ protected Javac160FilteringCompiler(JavaVersion.FullVersion version,
8686
}
8787
else {
8888
// LOG.log("\tjunit.jar not found");
89-
if (tempJUnit!=null) {
89+
if (tempJUnit != null) {
9090
tempJUnit.delete();
9191
tempJUnit = null;
9292
}
9393
}
9494
}
9595
catch(IOException ioe) {
96-
if (tempJUnit!=null) {
96+
if (tempJUnit != null) {
9797
tempJUnit.delete();
9898
tempJUnit = null;
9999
}

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,6 @@ public static void runCommand(String s, Class<?> c) throws Throwable {
296296
If a), then DrJava inserts "code=MyClass" as argument 0.
297297
If b), then DrJava performs the same as "applet MyClass" (see above).
298298
If c), then DrJava executes MyClass.main (traditional java behavior).
299-
300-
It formerly was static, but it is overriden in ScalacCompiler.
301299
*/
302300
public String transformRunCommand(String s) {
303301
if (s.endsWith(";")) s = _deleteSemiColon(s);

0 commit comments

Comments
 (0)