diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/ApiBuilderTest.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/ApiBuilderTest.java index 7e357b13d8..846e11c78d 100644 --- a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/ApiBuilderTest.java +++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/ApiBuilderTest.java @@ -66,7 +66,6 @@ import org.eclipse.pde.api.tools.internal.util.Util; import org.eclipse.pde.api.tools.model.tests.TestSuiteHelper; import org.eclipse.pde.api.tools.tests.util.FileUtils; -import org.eclipse.pde.api.tools.tests.util.ProjectUtils; import org.eclipse.pde.internal.core.ICoreConstants; import org.eclipse.pde.internal.core.PDECore; import org.eclipse.pde.internal.core.natures.PluginProject; @@ -1036,12 +1035,8 @@ private static Class[] getAllTestClasses() { classes.add(LeakTest.class); classes.add(TagTest.class); classes.add(AnnotationTest.class); - if (ProjectUtils.isJava7Compatible()) { - classes.add(Java7UsageTest.class); - } - if (ProjectUtils.isJava8Compatible()) { - classes.add(Java8UsageTest.class); - } + classes.add(Java7UsageTest.class); + classes.add(Java8UsageTest.class); return classes.toArray(new Class[classes.size()]); } diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/annotations/AnnotationTest.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/annotations/AnnotationTest.java index 7c6ecf0711..d12c9a88f9 100644 --- a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/annotations/AnnotationTest.java +++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/annotations/AnnotationTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013, 2018 IBM Corporation and others. + * Copyright (c) 2013, 2024 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -25,7 +25,6 @@ import org.eclipse.pde.api.tools.builder.tests.ApiProblem; import org.eclipse.pde.api.tools.builder.tests.ApiTestingEnvironment; import org.eclipse.pde.api.tools.model.tests.TestSuiteHelper; -import org.eclipse.pde.api.tools.tests.util.ProjectUtils; import junit.framework.Test; import junit.framework.TestSuite; @@ -76,11 +75,9 @@ private static Class[] getAllTestClasses() { classes.add(ValidEnumAnnotationsTests.class); classes.add(FieldAnnotationTest.class); classes.add(MethodAnnotationTest.class); - if (ProjectUtils.isJava8Compatible()) { - classes.add(InvalidJava8InterfaceAnnotationTests.class); - classes.add(ValidJava8InterfaceAnnotationTests.class); - classes.add(Java8TypeAnnotationTests.class); - } + classes.add(InvalidJava8InterfaceAnnotationTests.class); + classes.add(ValidJava8InterfaceAnnotationTests.class); + classes.add(Java8TypeAnnotationTests.class); return classes.toArray(new Class[classes.size()]); } diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/annotations/MethodAnnotationTest.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/annotations/MethodAnnotationTest.java index 02979ce4d1..3d993fb9fb 100644 --- a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/annotations/MethodAnnotationTest.java +++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/annotations/MethodAnnotationTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2014, 2018 IBM Corporation and others. + * Copyright (c) 2014, 2024 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -22,7 +22,6 @@ import org.eclipse.pde.api.tools.internal.problems.ApiProblemFactory; import org.eclipse.pde.api.tools.internal.provisional.descriptors.IElementDescriptor; import org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblem; -import org.eclipse.pde.api.tools.tests.util.ProjectUtils; import junit.framework.Test; import junit.framework.TestSuite; @@ -65,9 +64,7 @@ private static Class[] getAllTestClasses() { tests.add(ValidDefaultMethodAnnotationTests.class); tests.add(InvalidInterfaceMethodAnnotationTests.class); tests.add(ValidInterfaceMethodAnnotationTests.class); - if (ProjectUtils.isJava8Compatible()) { - tests.add(InvalidDefaultMethodAnnotationTests.class); - } + tests.add(InvalidDefaultMethodAnnotationTests.class); return tests.toArray(new Class[tests.size()]); } diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/tags/TagTest.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/tags/TagTest.java index a25dc8e3f6..10e3fae080 100644 --- a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/tags/TagTest.java +++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/tags/TagTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2018 IBM Corporation and others. + * Copyright (c) 2008, 2024 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -24,7 +24,6 @@ import org.eclipse.pde.api.tools.builder.tests.ApiProblem; import org.eclipse.pde.api.tools.builder.tests.ApiTestingEnvironment; import org.eclipse.pde.api.tools.model.tests.TestSuiteHelper; -import org.eclipse.pde.api.tools.tests.util.ProjectUtils; import junit.framework.Test; import junit.framework.TestSuite; @@ -74,10 +73,8 @@ private static Class[] getAllTestClasses() { classes.add(ValidAnnotationTagTests.class); classes.add(InvalidAnnotationTagTests.class); classes.add(InvalidDuplicateTagsTests.class); - if (ProjectUtils.isJava8Compatible()) { - classes.add(ValidJava8InterfaceTagTests.class); - classes.add(InvalidJava8InterfaceTagTests.class); - } + classes.add(ValidJava8InterfaceTagTests.class); + classes.add(InvalidJava8InterfaceTagTests.class); return classes.toArray(new Class[classes.size()]); } diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/usage/UsageTest.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/usage/UsageTest.java index b1b9486c5c..fc25721d8d 100644 --- a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/usage/UsageTest.java +++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/usage/UsageTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2018 IBM Corporation and others. + * Copyright (c) 2008, 2024 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -26,7 +26,6 @@ import org.eclipse.pde.api.tools.builder.tests.ApiProblem; import org.eclipse.pde.api.tools.builder.tests.ApiTestingEnvironment; import org.eclipse.pde.api.tools.model.tests.TestSuiteHelper; -import org.eclipse.pde.api.tools.tests.util.ProjectUtils; import junit.framework.Test; import junit.framework.TestSuite; @@ -214,13 +213,11 @@ private static Class[] getAllTestClasses() { classes.add(UnusedApiProblemFilterTests.class); classes.add(DependentUsageTests.class); classes.add(FragmentUsageTests.class); - if (ProjectUtils.isJava5Compatible()) { - classes.add(Java5FieldUsageTests.class); - classes.add(Java5MethodUsageTests.class); - classes.add(Java5ClassUsageTests.class); - classes.add(AnnotationUsageTests.class); - // classes.add(EnumUsageTests.class); - } + classes.add(Java5FieldUsageTests.class); + classes.add(Java5MethodUsageTests.class); + classes.add(Java5ClassUsageTests.class); + classes.add(AnnotationUsageTests.class); + // classes.add(EnumUsageTests.class); return classes.toArray(new Class[classes.size()]); } } diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/model/tests/TestSuiteHelper.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/model/tests/TestSuiteHelper.java index 3fba468fe3..20a38e2504 100644 --- a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/model/tests/TestSuiteHelper.java +++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/model/tests/TestSuiteHelper.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2021 IBM Corporation and others. + * Copyright (c) 2007, 2024 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -49,7 +49,6 @@ import org.eclipse.pde.api.tools.internal.search.IReferenceCollection; import org.eclipse.pde.api.tools.internal.search.UseScanReferences; import org.eclipse.pde.api.tools.internal.util.Util; -import org.eclipse.pde.api.tools.tests.util.ProjectUtils; import org.junit.Assert; import org.osgi.framework.Bundle; @@ -61,22 +60,15 @@ public class TestSuiteHelper { /** - * Computes the compile options to use. Currently this only changes if we - * are running the tests on Java 8. + * Computes the compile options to use. Currently this sets params as if + * running the tests on Java 8. * * @return the array of compiler options to use * @since 1.0.400 */ public static String[] getCompilerOptions() { - ArrayList args = new ArrayList<>(); - if (ProjectUtils.isJava8Compatible()) { - args.add("-1.8"); //$NON-NLS-1$ - } else { - args.add("-1.5"); //$NON-NLS-1$ - } - args.add("-preserveAllLocals"); //$NON-NLS-1$ - args.add("-nowarn"); //$NON-NLS-1$ - return args.toArray(new String[] {}); + List args = List.of("-1.8", "-preserveAllLocals", "-nowarn"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + return args.toArray(String[]::new); } /** diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/tests/util/ProjectUtils.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/tests/util/ProjectUtils.java index 9e4d4eed72..490af75d58 100644 --- a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/tests/util/ProjectUtils.java +++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/tests/util/ProjectUtils.java @@ -66,95 +66,6 @@ public static IBundleProjectService getBundleProjectService() { return PDECore.getDefault().acquireService(IBundleProjectService.class); } - /** - * Returns if the currently running VM is version compatible with Java 7 - * - * @return true if a Java 7 (or greater) VM is running - * false otherwise - */ - public static boolean isJava7Compatible() { - return isCompatible(7); - } - - /** - * Returns if the currently running VM is version compatible with Java 6 - * - * @return true if a Java 6 (or greater) VM is running - * false otherwise - */ - public static boolean isJava6Compatible() { - return isCompatible(6); - } - - /** - * Returns if the currently running VM is version compatible with Java 5 - * - * @return true if a Java 5 (or greater) VM is running - * false otherwise - */ - public static boolean isJava5Compatible() { - return isCompatible(5); - } - - /** - * Returns if the currently running VM is version compatible with Java 8 - * - * @return true if a Java 8 (or greater) VM is running - * false otherwise - */ - public static boolean isJava8Compatible() { - return isCompatible(8); - } - - /** - * Returns if the currently running VM is version compatible with Java 9 - * - * @return true if a Java 9 (or greater) VM is running - * false otherwise - */ - public static boolean isJava9Compatible() { - return isCompatible(9); - } - - /** - * Returns if the current running system is compatible with the given Java minor - * version - * - * @param ver - * the version to test - either 4, 5, 6 , 7 or 8 - * @return true if compatible false otherwise - */ - static boolean isCompatible(int ver) { - String version = System.getProperty("java.specification.version"); //$NON-NLS-1$ - if (version != null) { - String[] nums = version.split("\\."); //$NON-NLS-1$ - if (nums.length == 2) { - try { - int major = Integer.parseInt(nums[0]); - int minor = Integer.parseInt(nums[1]); - if (major >= 1) { - if (minor >= ver) { - return true; - } - } - } catch (NumberFormatException e) { - } - } - if (nums.length == 1) { - // java 9 and above - try { - int major = Integer.parseInt(nums[0]); - if (major >= ver) { - return true; - } - - } catch (NumberFormatException e) { - } - } - } - return false; - } - /** * Crate a plug-in project with the given name *