Skip to content

Commit 739fcd5

Browse files
committed
Tests should not explicitly set pre 1.8 compliance
ECJ no longer supports it.
1 parent af96d1e commit 739fcd5

File tree

3 files changed

+24
-27
lines changed

3 files changed

+24
-27
lines changed

org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/AbstractForLoopJavaContextTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2014, 2020 IBM Corporation and others.
2+
* Copyright (c) 2014, 2024 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -55,11 +55,11 @@ public abstract class AbstractForLoopJavaContextTest {
5555

5656
private static final String CU_PREFIX= """
5757
package test;
58-
58+
5959
import java.io.Serializable;
6060
import java.util.Collection;
6161
import java.util.List;
62-
62+
6363
public class A<E extends Number> {
6464
""";
6565

@@ -84,13 +84,13 @@ public void setUp() throws Exception {
8484
// options.put(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE, "4");
8585
JavaCore.setOptions(options);
8686
}
87-
setUpProject(JavaCore.VERSION_1_5);
87+
setUpProject();
8888
}
8989

90-
private void setUpProject(String sourceLevel) throws CoreException, JavaModelException {
90+
private void setUpProject() throws CoreException, JavaModelException {
9191
fProject= JavaProjectHelper.createJavaProject(PROJECT, "bin");
9292
JavaProjectHelper.addRTJar(fProject);
93-
fProject.setOption(JavaCore.COMPILER_SOURCE, sourceLevel);
93+
fProject.setOption(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_8);
9494
IPackageFragmentRoot fragmentRoot= JavaProjectHelper.addSourceContainer(fProject, SRC);
9595
IPackageFragment fragment= fragmentRoot.createPackageFragment("test", true, new NullProgressMonitor());
9696
fCU= fragment.createCompilationUnit(CU_NAME, "", true, new NullProgressMonitor());

org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaModelOpCompundUndoTest.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2009 IBM Corporation and others.
2+
* Copyright (c) 2000, 2024 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -74,9 +74,9 @@ public class JavaModelOpCompundUndoTest {
7474
private static final String CU_NAME= "Bug75423.java";
7575
private static final String CU_CONTENTS= """
7676
package com.example.bugs;
77-
77+
7878
public class Bug75423 {
79-
79+
8080
void foo() {
8181
\s
8282
}
@@ -94,17 +94,17 @@ void bar() {
9494
private ICompilationUnit fCompilationUnit;
9595
private IUndoManager fUndoManager;
9696

97-
private void setUpProject(String sourceLevel) throws CoreException, JavaModelException {
97+
private void setUpProject() throws CoreException, JavaModelException {
9898
fProject= JavaProjectHelper.createJavaProject(tn.getMethodName(), "bin");
99-
fProject.setOption(JavaCore.COMPILER_SOURCE, sourceLevel);
99+
fProject.setOption(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_8);
100100
JavaProjectHelper.addSourceContainer(fProject, SRC);
101101
IPackageFragment fragment= fProject.findPackageFragment(new Path(SEP + tn.getMethodName() + SEP + SRC));
102102
fCompilationUnit= fragment.createCompilationUnit(CU_NAME, CU_CONTENTS, true, new NullProgressMonitor());
103103
}
104104

105105
@Before
106106
public void setUp() throws Exception {
107-
setUpProject(JavaCore.VERSION_1_5);
107+
setUpProject();
108108
setUpEditor();
109109
}
110110

@@ -161,9 +161,6 @@ public void test1() throws Exception {
161161

162162
@Test
163163
public void test2() throws Exception {
164-
setUpProject(JavaCore.VERSION_1_5);
165-
setUpEditor();
166-
167164
assertEquals(CU_CONTENTS, fDocument.get());
168165
fUndoManager.beginCompoundChange();
169166

org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/buildpath/BuildpathProblemQuickFixTest.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2020 Till Brychcy and others.
2+
* Copyright (c) 2020, 2024 Till Brychcy and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -169,16 +169,16 @@ public void test2Cyclic() throws CoreException, IOException {
169169

170170
@Test
171171
public void test3RequiredBinaryLevel() throws CoreException, IOException {
172-
IPath container= new Path("org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7");
172+
IPath container= new Path("org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8");
173173
@SuppressWarnings("restriction")
174174
IVMInstall vm= org.eclipse.jdt.internal.launching.JREContainerInitializer.resolveVM(container);
175175
if (vm == null) {
176176
return;
177177
}
178178
if (vm instanceof IVMInstall2) {
179179
String version= ((IVMInstall2) vm).getJavaVersion();
180-
if (version == null || !version.startsWith(JavaCore.VERSION_1_7)) {
181-
// higher version instead of JavaSE 1.7 not found:
180+
if (version == null || !version.startsWith(JavaCore.VERSION_1_8)) {
181+
// higher version instead of JavaSE 1.8 not found:
182182
// skip test as error against vm's class files would be reported
183183
return;
184184
}
@@ -194,17 +194,17 @@ public void test3RequiredBinaryLevel() throws CoreException, IOException {
194194
String classpath= """
195195
<?xml version="1.0" encoding="UTF-8"?>
196196
<classpath>
197-
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
197+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
198198
<classpathentry kind="src" path="src"/>
199199
<classpathentry combineaccessrules="false" kind="src" path="/3_JDKLevelHigh"/>
200200
<classpathentry kind="output" path="bin"/>
201201
</classpath>
202202
""";
203203
addFile(fJavaProject1.getPath(), ".classpath", classpath);
204204
addFile(src1.getFullPath(), "LowClass.java", "public class LowClass{HighClass x;}");
205-
fJavaProject1.setOption(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_7);
206-
fJavaProject1.setOption(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_7);
207-
fJavaProject1.setOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_7);
205+
fJavaProject1.setOption(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_8);
206+
fJavaProject1.setOption(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_8);
207+
fJavaProject1.setOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_8);
208208
fJavaProject1.setOption(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL, JavaCore.ERROR);
209209

210210

@@ -222,15 +222,15 @@ public void test3RequiredBinaryLevel() throws CoreException, IOException {
222222
""";
223223
addFile(fJavaProject2.getPath(), ".classpath", classpath2);
224224
addFile(src2.getFullPath(), "HighClass.java", "public class HighClass{}");
225-
fJavaProject2.setOption(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_8);
226-
fJavaProject2.setOption(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_8);
227-
fJavaProject2.setOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_8);
225+
fJavaProject2.setOption(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_11);
226+
fJavaProject2.setOption(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_11);
227+
fJavaProject2.setOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_11);
228228

229229
fJavaProject1.getProject().getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, null);
230230

231231
IMarker[] markers= fJavaProject1.getResource().findMarkers("org.eclipse.jdt.core.buildpath_problem", true, IResource.DEPTH_INFINITE);
232232
assertEquals(
233-
"Incompatible .class files version in required binaries. Project '3_JDKLevelLow' is targeting a 1.7 runtime, but is compiled against '3_JDKLevelHigh' which requires a 1.8 runtime",
233+
"Incompatible .class files version in required binaries. Project '3_JDKLevelLow' is targeting a 1.8 runtime, but is compiled against '3_JDKLevelHigh' which requires a 11 runtime",
234234
markers[0].getAttribute(IMarker.MESSAGE));
235235
assertEquals(1, markers.length);
236236
IMarkerResolution[] resolutions= sortResolutions(IDE.getMarkerHelpRegistry().getResolutions(markers[0]));

0 commit comments

Comments
 (0)