diff options
author | Lars Grefer <eclipse@larsgrefer.de> | 2020-08-13 23:21:11 +0200 |
---|---|---|
committer | Lars Grefer <eclipse@larsgrefer.de> | 2020-08-13 23:21:11 +0200 |
commit | d7ba05ce26dd8f72c1d0695ece2cb03d035e3cf9 (patch) | |
tree | b0ca80a1154a73ca8ed1d5d4cf175c2682af6fce | |
parent | 4f027bd94fe71756894f13a4a82123eda4f28b98 (diff) | |
download | aspectj-d7ba05ce26dd8f72c1d0695ece2cb03d035e3cf9.tar.gz aspectj-d7ba05ce26dd8f72c1d0695ece2cb03d035e3cf9.zip |
Remove checks for old Java Versions
Signed-off-by: Lars Grefer <eclipse@larsgrefer.de>
24 files changed, 157 insertions, 236 deletions
diff --git a/ajde.core/src/test/java/org/aspectj/ajde/core/tests/ShowWeaveMessagesTest.java b/ajde.core/src/test/java/org/aspectj/ajde/core/tests/ShowWeaveMessagesTest.java index 4e5a87882..3bd3fbdb6 100644 --- a/ajde.core/src/test/java/org/aspectj/ajde/core/tests/ShowWeaveMessagesTest.java +++ b/ajde.core/src/test/java/org/aspectj/ajde/core/tests/ShowWeaveMessagesTest.java @@ -165,8 +165,6 @@ public class ShowWeaveMessagesTest extends AjdeCoreTestCase { * Weave 'declare @type, @constructor, @method and @field' and check the weave messages that come out. */ public void testWeaveMessagesDeclareAnnotation() { - if (!LangUtil.is15VMOrGreater()) - return; // annotation classes won't be about pre 15 if (debugTests) System.out.println("\ntestWeaveMessagesDeclareAnnotation: Building with Six.lst"); compilerConfig.setProjectSourceFiles(getSourceFileList(six)); diff --git a/loadtime/src/main/java/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java b/loadtime/src/main/java/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java index 0edd55721..ca297eb6e 100644 --- a/loadtime/src/main/java/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java +++ b/loadtime/src/main/java/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java @@ -371,7 +371,7 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor { world.performExtraConfiguration(weaverOption.xSet); world.setXnoInline(weaverOption.noInline); // AMC - autodetect as per line below, needed for AtAjLTWTests.testLTWUnweavable - world.setBehaveInJava5Way(LangUtil.is15VMOrGreater()); + world.setBehaveInJava5Way(true); world.setAddSerialVerUID(weaverOption.addSerialVersionUID); /* First load defaults */ diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegateFactory.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegateFactory.java index eee1b6f32..5de4aa288 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegateFactory.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegateFactory.java @@ -36,11 +36,9 @@ public class ReflectionBasedReferenceTypeDelegateFactory { ClassLoader usingClassLoader) { try { Class c = Class.forName(forReferenceType.getName(), false, usingClassLoader); - if (LangUtil.is15VMOrGreater()) { - ReflectionBasedReferenceTypeDelegate rbrtd = create15Delegate(forReferenceType, c, usingClassLoader, inWorld); - if (rbrtd != null) { - return rbrtd; // can be null if we didn't find the class the delegate logic loads - } + ReflectionBasedReferenceTypeDelegate rbrtd = create15Delegate(forReferenceType, c, usingClassLoader, inWorld); + if (rbrtd != null) { + return rbrtd; // can be null if we didn't find the class the delegate logic loads } return new ReflectionBasedReferenceTypeDelegate(c, usingClassLoader, inWorld, forReferenceType); } catch (ClassNotFoundException cnfEx) { @@ -50,11 +48,9 @@ public class ReflectionBasedReferenceTypeDelegateFactory { public static ReflectionBasedReferenceTypeDelegate createDelegate(ReferenceType forReferenceType, World inWorld, Class<?> clazz) { - if (LangUtil.is15VMOrGreater()) { - ReflectionBasedReferenceTypeDelegate rbrtd = create15Delegate(forReferenceType, clazz, clazz.getClassLoader(), inWorld); - if (rbrtd != null) { - return rbrtd; // can be null if we didn't find the class the delegate logic loads - } + ReflectionBasedReferenceTypeDelegate rbrtd = create15Delegate(forReferenceType, clazz, clazz.getClassLoader(), inWorld); + if (rbrtd != null) { + return rbrtd; // can be null if we didn't find the class the delegate logic loads } return new ReflectionBasedReferenceTypeDelegate(clazz, clazz.getClassLoader(), inWorld, forReferenceType); } @@ -90,30 +86,28 @@ public class ReflectionBasedReferenceTypeDelegateFactory { } private static GenericSignatureInformationProvider createGenericSignatureProvider(World inWorld) { - if (LangUtil.is15VMOrGreater()) { - try { - Class providerClass = Class.forName("org.aspectj.weaver.reflect.Java15GenericSignatureInformationProvider"); - Constructor cons = providerClass.getConstructor(new Class[] { World.class }); - GenericSignatureInformationProvider ret = (GenericSignatureInformationProvider) cons - .newInstance(new Object[] { inWorld }); - return ret; - } catch (ClassNotFoundException cnfEx) { - // drop through and create a 14 provider... - // throw new - // IllegalStateException("Attempted to create Java 1.5 generic signature provider but org.aspectj.weaver.reflect.Java15GenericSignatureInformationProvider was not found on classpath"); - } catch (NoSuchMethodException nsmEx) { - throw new IllegalStateException("Attempted to create Java 1.5 generic signature provider but: " + nsmEx - + " occured"); - } catch (InstantiationException insEx) { - throw new IllegalStateException("Attempted to create Java 1.5 generic signature provider but: " + insEx - + " occured"); - } catch (InvocationTargetException invEx) { - throw new IllegalStateException("Attempted to create Java 1.5 generic signature provider but: " + invEx - + " occured"); - } catch (IllegalAccessException illAcc) { - throw new IllegalStateException("Attempted to create Java 1.5 generic signature provider but: " + illAcc - + " occured"); - } + try { + Class providerClass = Class.forName("org.aspectj.weaver.reflect.Java15GenericSignatureInformationProvider"); + Constructor cons = providerClass.getConstructor(new Class[] { World.class }); + GenericSignatureInformationProvider ret = (GenericSignatureInformationProvider) cons + .newInstance(new Object[] { inWorld }); + return ret; + } catch (ClassNotFoundException cnfEx) { + // drop through and create a 14 provider... + // throw new + // IllegalStateException("Attempted to create Java 1.5 generic signature provider but org.aspectj.weaver.reflect.Java15GenericSignatureInformationProvider was not found on classpath"); + } catch (NoSuchMethodException nsmEx) { + throw new IllegalStateException("Attempted to create Java 1.5 generic signature provider but: " + nsmEx + + " occured"); + } catch (InstantiationException insEx) { + throw new IllegalStateException("Attempted to create Java 1.5 generic signature provider but: " + insEx + + " occured"); + } catch (InvocationTargetException invEx) { + throw new IllegalStateException("Attempted to create Java 1.5 generic signature provider but: " + invEx + + " occured"); + } catch (IllegalAccessException illAcc) { + throw new IllegalStateException("Attempted to create Java 1.5 generic signature provider but: " + illAcc + + " occured"); } return new Java14GenericSignatureInformationProvider(); } diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/reflect/ReflectionWorld.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/reflect/ReflectionWorld.java index c4bcb3665..28cd56607 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/reflect/ReflectionWorld.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/reflect/ReflectionWorld.java @@ -92,7 +92,7 @@ public class ReflectionWorld extends World implements IReflectionWorld { public ReflectionWorld(WeakClassLoaderReference classloaderRef) { this.setMessageHandler(new ExceptionBasedMessageHandler()); - setBehaveInJava5Way(LangUtil.is15VMOrGreater()); + setBehaveInJava5Way(true); classLoaderReference = classloaderRef; annotationFinder = makeAnnotationFinderIfAny(classLoaderReference.getClassLoader(), this); } @@ -100,7 +100,7 @@ public class ReflectionWorld extends World implements IReflectionWorld { public ReflectionWorld(ClassLoader aClassLoader) { super(); this.setMessageHandler(new ExceptionBasedMessageHandler()); - setBehaveInJava5Way(LangUtil.is15VMOrGreater()); + setBehaveInJava5Way(true); classLoaderReference = new WeakClassLoaderReference(aClassLoader); annotationFinder = makeAnnotationFinderIfAny(classLoaderReference.getClassLoader(), this); } @@ -117,12 +117,10 @@ public class ReflectionWorld extends World implements IReflectionWorld { public static AnnotationFinder makeAnnotationFinderIfAny(ClassLoader loader, World world) { AnnotationFinder annotationFinder = null; try { - if (LangUtil.is15VMOrGreater()) { - Class<?> java15AnnotationFinder = Class.forName("org.aspectj.weaver.reflect.Java15AnnotationFinder"); - annotationFinder = (AnnotationFinder) java15AnnotationFinder.newInstance(); - annotationFinder.setClassLoader(loader); - annotationFinder.setWorld(world); - } + Class<?> java15AnnotationFinder = Class.forName("org.aspectj.weaver.reflect.Java15AnnotationFinder"); + annotationFinder = (AnnotationFinder) java15AnnotationFinder.newInstance(); + annotationFinder.setClassLoader(loader); + annotationFinder.setWorld(world); } catch (ClassNotFoundException ex) { // must be on 1.4 or earlier } catch (IllegalAccessException ex) { diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/tools/TraceFactory.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/tools/TraceFactory.java index e9b42fb83..9454b209a 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/tools/TraceFactory.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/tools/TraceFactory.java @@ -58,12 +58,9 @@ public abstract class TraceFactory { * Try to load external trace infrastructure using supplied factories */ if (instance == null) try { - if (LangUtil.is15VMOrGreater()) { + { Class factoryClass = Class.forName("org.aspectj.weaver.tools.Jdk14TraceFactory"); instance = (TraceFactory)factoryClass.newInstance(); - } else { - Class factoryClass = Class.forName("org.aspectj.weaver.tools.CommonsTraceFactory"); - instance = (TraceFactory)factoryClass.newInstance(); } } catch (Throwable th) { diff --git a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/ArgsTestCase.java b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/ArgsTestCase.java index b60cad835..623af002f 100644 --- a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/ArgsTestCase.java +++ b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/ArgsTestCase.java @@ -115,17 +115,10 @@ public class ArgsTestCase extends TestCase { Method oneIntM = A.class.getMethod("anInt", new Class[] { int.class }); Method oneIntegerM = A.class.getMethod("anInteger", new Class[] { Integer.class }); - if (LangUtil.is15VMOrGreater()) { - checkMatches(oneInt.matchesMethodExecution(oneIntM), new A(), new A(), new Object[] {5}); - checkMatches(oneInt.matchesMethodExecution(oneIntegerM), new A(), new A(), new Object[] {5}); - checkMatches(oneInteger.matchesMethodExecution(oneIntM), new A(), new A(), new Object[] {5}); - checkMatches(oneInteger.matchesMethodExecution(oneIntegerM), new A(), new A(), new Object[] {5}); - } else { - checkMatches(oneInt.matchesMethodExecution(oneIntM), new A(), new A(), new Object[] {5}); - checkNoMatch(oneInt.matchesMethodExecution(oneIntegerM), new A(), new A(), new Object[] {5}); - checkNoMatch(oneInteger.matchesMethodExecution(oneIntM), new A(), new A(), new Object[] {5}); - checkMatches(oneInteger.matchesMethodExecution(oneIntegerM), new A(), new A(), new Object[] {5}); - } + checkMatches(oneInt.matchesMethodExecution(oneIntM), new A(), new A(), new Object[] {5}); + checkMatches(oneInt.matchesMethodExecution(oneIntegerM), new A(), new A(), new Object[] {5}); + checkMatches(oneInteger.matchesMethodExecution(oneIntM), new A(), new A(), new Object[] {5}); + checkMatches(oneInteger.matchesMethodExecution(oneIntegerM), new A(), new A(), new Object[] {5}); } catch (Exception ex) { fail("Unexpected exception " + ex); @@ -173,8 +166,6 @@ public class ArgsTestCase extends TestCase { /** this condition can occur on the build machine only, and is way too complex to fix right now... */ private boolean needToSkipPointcutParserTests() { - if (!LangUtil.is15VMOrGreater()) - return false; try { Class.forName("org.aspectj.weaver.reflect.Java15ReflectionBasedReferenceTypeDelegate", false, this.getClass() .getClassLoader());// ReflectionBasedReferenceTypeDelegate.class.getClassLoader()); diff --git a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/ThisOrTargetTestCase.java b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/ThisOrTargetTestCase.java index 6c8d70be8..b52146849 100644 --- a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/ThisOrTargetTestCase.java +++ b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/ThisOrTargetTestCase.java @@ -38,9 +38,6 @@ public class ThisOrTargetTestCase extends TestCase { /** this condition can occur on the build machine only, and is way too complex to fix right now... */ private boolean needToSkipPointcutParserTests() { - if (!LangUtil.is15VMOrGreater()) { - return false; - } try { Class.forName("org.aspectj.weaver.reflect.Java15ReflectionBasedReferenceTypeDelegate", false, this.getClass() .getClassLoader());// ReflectionBasedReferenceTypeDelegate.class.getClassLoader()); diff --git a/testing/src/test/java/org/aspectj/testing/AjcTest.java b/testing/src/test/java/org/aspectj/testing/AjcTest.java index e8098ed09..09e623554 100644 --- a/testing/src/test/java/org/aspectj/testing/AjcTest.java +++ b/testing/src/test/java/org/aspectj/testing/AjcTest.java @@ -34,10 +34,10 @@ public class AjcTest { private static boolean is14VMOrGreater = false; static { // matching logic is also in org.aspectj.util.LangUtil - is1dot4VMOrGreater = LangUtil.is1dot4VMOrGreater(); - is15VMOrGreater = LangUtil.is15VMOrGreater(); - is16VMOrGreater = LangUtil.is16VMOrGreater(); - is17VMOrGreater = LangUtil.is17VMOrGreater(); + is1dot4VMOrGreater = true; + is15VMOrGreater = true; + is16VMOrGreater = true; + is17VMOrGreater = true; is18VMOrGreater = LangUtil.is18VMOrGreater(); is19VMOrGreater = LangUtil.is19VMOrGreater(); is10VMOrGreater = LangUtil.is10VMOrGreater(); diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc11/Ajc11Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc11/Ajc11Tests.java index b7fa755db..47c64f2f5 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc11/Ajc11Tests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc11/Ajc11Tests.java @@ -389,11 +389,7 @@ public class Ajc11Tests extends org.aspectj.testing.XMLBasedAjcTestCase { } public void test092() { - if (LangUtil.is17VMOrGreater()) { - runTest("Compiler crash in ajc 1.1 - terrible error for inaccessible constructor - 1.7"); - } else { - runTest("Compiler crash in ajc 1.1 - terrible error for inaccessible constructor"); - } + runTest("Compiler crash in ajc 1.1 - terrible error for inaccessible constructor - 1.7"); } public void test093() { diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/Ajc150Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc150/Ajc150Tests.java index 8dcb8c34d..62e96d0df 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc150/Ajc150Tests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/Ajc150Tests.java @@ -406,14 +406,12 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase { public void testBadASMforEnums() throws IOException { runTest("bad asm for enums"); - if (LangUtil.is15VMOrGreater()) { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - PrintWriter pw = new PrintWriter(baos); - AsmManager.dumptree(pw, AsmManager.lastActiveStructureModel.getHierarchy().getRoot(), 0); - pw.flush(); - String tree = baos.toString(); - assertTrue("Expected 'Red [enumvalue]' somewhere in here:" + tree, tree.contains("Red [enumvalue]")); - } + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + PrintWriter pw = new PrintWriter(baos); + AsmManager.dumptree(pw, AsmManager.lastActiveStructureModel.getHierarchy().getRoot(), 0); + pw.flush(); + String tree = baos.toString(); + assertTrue("Expected 'Red [enumvalue]' somewhere in here:" + tree, tree.contains("Red [enumvalue]")); } public void npeOnTypeNotFound() { @@ -840,11 +838,7 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase { } public void testJava5SpecificFeaturesUsedAtJava14OrLower() { - if (LangUtil.is17VMOrGreater()) { - runTest("java 5 pointcuts and declares at pre-java 5 compliance levels - 1.7"); - } else { - runTest("java 5 pointcuts and declares at pre-java 5 compliance levels"); - } + runTest("java 5 pointcuts and declares at pre-java 5 compliance levels - 1.7"); } public void testAnonymousTypes() { diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/GenericsTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc150/GenericsTests.java index 76c956965..95ab500fc 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc150/GenericsTests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/GenericsTests.java @@ -922,10 +922,7 @@ public class GenericsTests extends XMLBasedAjcTestCase { */ public static boolean isBridge(java.lang.reflect.Method m) { // why not importing java.lang.reflect.Method? No BCEL clash? - if (!LangUtil.is15VMOrGreater()) { - return false; - } - try { + try { final Class<?>[] noparms = new Class[0]; java.lang.reflect.Method isBridge = java.lang.reflect.Method.class.getMethod("isBridge", noparms); diff --git a/tests/src/test/java/org/aspectj/systemtest/java14/Java14Tests.java b/tests/src/test/java/org/aspectj/systemtest/java14/Java14Tests.java index c46708feb..aa9531979 100644 --- a/tests/src/test/java/org/aspectj/systemtest/java14/Java14Tests.java +++ b/tests/src/test/java/org/aspectj/systemtest/java14/Java14Tests.java @@ -49,17 +49,14 @@ public class Java14Tests extends org.aspectj.testing.XMLBasedAjcTestCase { // } public void test006(){ - if (!LangUtil.is1dot4VMOrGreater()) { System.err.println("Skipping test 006 not >=1.4");return;} runTest("compiling asserts in methods"); } public void test007(){ - if (!LangUtil.is1dot4VMOrGreater()) { System.err.println("Skipping test 007 not >=1.4");return;} runTest("asserts"); } public void test008(){ - if (!LangUtil.is1dot4VMOrGreater()) { System.err.println("Skipping test 008 not >=1.4");return;} runTest("asserts in aspect and declared methods [requires 1.4]"); } @@ -76,7 +73,7 @@ public class Java14Tests extends org.aspectj.testing.XMLBasedAjcTestCase { } public void test012(){ - if (!LangUtil.is1dot4VMOrGreater()) { System.err.println("Skipping test 012 not >=1.4");return;} + if (!true) { System.err.println("Skipping test 012 not >=1.4");return;} runTest("assert tests in introduction [requires 1.4]"); } @@ -85,22 +82,18 @@ public class Java14Tests extends org.aspectj.testing.XMLBasedAjcTestCase { } public void test014(){ - if (!LangUtil.is1dot4VMOrGreater()) { System.err.println("Skipping test 014 not >=1.4");return;} runTest("assert statement in advice coverage [requires 1.4]"); } public void test015(){ - if (!LangUtil.is1dot4VMOrGreater()) { System.err.println("Skipping test 015 not >=1.4");return;} runTest("assert statement in advice [requires 1.4]"); } public void test016(){ - if (!LangUtil.is1dot4VMOrGreater()) { System.err.println("Skipping test 016 not >=1.4");return;} runTest("assert and pertarget crashes compiler"); } public void test017(){ - if (!LangUtil.is1dot4VMOrGreater()) { System.err.println("Skipping test 017 not >=1.4");return;} runTest("testing that assert works like .class"); } @@ -117,7 +110,6 @@ public class Java14Tests extends org.aspectj.testing.XMLBasedAjcTestCase { // } public void test021(){ - if (!LangUtil.is1dot4VMOrGreater()) { System.err.println("Skipping test 021 not >=1.4");return;} runTest("Class Literals as non final fields (also assert, and this$0)"); } diff --git a/tests/src/test/java/org/aspectj/tests/TestsModuleTests.java b/tests/src/test/java/org/aspectj/tests/TestsModuleTests.java index 1232f3909..9c83f47f0 100644 --- a/tests/src/test/java/org/aspectj/tests/TestsModuleTests.java +++ b/tests/src/test/java/org/aspectj/tests/TestsModuleTests.java @@ -1,7 +1,5 @@ package org.aspectj.tests; -import org.aspectj.systemtest.AllTests; -import org.aspectj.systemtest.AllTests14; import org.aspectj.systemtest.AllTests17; import org.aspectj.systemtest.AllTests18; import org.aspectj.systemtest.AllTests19; @@ -33,18 +31,10 @@ public class TestsModuleTests extends TestCase { suite.addTest(AllTests19.suite()); } else if (LangUtil.is18VMOrGreater()) { suite.addTest(AllTests18.suite()); - } else if (LangUtil.is15VMOrGreater()) { + } else { // suite.addTest(AllTests15.suite()); suite.addTest(AllTests17.suite()); // there are currently (28/11/06) no tests specific to a 1.6/1.7 vm - so we can do // this - } else if (LangUtil.is1dot4VMOrGreater()) { - System.err.println("Skipping tests for 1.5"); - // suite.addTest(TestUtil.skipTest("for 1.5")); - suite.addTest(AllTests14.suite()); - } else { - System.err.println("Skipping tests for 1.4 and 1.5"); - // suite.addTest(TestUtil.skipTest("for 1.4 and 1.5")); - suite.addTest(AllTests.suite()); } return suite; } diff --git a/util/src/main/java/org/aspectj/util/LangUtil.java b/util/src/main/java/org/aspectj/util/LangUtil.java index 5c656cd7a..98f53e3c8 100644 --- a/util/src/main/java/org/aspectj/util/LangUtil.java +++ b/util/src/main/java/org/aspectj/util/LangUtil.java @@ -125,22 +125,27 @@ public class LangUtil { return result; } + @Deprecated public static boolean isOnePointThreeVMOrGreater() { return 1.3 <= vmVersion; } + @Deprecated public static boolean is1dot4VMOrGreater() { return 1.4 <= vmVersion; } + @Deprecated public static boolean is15VMOrGreater() { return 1.5 <= vmVersion; } + @Deprecated public static boolean is16VMOrGreater() { return 1.6 <= vmVersion; } + @Deprecated public static boolean is17VMOrGreater() { return 1.7 <= vmVersion; } diff --git a/util/src/test/java/org/aspectj/util/LangUtilTest.java b/util/src/test/java/org/aspectj/util/LangUtilTest.java index 545cdd904..87b976957 100644 --- a/util/src/test/java/org/aspectj/util/LangUtilTest.java +++ b/util/src/test/java/org/aspectj/util/LangUtilTest.java @@ -101,9 +101,10 @@ public class LangUtilTest extends TestCase { // } public void testVersion() { - assertTrue(LangUtil.isOnePointThreeVMOrGreater()); // min vm now - floor may change - if (LangUtil.is15VMOrGreater()) { - assertTrue(LangUtil.is1dot4VMOrGreater()); + assertTrue(LangUtil.is18VMOrGreater()); // min vm now - floor may change + if (LangUtil.is11VMOrGreater()) { + assertTrue(LangUtil.is19VMOrGreater()); + assertTrue(LangUtil.is10VMOrGreater()); } } diff --git a/weaver/src/main/java/org/aspectj/weaver/ltw/LTWWorld.java b/weaver/src/main/java/org/aspectj/weaver/ltw/LTWWorld.java index 1fc72dd06..c9f1ecffc 100644 --- a/weaver/src/main/java/org/aspectj/weaver/ltw/LTWWorld.java +++ b/weaver/src/main/java/org/aspectj/weaver/ltw/LTWWorld.java @@ -80,7 +80,7 @@ public class LTWWorld extends BcelWorld implements IReflectionWorld { classLoaderString = loader.getClass().getName()+":"+Integer.toString(System.identityHashCode(loader)); } classLoaderParentString = (loader.getParent() == null ? "<NullParent>" : loader.getParent().toString()); - setBehaveInJava5Way(LangUtil.is15VMOrGreater()); + setBehaveInJava5Way(true); annotationFinder = ReflectionWorld.makeAnnotationFinderIfAny(loader, this); } 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 d3a194fcc..5571ad51f 100644 --- a/weaver/src/main/java/org/aspectj/weaver/tools/WeavingAdaptor.java +++ b/weaver/src/main/java/org/aspectj/weaver/tools/WeavingAdaptor.java @@ -200,9 +200,7 @@ public class WeavingAdaptor implements IMessageContext { bcelWorld = new BcelWorld(classPath, messageHandler, null); bcelWorld.setXnoInline(false); bcelWorld.getLint().loadDefaultProperties(); - if (LangUtil.is15VMOrGreater()) { - bcelWorld.setBehaveInJava5Way(true); - } + bcelWorld.setBehaveInJava5Way(true); weaver = new BcelWeaver(bcelWorld); registerAspectLibraries(aspectPath); diff --git a/weaver/src/test/java/org/aspectj/weaver/TypeXTestCase.java b/weaver/src/test/java/org/aspectj/weaver/TypeXTestCase.java index d6b60eb5f..067e12a4c 100644 --- a/weaver/src/test/java/org/aspectj/weaver/TypeXTestCase.java +++ b/weaver/src/test/java/org/aspectj/weaver/TypeXTestCase.java @@ -107,42 +107,38 @@ public class TypeXTestCase extends TestCase { } public void testTypeXForParameterizedTypes() { - if (LangUtil.is15VMOrGreater()) { // no funny types pre 1.5 - World world = new BcelWorld(); - UnresolvedType stringType = UnresolvedType.forName("java/lang/String"); - ResolvedType listOfStringType = - TypeFactory.createParameterizedType( - UnresolvedType.forName("java/util/List").resolve(world), - new UnresolvedType[] {stringType}, - world); - assertEquals("1 type param",1,listOfStringType.typeParameters.length); - assertEquals(stringType,listOfStringType.typeParameters[0]); - assertTrue(listOfStringType.isParameterizedType()); - assertFalse(listOfStringType.isGenericType()); - } + World world = new BcelWorld(); + UnresolvedType stringType = UnresolvedType.forName("java/lang/String"); + ResolvedType listOfStringType = + TypeFactory.createParameterizedType( + UnresolvedType.forName("java/util/List").resolve(world), + new UnresolvedType[] {stringType}, + world); + assertEquals("1 type param",1,listOfStringType.typeParameters.length); + assertEquals(stringType,listOfStringType.typeParameters[0]); + assertTrue(listOfStringType.isParameterizedType()); + assertFalse(listOfStringType.isGenericType()); } public void testTypeFactoryForParameterizedTypes() { - if (LangUtil.is15VMOrGreater()) { // no funny types pre 1.5 - UnresolvedType enumOfSimpleType = - TypeFactory.createTypeFromSignature("Pjava/lang/Enum<Ljava/lang/String;>;"); - assertEquals(1, enumOfSimpleType.getTypeParameters().length); - - UnresolvedType enumOfNestedType = - TypeFactory.createTypeFromSignature("Pjava/lang/Enum<Ljavax/jws/soap/SOAPBinding$ParameterStyle;>;"); - assertEquals(1, enumOfNestedType.getTypeParameters().length); - - // is this signature right? - UnresolvedType nestedTypeOfParameterized = - TypeFactory.createTypeFromSignature("PMyInterface<Ljava/lang/String;>$MyOtherType;"); - assertEquals(0, nestedTypeOfParameterized.getTypeParameters().length); - - // how about this one? is this valid? - UnresolvedType doublyNestedTypeSignatures = - TypeFactory.createTypeFromSignature("PMyInterface<Ljava/lang/String;Ljava/lang/String;>$MyOtherType<Ljava/lang/Object;>;"); - assertEquals(1, doublyNestedTypeSignatures.getTypeParameters().length); - - } + UnresolvedType enumOfSimpleType = + TypeFactory.createTypeFromSignature("Pjava/lang/Enum<Ljava/lang/String;>;"); + assertEquals(1, enumOfSimpleType.getTypeParameters().length); + + UnresolvedType enumOfNestedType = + TypeFactory.createTypeFromSignature("Pjava/lang/Enum<Ljavax/jws/soap/SOAPBinding$ParameterStyle;>;"); + assertEquals(1, enumOfNestedType.getTypeParameters().length); + + // is this signature right? + UnresolvedType nestedTypeOfParameterized = + TypeFactory.createTypeFromSignature("PMyInterface<Ljava/lang/String;>$MyOtherType;"); + assertEquals(0, nestedTypeOfParameterized.getTypeParameters().length); + + // how about this one? is this valid? + UnresolvedType doublyNestedTypeSignatures = + TypeFactory.createTypeFromSignature("PMyInterface<Ljava/lang/String;Ljava/lang/String;>$MyOtherType<Ljava/lang/Object;>;"); + assertEquals(1, doublyNestedTypeSignatures.getTypeParameters().length); + } private void checkTX(UnresolvedType tx,boolean shouldBeParameterized,int numberOfTypeParameters) { diff --git a/weaver/src/test/java/org/aspectj/weaver/patterns/AnnotationPatternMatchingTestCase.java b/weaver/src/test/java/org/aspectj/weaver/patterns/AnnotationPatternMatchingTestCase.java index eb5c50948..ea276614c 100644 --- a/weaver/src/test/java/org/aspectj/weaver/patterns/AnnotationPatternMatchingTestCase.java +++ b/weaver/src/test/java/org/aspectj/weaver/patterns/AnnotationPatternMatchingTestCase.java @@ -81,14 +81,12 @@ public class AnnotationPatternMatchingTestCase extends TestCase { } public void testAnnotationPatternMatchingOnTypes() { - if (LangUtil.is15VMOrGreater()) { - ResolvedType rtx = loadType("AnnotatedClass"); - initAnnotationTypePatterns(); + ResolvedType rtx = loadType("AnnotatedClass"); + initAnnotationTypePatterns(); - // One should match - assertTrue("@Foo should not match on the AnnotatedClass", fooTP.matches(rtx).alwaysFalse()); - assertTrue("@SimpleAnnotation should match on the AnnotatedClass", simpleAnnotationTP.matches(rtx).alwaysTrue()); - } + // One should match + assertTrue("@Foo should not match on the AnnotatedClass", fooTP.matches(rtx).alwaysFalse()); + assertTrue("@SimpleAnnotation should match on the AnnotatedClass", simpleAnnotationTP.matches(rtx).alwaysTrue()); } @@ -167,35 +165,31 @@ public class AnnotationPatternMatchingTestCase extends TestCase { } public void testAnnotationPatternMatchingOnMethods() { - if (LangUtil.is15VMOrGreater()) { - ResolvedType rtx = loadType("AnnotatedClass"); - ResolvedMember aMethod = rtx.getDeclaredMethods()[1]; + ResolvedType rtx = loadType("AnnotatedClass"); + ResolvedMember aMethod = rtx.getDeclaredMethods()[1]; - assertTrue("Haven't got the right method, I'm looking for 'm1()': " + aMethod.getName(), aMethod.getName().equals("m1")); + assertTrue("Haven't got the right method, I'm looking for 'm1()': " + aMethod.getName(), aMethod.getName().equals("m1")); - initAnnotationTypePatterns(); + initAnnotationTypePatterns(); - // One should match - assertTrue("@Foo should not match on the AnnotatedClass.m1() method", fooTP.matches(aMethod).alwaysFalse()); - assertTrue("@SimpleAnnotation should match on the AnnotatedClass.m1() method", simpleAnnotationTP.matches(aMethod) - .alwaysTrue()); - } + // One should match + assertTrue("@Foo should not match on the AnnotatedClass.m1() method", fooTP.matches(aMethod).alwaysFalse()); + assertTrue("@SimpleAnnotation should match on the AnnotatedClass.m1() method", simpleAnnotationTP.matches(aMethod) + .alwaysTrue()); } public void testAnnotationPatternMatchingOnFields() { - if (LangUtil.is15VMOrGreater()) { - ResolvedType rtx = loadType("AnnotatedClass"); - ResolvedMember aField = rtx.getDeclaredFields()[0]; + ResolvedType rtx = loadType("AnnotatedClass"); + ResolvedMember aField = rtx.getDeclaredFields()[0]; - assertTrue("Haven't got the right field, I'm looking for 'i'" + aField.getName(), aField.getName().equals("i")); + assertTrue("Haven't got the right field, I'm looking for 'i'" + aField.getName(), aField.getName().equals("i")); - initAnnotationTypePatterns(); + initAnnotationTypePatterns(); - // One should match - assertTrue("@Foo should not match on the AnnotatedClass.i field", fooTP.matches(aField).alwaysFalse()); - assertTrue("@SimpleAnnotation should match on the AnnotatedClass.i field", simpleAnnotationTP.matches(aField) - .alwaysTrue()); - } + // One should match + assertTrue("@Foo should not match on the AnnotatedClass.i field", fooTP.matches(aField).alwaysFalse()); + assertTrue("@SimpleAnnotation should match on the AnnotatedClass.i field", simpleAnnotationTP.matches(aField) + .alwaysTrue()); } diff --git a/weaver/src/test/java/org/aspectj/weaver/patterns/AnnotationPatternTestCase.java b/weaver/src/test/java/org/aspectj/weaver/patterns/AnnotationPatternTestCase.java index 0433846fb..05291af1f 100644 --- a/weaver/src/test/java/org/aspectj/weaver/patterns/AnnotationPatternTestCase.java +++ b/weaver/src/test/java/org/aspectj/weaver/patterns/AnnotationPatternTestCase.java @@ -253,52 +253,46 @@ public class AnnotationPatternTestCase extends TestCase { } public void testExactAnnotationPatternMatching() { - if (LangUtil.is15VMOrGreater()) { - PatternParser p = new PatternParser("@Foo"); - AnnotationTypePattern ap = p.maybeParseAnnotationPattern(); - ap = ap.resolveBindings(makeSimpleScope(), new Bindings(3), true); - AnnotatedElementImpl ae = new AnnotatedElementImpl(new String[] { "Foo" }); - assertTrue("matches element with Foo", ap.matches(ae).alwaysTrue()); - AnnotatedElementImpl ae2 = new AnnotatedElementImpl(new String[] { "Boo" }); - assertTrue("does not match element with Boo", ap.matches(ae2).alwaysFalse()); - } + PatternParser p = new PatternParser("@Foo"); + AnnotationTypePattern ap = p.maybeParseAnnotationPattern(); + ap = ap.resolveBindings(makeSimpleScope(), new Bindings(3), true); + AnnotatedElementImpl ae = new AnnotatedElementImpl(new String[] { "Foo" }); + assertTrue("matches element with Foo", ap.matches(ae).alwaysTrue()); + AnnotatedElementImpl ae2 = new AnnotatedElementImpl(new String[] { "Boo" }); + assertTrue("does not match element with Boo", ap.matches(ae2).alwaysFalse()); } public void testBindingAnnotationPatternMatching() { - if (LangUtil.is15VMOrGreater()) { - PatternParser p = new PatternParser("foo"); - AnnotationTypePattern ap = p.parseAnnotationNameOrVarTypePattern(); - try { - ap = ap.resolveBindings(makeSimpleScope(), new Bindings(3), true); - } catch (AbortException abEx) { - assertEquals("Binding not supported in @pcds (1.5.0 M1 limitation): null", abEx.getMessage()); - } - // uncomment these next lines once binding is supported - // AnnotatedElementImpl ae = new AnnotatedElementImpl(new - // String[]{"Foo"}); - // assertTrue("matches element with Foo",ap.matches(ae).alwaysTrue()) - // ; - // AnnotatedElementImpl ae2 = new AnnotatedElementImpl(new - // String[]{"Boo"}); - // assertTrue("does not match element with Boo",ap.matches(ae2). - // alwaysFalse()); + PatternParser p = new PatternParser("foo"); + AnnotationTypePattern ap = p.parseAnnotationNameOrVarTypePattern(); + try { + ap = ap.resolveBindings(makeSimpleScope(), new Bindings(3), true); + } catch (AbortException abEx) { + assertEquals("Binding not supported in @pcds (1.5.0 M1 limitation): null", abEx.getMessage()); } + // uncomment these next lines once binding is supported + // AnnotatedElementImpl ae = new AnnotatedElementImpl(new + // String[]{"Foo"}); + // assertTrue("matches element with Foo",ap.matches(ae).alwaysTrue()) + // ; + // AnnotatedElementImpl ae2 = new AnnotatedElementImpl(new + // String[]{"Boo"}); + // assertTrue("does not match element with Boo",ap.matches(ae2). + // alwaysFalse()); } public void testAndAnnotationPatternMatching() { - if (LangUtil.is15VMOrGreater()) { - PatternParser p = new PatternParser("@Foo @Boo"); - AnnotationTypePattern ap = p.maybeParseAnnotationPattern(); - ap = ap.resolveBindings(makeSimpleScope(), new Bindings(3), true); - AnnotatedElementImpl ae = new AnnotatedElementImpl(new String[] { "Foo", "Boo" }); - assertTrue("matches foo and boo", ap.matches(ae).alwaysTrue()); - ae = new AnnotatedElementImpl(new String[] { "Foo" }); - assertTrue("does not match foo", ap.matches(ae).alwaysFalse()); - ae = new AnnotatedElementImpl(new String[] { "Boo" }); - assertTrue("does not match boo", ap.matches(ae).alwaysFalse()); - ae = new AnnotatedElementImpl(new String[] { "Goo" }); - assertTrue("does not match goo", ap.matches(ae).alwaysFalse()); - } + PatternParser p = new PatternParser("@Foo @Boo"); + AnnotationTypePattern ap = p.maybeParseAnnotationPattern(); + ap = ap.resolveBindings(makeSimpleScope(), new Bindings(3), true); + AnnotatedElementImpl ae = new AnnotatedElementImpl(new String[] { "Foo", "Boo" }); + assertTrue("matches foo and boo", ap.matches(ae).alwaysTrue()); + ae = new AnnotatedElementImpl(new String[] { "Foo" }); + assertTrue("does not match foo", ap.matches(ae).alwaysFalse()); + ae = new AnnotatedElementImpl(new String[] { "Boo" }); + assertTrue("does not match boo", ap.matches(ae).alwaysFalse()); + ae = new AnnotatedElementImpl(new String[] { "Goo" }); + assertTrue("does not match goo", ap.matches(ae).alwaysFalse()); } // @@ -318,15 +312,13 @@ public class AnnotationPatternTestCase extends TestCase { // } // public void testNotAnnotationPatternMatching() { - if (LangUtil.is15VMOrGreater()) { - PatternParser p = new PatternParser("!@Foo"); - AnnotationTypePattern ap = p.maybeParseAnnotationPattern(); - ap = ap.resolveBindings(makeSimpleScope(), new Bindings(3), true); - AnnotatedElementImpl ae = new AnnotatedElementImpl(new String[] { "Foo", "Boo" }); - assertTrue("does not match foo and boo", ap.matches(ae).alwaysFalse()); - ae = new AnnotatedElementImpl(new String[] { "Boo" }); - assertTrue("matches boo", ap.matches(ae).alwaysTrue()); - } + PatternParser p = new PatternParser("!@Foo"); + AnnotationTypePattern ap = p.maybeParseAnnotationPattern(); + ap = ap.resolveBindings(makeSimpleScope(), new Bindings(3), true); + AnnotatedElementImpl ae = new AnnotatedElementImpl(new String[] { "Foo", "Boo" }); + assertTrue("does not match foo and boo", ap.matches(ae).alwaysFalse()); + ae = new AnnotatedElementImpl(new String[] { "Boo" }); + assertTrue("matches boo", ap.matches(ae).alwaysTrue()); } public void testAnyAnnotationPatternMatching() { diff --git a/weaver/src/test/java/org/aspectj/weaver/tools/PointcutDesignatorHandlerTest.java b/weaver/src/test/java/org/aspectj/weaver/tools/PointcutDesignatorHandlerTest.java index 1ea33c465..8d910baf5 100644 --- a/weaver/src/test/java/org/aspectj/weaver/tools/PointcutDesignatorHandlerTest.java +++ b/weaver/src/test/java/org/aspectj/weaver/tools/PointcutDesignatorHandlerTest.java @@ -30,7 +30,6 @@ public class PointcutDesignatorHandlerTest extends TestCase { /** this condition can occur on the build machine only, and is way too complex to fix right now... */ private boolean needToSkipPointcutParserTests() { - if (!LangUtil.is15VMOrGreater()) return false; try { Class.forName("org.aspectj.weaver.reflect.Java15ReflectionBasedReferenceTypeDelegate",false,this.getClass().getClassLoader());//ReflectionBasedReferenceTypeDelegate.class.getClassLoader()); } catch (ClassNotFoundException cnfEx) { diff --git a/weaver/src/test/java/org/aspectj/weaver/tools/PointcutExpressionTest.java b/weaver/src/test/java/org/aspectj/weaver/tools/PointcutExpressionTest.java index ab7762525..d98d1e30e 100644 --- a/weaver/src/test/java/org/aspectj/weaver/tools/PointcutExpressionTest.java +++ b/weaver/src/test/java/org/aspectj/weaver/tools/PointcutExpressionTest.java @@ -448,11 +448,7 @@ public class PointcutExpressionTest extends TestCase { assertFalse("Matches maybe", ex.matchesMethodExecution(foo).alwaysMatches()); // never match ex = p.parsePointcutExpression("args(String,Integer,Number)"); - if (LangUtil.is15VMOrGreater()) { - assertTrue("matches", ex.matchesMethodExecution(foo).alwaysMatches()); - } else { - assertTrue("Does not match", ex.matchesMethodExecution(foo).neverMatches()); - } + assertTrue("matches", ex.matchesMethodExecution(foo).alwaysMatches()); } // public void testMatchesDynamically() { diff --git a/weaver/src/test/java/org/aspectj/weaver/tools/PointcutParserTest.java b/weaver/src/test/java/org/aspectj/weaver/tools/PointcutParserTest.java index 46f841666..589fd6c9b 100644 --- a/weaver/src/test/java/org/aspectj/weaver/tools/PointcutParserTest.java +++ b/weaver/src/test/java/org/aspectj/weaver/tools/PointcutParserTest.java @@ -34,9 +34,6 @@ public class PointcutParserTest extends TestCase { /** this condition can occur on the build machine only, and is way too complex to fix right now... */ private boolean needToSkipPointcutParserTests() { - if (!LangUtil.is15VMOrGreater()) { - return false; - } try { Class.forName("org.aspectj.weaver.reflect.Java15ReflectionBasedReferenceTypeDelegate", false, this.getClass() .getClassLoader());// ReflectionBasedReferenceTypeDelegate.class.getClassLoader()); diff --git a/weaver/src/test/java/org/aspectj/weaver/tools/TypePatternMatcherTest.java b/weaver/src/test/java/org/aspectj/weaver/tools/TypePatternMatcherTest.java index 523ee4a83..0096b5482 100644 --- a/weaver/src/test/java/org/aspectj/weaver/tools/TypePatternMatcherTest.java +++ b/weaver/src/test/java/org/aspectj/weaver/tools/TypePatternMatcherTest.java @@ -25,7 +25,6 @@ public class TypePatternMatcherTest extends TestCase { /** this condition can occur on the build machine only, and is way too complex to fix right now... */ private boolean needToSkipPointcutParserTests() { - if (!LangUtil.is15VMOrGreater()) return false; try { Class.forName("org.aspectj.weaver.reflect.Java15ReflectionBasedReferenceTypeDelegate",false,this.getClass().getClassLoader());//ReflectionBasedReferenceTypeDelegate.class.getClassLoader()); } catch (ClassNotFoundException cnfEx) { |