Skip to content

Commit

Permalink
Fix failure of tests caused by change in org.eclipse.jdt.core 3.39.0 (#…
Browse files Browse the repository at this point in the history
…60)

Prior to this change execution of

    mvn verify -Pe4.33 -DskipUITests=false

leads to

    java.lang.AssertionError: Compiling for Java version '1.5' is no longer supported. Minimal supported version is '1.8'
            at org.eclipse.eclemma.internal.core.analysis.SourceSignatureResolverTest.setup(SourceSignatureResolverTest.java:41)

which is caused by change in
eclipse-jdt/eclipse.jdt.core@08978b8
  • Loading branch information
Godin authored Sep 10, 2024
1 parent 90a4436 commit 30eba40
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.launching.JavaRuntime;
import org.osgi.framework.Version;

import org.eclipse.eclemma.internal.core.EclEmmaCorePlugin;

Expand All @@ -54,6 +55,9 @@
*/
public class JavaProjectKit {

private static final boolean JDT_3_39 = JavaCore.getPlugin().getBundle()
.getVersion().compareTo(new Version("3.39.0")) >= 0;

private static final String DEFAULT_PROJECT_NAME = "UnitTestProject";

public final IWorkspace workspace;
Expand All @@ -80,9 +84,12 @@ public JavaProjectKit(String name) throws CoreException {
addClassPathEntry(JavaRuntime.getDefaultJREContainerEntry());
}

public void enableJava5() {
javaProject.setOption(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5);
javaProject.setOption(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5);
public void enableJava() {
final String lowestSupportedJavaVersion = JDT_3_39 ? JavaCore.VERSION_1_8
: JavaCore.VERSION_1_5;
javaProject.setOption(JavaCore.COMPILER_COMPLIANCE,
lowestSupportedJavaVersion);
javaProject.setOption(JavaCore.COMPILER_SOURCE, lowestSupportedJavaVersion);
}

public IFolder setDefaultOutputLocation(String foldername)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class BinarySignatureResolverTest extends SignatureResolverTestBase {
@Before
public void setup() throws Exception {
javaProject = new JavaProjectKit();
javaProject.enableJava5();
javaProject.enableJava();
final IPackageFragmentRoot root = javaProject.createJAR(
"testdata/bin/signatureresolver.jar", "/signatureresolver.jar",
new Path("/UnitTestProject/signatureresolver.jar"), null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class MethodLocatorTest {
@Before
public void setup() throws Exception {
javaProject = new JavaProjectKit();
javaProject.enableJava5();
javaProject.enableJava();
final IPackageFragmentRoot root = javaProject.createSourceFolder("src");
final ICompilationUnit compilationUnit = javaProject.createCompilationUnit(
root, "testdata/src", "methodlocator/Samples.java");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class SourceSignatureResolverTest extends SignatureResolverTestBase {
@Before
public void setup() throws Exception {
javaProject = new JavaProjectKit();
javaProject.enableJava5();
javaProject.enableJava();
final IPackageFragmentRoot root = javaProject.createSourceFolder("src");
final ICompilationUnit compilationUnit = javaProject.createCompilationUnit(
root, "testdata/src", "signatureresolver/Samples.java");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static void setup() throws Exception {
openCoverageView();

JavaProjectKit project = new JavaProjectKit();
project.enableJava5();
project.enableJava();
final IPackageFragmentRoot root = project.createSourceFolder();
final IPackageFragment fragment = project.createPackage(root, "example");
project.createCompilationUnit(fragment, "Example.java", "package example;" //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
import org.eclipse.jdt.launching.JavaRuntime;
import org.osgi.framework.Version;

/**
* Utility class to setup Java projects programmatically.
Expand All @@ -46,6 +47,9 @@
*/
public class JavaProjectKit {

private static final boolean JDT_3_39 = JavaCore.getPlugin().getBundle()
.getVersion().compareTo(new Version("3.39.0")) >= 0;

private static final String DEFAULT_PROJECT_NAME = "UnitTestProject";

public final IWorkspace workspace;
Expand All @@ -72,9 +76,12 @@ public JavaProjectKit(String name) throws CoreException {
addClassPathEntry(JavaRuntime.getDefaultJREContainerEntry());
}

public void enableJava5() {
javaProject.setOption(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5);
javaProject.setOption(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5);
public void enableJava() {
final String lowestSupportedJavaVersion = JDT_3_39 ? JavaCore.VERSION_1_8
: JavaCore.VERSION_1_5;
javaProject.setOption(JavaCore.COMPILER_COMPLIANCE,
lowestSupportedJavaVersion);
javaProject.setOption(JavaCore.COMPILER_SOURCE, lowestSupportedJavaVersion);
}

public IPackageFragmentRoot createSourceFolder() throws CoreException {
Expand Down

0 comments on commit 30eba40

Please sign in to comment.