Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use more general Map interface for setOptions() #3610

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import java.nio.file.StandardCopyOption;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
Expand Down Expand Up @@ -64,7 +64,6 @@
/**
* Basic tests of the image builder.
*/
@SuppressWarnings({"rawtypes", "unchecked"})
public class BasicBuildTests extends BuilderTests {
public BasicBuildTests(String name) {
super(name);
Expand Down Expand Up @@ -106,8 +105,8 @@ public void testBuild() throws JavaModelException {
* http://bugs.eclipse.org/bugs/show_bug.cgi?id=23894
*/
public void testToDoMarker() throws JavaModelException {
Hashtable options = JavaCore.getOptions();
Hashtable newOptions = JavaCore.getOptions();
Map<String, String> options = JavaCore.getUnmodifiableOptions();
Map<String, String> newOptions = new HashMap<>(options);
newOptions.put(JavaCore.COMPILER_TASK_TAGS, "todo"); //$NON-NLS-1$
newOptions.put(JavaCore.COMPILER_TASK_PRIORITIES, "NORMAL"); //$NON-NLS-1$

Expand Down Expand Up @@ -138,8 +137,8 @@ public void testToDoMarker() throws JavaModelException {
* http://bugs.eclipse.org/bugs/show_bug.cgi?id=91426
*/
public void testToDoMarker2() throws JavaModelException {
Hashtable options = JavaCore.getOptions();
Hashtable newOptions = JavaCore.getOptions();
Map<String, String> options = JavaCore.getUnmodifiableOptions();
Map<String, String> newOptions = new HashMap<>(options);
newOptions.put(JavaCore.COMPILER_TASK_TAGS, "TODO,FIXME,XXX"); //$NON-NLS-1$
newOptions.put(JavaCore.COMPILER_TASK_PRIORITIES, "NORMAL,HIGH,LOW"); //$NON-NLS-1$

Expand Down Expand Up @@ -200,8 +199,8 @@ public void testToDoMarker2() throws JavaModelException {
* http://bugs.eclipse.org/bugs/show_bug.cgi?id=110797
*/
public void testTags() throws JavaModelException {
Hashtable options = JavaCore.getOptions();
Hashtable newOptions = JavaCore.getOptions();
Map<String, String> options = JavaCore.getUnmodifiableOptions();
Map<String, String> newOptions = new HashMap<>(options);
newOptions.put(JavaCore.COMPILER_TASK_TAGS, "TODO,FIXME,XXX"); //$NON-NLS-1$
newOptions.put(JavaCore.COMPILER_TASK_PRIORITIES, "NORMAL,HIGH,LOW"); //$NON-NLS-1$

Expand Down Expand Up @@ -256,8 +255,8 @@ public void testTags() throws JavaModelException {
* http://bugs.eclipse.org/bugs/show_bug.cgi?id=110797
*/
public void testTags2() throws JavaModelException {
Hashtable options = JavaCore.getOptions();
Hashtable newOptions = JavaCore.getOptions();
Map<String, String> options = JavaCore.getUnmodifiableOptions();
Map<String, String> newOptions = new HashMap<>(options);
newOptions.put(JavaCore.COMPILER_TASK_TAGS, "TODO,FIXME,XXX"); //$NON-NLS-1$
newOptions.put(JavaCore.COMPILER_TASK_PRIORITIES, "NORMAL,HIGH,LOW"); //$NON-NLS-1$

Expand Down Expand Up @@ -306,10 +305,10 @@ public void testTags2() throws JavaModelException {
* (regression test for bug 123721 two types of 'remove' for TODO task tags)
*/
public void testTags3() throws CoreException {
Hashtable options = JavaCore.getOptions();
Map<String, String> options = JavaCore.getUnmodifiableOptions();

try {
Hashtable newOptions = JavaCore.getOptions();
Map<String, String> newOptions = new HashMap<>(options);
newOptions.put(JavaCore.COMPILER_TASK_TAGS, "TODO,FIXME,XXX"); //$NON-NLS-1$
newOptions.put(JavaCore.COMPILER_TASK_PRIORITIES, "NORMAL,HIGH,LOW"); //$NON-NLS-1$

Expand Down Expand Up @@ -342,8 +341,8 @@ public void testTags3() throws CoreException {
* http://bugs.eclipse.org/bugs/show_bug.cgi?id=92821
*/
public void testUnusedImport() throws JavaModelException {
Hashtable options = JavaCore.getOptions();
Hashtable newOptions = JavaCore.getOptions();
Map<String, String> options = JavaCore.getUnmodifiableOptions();
Map<String, String> newOptions = new HashMap<>(options);
newOptions.put(JavaCore.COMPILER_PB_UNUSED_IMPORT, JavaCore.WARNING);

JavaCore.setOptions(newOptions);
Expand Down Expand Up @@ -510,8 +509,8 @@ public void _testUpdateWkspPreferences() throws JavaModelException {
}

public void testTags4() throws JavaModelException {
Hashtable options = JavaCore.getOptions();
Hashtable newOptions = JavaCore.getOptions();
Map<String, String> options = JavaCore.getUnmodifiableOptions();
Map<String, String> newOptions = new HashMap<>(options);
newOptions.put(JavaCore.COMPILER_TASK_TAGS, "TODO!,TODO,TODO?"); //$NON-NLS-1$
newOptions.put(JavaCore.COMPILER_TASK_PRIORITIES, "HIGH,NORMAL,LOW"); //$NON-NLS-1$

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import junit.framework.Test;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
Expand Down Expand Up @@ -164,7 +164,7 @@ public void testClosedProject() throws JavaModelException, IOException {
//----------------------------
// Step 3
//----------------------------
Hashtable<String, String> options = JavaCore.getOptions();
Map<String, String> options = JavaCore.getUnmodifiableOptions();
options.put(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, JavaCore.IGNORE);
JavaCore.setOptions(options);
env.closeProject(project1Path);
Expand Down Expand Up @@ -215,7 +215,7 @@ public void testCorruptBuilder() throws JavaModelException {
fullBuild();
expectingNoProblems();

Hashtable<String, String> options = JavaCore.getOptions();
Map<String, String> options = JavaCore.getUnmodifiableOptions();
options.put(JavaCore.CORE_JAVA_BUILD_RECREATE_MODIFIED_CLASS_FILES_IN_OUTPUT_FOLDER, JavaCore.ENABLED);
JavaCore.setOptions(options);

Expand Down Expand Up @@ -264,7 +264,7 @@ public void testCorruptBuilder2() throws JavaModelException {
env.waitForAutoBuild();
expectingNoProblems();

Hashtable<String, String> options = JavaCore.getOptions();
Map<String, String> options = JavaCore.getUnmodifiableOptions();
options.put(JavaCore.CORE_JAVA_BUILD_RECREATE_MODIFIED_CLASS_FILES_IN_OUTPUT_FOLDER, JavaCore.ENABLED);
JavaCore.setOptions(options);

Expand Down Expand Up @@ -920,7 +920,7 @@ public void testMissingProject() throws JavaModelException {
//----------------------------
// Step 3
//----------------------------
Hashtable<String, String> options = JavaCore.getOptions();
Map<String, String> options = JavaCore.getUnmodifiableOptions();
options.put(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, JavaCore.IGNORE);
JavaCore.setOptions(options);
env.waitForManualRefresh();
Expand Down Expand Up @@ -971,7 +971,7 @@ public void testMissingOptionalProject() throws JavaModelException {
//----------------------------
// Step 3
//----------------------------
Hashtable<String, String> options = JavaCore.getOptions();
Map<String, String> options = JavaCore.getUnmodifiableOptions();
options.put(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, JavaCore.IGNORE);
JavaCore.setOptions(options);
env.waitForManualRefresh();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
import java.io.StringWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Hashtable;
import java.util.HashMap;
import java.util.Map;
import junit.framework.Test;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
Expand Down Expand Up @@ -440,8 +441,8 @@ private String getResourceOuput(IResource[] resources) {

// ignore optional errors
public void test0108() throws JavaModelException {
Hashtable options = JavaCore.getOptions();
Hashtable newOptions = JavaCore.getOptions();
Map<String, String> options = JavaCore.getUnmodifiableOptions();
Map<String, String> newOptions = new HashMap<>(options);
newOptions.put(JavaCore.COMPILER_PB_UNUSED_LOCAL, JavaCore.ERROR);

JavaCore.setOptions(newOptions);
Expand Down Expand Up @@ -473,8 +474,8 @@ public void test0108() throws JavaModelException {

// two different source folders ignore only from one
public void test0109() throws JavaModelException {
Hashtable options = JavaCore.getOptions();
Hashtable newOptions = JavaCore.getOptions();
Map<String, String> options = JavaCore.getUnmodifiableOptions();
Map<String, String> newOptions = new HashMap<>(options);
newOptions.put(JavaCore.COMPILER_PB_UNUSED_LOCAL, JavaCore.ERROR);

JavaCore.setOptions(newOptions);
Expand Down Expand Up @@ -517,8 +518,8 @@ public void test0109() throws JavaModelException {

// two different source folders ignore from both
public void test0110() throws JavaModelException {
Hashtable options = JavaCore.getOptions();
Hashtable newOptions = JavaCore.getOptions();
Map<String, String> options = JavaCore.getUnmodifiableOptions();
Map<String, String> newOptions = new HashMap<>(options);
newOptions.put(JavaCore.COMPILER_PB_UNUSED_LOCAL, JavaCore.ERROR);

JavaCore.setOptions(newOptions);
Expand Down Expand Up @@ -561,8 +562,8 @@ public void test0110() throws JavaModelException {

//non-optional errors cannot be ignored
public void test0111() throws JavaModelException {
Hashtable options = JavaCore.getOptions();
Hashtable newOptions = JavaCore.getOptions();
Map<String, String> options = JavaCore.getUnmodifiableOptions();
Map<String, String> newOptions = new HashMap<>(options);
newOptions.put(JavaCore.COMPILER_PB_UNUSED_LOCAL, JavaCore.ERROR);

JavaCore.setOptions(newOptions);
Expand Down Expand Up @@ -597,8 +598,8 @@ public void test0111() throws JavaModelException {

//task tags cannot be ignored
public void test0112() throws JavaModelException {
Hashtable options = JavaCore.getOptions();
Hashtable newOptions = JavaCore.getOptions();
Map<String, String> options = JavaCore.getUnmodifiableOptions();
Map<String, String> newOptions = new HashMap<>(options);
newOptions.put(JavaCore.COMPILER_PB_UNUSED_LOCAL, JavaCore.ERROR);
newOptions.put(JavaCore.COMPILER_TASK_TAGS, "TODO");
newOptions.put(JavaCore.COMPILER_TASK_PRIORITIES, "NORMAL");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
*******************************************************************************/
package org.eclipse.jdt.core.tests.builder;

import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;
import junit.framework.Test;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IMarker;
Expand Down Expand Up @@ -1136,7 +1138,7 @@ public void testBug334377() throws JavaModelException {
Hashtable options = null;
try {
options = JavaCore.getOptions();
Hashtable newOptions = JavaCore.getOptions();
Map<String, String> newOptions = new HashMap<>(options);
newOptions.put(JavaCore.COMPILER_COMPLIANCE, CompilerOptions.getFirstSupportedJavaVersion());
newOptions.put(JavaCore.COMPILER_SOURCE, CompilerOptions.getFirstSupportedJavaVersion());
newOptions.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, CompilerOptions.getFirstSupportedJavaVersion());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
*******************************************************************************/
package org.eclipse.jdt.core.tests.builder;

import java.util.Hashtable;
import java.util.HashMap;
import java.util.Map;
import junit.framework.Test;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
Expand All @@ -29,7 +30,6 @@
import org.eclipse.test.OrderedTestSuite;


@SuppressWarnings({"rawtypes", "unchecked"})
public class MultiProjectTests extends BuilderTests {

static {
Expand Down Expand Up @@ -176,7 +176,7 @@ public void testCompileOnlyStructuralDependent() throws JavaModelException {
}

public void testRemoveField() throws JavaModelException {
Hashtable options = JavaCore.getOptions();
Map<String, String> options = JavaCore.getOptions();
options.put(JavaCore.COMPILER_PB_UNUSED_LOCAL, JavaCore.IGNORE);
JavaCore.setOptions(options);

Expand Down Expand Up @@ -230,8 +230,8 @@ public void testRemoveField() throws JavaModelException {
}

public void testCompileOrder() throws JavaModelException {
Hashtable options = JavaCore.getOptions();
Hashtable newOptions = JavaCore.getOptions();
Map<String, String> options = JavaCore.getUnmodifiableOptions();
Map<String, String> newOptions = new HashMap<>(options);
newOptions.put(JavaCore.CORE_CIRCULAR_CLASSPATH, JavaCore.WARNING);

JavaCore.setOptions(newOptions);
Expand Down Expand Up @@ -348,8 +348,8 @@ public void testCyclesCleared() throws JavaModelException {
}

public void testCycle1() throws JavaModelException {
Hashtable options = JavaCore.getOptions();
Hashtable newOptions = JavaCore.getOptions();
Map<String, String> options = JavaCore.getUnmodifiableOptions();
Map<String, String> newOptions = new HashMap<>(options);
newOptions.put(JavaCore.CORE_CIRCULAR_CLASSPATH, JavaCore.WARNING);

JavaCore.setOptions(newOptions);
Expand Down Expand Up @@ -461,8 +461,8 @@ public void testCycle1() throws JavaModelException {
}

public void testCycle2() throws JavaModelException {
Hashtable options = JavaCore.getOptions();
Hashtable newOptions = JavaCore.getOptions();
Map<String, String> options = JavaCore.getUnmodifiableOptions();
Map<String, String> newOptions = new HashMap<>(options);
newOptions.put(JavaCore.CORE_CIRCULAR_CLASSPATH, JavaCore.WARNING);

JavaCore.setOptions(newOptions);
Expand Down Expand Up @@ -575,8 +575,8 @@ public void testCycle2() throws JavaModelException {
}

public void testCycle3() throws JavaModelException {
Hashtable options = JavaCore.getOptions();
Hashtable newOptions = JavaCore.getOptions();
Map<String, String> options = JavaCore.getUnmodifiableOptions();
Map<String, String> newOptions = new HashMap<>(options);
newOptions.put(JavaCore.CORE_CIRCULAR_CLASSPATH, JavaCore.WARNING);

JavaCore.setOptions(newOptions);
Expand Down Expand Up @@ -719,8 +719,8 @@ public void testCycle3() throws JavaModelException {
}
}
public void testCycle4() throws JavaModelException {
Hashtable options = JavaCore.getOptions();
Hashtable newOptions = JavaCore.getOptions();
Map<String, String> options = JavaCore.getUnmodifiableOptions();
Map<String, String> newOptions = new HashMap<>(options);
newOptions.put(JavaCore.CORE_CIRCULAR_CLASSPATH, JavaCore.WARNING);

JavaCore.setOptions(newOptions);
Expand Down Expand Up @@ -861,8 +861,8 @@ public void testCycle4() throws JavaModelException {
}

public void testCycle5() throws JavaModelException {
Hashtable options = JavaCore.getOptions();
Hashtable newOptions = JavaCore.getOptions();
Map<String, String> options = JavaCore.getUnmodifiableOptions();
Map<String, String> newOptions = new HashMap<>(options);
newOptions.put(JavaCore.CORE_CIRCULAR_CLASSPATH, JavaCore.WARNING); // $NON-NLS-1$

JavaCore.setOptions(newOptions);
Expand Down Expand Up @@ -971,8 +971,8 @@ public void testCycle5() throws JavaModelException {
// this one fails; compare with testCycle7 (only one change in Object source),
// which passes
public void testCycle6() throws JavaModelException {
Hashtable options = JavaCore.getOptions();
Hashtable newOptions = JavaCore.getOptions();
Map<String, String> options = JavaCore.getUnmodifiableOptions();
Map<String, String> newOptions = new HashMap<>(options);
newOptions.put(JavaCore.CORE_CIRCULAR_CLASSPATH, JavaCore.WARNING);

JavaCore.setOptions(newOptions);
Expand Down Expand Up @@ -1085,8 +1085,8 @@ public void testCycle6() throws JavaModelException {
// this one passes; compare with testCycle6 (only one change in Object source),
// which fails
public void testCycle7() throws JavaModelException {
Hashtable options = JavaCore.getOptions();
Hashtable newOptions = JavaCore.getOptions();
Map<String, String> options = JavaCore.getUnmodifiableOptions();
Map<String, String> newOptions = new HashMap<>(options);
newOptions.put(JavaCore.CORE_CIRCULAR_CLASSPATH, JavaCore.WARNING);

JavaCore.setOptions(newOptions);
Expand Down Expand Up @@ -1193,8 +1193,8 @@ public void testCycle7() throws JavaModelException {
}
public void testCycle8() throws JavaModelException {
// specifically tests projects with (transitive) dependencies on a cycle, i.e., error messages with a non-empty prefix
Hashtable options = JavaCore.getOptions();
Hashtable newOptions = JavaCore.getOptions();
Map<String, String> options = JavaCore.getUnmodifiableOptions();
Map<String, String> newOptions = new HashMap<>(options);
newOptions.put(JavaCore.CORE_CIRCULAR_CLASSPATH, JavaCore.WARNING);

JavaCore.setOptions(newOptions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ public void test7() throws IOException {
try {
ASTParser parser = ASTParser.newParser(AST_JLS_LATEST);
parser.setKind(ASTParser.K_COMPILATION_UNIT);
parser.setCompilerOptions(JavaCore.getOptions());
parser.setCompilerOptions(JavaCore.getUnmodifiableOptions());
parser.createASTs(
new String[] { file.toPath().normalize().toAbsolutePath().toString(), fileY.toPath().normalize().toAbsolutePath().toString() },
null,
Expand Down Expand Up @@ -1667,7 +1667,7 @@ public void testBug482254() throws IOException {
parser.setKind(ASTParser.K_COMPILATION_UNIT);
parser.setEnvironment(null, null, null, true);
parser.setResolveBindings(true);
parser.setCompilerOptions(JavaCore.getOptions());
parser.setCompilerOptions(JavaCore.getUnmodifiableOptions());
parser.createASTs(
new String[] { file.toPath().normalize().toAbsolutePath().toString(), fileYPath, fileZPath, file2.toPath().normalize().toAbsolutePath().toString() },
null,
Expand Down
Loading
Loading