aboutsummaryrefslogtreecommitdiffstats
path: root/weaver
diff options
context:
space:
mode:
authoracolyer <acolyer>2005-12-06 01:11:13 +0000
committeracolyer <acolyer>2005-12-06 01:11:13 +0000
commit5611db4f27a752ef5b65f61b614eb3d5ca30bb01 (patch)
tree9b5d55879d5d1f1f22e9e786e057513fa59da0a5 /weaver
parent278718a6d3bd0c15ebdb9fcf149811575fc99454 (diff)
downloadaspectj-5611db4f27a752ef5b65f61b614eb3d5ca30bb01.tar.gz
aspectj-5611db4f27a752ef5b65f61b614eb3d5ca30bb01.zip
fixes getGenericXXX methods in Reflection-based resolved member impl, GenericSignatureInformationProvider allows this to work across both 1.4 and 1.5
Diffstat (limited to 'weaver')
-rw-r--r--weaver/src/org/aspectj/weaver/reflect/AnnotationFinder.java5
-rw-r--r--weaver/src/org/aspectj/weaver/reflect/GenericSignatureInformationProvider.java31
-rw-r--r--weaver/src/org/aspectj/weaver/reflect/Java14GenericSignatureInformationProvider.java60
-rw-r--r--weaver/src/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegate.java5
-rw-r--r--weaver/src/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegateFactory.java30
-rw-r--r--weaver/src/org/aspectj/weaver/reflect/ReflectionBasedResolvedMemberImpl.java49
-rw-r--r--weaver/src/org/aspectj/weaver/reflect/ReflectionWorld.java1
7 files changed, 179 insertions, 2 deletions
diff --git a/weaver/src/org/aspectj/weaver/reflect/AnnotationFinder.java b/weaver/src/org/aspectj/weaver/reflect/AnnotationFinder.java
index 88b2c7450..07d7e7cac 100644
--- a/weaver/src/org/aspectj/weaver/reflect/AnnotationFinder.java
+++ b/weaver/src/org/aspectj/weaver/reflect/AnnotationFinder.java
@@ -15,6 +15,7 @@ import java.lang.reflect.Member;
import java.util.Set;
import org.aspectj.weaver.ResolvedType;
+import org.aspectj.weaver.World;
/**
* @author colyer
@@ -24,11 +25,13 @@ public interface AnnotationFinder {
void setClassLoader(ClassLoader annotationLoader);
+ void setWorld(World aWorld);
+
Object getAnnotation(ResolvedType annotationType, Object onObject);
Object getAnnotationFromMember(ResolvedType annotationType, Member aMember);
Object getAnnotationFromClass(ResolvedType annotationType, Class aClass);
- Set/*UnresolvedType*/ getAnnotations(Member onMember);
+ Set/*ResolvedType*/ getAnnotations(Member onMember);
}
diff --git a/weaver/src/org/aspectj/weaver/reflect/GenericSignatureInformationProvider.java b/weaver/src/org/aspectj/weaver/reflect/GenericSignatureInformationProvider.java
new file mode 100644
index 000000000..fce972348
--- /dev/null
+++ b/weaver/src/org/aspectj/weaver/reflect/GenericSignatureInformationProvider.java
@@ -0,0 +1,31 @@
+/* *******************************************************************
+ * Copyright (c) 2005 Contributors.
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Adrian Colyer Initial implementation
+ * ******************************************************************/
+package org.aspectj.weaver.reflect;
+
+import org.aspectj.weaver.UnresolvedType;
+
+/**
+ * This interface exists to support two different strategies for answering
+ * generic signature related questions on Java 5 and pre-Java 5.
+ */
+public interface GenericSignatureInformationProvider {
+
+ UnresolvedType[] getGenericParameterTypes(ReflectionBasedResolvedMemberImpl resolvedMember);
+
+ UnresolvedType getGenericReturnType(ReflectionBasedResolvedMemberImpl resolvedMember);
+
+ boolean isBridge(ReflectionBasedResolvedMemberImpl resolvedMember);
+
+ boolean isVarArgs(ReflectionBasedResolvedMemberImpl resolvedMember);
+
+ boolean isSynthetic(ReflectionBasedResolvedMemberImpl resolvedMember);
+}
diff --git a/weaver/src/org/aspectj/weaver/reflect/Java14GenericSignatureInformationProvider.java b/weaver/src/org/aspectj/weaver/reflect/Java14GenericSignatureInformationProvider.java
new file mode 100644
index 000000000..91b32ff0e
--- /dev/null
+++ b/weaver/src/org/aspectj/weaver/reflect/Java14GenericSignatureInformationProvider.java
@@ -0,0 +1,60 @@
+/* *******************************************************************
+ * Copyright (c) 2005 Contributors.
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Adrian Colyer Initial implementation
+ * ******************************************************************/
+package org.aspectj.weaver.reflect;
+
+import org.aspectj.weaver.UnresolvedType;
+
+/**
+ * Under JDK 1.4 or lower, we can't give generic signature info...
+ */
+public class Java14GenericSignatureInformationProvider implements
+ GenericSignatureInformationProvider {
+
+ /* (non-Javadoc)
+ * @see org.aspectj.weaver.reflect.GenericSignatureInformationProvider#getGenericParameterTypes(org.aspectj.weaver.reflect.ReflectionBasedResolvedMemberImpl)
+ */
+ public UnresolvedType[] getGenericParameterTypes(
+ ReflectionBasedResolvedMemberImpl resolvedMember) {
+ return resolvedMember.getParameterTypes();
+ }
+
+ /* (non-Javadoc)
+ * @see org.aspectj.weaver.reflect.GenericSignatureInformationProvider#getGenericReturnType(org.aspectj.weaver.reflect.ReflectionBasedResolvedMemberImpl)
+ */
+ public UnresolvedType getGenericReturnType(
+ ReflectionBasedResolvedMemberImpl resolvedMember) {
+ return resolvedMember.getReturnType();
+ }
+
+ /* (non-Javadoc)
+ * @see org.aspectj.weaver.reflect.GenericSignatureInformationProvider#isBridge()
+ */
+ public boolean isBridge(ReflectionBasedResolvedMemberImpl resolvedMember) {
+ return false;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.aspectj.weaver.reflect.GenericSignatureInformationProvider#isVarArgs()
+ */
+ public boolean isVarArgs(ReflectionBasedResolvedMemberImpl resolvedMember) {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.aspectj.weaver.reflect.GenericSignatureInformationProvider#isSynthetic()
+ */
+ public boolean isSynthetic(ReflectionBasedResolvedMemberImpl resolvedMember) {
+ return false;
+ }
+
+}
diff --git a/weaver/src/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegate.java b/weaver/src/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegate.java
index 300df73af..739e1bc6f 100644
--- a/weaver/src/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegate.java
+++ b/weaver/src/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegate.java
@@ -13,6 +13,7 @@ package org.aspectj.weaver.reflect;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
+import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.Collections;
@@ -346,5 +347,9 @@ public class ReflectionBasedReferenceTypeDelegate implements ReferenceTypeDelega
public void ensureDelegateConsistent() {
// Nothing to do - a reflection based delegate can't become inconsistent...
}
+
+ public ReflectionBasedResolvedMemberImpl createResolvedMemberFor(Member aMember) {
+ return null;
+ }
}
diff --git a/weaver/src/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegateFactory.java b/weaver/src/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegateFactory.java
index 1b5abc058..5063fb0a0 100644
--- a/weaver/src/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegateFactory.java
+++ b/weaver/src/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegateFactory.java
@@ -13,6 +13,7 @@ package org.aspectj.weaver.reflect;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
@@ -62,6 +63,29 @@ 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) {
+ 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");
+ }
+ } else {
+ return new Java14GenericSignatureInformationProvider();
+ }
+ }
+
/**
* convert a java.lang.reflect.Member into a resolved member in the world
* @param reflectMember
@@ -91,6 +115,7 @@ public class ReflectionBasedReferenceTypeDelegateFactory {
if (inWorld instanceof ReflectionWorld) {
ret.setAnnotationFinder(((ReflectionWorld)inWorld).getAnnotationFinder());
}
+ ret.setGenericSignatureInformationProvider(createGenericSignatureProvider(inWorld));
return ret;
}
@@ -108,6 +133,7 @@ public class ReflectionBasedReferenceTypeDelegateFactory {
if (inWorld instanceof ReflectionWorld) {
ret.setAnnotationFinder(((ReflectionWorld)inWorld).getAnnotationFinder());
}
+ ret.setGenericSignatureInformationProvider(createGenericSignatureProvider(inWorld));
return ret;
}
@@ -136,6 +162,7 @@ public class ReflectionBasedReferenceTypeDelegateFactory {
if (inWorld instanceof ReflectionWorld) {
ret.setAnnotationFinder(((ReflectionWorld)inWorld).getAnnotationFinder());
}
+ ret.setGenericSignatureInformationProvider(createGenericSignatureProvider(inWorld));
return ret;
}
@@ -151,6 +178,7 @@ public class ReflectionBasedReferenceTypeDelegateFactory {
if (inWorld instanceof ReflectionWorld) {
ret.setAnnotationFinder(((ReflectionWorld)inWorld).getAnnotationFinder());
}
+ ret.setGenericSignatureInformationProvider(createGenericSignatureProvider(inWorld));
return ret;
}
@@ -167,7 +195,7 @@ public class ReflectionBasedReferenceTypeDelegateFactory {
// classes that represent arrays return a class name that is the signature of the array type, ho-hum...
String className = aClass.getName();
if (aClass.isArray()) {
- return aWorld.resolve(UnresolvedType.forSignature(className));
+ return aWorld.resolve(UnresolvedType.forSignature(className.replace('.','/')));
}
else{
return aWorld.resolve(className);
diff --git a/weaver/src/org/aspectj/weaver/reflect/ReflectionBasedResolvedMemberImpl.java b/weaver/src/org/aspectj/weaver/reflect/ReflectionBasedResolvedMemberImpl.java
index ecdd60d1f..86aab4599 100644
--- a/weaver/src/org/aspectj/weaver/reflect/ReflectionBasedResolvedMemberImpl.java
+++ b/weaver/src/org/aspectj/weaver/reflect/ReflectionBasedResolvedMemberImpl.java
@@ -26,6 +26,8 @@ import org.aspectj.weaver.UnresolvedType;
public class ReflectionBasedResolvedMemberImpl extends ResolvedMemberImpl {
private AnnotationFinder annotationFinder = null;
+ private GenericSignatureInformationProvider gsigInfoProvider =
+ new Java14GenericSignatureInformationProvider();
private Member reflectMember;
@@ -101,6 +103,53 @@ public class ReflectionBasedResolvedMemberImpl extends ResolvedMemberImpl {
this.reflectMember = reflectMember;
}
+ public Member getMember() {
+ return this.reflectMember;
+ }
+
+ // generic signature support
+
+ public void setGenericSignatureInformationProvider(GenericSignatureInformationProvider gsigProvider) {
+ this.gsigInfoProvider = gsigProvider;
+ }
+
+ /* (non-Javadoc)
+ * @see org.aspectj.weaver.ResolvedMemberImpl#getGenericParameterTypes()
+ */
+ public UnresolvedType[] getGenericParameterTypes() {
+ return this.gsigInfoProvider.getGenericParameterTypes(this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.aspectj.weaver.ResolvedMemberImpl#getGenericReturnType()
+ */
+ public UnresolvedType getGenericReturnType() {
+ return this.gsigInfoProvider.getGenericReturnType(this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.aspectj.weaver.ResolvedMemberImpl#isSynthetic()
+ */
+ public boolean isSynthetic() {
+ return this.gsigInfoProvider.isSynthetic(this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.aspectj.weaver.ResolvedMemberImpl#isVarargsMethod()
+ */
+ public boolean isVarargsMethod() {
+ return this.gsigInfoProvider.isVarArgs(this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.aspectj.weaver.ResolvedMemberImpl#isBridgeMethod()
+ */
+ public boolean isBridgeMethod() {
+ return this.gsigInfoProvider.isBridge(this);
+ }
+
+ // annotation support
+
public void setAnnotationFinder(AnnotationFinder finder) {
this.annotationFinder = finder;
}
diff --git a/weaver/src/org/aspectj/weaver/reflect/ReflectionWorld.java b/weaver/src/org/aspectj/weaver/reflect/ReflectionWorld.java
index 01b2c6e79..03aca9ac8 100644
--- a/weaver/src/org/aspectj/weaver/reflect/ReflectionWorld.java
+++ b/weaver/src/org/aspectj/weaver/reflect/ReflectionWorld.java
@@ -66,6 +66,7 @@ public class ReflectionWorld extends World {
Class java15AnnotationFinder = Class.forName("org.aspectj.weaver.reflect.Java15AnnotationFinder");
this.annotationFinder = (AnnotationFinder) java15AnnotationFinder.newInstance();
this.annotationFinder.setClassLoader(loader);
+ this.annotationFinder.setWorld(this);
} catch(ClassNotFoundException ex) {
// must be on 1.4 or earlier
} catch(IllegalAccessException ex) {