From 2c2f1578591c8c1897e5167a4e07b27fe5f22395 Mon Sep 17 00:00:00 2001 From: Andrey Loskutov Date: Fri, 26 Jul 2024 19:15:23 +0200 Subject: [PATCH] Don't use compiler options below 1.8 See https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2536 --- .../jdt/text/tests/MarkOccurrenceTest1d7.java | 4 +- .../Java1d7CompletionTestSetup.java | 4 +- .../tests/refactoring/RenamePackageTests.java | 4 +- .../jdt/testplugin/JavaProjectHelper.java | 89 +------ .../eclipse/jdt/testplugin/TestOptions.java | 2 +- .../jdt/junit/tests/JUnitTestFinderTest.java | 66 ++--- .../jdt/ui/tests/core/AddImportTest.java | 4 +- .../jdt/ui/tests/core/JDTFlagsTest18.java | 6 +- .../core/rules/Java1d4ProjectTestSetup.java | 3 +- .../core/rules/Java1d5ProjectTestSetup.java | 3 +- .../core/rules/Java1d6ProjectTestSetup.java | 3 +- .../core/rules/Java1d7ProjectTestSetup.java | 3 +- .../source/GenerateHashCodeEqualsTest.java | 243 ++++++++---------- .../ui/tests/jarexport/FatJarExportTests.java | 8 - .../tests/jarexport/PlainJarExportTests.java | 10 - .../quickfix/AdvancedQuickAssistTest.java | 4 +- .../quickfix/AdvancedQuickAssistTest1d5.java | 4 +- .../quickfix/AdvancedQuickAssistTest1d7.java | 4 +- .../ui/tests/quickfix/AssistQuickFixTest.java | 151 +++++------ .../tests/quickfix/AssistQuickFixTest1d7.java | 4 +- .../jdt/ui/tests/quickfix/CleanUpTest1d4.java | 6 +- .../jdt/ui/tests/quickfix/CleanUpTest1d5.java | 4 +- .../jdt/ui/tests/quickfix/CleanUpTest1d6.java | 4 +- .../jdt/ui/tests/quickfix/CleanUpTest1d7.java | 220 ++++++++-------- .../ConvertIterableLoopQuickFixTest1d7.java | 4 +- .../LocalCorrectionsQuickFixTest.java | 1 - .../LocalCorrectionsQuickFixTest1d7.java | 88 +++---- .../ModifierCorrectionsQuickFixTest1d7.java | 4 +- .../quickfix/QuickFixEnablementTest.java | 8 - .../quickfix/TypeMismatchQuickFixTests.java | 75 +++--- .../jdt/ui/tests/views/SmokeViewsTest.java | 2 +- 31 files changed, 434 insertions(+), 601 deletions(-) diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/MarkOccurrenceTest1d7.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/MarkOccurrenceTest1d7.java index 515a8bb49d8..0add9ba801a 100644 --- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/MarkOccurrenceTest1d7.java +++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/MarkOccurrenceTest1d7.java @@ -40,7 +40,7 @@ import org.eclipse.jdt.internal.core.manipulation.search.MethodExitsFinder; import org.eclipse.jdt.ui.PreferenceConstants; -import org.eclipse.jdt.ui.tests.core.rules.Java1d7ProjectTestSetup; +import org.eclipse.jdt.ui.tests.core.rules.Java1d8ProjectTestSetup; import org.eclipse.jdt.internal.ui.JavaPlugin; @@ -50,7 +50,7 @@ */ public class MarkOccurrenceTest1d7 { @Rule - public Java1d7ProjectTestSetup j7s= new Java1d7ProjectTestSetup(); + public Java1d8ProjectTestSetup j7s= new Java1d8ProjectTestSetup(); private ASTParser fParser; diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/Java1d7CompletionTestSetup.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/Java1d7CompletionTestSetup.java index be0467cc79b..2adae5bcd3e 100644 --- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/Java1d7CompletionTestSetup.java +++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/Java1d7CompletionTestSetup.java @@ -21,12 +21,12 @@ import org.eclipse.jdt.core.IPackageFragment; import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jdt.ui.tests.core.rules.Java1d7ProjectTestSetup; +import org.eclipse.jdt.ui.tests.core.rules.Java1d8ProjectTestSetup; /** * This class is used to run tests on Java Dolphin 1.7 . */ -class Java1d7CompletionTestSetup extends Java1d7ProjectTestSetup { +class Java1d7CompletionTestSetup extends Java1d8ProjectTestSetup { public IPackageFragment getTestPackage() throws CoreException { IJavaProject project= getProject(); IPackageFragmentRoot root= project.getPackageFragmentRoot("src"); diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenamePackageTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenamePackageTests.java index 4edf2d0ed9d..a2a882cc6c4 100644 --- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenamePackageTests.java +++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenamePackageTests.java @@ -508,14 +508,14 @@ private void helperProjectsPrgTest(String[][] packageNames, String newPackageNam assertNotNull(JavaProjectHelper.addRTJar(projectPrg)); IPackageFragmentRoot srcPrg= JavaProjectHelper.addSourceContainer(projectPrg, "srcPrg"); Map optionsPrg= projectPrg.getOptions(false); - JavaProjectHelper.set15CompilerOptions(optionsPrg); + JavaProjectHelper.set18CompilerOptions(optionsPrg); projectPrg.setOptions(optionsPrg); projectTest= JavaProjectHelper.createJavaProject("RenamePack2", "bin"); assertNotNull(JavaProjectHelper.addRTJar(projectTest)); IPackageFragmentRoot srcTest= JavaProjectHelper.addSourceContainer(projectTest, "srcTest"); Map optionsTest= projectTest.getOptions(false); - JavaProjectHelper.set15CompilerOptions(optionsTest); + JavaProjectHelper.set18CompilerOptions(optionsTest); projectTest.setOptions(optionsTest); JavaProjectHelper.addRequiredProject(projectTest, projectPrg); diff --git a/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/JavaProjectHelper.java b/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/JavaProjectHelper.java index cb0bbbe3eb7..a64e147ff54 100644 --- a/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/JavaProjectHelper.java +++ b/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/JavaProjectHelper.java @@ -356,47 +356,6 @@ public static void set18CompilerOptions(IJavaProject project) { project.setOptions(options); } - /** - * Sets the compiler options to 1.7 for the given project. - * @param project the java project - */ - public static void set17CompilerOptions(IJavaProject project) { - Map options= project.getOptions(false); - JavaProjectHelper.set17CompilerOptions(options); - project.setOptions(options); - } - - /** - * Sets the compiler options to 1.6 for the given project. - * @param project the java project - */ - public static void set16CompilerOptions(IJavaProject project) { - Map options= project.getOptions(false); - JavaProjectHelper.set16CompilerOptions(options); - project.setOptions(options); - } - - /** - * Sets the compiler options to 1.5 for the given project. - * @param project the java project - */ - public static void set15CompilerOptions(IJavaProject project) { - Map options= project.getOptions(false); - JavaProjectHelper.set15CompilerOptions(options); - project.setOptions(options); - } - - /** - * Sets the compiler options to 1.4 for the given project. - * @param project the java project - */ - public static void set14CompilerOptions(IJavaProject project) { - Map options= project.getOptions(false); - JavaProjectHelper.set14CompilerOptions(options); - project.setOptions(options); - } - - /** * Sets the compiler options to 9. * @@ -508,46 +467,6 @@ public static void setLatestCompilerOptions(IJavaProject project) { project.setOptions(options); } - /** - * Sets the compiler options to 1.7 - * @param options The compiler options to configure - */ - public static void set17CompilerOptions(Map options) { - JavaCore.setComplianceOptions(JavaCore.VERSION_1_7, options); - } - - /** - * Sets the compiler options to 1.6 - * @param options The compiler options to configure - */ - public static void set16CompilerOptions(Map options) { - JavaCore.setComplianceOptions(JavaCore.VERSION_1_6, options); - } - - /** - * Sets the compiler options to 1.5 - * @param options The compiler options to configure - */ - public static void set15CompilerOptions(Map options) { - JavaCore.setComplianceOptions(JavaCore.VERSION_1_5, options); - } - - /** - * Sets the compiler options to 1.4 - * @param options The compiler options to configure - */ - public static void set14CompilerOptions(Map options) { - JavaCore.setComplianceOptions(JavaCore.VERSION_1_4, options); - } - - /** - * Sets the compiler options to 1.3 - * @param options The compiler options to configure - */ - public static void set13CompilerOptions(Map options) { - JavaCore.setComplianceOptions(JavaCore.VERSION_1_3, options); - } - /** * Removes an IJavaElement's resource. Retries if deletion failed (e.g. because the indexer * still locks the file). @@ -931,7 +850,7 @@ public static IPackageFragmentRoot addRTJar13(IJavaProject jproject) throws Core IPath[] rtJarPath= findRtJar(RT_STUBS_13); Map options= jproject.getOptions(false); - JavaProjectHelper.set13CompilerOptions(options); + JavaProjectHelper.set18CompilerOptions(options); jproject.setOptions(options); return addLibrary(jproject, rtJarPath[0], rtJarPath[1], rtJarPath[2]); @@ -939,19 +858,19 @@ public static IPackageFragmentRoot addRTJar13(IJavaProject jproject) throws Core public static IPackageFragmentRoot addRTJar15(IJavaProject jproject) throws CoreException, JavaModelException { IPath[] rtJarPath= findRtJar(RT_STUBS_15); - set15CompilerOptions(jproject); + set18CompilerOptions(jproject); return addLibrary(jproject, rtJarPath[0], rtJarPath[1], rtJarPath[2]); } public static IPackageFragmentRoot addRTJar16(IJavaProject jproject) throws CoreException { IPath[] rtJarPath= findRtJar(RT_STUBS_16); - set16CompilerOptions(jproject); + set18CompilerOptions(jproject); return addLibrary(jproject, rtJarPath[0], rtJarPath[1], rtJarPath[2]); } public static IPackageFragmentRoot addRTJar17(IJavaProject jproject) throws CoreException { IPath[] rtJarPath= findRtJar(RT_STUBS_17); - set17CompilerOptions(jproject); + set18CompilerOptions(jproject); return addLibrary(jproject, rtJarPath[0], rtJarPath[1], rtJarPath[2]); } diff --git a/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/TestOptions.java b/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/TestOptions.java index f2307d9fabf..4ec5dcf0b2f 100644 --- a/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/TestOptions.java +++ b/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/TestOptions.java @@ -60,7 +60,7 @@ public static void initializeCodeGenerationOptions() { public static void initializeProjectOptions(IJavaProject project) { Map options= new HashMap<>(); - JavaProjectHelper.set15CompilerOptions(options); + JavaProjectHelper.set18CompilerOptions(options); project.setOptions(options); } diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/JUnitTestFinderTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/JUnitTestFinderTest.java index 6ccd4a620b4..840299bb8c9 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/JUnitTestFinderTest.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/JUnitTestFinderTest.java @@ -68,7 +68,7 @@ public String toString() { @Parameters(name = "{0}") public static Collection getTestScenarios() { - return List.of(new TestScenario("JUnit4", JUnitCore.JUNIT4_CONTAINER_PATH, JavaProjectHelper::set15CompilerOptions, TestKindRegistry.JUNIT4_TEST_KIND_ID), // + return List.of(new TestScenario("JUnit4", JUnitCore.JUNIT4_CONTAINER_PATH, JavaProjectHelper::set18CompilerOptions, TestKindRegistry.JUNIT4_TEST_KIND_ID), // new TestScenario("JUnit5", JUnitCore.JUNIT5_CONTAINER_PATH, JavaProjectHelper::set18CompilerOptions, TestKindRegistry.JUNIT5_TEST_KIND_ID)); } @@ -102,7 +102,7 @@ public void testTestCase() throws Exception { String str= """ package p; import junit.framework.TestCase; - + public class MyTest extends TestCase { public void testFoo() { } @@ -116,7 +116,7 @@ public void testFoo() { String str1= """ package p; import junit.framework.TestCase; - + public class MySuperTest extends MyTest { public void testFoo() { } @@ -130,7 +130,7 @@ public void testFoo() { String str2= """ package p; import junit.framework.TestCase; - + class InvisibleTest extends TestCase { public void testFoo() { } @@ -145,7 +145,7 @@ public void testFoo() { String str3= """ package p; import junit.framework.TestCase; - + public class Outer { public static class InnerTest extends TestCase { public void testFoo() { @@ -188,7 +188,7 @@ public void testFoo() { String str4= """ package p; import junit.framework.TestCase; - + public abstract class AbstractTest extends TestCase { public void testFoo() { } @@ -202,7 +202,7 @@ public void testFoo() { String str5= """ package p; import java.util.Vector; - + public class NoTest extends Vector { public void testFoo() { } @@ -226,7 +226,7 @@ public void testSuiteFinder() throws Exception { String str= """ package p; import junit.framework.Test; - + public class SuiteClass { public static Test suite() { return null; @@ -249,9 +249,9 @@ public void testRunWith() throws Exception { IPackageFragment p= fRoot.createPackageFragment("p", true, null); String str= """ package p; - + import org.junit.Test; - + public class Test1 { @Test public void testFoo() { } @@ -261,11 +261,11 @@ public class Test1 { String str1= """ package p; - + import org.junit.runner.RunWith; import org.junit.runners.Suite; import org.junit.runners.Suite.SuiteClasses; - + @RunWith(Suite.class) @SuiteClasses(Test1.class) public class Test2 { @@ -279,7 +279,7 @@ public class Test2 { String str2= """ package p; - + public class Test3 extends Test2 { \s } @@ -291,11 +291,11 @@ public class Test3 extends Test2 { String str3= """ package p; - + import org.junit.runner.RunWith; import org.junit.runners.Suite; import org.junit.runners.Suite.SuiteClasses; - + @RunWith(Suite.class) @SuiteClasses(Test1.class) public interface Test4 { @@ -309,11 +309,11 @@ public interface Test4 { String str4= """ package p; - + import org.junit.runner.RunWith; import org.junit.runners.Suite; import org.junit.runners.Suite.SuiteClasses; - + @RunWith(Suite.class) @SuiteClasses(Test1.class) class Test5 { @@ -327,9 +327,9 @@ class Test5 { String str5= """ package p; - + import org.junit.runner.RunWith; - + @SuiteClasses(Test1.class) public class Test6 { RunWith aRunWith; @@ -343,11 +343,11 @@ public class Test6 { String str6= """ import java.util.Arrays; import java.util.Collection; - + import org.junit.runners.Parameterized.Parameters; - + public class Test7 extends StackTest { - + public Test7(int num) { super(num); } @@ -383,9 +383,9 @@ public void testTestAnnotation() throws Exception { IPackageFragment p= fRoot.createPackageFragment("p", true, null); String str= """ package p; - + import org.junit.Test; - + public class Test1 { @Test public void testFoo() { } @@ -399,7 +399,7 @@ public class Test1 { String str1= """ package p; - + public class Test2 extends Test1 { public void testBar() { } @@ -413,9 +413,9 @@ public void testBar() { String str2= """ package p; - + import org.junit.Test; - + public class Test3 { @Test void testFoo() { } @@ -429,9 +429,9 @@ public class Test3 { String str3= """ package p; - + import org.junit.Test; - + public abstract class AbstractTest { @Test public void testBar() { } @@ -455,9 +455,9 @@ public void testTestAnnotation_bug204682() throws Exception { IPackageFragment p= fRoot.createPackageFragment("p", true, null); String str= """ package p; - + import org.junit.Test; - + public class Test1 { Test testFoo1() { return null; @@ -479,9 +479,9 @@ public void testTestAnnotation2() throws Exception { IPackageFragment p= fRoot.createPackageFragment("p", true, null); String str= """ package p; - + import org.junit.Test; - + @RunWith(Suite.class) @SuiteClasses(Test1.class) public class Test1 { diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/AddImportTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/AddImportTest.java index d57d4f05761..9bc71bbd864 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/AddImportTest.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/AddImportTest.java @@ -69,7 +69,7 @@ public class AddImportTest extends CoreTests { @Before public void setUp() throws Exception { fJProject1= pts.getProject(); - JavaProjectHelper.set15CompilerOptions(fJProject1); + JavaProjectHelper.set18CompilerOptions(fJProject1); Hashtable options= TestOptions.getDefaultOptions(); options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, String.valueOf(99)); @@ -1377,7 +1377,7 @@ public class C { @Test public void testAddImportActionStaticWith14() throws Exception { - JavaProjectHelper.set14CompilerOptions(fJProject1); + JavaProjectHelper.set18CompilerOptions(fJProject1); IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src"); diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/JDTFlagsTest18.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/JDTFlagsTest18.java index 68d65bea6f7..70c5d887957 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/JDTFlagsTest18.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/JDTFlagsTest18.java @@ -130,7 +130,7 @@ public void testNestedEnumInEnum() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); String str= """ package test1; - + enum Snippet { A; enum E { @@ -157,7 +157,7 @@ public String getLidCode() { return "B"; } }, OVERWHELMING { - + public String getLidCode() { return "A"; } @@ -478,7 +478,7 @@ public void testIsStaticAnnotationType() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); String str= """ package test1; - + public @interface Snippet { int i= 0; public String name(); diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/rules/Java1d4ProjectTestSetup.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/rules/Java1d4ProjectTestSetup.java index b52b36d2bbe..b4ac66d1127 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/rules/Java1d4ProjectTestSetup.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/rules/Java1d4ProjectTestSetup.java @@ -26,6 +26,7 @@ /** * Setup the tests related to Java 1.4 (i.e. Merlin). */ +@Deprecated public class Java1d4ProjectTestSetup extends ProjectTestSetup { public Java1d4ProjectTestSetup() { @@ -36,7 +37,7 @@ public Java1d4ProjectTestSetup() { @Override protected IJavaProject createAndInitializeProject() throws CoreException { IJavaProject javaProject= super.createAndInitializeProject(); - JavaProjectHelper.set14CompilerOptions(javaProject); + JavaProjectHelper.set18CompilerOptions(javaProject); return javaProject; } } diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/rules/Java1d5ProjectTestSetup.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/rules/Java1d5ProjectTestSetup.java index d9bc9c88cd9..fca9db43676 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/rules/Java1d5ProjectTestSetup.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/rules/Java1d5ProjectTestSetup.java @@ -26,6 +26,7 @@ /** * Setups the tests related to Java 5 (i.e. Tiger). */ +@Deprecated public class Java1d5ProjectTestSetup extends ProjectTestSetup { public Java1d5ProjectTestSetup() { @@ -35,7 +36,7 @@ public Java1d5ProjectTestSetup() { @Override protected IJavaProject createAndInitializeProject() throws CoreException { IJavaProject javaProject= super.createAndInitializeProject(); - JavaProjectHelper.set15CompilerOptions(javaProject); + JavaProjectHelper.set18CompilerOptions(javaProject); return javaProject; } } diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/rules/Java1d6ProjectTestSetup.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/rules/Java1d6ProjectTestSetup.java index 21bb5a4d9fc..b5bba0b3193 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/rules/Java1d6ProjectTestSetup.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/rules/Java1d6ProjectTestSetup.java @@ -26,6 +26,7 @@ /** * Setup the tests related to Java 6 (i.e. Mustang). */ +@Deprecated public class Java1d6ProjectTestSetup extends ProjectTestSetup { public Java1d6ProjectTestSetup() { @@ -35,7 +36,7 @@ public Java1d6ProjectTestSetup() { @Override protected IJavaProject createAndInitializeProject() throws CoreException { IJavaProject javaProject= super.createAndInitializeProject(); - JavaProjectHelper.set16CompilerOptions(javaProject); + JavaProjectHelper.set18CompilerOptions(javaProject); return javaProject; } } diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/rules/Java1d7ProjectTestSetup.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/rules/Java1d7ProjectTestSetup.java index 54fa33ae801..851e5ccdca7 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/rules/Java1d7ProjectTestSetup.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/rules/Java1d7ProjectTestSetup.java @@ -23,6 +23,7 @@ import org.eclipse.jdt.core.IJavaProject; +@Deprecated public class Java1d7ProjectTestSetup extends ProjectTestSetup { public Java1d7ProjectTestSetup() { @@ -32,7 +33,7 @@ public Java1d7ProjectTestSetup() { @Override protected IJavaProject createAndInitializeProject() throws CoreException { IJavaProject javaProject= super.createAndInitializeProject(); - JavaProjectHelper.set17CompilerOptions(javaProject); + JavaProjectHelper.set18CompilerOptions(javaProject); return javaProject; } diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/source/GenerateHashCodeEqualsTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/source/GenerateHashCodeEqualsTest.java index 5b39443b36d..e41feb744b8 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/source/GenerateHashCodeEqualsTest.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/source/GenerateHashCodeEqualsTest.java @@ -21,9 +21,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import java.util.HashMap; -import java.util.Map; - import org.junit.Rule; import org.junit.Test; @@ -35,9 +32,7 @@ import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IField; import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.dom.AbstractTypeDeclaration; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jdt.core.dom.ITypeBinding; @@ -1845,77 +1840,68 @@ public class A {\r */ @Test public void subTypeAndArraysIn14() throws Exception { - IJavaProject javaProject= fPackageP.getJavaProject(); - Map oldOptions= javaProject.getOptions(false); - Map newOptions= new HashMap<>(oldOptions); - JavaModelUtil.setComplianceOptions(newOptions, JavaCore.VERSION_1_4); - javaProject.setOptions(newOptions); - try { - fPackageP.createCompilationUnit("B.java", "package p;\r\n" + - "\r\n" + - "public class B {\r\n" + - " public int hashCode() {\r\n" + - " return 1;\r\n" + - " }\r\n" + - " public boolean equals(Object obj) {\r\n" + - " return obj instanceof B;\r\n" + - " }\r\n" + - "\r\n" + - "}\r\n" + - "", true, null); - - ICompilationUnit a= fPackageP.createCompilationUnit("A.java", "package p;\r\n" + - "\r\n" + - "public class A extends B {\r\n" + - "\r\n" + - " A[] anArray;\r\n" + - " double[] anDArray;\r\n" + - "\r\n" + - "}\r\n" + - "", true, null); - - IField[] fields= getFields(a.getType("A"), new String[] {"anArray", "anDArray"}); - runOperation(a.getType("A"), fields, false, false); - - String expected= "package p;\r\n" + - "\r\n" + - "import java.util.Arrays;\r\n" + - "\r\n" + - "public class A extends B {\r\n" + - "\r\n" + - " A[] anArray;\r\n" + - " double[] anDArray;\r\n" + - " @Override\r\n" + - " public int hashCode() {\r\n" + - " final int prime = 31;\r\n" + - " int result = super.hashCode();\r\n" + - " result = prime * result + Arrays.hashCode(anArray);\r\n" + - " result = prime * result + Arrays.hashCode(anDArray);\r\n" + - " return result;\r\n" + - " }\r\n" + - " @Override\r\n" + - " public boolean equals(Object obj) {\r\n" + - " if (this == obj)\r\n" + - " return true;\r\n" + - " if (!super.equals(obj))\r\n" + - " return false;\r\n" + - " if (getClass() != obj.getClass())\r\n" + - " return false;\r\n" + - " A other = (A) obj;\r\n" + - " if (!Arrays.equals(anArray, other.anArray))\r\n" + - " return false;\r\n" + - " if (!Arrays.equals(anDArray, other.anDArray))\r\n" + - " return false;\r\n" + - " return true;\r\n" + - " }\r\n" + - "\r\n" + - "}\r\n" + - ""; - - compareSource(expected, a.getSource()); - } finally { - javaProject.setOptions(oldOptions); - } + fPackageP.createCompilationUnit("B.java", "package p;\r\n" + + "\r\n" + + "public class B {\r\n" + + " public int hashCode() {\r\n" + + " return 1;\r\n" + + " }\r\n" + + " public boolean equals(Object obj) {\r\n" + + " return obj instanceof B;\r\n" + + " }\r\n" + + "\r\n" + + "}\r\n" + + "", true, null); + + ICompilationUnit a= fPackageP.createCompilationUnit("A.java", "package p;\r\n" + + "\r\n" + + "public class A extends B {\r\n" + + "\r\n" + + " A[] anArray;\r\n" + + " double[] anDArray;\r\n" + + "\r\n" + + "}\r\n" + + "", true, null); + + IField[] fields= getFields(a.getType("A"), new String[] {"anArray", "anDArray"}); + runOperation(a.getType("A"), fields, false, false); + + String expected= "package p;\r\n" + + "\r\n" + + "import java.util.Arrays;\r\n" + + "\r\n" + + "public class A extends B {\r\n" + + "\r\n" + + " A[] anArray;\r\n" + + " double[] anDArray;\r\n" + + " @Override\r\n" + + " public int hashCode() {\r\n" + + " final int prime = 31;\r\n" + + " int result = super.hashCode();\r\n" + + " result = prime * result + Arrays.hashCode(anArray);\r\n" + + " result = prime * result + Arrays.hashCode(anDArray);\r\n" + + " return result;\r\n" + + " }\r\n" + + " @Override\r\n" + + " public boolean equals(Object obj) {\r\n" + + " if (this == obj)\r\n" + + " return true;\r\n" + + " if (!super.equals(obj))\r\n" + + " return false;\r\n" + + " if (getClass() != obj.getClass())\r\n" + + " return false;\r\n" + + " A other = (A) obj;\r\n" + + " if (!Arrays.equals(anArray, other.anArray))\r\n" + + " return false;\r\n" + + " if (!Arrays.equals(anDArray, other.anDArray))\r\n" + + " return false;\r\n" + + " return true;\r\n" + + " }\r\n" + + "\r\n" + + "}\r\n" + + ""; + + compareSource(expected, a.getSource()); } /** @@ -2203,62 +2189,53 @@ public void abstractSuperMethods() throws Exception { */ @Test public void arraysDeepEqualsIn15() throws Exception { - IJavaProject javaProject= fPackageP.getJavaProject(); - Map oldOptions= javaProject.getOptions(false); - Map newOptions= new HashMap<>(oldOptions); - JavaModelUtil.setComplianceOptions(newOptions, JavaCore.VERSION_1_5); - javaProject.setOptions(newOptions); - try { - ICompilationUnit a= fPackageP.createCompilationUnit("A.java", "package p;\r\n" + - "\r\n" + - "public class A {\r\n" + - "\r\n" + - " int[][][] a = new int[][][] {{null}};\r\n" + - " int[][][] b = new int[][][] {{null}};\r\n" + - "\r\n" + - "}\r\n" + - "", true, null); - - IField[] fields= getFields(a.getType("A"), new String[] {"a", "b"}); - runOperation(a.getType("A"), fields, false, false); - - String expected= "package p;\r\n" + - "\r\n" + - "import java.util.Arrays;\r\n" + - "\r\n" + - "public class A {\r\n" + - "\r\n" + - " int[][][] a = new int[][][] {{null}};\r\n" + - " int[][][] b = new int[][][] {{null}};\r\n" + - " @Override\r\n" + - " public int hashCode() {\r\n" + - " final int prime = 31;\r\n" + - " int result = 1;\r\n" + - " result = prime * result + Arrays.deepHashCode(a);\r\n" + - " result = prime * result + Arrays.deepHashCode(b);\r\n" + - " return result;\r\n" + - " }\r\n" + - " @Override\r\n" + - " public boolean equals(Object obj) {\r\n" + - " if (this == obj)\r\n" + - " return true;\r\n" + - " if (obj == null)\r\n" + - " return false;\r\n" + - " if (getClass() != obj.getClass())\r\n" + - " return false;\r\n" + - " A other = (A) obj;\r\n" + - " if (!Arrays.deepEquals(a, other.a))\r\n" + - " return false;\r\n" + - " if (!Arrays.deepEquals(b, other.b))\r\n" + - " return false;\r\n" + - " return true;\r\n" + - " }\r\n" + - "\r\n" + - "}" + - ""; - compareSource(expected, a.getSource()); - } finally { - javaProject.setOptions(oldOptions); - } + ICompilationUnit a= fPackageP.createCompilationUnit("A.java", "package p;\r\n" + + "\r\n" + + "public class A {\r\n" + + "\r\n" + + " int[][][] a = new int[][][] {{null}};\r\n" + + " int[][][] b = new int[][][] {{null}};\r\n" + + "\r\n" + + "}\r\n" + + "", true, null); + + IField[] fields= getFields(a.getType("A"), new String[] {"a", "b"}); + runOperation(a.getType("A"), fields, false, false); + + String expected= "package p;\r\n" + + "\r\n" + + "import java.util.Arrays;\r\n" + + "\r\n" + + "public class A {\r\n" + + "\r\n" + + " int[][][] a = new int[][][] {{null}};\r\n" + + " int[][][] b = new int[][][] {{null}};\r\n" + + " @Override\r\n" + + " public int hashCode() {\r\n" + + " final int prime = 31;\r\n" + + " int result = 1;\r\n" + + " result = prime * result + Arrays.deepHashCode(a);\r\n" + + " result = prime * result + Arrays.deepHashCode(b);\r\n" + + " return result;\r\n" + + " }\r\n" + + " @Override\r\n" + + " public boolean equals(Object obj) {\r\n" + + " if (this == obj)\r\n" + + " return true;\r\n" + + " if (obj == null)\r\n" + + " return false;\r\n" + + " if (getClass() != obj.getClass())\r\n" + + " return false;\r\n" + + " A other = (A) obj;\r\n" + + " if (!Arrays.deepEquals(a, other.a))\r\n" + + " return false;\r\n" + + " if (!Arrays.deepEquals(b, other.b))\r\n" + + " return false;\r\n" + + " return true;\r\n" + + " }\r\n" + + "\r\n" + + "}" + + ""; + compareSource(expected, a.getSource()); } } \ No newline at end of file diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/jarexport/FatJarExportTests.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/jarexport/FatJarExportTests.java index 1e4e531e88b..b5d2b10b149 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/jarexport/FatJarExportTests.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/jarexport/FatJarExportTests.java @@ -29,7 +29,6 @@ import java.io.File; import java.io.FileInputStream; import java.io.InputStream; -import java.util.Map; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; @@ -79,7 +78,6 @@ import org.eclipse.jdt.core.IPackageFragmentRoot; import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.internal.corext.util.JavaModelUtil; import org.eclipse.jdt.internal.junit.util.XmlProcessorFactoryJdtJunit; import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; @@ -126,12 +124,6 @@ public static void setUpTest() { public void setUp() throws Exception { fProject= pts.getProject(); - Map options= fProject.getOptions(false); - String compliance= JavaCore.VERSION_1_4; - JavaModelUtil.setComplianceOptions(options, compliance); - JavaModelUtil.setDefaultClassfileOptions(options, compliance); // complete compliance options - fProject.setOptions(options); - fMainRoot= JavaProjectHelper.addSourceContainer(fProject, "src"); //$NON-NLS-1$ IPackageFragment fragment= fMainRoot.createPackageFragment("org.eclipse.jdt.ui.test", true, null); //$NON-NLS-1$ String str = """ diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/jarexport/PlainJarExportTests.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/jarexport/PlainJarExportTests.java index d54da8a2687..a0b58b1bbd1 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/jarexport/PlainJarExportTests.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/jarexport/PlainJarExportTests.java @@ -23,7 +23,6 @@ import java.util.Collections; import java.util.Enumeration; import java.util.List; -import java.util.Map; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; @@ -50,9 +49,6 @@ import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IPackageFragment; import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jdt.core.JavaCore; - -import org.eclipse.jdt.internal.corext.util.JavaModelUtil; import org.eclipse.jdt.ui.jarpackager.IJarExportRunnable; import org.eclipse.jdt.ui.jarpackager.JarPackageData; @@ -80,12 +76,6 @@ public static void setUpTest() { public void setUp() throws Exception { fProject= pts.getProject(); - Map options= fProject.getOptions(false); - String compliance= JavaCore.VERSION_1_4; - JavaModelUtil.setComplianceOptions(options, compliance); - JavaModelUtil.setDefaultClassfileOptions(options, compliance); - fProject.setOptions(options); - fMainRoot= JavaProjectHelper.addSourceContainer(fProject, "src"); IPackageFragment fragment= fMainRoot.createPackageFragment("org.eclipse.jdt.ui.test", true, null); String str= """ diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AdvancedQuickAssistTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AdvancedQuickAssistTest.java index ef6d5e04584..5277e7918d7 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AdvancedQuickAssistTest.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AdvancedQuickAssistTest.java @@ -3335,7 +3335,7 @@ public String foo(Object b) { @Test public void testReplaceReturnIfWithCondition2() throws Exception { try { - JavaProjectHelper.set14CompilerOptions(fJProject1); + JavaProjectHelper.set18CompilerOptions(fJProject1); IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); String str= """ @@ -3370,7 +3370,7 @@ public Number foo(Integer integer) { assertExpectedExistInProposals(proposals, new String[] {expected1}); } finally { - JavaProjectHelper.set15CompilerOptions(fJProject1); + JavaProjectHelper.set18CompilerOptions(fJProject1); } } diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AdvancedQuickAssistTest1d5.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AdvancedQuickAssistTest1d5.java index 80356cf8b31..5cbd9a8ca8e 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AdvancedQuickAssistTest1d5.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AdvancedQuickAssistTest1d5.java @@ -38,7 +38,7 @@ import org.eclipse.jdt.internal.core.manipulation.StubUtility; import org.eclipse.jdt.ui.PreferenceConstants; -import org.eclipse.jdt.ui.tests.core.rules.Java1d5ProjectTestSetup; +import org.eclipse.jdt.ui.tests.core.rules.Java1d8ProjectTestSetup; import org.eclipse.jdt.ui.tests.core.rules.ProjectTestSetup; import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal; @@ -51,7 +51,7 @@ */ public class AdvancedQuickAssistTest1d5 extends QuickFixTest { @Rule - public ProjectTestSetup projectSetup= new Java1d5ProjectTestSetup(); + public ProjectTestSetup projectSetup= new Java1d8ProjectTestSetup(); private IJavaProject fJProject1; diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AdvancedQuickAssistTest1d7.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AdvancedQuickAssistTest1d7.java index de262fe8a62..0f2370a1cb6 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AdvancedQuickAssistTest1d7.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AdvancedQuickAssistTest1d7.java @@ -39,7 +39,7 @@ import org.eclipse.jdt.internal.core.manipulation.StubUtility; import org.eclipse.jdt.ui.PreferenceConstants; -import org.eclipse.jdt.ui.tests.core.rules.Java1d7ProjectTestSetup; +import org.eclipse.jdt.ui.tests.core.rules.Java1d8ProjectTestSetup; import org.eclipse.jdt.ui.tests.core.rules.ProjectTestSetup; import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal; @@ -52,7 +52,7 @@ */ public class AdvancedQuickAssistTest1d7 extends QuickFixTest { @Rule - public ProjectTestSetup projectSetup= new Java1d7ProjectTestSetup(); + public ProjectTestSetup projectSetup= new Java1d8ProjectTestSetup(); private IJavaProject fJProject1; diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest.java index 22dee729a2a..ede1e0076e6 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest.java @@ -7857,43 +7857,34 @@ public void foo() { @Test public void testConvertToMessageFormat14() throws Exception { - Map oldOptions= fJProject1.getOptions(false); - Map newOptions= new HashMap<>(oldOptions); - JavaCore.setComplianceOptions(JavaCore.VERSION_1_4, newOptions); - fJProject1.setOptions(newOptions); - - try { - IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); - String str= """ - package test1; - public class A { - public void foo(Object o1, Object o2) { - System.out.println("foo" + o1 + " \\"bar\\" " + o2); - } - } - """; - ICompilationUnit cu= pack1.createCompilationUnit("A.java", str, false, null); + IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); + String str= """ + package test1; + public class A { + public void foo(Object o1, Object o2) { + System.out.println("foo" + o1 + " \\"bar\\" " + o2); + } + } + """; + ICompilationUnit cu= pack1.createCompilationUnit("A.java", str, false, null); - AssistContext context= getCorrectionContext(cu, str.indexOf("\" + o1 + \""), 0); - List proposals= collectAssists(context, false); + AssistContext context= getCorrectionContext(cu, str.indexOf("\" + o1 + \""), 0); + List proposals= collectAssists(context, false); - assertCorrectLabels(proposals); + assertCorrectLabels(proposals); - String str1= """ - package test1; + String str1= """ + package test1; - import java.text.MessageFormat; + import java.text.MessageFormat; - public class A { - public void foo(Object o1, Object o2) { - System.out.println(MessageFormat.format("foo{0} \\"bar\\" {1}", o1, o2)); - } - } - """; - assertProposalPreviewEquals(str1, CorrectionMessages.QuickAssistProcessor_convert_to_message_format, proposals); - } finally { - fJProject1.setOptions(oldOptions); - } + public class A { + public void foo(Object o1, Object o2) { + System.out.println(MessageFormat.format("foo{0} \\"bar\\" {1}", o1, o2)); + } + } + """; + assertProposalPreviewEquals(str1, CorrectionMessages.QuickAssistProcessor_convert_to_message_format, proposals); } @Test @@ -7920,43 +7911,34 @@ public void foo(Object o1, Object o2) { @Test public void testConvertToMessageFormatStringBoxing14() throws Exception { - Map oldOptions= fJProject1.getOptions(false); - Map newOptions= new HashMap<>(oldOptions); - JavaCore.setComplianceOptions(JavaCore.VERSION_1_4, newOptions); - fJProject1.setOptions(newOptions); - - try { - IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); - String str= """ - package test1; - public class A { - public void foo(Object o1, Object o2) { - System.out.println("foo" + 1 + " \\"bar\\" "); - } - } - """; - ICompilationUnit cu= pack1.createCompilationUnit("A.java", str, false, null); + IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); + String str= """ + package test1; + public class A { + public void foo(Object o1, Object o2) { + System.out.println("foo" + 1 + " \\"bar\\" "); + } + } + """; + ICompilationUnit cu= pack1.createCompilationUnit("A.java", str, false, null); - AssistContext context= getCorrectionContext(cu, str.indexOf("1 + \""), 0); - List proposals= collectAssists(context, false); + AssistContext context= getCorrectionContext(cu, str.indexOf("1 + \""), 0); + List proposals= collectAssists(context, false); - assertCorrectLabels(proposals); + assertCorrectLabels(proposals); - String str1= """ - package test1; + String str1= """ + package test1; - import java.text.MessageFormat; + import java.text.MessageFormat; - public class A { - public void foo(Object o1, Object o2) { - System.out.println(MessageFormat.format("foo{0} \\"bar\\" ", 1)); - } - } - """; - assertProposalPreviewEquals(str1, CorrectionMessages.QuickAssistProcessor_convert_to_message_format, proposals); - } finally { - fJProject1.setOptions(oldOptions); - } + public class A { + public void foo(Object o1, Object o2) { + System.out.println(MessageFormat.format("foo{0} \\"bar\\" ", 1)); + } + } + """; + assertProposalPreviewEquals(str1, CorrectionMessages.QuickAssistProcessor_convert_to_message_format, proposals); } @Test @@ -8091,33 +8073,23 @@ public void foo() { @Test public void testConvertToStringFormat14() throws Exception { + IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); + String str= """ + package test1; + public class A { + public void foo(Object o1, Object o2) { + System.out.println("foo" + o1 + " \\"bar\\" " + o2); + } + } + """; + ICompilationUnit cu= pack1.createCompilationUnit("A.java", str, false, null); - Map oldOptions= fJProject1.getOptions(false); - Map newOptions= new HashMap<>(oldOptions); - JavaCore.setComplianceOptions(JavaCore.VERSION_1_4, newOptions); - fJProject1.setOptions(newOptions); - - try { - IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); - String str= """ - package test1; - public class A { - public void foo(Object o1, Object o2) { - System.out.println("foo" + o1 + " \\"bar\\" " + o2); - } - } - """; - ICompilationUnit cu= pack1.createCompilationUnit("A.java", str, false, null); - - AssistContext context= getCorrectionContext(cu, str.indexOf('+'), 0); - List proposals= collectAssists(context, false); + AssistContext context= getCorrectionContext(cu, str.indexOf('+'), 0); + List proposals= collectAssists(context, false); - assertCorrectLabels(proposals); + assertCorrectLabels(proposals); - assertCommandIdDoesNotExist(proposals, QuickAssistProcessor.CONVERT_TO_STRING_FORMAT_ID); - } finally { - fJProject1.setOptions(oldOptions); - } + assertCommandIdDoesNotExist(proposals, QuickAssistProcessor.CONVERT_TO_STRING_FORMAT_ID); } @Test @@ -9910,7 +9882,6 @@ static Set raw(int i) { Map saveOptions= fJProject1.getOptions(false); Map newOptions= new HashMap<>(); - JavaCore.setComplianceOptions(JavaCore.VERSION_1_8, newOptions); newOptions.put(DefaultCodeFormatterConstants.FORMATTER_PUT_EMPTY_STATEMENT_ON_NEW_LINE, "true"); try { fJProject1.setOptions(newOptions); @@ -10008,7 +9979,6 @@ static Set raw(int i) { Map saveOptions= fJProject1.getOptions(false); Map newOptions= new HashMap<>(); - JavaCore.setComplianceOptions(JavaCore.VERSION_1_8, newOptions); newOptions.put(DefaultCodeFormatterConstants.FORMATTER_PUT_EMPTY_STATEMENT_ON_NEW_LINE, "true"); try { fJProject1.setOptions(newOptions); @@ -10080,7 +10050,6 @@ static Date[] get() { Map saveOptions= fJProject1.getOptions(false); Map newOptions= new HashMap<>(); - JavaCore.setComplianceOptions(JavaCore.VERSION_1_8, newOptions); newOptions.put(DefaultCodeFormatterConstants.FORMATTER_PUT_EMPTY_STATEMENT_ON_NEW_LINE, "true"); try { fJProject1.setOptions(newOptions); diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest1d7.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest1d7.java index 6dbad9d3a93..aa19cbaa269 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest1d7.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest1d7.java @@ -39,7 +39,7 @@ import org.eclipse.jdt.internal.core.manipulation.StubUtility; import org.eclipse.jdt.ui.PreferenceConstants; -import org.eclipse.jdt.ui.tests.core.rules.Java1d7ProjectTestSetup; +import org.eclipse.jdt.ui.tests.core.rules.Java1d8ProjectTestSetup; import org.eclipse.jdt.ui.tests.core.rules.ProjectTestSetup; import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal; import org.eclipse.jdt.ui.text.java.correction.CUCorrectionProposal; @@ -54,7 +54,7 @@ public class AssistQuickFixTest1d7 extends QuickFixTest { @Rule - public ProjectTestSetup projectSetup = new Java1d7ProjectTestSetup(); + public ProjectTestSetup projectSetup = new Java1d8ProjectTestSetup(); private static final String REMOVE_CATCH_CLAUSE= CorrectionMessages.QuickAssistProcessor_removecatchclause_description; private static final String REPLACE_CATCH_CLAUSE_WITH_THROWS= CorrectionMessages.QuickAssistProcessor_catchclausetothrows_description; diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest1d4.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest1d4.java index 2b6141142bc..501164ae9f4 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest1d4.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest1d4.java @@ -30,7 +30,7 @@ import org.eclipse.jdt.internal.corext.fix.CleanUpConstants; -import org.eclipse.jdt.ui.tests.core.rules.Java1d4ProjectTestSetup; +import org.eclipse.jdt.ui.tests.core.rules.Java1d8ProjectTestSetup; import org.eclipse.jdt.ui.tests.core.rules.ProjectTestSetup; /** @@ -38,7 +38,7 @@ */ public class CleanUpTest1d4 extends CleanUpTestCase { @Rule - public ProjectTestSetup projectSetup= new Java1d4ProjectTestSetup(); + public ProjectTestSetup projectSetup= new Java1d8ProjectTestSetup(); @Override protected IJavaProject getProject() { @@ -208,7 +208,7 @@ public void testSerialVersion05() throws Exception { package test1; import java.io.Serializable; public class E1 implements Serializable { - + private Serializable s= new Serializable() { \s }; diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest1d5.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest1d5.java index 4a4265521f2..590a88289c6 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest1d5.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest1d5.java @@ -50,7 +50,7 @@ import org.eclipse.jdt.ui.cleanup.CleanUpOptions; import org.eclipse.jdt.ui.cleanup.ICleanUpFix; -import org.eclipse.jdt.ui.tests.core.rules.Java1d5ProjectTestSetup; +import org.eclipse.jdt.ui.tests.core.rules.Java1d8ProjectTestSetup; import org.eclipse.jdt.ui.tests.core.rules.ProjectTestSetup; import org.eclipse.jdt.ui.text.java.IProblemLocation; @@ -65,7 +65,7 @@ */ public class CleanUpTest1d5 extends CleanUpTestCase { @Rule - public ProjectTestSetup projectSetup= new Java1d5ProjectTestSetup(); + public ProjectTestSetup projectSetup= new Java1d8ProjectTestSetup(); @Override protected IJavaProject getProject() { diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest1d6.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest1d6.java index 9e50433be72..a659dcfe1f6 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest1d6.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest1d6.java @@ -34,7 +34,7 @@ import org.eclipse.jdt.internal.corext.fix.UpdateProperty; import org.eclipse.jdt.internal.corext.util.Messages; -import org.eclipse.jdt.ui.tests.core.rules.Java1d6ProjectTestSetup; +import org.eclipse.jdt.ui.tests.core.rules.Java1d8ProjectTestSetup; import org.eclipse.jdt.ui.tests.core.rules.ProjectTestSetup; /** @@ -42,7 +42,7 @@ */ public class CleanUpTest1d6 extends CleanUpTestCase { @Rule - public ProjectTestSetup projectSetup= new Java1d6ProjectTestSetup(); + public ProjectTestSetup projectSetup= new Java1d8ProjectTestSetup(); @Override protected IJavaProject getProject() { diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest1d7.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest1d7.java index a4e0fc16517..510797de735 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest1d7.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest1d7.java @@ -31,14 +31,14 @@ import org.eclipse.jdt.internal.corext.fix.CleanUpConstants; import org.eclipse.jdt.internal.corext.fix.FixMessages; -import org.eclipse.jdt.ui.tests.core.rules.Java1d7ProjectTestSetup; +import org.eclipse.jdt.ui.tests.core.rules.Java1d8ProjectTestSetup; import org.eclipse.jdt.ui.tests.core.rules.ProjectTestSetup; import org.eclipse.jdt.internal.ui.fix.MultiFixMessages; public class CleanUpTest1d7 extends CleanUpTestCase { @Rule - public ProjectTestSetup projectSetup= new Java1d7ProjectTestSetup(); + public ProjectTestSetup projectSetup= new Java1d8ProjectTestSetup(); @Override protected IJavaProject getProject() { @@ -95,11 +95,11 @@ public void testHash() throws Exception { IPackageFragment pack= fSourceFolder.createPackageFragment("test1", false, null); String input= """ package test1; - + import java.util.Arrays; import java.util.Map; import java.util.Observable; - + public class E { public class RefactoredClass { private Map innerTextById; @@ -117,7 +117,7 @@ public class RefactoredClass { private float innerFloat; private double innerOtherDouble; private Boolean innerBooleanWrapper; - + @Override public int hashCode() { // Keep this comment @@ -142,12 +142,12 @@ public int hashCode() { result = prime * result + ((this.innerBooleanWrapper != null) ? innerBooleanWrapper.hashCode() : 0); return prime * result + Arrays.hashCode(innerTexts); } - + private E getEnclosingInstance() { return E.this; } } - + private Map textById; private Observable anObservable; private String aText; @@ -162,7 +162,7 @@ private E getEnclosingInstance() { private short aShort; private float aFloat; private double anotherDouble; - + @Override public int hashCode() { // Keep this comment @@ -195,12 +195,12 @@ public int hashCode() { String output= """ package test1; - + import java.util.Arrays; import java.util.Map; import java.util.Objects; import java.util.Observable; - + public class E { public class RefactoredClass { private Map innerTextById; @@ -218,7 +218,7 @@ public class RefactoredClass { private float innerFloat; private double innerOtherDouble; private Boolean innerBooleanWrapper; - + @Override public int hashCode() { // Keep this comment @@ -226,12 +226,12 @@ public int hashCode() { innerFloat, innerInt, Arrays.hashCode(innerIntegers), innerLong, innerObservable, innerOtherDouble, innerShort, innerText, innerTextById, innerBooleanWrapper, Arrays.hashCode(innerTexts)); } - + private E getEnclosingInstance() { return E.this; } } - + private Map textById; private Observable anObservable; private String aText; @@ -246,7 +246,7 @@ private E getEnclosingInstance() { private short aShort; private float aFloat; private double anotherDouble; - + @Override public int hashCode() { // Keep this comment @@ -265,11 +265,11 @@ public void testKeepHash() throws Exception { IPackageFragment pack= fSourceFolder.createPackageFragment("test1", false, null); String sample= """ package test1; - + public class E { public class DoNotRefactorNewClass { private boolean innerBoolean; - + @Override public int hashCode() { final int prime = 31; @@ -278,15 +278,15 @@ public int hashCode() { result = prime * result + (innerBoolean ? 1231 : 1237); return result; } - + private E getEnclosingInstance() { return new E(); } } - + public class DoNotRefactorCustomHash { private boolean innerBoolean; - + @Override public int hashCode() { final int prime = 63; @@ -295,9 +295,9 @@ public int hashCode() { return result; } } - + private boolean innerBoolean; - + @Override public int hashCode() { final int prime = 31; @@ -319,15 +319,15 @@ public void testObjectsEquals() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); String sample= """ package test1; - + import java.util.Map; import java.util.Observable; - + public class E1 { private Map textById; private Observable anObservable; private String aText; - + /* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ @@ -366,16 +366,16 @@ public boolean equals(Object obj) { sample= """ package test1; - + import java.util.Map; import java.util.Objects; import java.util.Observable; - + public class E1 { private Map textById; private Observable anObservable; private String aText; - + /* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ @@ -411,15 +411,15 @@ public void testDoNotRefactorObjectsEquals() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); String sample= """ package test1; - + import java.util.Map; import java.util.Observable; - + public class E1 { private Map textById; private Observable anObservable; private String aText; - + /* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ @@ -463,9 +463,9 @@ public void testUseTryWithResource() throws Exception { IPackageFragment pack= fSourceFolder.createPackageFragment("test1", false, null); String given= """ package test1; - + import java.io.FileInputStream; - + public class E { public void refactorFullyInitializedResourceRemoveFinally() throws Exception { // Keep this comment @@ -477,7 +477,7 @@ public void refactorFullyInitializedResourceRemoveFinally() throws Exception { inputStream.close(); } } - + public void refactorFullyInitializedResourceDoNotRemoveFinally() throws Exception { // Keep this comment final FileInputStream inputStream = new FileInputStream("out.txt"); @@ -489,7 +489,7 @@ public void refactorFullyInitializedResourceDoNotRemoveFinally() throws Exceptio System.out.println("Done"); } } - + public void refactorNullInitializedResourceRemoveFinally() throws Exception { // Keep this comment FileInputStream inputStream = null; @@ -503,7 +503,7 @@ public void refactorNullInitializedResourceRemoveFinally() throws Exception { } } } - + public void refactorNullInitializedResourceDoNotRemoveFinally() throws Exception { // Keep this comment FileInputStream inputStream = null; @@ -526,9 +526,9 @@ public void refactorNullInitializedResourceDoNotRemoveFinally() throws Exception String expected= """ package test1; - + import java.io.FileInputStream; - + public class E { public void refactorFullyInitializedResourceRemoveFinally() throws Exception { // Keep this comment @@ -537,7 +537,7 @@ public void refactorFullyInitializedResourceRemoveFinally() throws Exception { System.out.println(inputStream.read()); } } - + public void refactorFullyInitializedResourceDoNotRemoveFinally() throws Exception { // Keep this comment // Keep this comment too @@ -547,7 +547,7 @@ public void refactorFullyInitializedResourceDoNotRemoveFinally() throws Exceptio System.out.println("Done"); } } - + public void refactorNullInitializedResourceRemoveFinally() throws Exception { // Keep this comment // Keep this comment too @@ -555,7 +555,7 @@ public void refactorNullInitializedResourceRemoveFinally() throws Exception { System.out.println(inputStream.read()); } } - + public void refactorNullInitializedResourceDoNotRemoveFinally() throws Exception { // Keep this comment // Keep this comment too @@ -578,16 +578,16 @@ public void testDoNotUseTryWithResource() throws Exception { IPackageFragment pack= fSourceFolder.createPackageFragment("test1", false, null); String sample= """ package test1; - + import java.io.FileInputStream; - + public class E { public void doNotRefactorNonEffectivelyFinalResource() throws Exception { try (FileInputStream inputStream = new FileInputStream("out.txt")) { System.out.println(inputStream.read()); } } - + public void doNotRefactorFurtherAssignmentsToResource() throws Exception { FileInputStream inputStream = null; try { @@ -598,7 +598,7 @@ public void doNotRefactorFurtherAssignmentsToResource() throws Exception { inputStream.close(); } } - + public boolean doNotRefactorStillUsedCloseable() throws Exception { FileInputStream inputStream = null; try { @@ -607,10 +607,10 @@ public boolean doNotRefactorStillUsedCloseable() throws Exception { } finally { inputStream.close(); } - + return inputStream != null; } - + public void doNotRefactorUnrelated() throws Exception { FileInputStream aStream = new FileInputStream("out.txt"); Object o = null; @@ -620,7 +620,7 @@ public void doNotRefactorUnrelated() throws Exception { aStream.close(); } } - + public void doNotRefactorUnclosedStream(int i) throws Exception { FileInputStream inputStream = null; try { @@ -632,7 +632,7 @@ public void doNotRefactorUnclosedStream(int i) throws Exception { } } } - + public void doNotMoveVariableFromOtherScope(boolean isValid) throws Exception { final FileInputStream inputStream = new FileInputStream("out.txt"); if (isValid) { @@ -643,7 +643,7 @@ public void doNotMoveVariableFromOtherScope(boolean isValid) throws Exception { } } } - + public void doNotMoveReusedVariable() throws Exception { final FileInputStream inputStream = new FileInputStream("out.txt"); try { @@ -651,7 +651,7 @@ public void doNotMoveReusedVariable() throws Exception { } finally { inputStream.close(); } - + inputStream.getFD(); } } @@ -669,43 +669,43 @@ public void testMultiCatch() throws Exception { IPackageFragment pack= fSourceFolder.createPackageFragment("test1", false, null); String given= """ package test1; - + import java.io.IOException; - + public class E { private static final class ThrowingObject { private void throwingMethod() throws E1, E2 { } } - + private static final class Ex1 extends Exception { private void print() { } - + private String getExplanation() { return ""; } } - + private static final class Ex2 extends Exception { private void print() { } } - + private static final class OverridingException1 extends Exception { @Override public void printStackTrace() { super.printStackTrace(); } } - + private static final class OverridingException2 extends Exception { @Override public void printStackTrace() { super.printStackTrace(); } } - + public void refactorMultiCatch(ThrowingObject obj) { try { obj.throwingMethod(); @@ -715,7 +715,7 @@ public void refactorMultiCatch(ThrowingObject obj) { try { obj.throwingMethod(); @@ -725,7 +725,7 @@ public void refactorAddToMultiCatch(ThrowingObject obj) { try { obj.throwingMethod(); @@ -735,7 +735,7 @@ public void removeMoreSpecializedException(ThrowingObject obj) { try { obj.throwingMethod(); @@ -745,7 +745,7 @@ public void refactorMultiCatchWithOverridenMethods(ThrowingObject obj) { try { obj.throwingMethod(); @@ -755,7 +755,7 @@ public void refactorMultiCatchWithOverridenMethodsFromSupertype(ThrowingObject obj) { try { obj.throwingMethod(); @@ -767,7 +767,7 @@ public void refactorUp(ThrowingObject obj, int errorCount) { try { obj.throwingMethod(); @@ -783,7 +783,7 @@ public void refactorDown(ThrowingObject obj) { try { obj.throwingMethod(); @@ -797,12 +797,12 @@ public void refactorMultiCatchWithLocalVariables(ThrowingObject { private void throwingMethod() throws E1, E2 { } } - + private static final class Ex1 extends Exception { private void print() { } - + private String getExplanation() { return ""; } } - + private static final class Ex2 extends Exception { private void print() { } } - + private static final class OverridingException1 extends Exception { @Override public void printStackTrace() { super.printStackTrace(); } } - + private static final class OverridingException2 extends Exception { @Override public void printStackTrace() { super.printStackTrace(); } } - + public void refactorMultiCatch(ThrowingObject obj) { try { obj.throwingMethod(); @@ -867,7 +867,7 @@ public void refactorMultiCatch(ThrowingObject obj) { try { obj.throwingMethod(); @@ -875,7 +875,7 @@ public void refactorAddToMultiCatch(ThrowingObject obj) { try { obj.throwingMethod(); @@ -883,7 +883,7 @@ public void removeMoreSpecializedException(ThrowingObject obj) { try { obj.throwingMethod(); @@ -891,7 +891,7 @@ public void refactorMultiCatchWithOverridenMethods(ThrowingObject obj) { try { obj.throwingMethod(); @@ -899,7 +899,7 @@ public void refactorMultiCatchWithOverridenMethodsFromSupertype(ThrowingObject obj) { try { obj.throwingMethod(); @@ -909,7 +909,7 @@ public void refactorUp(ThrowingObject obj, int errorCount) { try { obj.throwingMethod(); @@ -922,7 +922,7 @@ public void refactorDown(ThrowingObject obj) { try { obj.throwingMethod(); @@ -932,12 +932,12 @@ public void refactorMultiCatchWithLocalVariables(ThrowingObject { private void throwingMethod() throws E1, E2 { } } - + private static final class Ex1 extends Exception { private static final long serialVersionUID = 1L; - + private void print() { } - + private String getExplanation() { return ""; } } - + private static final class Ex2 extends Exception { private static final long serialVersionUID = 1L; - + private void print() { } } - + private static final class Ex3 extends Exception { private static final long serialVersionUID = 1L; - + private void print() { } - + private String getExplanation() { return ""; } } - + public void doNotRefactorMultiCatchWithNoOverridenMethods(ThrowingObject obj) { try { obj.throwingMethod(); @@ -1024,7 +1024,7 @@ public void doNotRefactorMultiCatchWithNoOverridenMethods(ThrowingObject obj) { try { obj.throwingMethod(); @@ -1034,7 +1034,7 @@ public void doNotRefactorNoCommonSuperType(ThrowingObject obj) { e2.print(); } } - + public void doNotRefactorChangeInBehaviourClassHierarchy(ThrowingObject obj) { try { obj.throwingMethod(); @@ -1046,7 +1046,7 @@ public void doNotRefactorChangeInBehaviourClassHierarchy(ThrowingObject object) { try { object.throwingMethod(); @@ -1070,15 +1070,15 @@ public void testObjectsEqualsWithImportConflict() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); String sample= """ package test1; - + import java.util.Map; import java.util.Observable; - + public class Objects { private Map textById; private Observable anObservable; private String aText; - + /* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ @@ -1116,15 +1116,15 @@ public boolean equals(Object obj) { sample= """ package test1; - + import java.util.Map; import java.util.Observable; - + public class Objects { private Map textById; private Observable anObservable; private String aText; - + /* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ @@ -1204,7 +1204,7 @@ public void testInstanceVarToLocal() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); String sample= """ package test1; - + public class Bar { private transient int zoz=38, fubu; \s @@ -1222,7 +1222,7 @@ public void baz() { String expected= """ package test1; - + public class Bar { private transient int fubu; \s diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ConvertIterableLoopQuickFixTest1d7.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ConvertIterableLoopQuickFixTest1d7.java index ee91c31db5b..f5da9d0716b 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ConvertIterableLoopQuickFixTest1d7.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ConvertIterableLoopQuickFixTest1d7.java @@ -36,7 +36,7 @@ import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants; import org.eclipse.jdt.ui.PreferenceConstants; -import org.eclipse.jdt.ui.tests.core.rules.Java1d7ProjectTestSetup; +import org.eclipse.jdt.ui.tests.core.rules.Java1d8ProjectTestSetup; import org.eclipse.jdt.ui.tests.core.rules.ProjectTestSetup; import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal; @@ -48,7 +48,7 @@ public final class ConvertIterableLoopQuickFixTest1d7 extends QuickFixTest { @Rule - public ProjectTestSetup projectSetup = new Java1d7ProjectTestSetup(); + public ProjectTestSetup projectSetup = new Java1d8ProjectTestSetup(); private FixCorrectionProposal fConvertLoopProposal; diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/LocalCorrectionsQuickFixTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/LocalCorrectionsQuickFixTest.java index 612e8a336bb..e24b18faf58 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/LocalCorrectionsQuickFixTest.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/LocalCorrectionsQuickFixTest.java @@ -12607,7 +12607,6 @@ void foo(Collection collection) { Map saveOptions= fJProject1.getOptions(false); Map newOptions= new HashMap<>(); - JavaCore.setComplianceOptions(JavaCore.VERSION_1_4, newOptions); newOptions.put(DefaultCodeFormatterConstants.FORMATTER_PUT_EMPTY_STATEMENT_ON_NEW_LINE, "true"); try { fJProject1.setOptions(newOptions); diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/LocalCorrectionsQuickFixTest1d7.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/LocalCorrectionsQuickFixTest1d7.java index 45e9d9c46af..d2b5e3c1cd5 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/LocalCorrectionsQuickFixTest1d7.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/LocalCorrectionsQuickFixTest1d7.java @@ -38,7 +38,7 @@ import org.eclipse.jdt.internal.core.manipulation.StubUtility; import org.eclipse.jdt.ui.PreferenceConstants; -import org.eclipse.jdt.ui.tests.core.rules.Java1d7ProjectTestSetup; +import org.eclipse.jdt.ui.tests.core.rules.Java1d8ProjectTestSetup; import org.eclipse.jdt.ui.tests.core.rules.ProjectTestSetup; import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal; import org.eclipse.jdt.ui.text.java.correction.CUCorrectionProposal; @@ -50,7 +50,7 @@ */ public class LocalCorrectionsQuickFixTest1d7 extends QuickFixTest { @Rule - public ProjectTestSetup projectSetup= new Java1d7ProjectTestSetup(); + public ProjectTestSetup projectSetup= new Java1d8ProjectTestSetup(); private IJavaProject fJProject1; @@ -92,11 +92,11 @@ public void testUncaughtExceptionUnionType() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); String str= """ package test1; - + import java.io.FileNotFoundException; import java.io.InterruptedIOException; import java.text.ParseException; - + public class E { void foo(int a) { try { @@ -121,11 +121,11 @@ else if (a < 20) String expected1= """ package test1; - + import java.io.FileNotFoundException; import java.io.InterruptedIOException; import java.text.ParseException; - + public class E { void foo(int a) throws ParseException { try { @@ -144,11 +144,11 @@ else if (a < 20) String expected2= """ package test1; - + import java.io.FileNotFoundException; import java.io.InterruptedIOException; import java.text.ParseException; - + public class E { void foo(int a) { try { @@ -168,11 +168,11 @@ else if (a < 20) String expected3= """ package test1; - + import java.io.FileNotFoundException; import java.io.InterruptedIOException; import java.text.ParseException; - + public class E { void foo(int a) { try { @@ -197,10 +197,10 @@ public void testUncaughtSuperException() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); String sample= """ package test1; - + import java.io.FileNotFoundException; import java.io.IOException; - + public class E { void foo(int a) { try { @@ -223,10 +223,10 @@ void foo(int a) { sample= """ package test1; - + import java.io.FileNotFoundException; import java.io.IOException; - + public class E { void foo(int a) throws IOException { try { @@ -244,10 +244,10 @@ void foo(int a) throws IOException { sample= """ package test1; - + import java.io.FileNotFoundException; import java.io.IOException; - + public class E { void foo(int a) { try { @@ -266,10 +266,10 @@ void foo(int a) { sample= """ package test1; - + import java.io.FileNotFoundException; import java.io.IOException; - + public class E { void foo(int a) { try { @@ -293,11 +293,11 @@ public void testUncaughtSuperExceptionUnionType() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); String sample= """ package test1; - + import java.io.FileNotFoundException; import java.io.IOException; import java.io.InterruptedIOException; - + public class E { void foo(int a) { try { @@ -322,11 +322,11 @@ else if (a < 20) sample= """ package test1; - + import java.io.FileNotFoundException; import java.io.IOException; import java.io.InterruptedIOException; - + public class E { void foo(int a) throws IOException { try { @@ -346,11 +346,11 @@ else if (a < 20) sample= """ package test1; - + import java.io.FileNotFoundException; import java.io.IOException; import java.io.InterruptedIOException; - + public class E { void foo(int a) { try { @@ -371,11 +371,11 @@ else if (a < 20) sample= """ package test1; - + import java.io.FileNotFoundException; import java.io.IOException; import java.io.InterruptedIOException; - + public class E { void foo(int a) { try { @@ -910,11 +910,11 @@ public void testUncaughtExceptionTryWithResources6() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); String str= """ package test1; - + import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; - + public class E { public static void main(String[] args) { try (InputStream foo = new ByteArrayInputStream("foo".getBytes("UTF-8"))) { @@ -922,7 +922,7 @@ public static void main(String[] args) { } } } - + class ByteStreams { public static byte[] toByteArray(InputStream foo) throws IOException, ArithmeticException { return null; @@ -941,12 +941,12 @@ public static byte[] toByteArray(InputStream foo) throws IOException, Arithmetic String expected1= """ package test1; - + import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.UnsupportedEncodingException; - + public class E { public static void main(String[] args) throws UnsupportedEncodingException, ArithmeticException, IOException { try (InputStream foo = new ByteArrayInputStream("foo".getBytes("UTF-8"))) { @@ -954,7 +954,7 @@ public static void main(String[] args) throws UnsupportedEncodingException, Arit } } } - + class ByteStreams { public static byte[] toByteArray(InputStream foo) throws IOException, ArithmeticException { return null; @@ -967,12 +967,12 @@ public static byte[] toByteArray(InputStream foo) throws IOException, Arithmetic String expected2= """ package test1; - + import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.UnsupportedEncodingException; - + public class E { public static void main(String[] args) { try (InputStream foo = new ByteArrayInputStream("foo".getBytes("UTF-8"))) { @@ -983,7 +983,7 @@ public static void main(String[] args) { } } } - + class ByteStreams { public static byte[] toByteArray(InputStream foo) throws IOException, ArithmeticException { return null; @@ -996,11 +996,11 @@ public static byte[] toByteArray(InputStream foo) throws IOException, Arithmetic String expected3= """ package test1; - + import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; - + public class E { public static void main(String[] args) { try (InputStream foo = new ByteArrayInputStream("foo".getBytes("UTF-8"))) { @@ -1009,7 +1009,7 @@ public static void main(String[] args) { } } } - + class ByteStreams { public static byte[] toByteArray(InputStream foo) throws IOException, ArithmeticException { return null; @@ -1022,11 +1022,11 @@ public static byte[] toByteArray(InputStream foo) throws IOException, Arithmetic String expected4= """ package test1; - + import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; - + public class E { public static void main(String[] args) { try (InputStream foo = new ByteArrayInputStream("foo".getBytes("UTF-8"))) { @@ -1037,7 +1037,7 @@ public static void main(String[] args) { } } } - + class ByteStreams { public static byte[] toByteArray(InputStream foo) throws IOException, ArithmeticException { return null; @@ -1050,12 +1050,12 @@ public static byte[] toByteArray(InputStream foo) throws IOException, Arithmetic String expected5= """ package test1; - + import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.UnsupportedEncodingException; - + public class E { public static void main(String[] args) { try (InputStream foo = new ByteArrayInputStream("foo".getBytes("UTF-8"))) { @@ -1068,7 +1068,7 @@ public static void main(String[] args) { } } } - + class ByteStreams { public static byte[] toByteArray(InputStream foo) throws IOException, ArithmeticException { return null; diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ModifierCorrectionsQuickFixTest1d7.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ModifierCorrectionsQuickFixTest1d7.java index 21918637016..da8e6787e48 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ModifierCorrectionsQuickFixTest1d7.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ModifierCorrectionsQuickFixTest1d7.java @@ -38,7 +38,7 @@ import org.eclipse.jdt.internal.core.manipulation.StubUtility; import org.eclipse.jdt.ui.PreferenceConstants; -import org.eclipse.jdt.ui.tests.core.rules.Java1d7ProjectTestSetup; +import org.eclipse.jdt.ui.tests.core.rules.Java1d8ProjectTestSetup; import org.eclipse.jdt.ui.tests.core.rules.ProjectTestSetup; import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal; @@ -51,7 +51,7 @@ public class ModifierCorrectionsQuickFixTest1d7 extends QuickFixTest { @Rule - public ProjectTestSetup projectSetup= new Java1d7ProjectTestSetup(); + public ProjectTestSetup projectSetup= new Java1d8ProjectTestSetup(); private IJavaProject fJProject1; diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/QuickFixEnablementTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/QuickFixEnablementTest.java index d0fa6f6d60b..a2529c0ca00 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/QuickFixEnablementTest.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/QuickFixEnablementTest.java @@ -14,7 +14,6 @@ package org.eclipse.jdt.ui.tests.quickfix; import java.util.ArrayList; -import java.util.HashMap; import org.junit.After; import org.junit.Before; @@ -28,11 +27,8 @@ import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IPackageFragment; import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jdt.internal.corext.util.JavaModelUtil; - import org.eclipse.jdt.ui.tests.core.rules.ProjectTestSetup; import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal; @@ -62,10 +58,6 @@ public void tearDown() throws Exception { @Test public void testContributedQuickFix1() throws Exception { - HashMap options= new HashMap<>(); - JavaModelUtil.setComplianceOptions(options, JavaCore.VERSION_1_5); - fJProject1.setOptions(options); - // quick fix is contributed only for files with name 'A.java' in a 1.5 project IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); String str= """ diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/TypeMismatchQuickFixTests.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/TypeMismatchQuickFixTests.java index 0adde951779..9f6d4760a60 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/TypeMismatchQuickFixTests.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/TypeMismatchQuickFixTests.java @@ -52,7 +52,6 @@ import org.eclipse.jdt.internal.core.manipulation.CodeTemplateContextType; import org.eclipse.jdt.internal.core.manipulation.StubUtility; -import org.eclipse.jdt.internal.corext.util.JavaModelUtil; import org.eclipse.jdt.ui.JavaElementLabels; import org.eclipse.jdt.ui.PreferenceConstants; @@ -1519,52 +1518,44 @@ public T getAnnotation(Class annotationClass) { @Test public void testMismatchingReturnTypeOnGenericMethod14() throws Exception { - Map options= fJProject1.getOptions(false); - try { - Map options14= new HashMap<>(options); - JavaModelUtil.setComplianceOptions(options14, JavaCore.VERSION_1_4); - fJProject1.setOptions(options14); - IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); + IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); - String str= """ - package test1; - import java.lang.reflect.AccessibleObject; - public class E { - void m() { - new AccessibleObject() { - public void getAnnotation(Class annotationClass) { - } - }; - } - } - """; - ICompilationUnit cu= pack1.createCompilationUnit("E.java", str, false, null); + String str= """ + package test1; + import java.lang.reflect.AccessibleObject; + public class E { + void m() { + new AccessibleObject() { + public void getAnnotation(Class annotationClass) { + } + }; + } + } + """; + ICompilationUnit cu= pack1.createCompilationUnit("E.java", str, false, null); - CompilationUnit astRoot= getASTRoot(cu); - ArrayList proposals= collectCorrections(cu, astRoot); - assertNumberOfProposals(proposals, 1); - assertCorrectLabels(proposals); + CompilationUnit astRoot= getASTRoot(cu); + ArrayList proposals= collectCorrections(cu, astRoot); + assertNumberOfProposals(proposals, 1); + assertCorrectLabels(proposals); - CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); - String preview1= getPreviewContent(proposal); + CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); + String preview1= getPreviewContent(proposal); - String expected1= """ - package test1; - import java.lang.reflect.AccessibleObject; - public class E { - void m() { - new AccessibleObject() { - public T getAnnotation(Class annotationClass) { - } - }; - } - } - """; + String expected1= """ + package test1; + import java.lang.reflect.AccessibleObject; + public class E { + void m() { + new AccessibleObject() { + public T getAnnotation(Class annotationClass) { + } + }; + } + } + """; - assertEqualStringsIgnoreOrder(new String[] { preview1 }, new String[] { expected1 }); - } finally { - fJProject1.setOptions(options); - } + assertEqualStringsIgnoreOrder(new String[] { preview1 }, new String[] { expected1 }); } @Test diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/views/SmokeViewsTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/views/SmokeViewsTest.java index 3932a446d52..102b42169da 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/views/SmokeViewsTest.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/views/SmokeViewsTest.java @@ -187,7 +187,7 @@ private IJavaProject createProject() throws CoreException { JavaProjectHelper.setLatestCompilerOptions(project); } else { // Smallest version available for tests on Jenkins/jipp - JavaProjectHelper.set17CompilerOptions(project); + JavaProjectHelper.set18CompilerOptions(project); } Path bootModPath = new Path(javaHome + "/lib/jrt-fs.jar");