Signed-off-by: Lars Grefer <eclipse@larsgrefer.de>tags/V1_9_7M1
@@ -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)); |
@@ -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 */ |
@@ -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(); | |||
} |
@@ -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) { |
@@ -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) { |
@@ -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()); |
@@ -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()); |
@@ -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(); |
@@ -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() { |
@@ -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() { |
@@ -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); |
@@ -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)"); | |||
} | |||
@@ -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; | |||
} |
@@ -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; | |||
} |
@@ -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()); | |||
} | |||
} | |||
@@ -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); | |||
} | |||
@@ -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); |
@@ -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) { |
@@ -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()); | |||
} | |||
@@ -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() { |
@@ -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) { |
@@ -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() { |
@@ -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()); |
@@ -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) { |