From 198957fd26d1e5cd347c0c1c3a0c9100295af4cf Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Mon, 19 Feb 2024 10:22:10 +0700 Subject: LangUtil: remove methods like 'is11VMOrGreater', 'is1dot5VMOrGreater' Replace them by a uniform method 'isVMGreaterOrEqual(double)', also overloaded for int. This gets rid of one 'AspectJ_JDK_Update' tag. One less place to check and update with each newly supported Java version. :-) Signed-off-by: Alexander Kriegisch --- weaver/src/main/java/org/aspectj/weaver/bcel/ClassPathManager.java | 2 +- weaver/src/main/java/org/aspectj/weaver/tools/WeavingAdaptor.java | 2 +- weaver/src/test/java/org/aspectj/weaver/WeaverModuleTests.java | 2 +- .../aspectj/weaver/bcel/BcelGenericSignatureToTypeXTestCase.java | 4 ++-- weaver/src/test/java/org/aspectj/weaver/bcel/JImageTestCase.java | 6 +++--- 5 files changed, 8 insertions(+), 8 deletions(-) (limited to 'weaver') diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/ClassPathManager.java b/weaver/src/main/java/org/aspectj/weaver/bcel/ClassPathManager.java index c76e91956..bfef435ec 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/ClassPathManager.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/ClassPathManager.java @@ -351,7 +351,7 @@ public class ClassPathManager { String jdkHome = new File(jrtFsPath).getParentFile().getParent(); FileSystem fs = null; try { - if (LangUtil.is9VMOrGreater()) { + if (LangUtil.isVMGreaterOrEqual(9)) { Map env = new HashMap<>(); env.put("java.home", jdkHome); fs = FileSystems.newFileSystem(JRT_URI, env); diff --git a/weaver/src/main/java/org/aspectj/weaver/tools/WeavingAdaptor.java b/weaver/src/main/java/org/aspectj/weaver/tools/WeavingAdaptor.java index 1617cb22b..9ee4c0962 100644 --- a/weaver/src/main/java/org/aspectj/weaver/tools/WeavingAdaptor.java +++ b/weaver/src/main/java/org/aspectj/weaver/tools/WeavingAdaptor.java @@ -149,7 +149,7 @@ public class WeavingAdaptor implements IMessageContext { } // On Java9 it is possible to fail to find a URLClassLoader from which to derive a suitable classpath // For now we can determine it from the java.class.path: - if (LangUtil.is9VMOrGreater()) { + if (LangUtil.isVMGreaterOrEqual(9)) { list.add(0, LangUtil.getJrtFsFilePath()); List javaClassPathEntries = makeClasspath(System.getProperty("java.class.path")); for (int i=javaClassPathEntries.size()-1;i>=0;i--) { diff --git a/weaver/src/test/java/org/aspectj/weaver/WeaverModuleTests.java b/weaver/src/test/java/org/aspectj/weaver/WeaverModuleTests.java index ef1a1f2f9..5f36e7e80 100644 --- a/weaver/src/test/java/org/aspectj/weaver/WeaverModuleTests.java +++ b/weaver/src/test/java/org/aspectj/weaver/WeaverModuleTests.java @@ -110,7 +110,7 @@ public class WeaverModuleTests extends TestCase { suite.addTestSuite(FieldSetTestCase.class); suite.addTestSuite(HierarchyDependsTestCase.class); suite.addTestSuite(IdWeaveTestCase.class); - if (LangUtil.is9VMOrGreater()) { + if (LangUtil.isVMGreaterOrEqual(9)) { suite.addTestSuite(JImageTestCase.class); } suite.addTestSuite(MegaZipTestCase.class); diff --git a/weaver/src/test/java/org/aspectj/weaver/bcel/BcelGenericSignatureToTypeXTestCase.java b/weaver/src/test/java/org/aspectj/weaver/bcel/BcelGenericSignatureToTypeXTestCase.java index 3ab35167c..bbe5e1892 100644 --- a/weaver/src/test/java/org/aspectj/weaver/bcel/BcelGenericSignatureToTypeXTestCase.java +++ b/weaver/src/test/java/org/aspectj/weaver/bcel/BcelGenericSignatureToTypeXTestCase.java @@ -48,13 +48,13 @@ public class BcelGenericSignatureToTypeXTestCase extends TestCase { cSig.formalTypeParameters, world); assertEquals("Ljava/lang/Object;", superclass.getSignature()); System.out.println(Arrays.toString(cSig.superInterfaceSignatures)); - if (LangUtil.is12VMOrGreater()) { + if (LangUtil.isVMGreaterOrEqual(12)) { // [Ljava/lang/constant/Constable;, Ljava/lang/Comparable;, Ljava/io/Serializable;] assertEquals("3 superinterfaces but "+Arrays.toString(cSig.superInterfaceSignatures), 3, cSig.superInterfaceSignatures.length); } else { assertEquals("2 superinterfaces", 2, cSig.superInterfaceSignatures.length); } - int idx = LangUtil.is12VMOrGreater()?1:0; + int idx = LangUtil.isVMGreaterOrEqual(12)?1:0; UnresolvedType comparable = BcelGenericSignatureToTypeXConverter.classTypeSignature2TypeX(cSig.superInterfaceSignatures[idx++], cSig.formalTypeParameters, world); assertEquals("Pjava/lang/Comparable;", comparable.getSignature()); diff --git a/weaver/src/test/java/org/aspectj/weaver/bcel/JImageTestCase.java b/weaver/src/test/java/org/aspectj/weaver/bcel/JImageTestCase.java index 1ca86c371..c6656fcff 100644 --- a/weaver/src/test/java/org/aspectj/weaver/bcel/JImageTestCase.java +++ b/weaver/src/test/java/org/aspectj/weaver/bcel/JImageTestCase.java @@ -49,13 +49,13 @@ public class JImageTestCase extends TestCase { } public void testOnJava9() { - if (!LangUtil.is9VMOrGreater()) { + if (!LangUtil.isVMGreaterOrEqual(9)) { System.out.println("SKIPPING JIMAGE TESTS AS NOT ON 1.9 OR LATER"); } } public void testBasicStructureAndCapabilities() { - if (!LangUtil.is9VMOrGreater()) return; + if (!LangUtil.isVMGreaterOrEqual(9)) return; // Should be one entry for finding JRT contents List entries = cpm.getEntries(); assertEquals(1,entries.size()); @@ -67,7 +67,7 @@ public class JImageTestCase extends TestCase { } public void testBehaviour() throws Exception { - if (!LangUtil.is9VMOrGreater()) return; + if (!LangUtil.isVMGreaterOrEqual(9)) return; JImageEntry jie = getJImageEntry(); Map packageCache = jie.getPackageCache(); -- cgit v1.2.3