aboutsummaryrefslogtreecommitdiffstats
path: root/weaver5
diff options
context:
space:
mode:
authorAndy Clement <aclement@pivotal.io>2017-09-20 21:34:21 -0700
committerAndy Clement <aclement@pivotal.io>2017-09-20 21:34:21 -0700
commit03752862ba3bc6ef132195673903dcf9109e8b93 (patch)
tree949971954474b167cbcef83fa3161de4c4a4a7c8 /weaver5
parentee99996fb7f727d34a5393374b5661dba1ec9f9f (diff)
parent784906d2ee0cb1b432a9aff6973c12cfd865db6e (diff)
downloadaspectj-03752862ba3bc6ef132195673903dcf9109e8b93.tar.gz
aspectj-03752862ba3bc6ef132195673903dcf9109e8b93.zip
Merged post 1.8.5 changes into Java9 branch
Diffstat (limited to 'weaver5')
-rw-r--r--weaver5/java5-src/org/aspectj/weaver/reflect/Java15AnnotationFinder.java2
-rw-r--r--weaver5/java5-src/org/aspectj/weaver/reflect/Java15ReflectionBasedReferenceTypeDelegate.java14
-rw-r--r--weaver5/java5-src/org/aspectj/weaver/reflect/JavaLangTypeToResolvedTypeConverter.java68
3 files changed, 38 insertions, 46 deletions
diff --git a/weaver5/java5-src/org/aspectj/weaver/reflect/Java15AnnotationFinder.java b/weaver5/java5-src/org/aspectj/weaver/reflect/Java15AnnotationFinder.java
index c19f38e46..a978d9605 100644
--- a/weaver5/java5-src/org/aspectj/weaver/reflect/Java15AnnotationFinder.java
+++ b/weaver5/java5-src/org/aspectj/weaver/reflect/Java15AnnotationFinder.java
@@ -254,7 +254,7 @@ public class Java15AnnotationFinder implements AnnotationFinder, ArgNameFinder {
org.aspectj.apache.bcel.classfile.annotation.AnnotationGen[] anns = jc.getAnnotations();
bcelRepository.clear();
if (anns == null)
- return new ResolvedType[0];
+ return ResolvedType.NONE;
ResolvedType[] ret = new ResolvedType[anns.length];
for (int i = 0; i < ret.length; i++) {
ret[i] = inWorld.resolve(UnresolvedType.forSignature(anns[i].getTypeSignature()));
diff --git a/weaver5/java5-src/org/aspectj/weaver/reflect/Java15ReflectionBasedReferenceTypeDelegate.java b/weaver5/java5-src/org/aspectj/weaver/reflect/Java15ReflectionBasedReferenceTypeDelegate.java
index e9606790a..6b65ed31e 100644
--- a/weaver5/java5-src/org/aspectj/weaver/reflect/Java15ReflectionBasedReferenceTypeDelegate.java
+++ b/weaver5/java5-src/org/aspectj/weaver/reflect/Java15ReflectionBasedReferenceTypeDelegate.java
@@ -37,8 +37,11 @@ import org.aspectj.weaver.tools.PointcutDesignatorHandler;
import org.aspectj.weaver.tools.PointcutParameter;
/**
- * @author colyer Provides Java 5 behaviour in reflection based delegates (overriding 1.4 behaviour from superclass where
- * appropriate)
+ * Provides Java 5 behaviour in reflection based delegates (overriding 1.4 behaviour from superclass where
+ * appropriate)
+ *
+ * @author Adrian Colyer
+ * @author Andy Clement
*/
public class Java15ReflectionBasedReferenceTypeDelegate extends ReflectionBasedReferenceTypeDelegate {
@@ -145,17 +148,16 @@ public class Java15ReflectionBasedReferenceTypeDelegate extends ReflectionBasedR
return superInterfaces;
}
- // If the superclass is null, return Object - same as bcel does
@Override
public ResolvedType getSuperclass() {
- if (superclass == null && getBaseClass() != Object.class) {// superclass
- // of Object
- // is null
+ // Superclass of object is null
+ if (superclass == null && getBaseClass() != Object.class) {
Type t = this.getBaseClass().getGenericSuperclass();
if (t != null) {
superclass = typeConverter.fromType(t);
}
if (t == null) {
+ // If the superclass is null, return Object - same as bcel does
superclass = getWorld().resolve(UnresolvedType.OBJECT);
}
}
diff --git a/weaver5/java5-src/org/aspectj/weaver/reflect/JavaLangTypeToResolvedTypeConverter.java b/weaver5/java5-src/org/aspectj/weaver/reflect/JavaLangTypeToResolvedTypeConverter.java
index 8e313dc40..51a9a4e84 100644
--- a/weaver5/java5-src/org/aspectj/weaver/reflect/JavaLangTypeToResolvedTypeConverter.java
+++ b/weaver5/java5-src/org/aspectj/weaver/reflect/JavaLangTypeToResolvedTypeConverter.java
@@ -5,9 +5,6 @@
* 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;
@@ -30,6 +27,7 @@ import org.aspectj.weaver.World;
/**
* Handles the translation of java.lang.reflect.Type objects into AspectJ UnresolvedTypes.
*
+ * @author Adrian Colyer
*/
public class JavaLangTypeToResolvedTypeConverter {
@@ -45,18 +43,21 @@ public class JavaLangTypeToResolvedTypeConverter {
return this.world;
}
- public ResolvedType fromType(Type aType) {
- if (aType instanceof Class) {
- Class clazz = (Class) aType;
+ public ResolvedType fromType(Type type) {
+ if (type instanceof Class) {
+ Class clazz = (Class) type;
String name = clazz.getName();
/**
* getName() can return:
*
- * 1. If this class object represents a reference type that is not an array type then the binary name of the class is
- * returned 2. If this class object represents a primitive type or void, then the name returned is a String equal to the
- * Java language keyword corresponding to the primitive type or void. 3. If this class object represents a class of
- * arrays, then the internal form of the name consists of the name of the element type preceded by one or more '['
- * characters representing the depth of the array nesting.
+ * 1. If this class object represents a reference type that is not an
+ * array type then the binary name of the class is returned
+ * 2. If this class object represents a primitive type or void, then
+ * the name returned is a String equal to the Java language keyword
+ * corresponding to the primitive type or void.
+ * 3. If this class object represents a class of arrays, then the internal
+ * form of the name consists of the name of the element type preceded by
+ * one or more '[' characters representing the depth of the array nesting.
*/
if (clazz.isArray()) {
UnresolvedType ut = UnresolvedType.forSignature(name.replace('.', '/'));
@@ -64,31 +65,22 @@ public class JavaLangTypeToResolvedTypeConverter {
} else {
return getWorld().resolve(name);
}
- } else if (aType instanceof ParameterizedType) {
- ParameterizedType pt = (ParameterizedType) aType;
- ResolvedType baseType = fromType(pt.getRawType());
- Type[] args = pt.getActualTypeArguments();
- ResolvedType[] resolvedArgs = fromTypes(args);
- /*
- * StringBuilder sb = new StringBuilder(); for (int i = 0; i < resolvedArgs.length; i++) {
- * sb.append(resolvedArgs[i]).append(" "); } for (int i = 0; i < resolvedArgs.length; i++) { if (resolvedArgs[i] ==
- * null) { String ss = ""; try { ss = aType.toString(); } catch (Exception e) { } throw new
- * IllegalStateException("Parameterized type problem. basetype=" + baseType + " arguments=" + sb.toString() + " ss=" +
- * ss); } }
- */
- return TypeFactory.createParameterizedType(baseType, resolvedArgs, getWorld());
- } else if (aType instanceof java.lang.reflect.TypeVariable) {
- TypeVariableReferenceType inprogressVar = typeVariablesInProgress.get(aType);
+ } else if (type instanceof ParameterizedType) {
+ ParameterizedType parameterizedType = (ParameterizedType) type;
+ ResolvedType baseType = fromType(parameterizedType.getRawType());
+ if (!baseType.isRawType()) throw new IllegalStateException("Expected raw type form of "+parameterizedType.getRawType().getTypeName());
+ Type[] typeArguments = parameterizedType.getActualTypeArguments();
+ ResolvedType[] resolvedTypeArguments = fromTypes(typeArguments);
+ return TypeFactory.createParameterizedType(baseType, resolvedTypeArguments, getWorld());
+ } else if (type instanceof java.lang.reflect.TypeVariable) {
+ TypeVariableReferenceType inprogressVar = typeVariablesInProgress.get(type);
if (inprogressVar != null) {
return inprogressVar;
}
-
- java.lang.reflect.TypeVariable tv = (java.lang.reflect.TypeVariable) aType;
+ java.lang.reflect.TypeVariable tv = (java.lang.reflect.TypeVariable) type;
TypeVariable rt_tv = new TypeVariable(tv.getName());
TypeVariableReferenceType tvrt = new TypeVariableReferenceType(rt_tv, getWorld());
-
- typeVariablesInProgress.put(aType, tvrt); // record what we are working on, for recursion case
-
+ typeVariablesInProgress.put(type, tvrt); // record what we are working on, for recursion case
Type[] bounds = tv.getBounds();
ResolvedType[] resBounds = fromTypes(bounds);
ResolvedType upperBound = resBounds[0];
@@ -99,12 +91,10 @@ public class JavaLangTypeToResolvedTypeConverter {
}
rt_tv.setUpperBound(upperBound);
rt_tv.setAdditionalInterfaceBounds(additionalBounds);
-
- typeVariablesInProgress.remove(aType); // we have finished working on it
-
+ typeVariablesInProgress.remove(type); // we have finished working on it
return tvrt;
- } else if (aType instanceof WildcardType) {
- WildcardType wildType = (WildcardType) aType;
+ } else if (type instanceof WildcardType) {
+ WildcardType wildType = (WildcardType) type;
Type[] lowerBounds = wildType.getLowerBounds();
Type[] upperBounds = wildType.getUpperBounds();
ResolvedType bound = null;
@@ -115,9 +105,9 @@ public class JavaLangTypeToResolvedTypeConverter {
bound = fromType(lowerBounds[0]);
}
return new BoundedReferenceType((ReferenceType) bound, isExtends, getWorld());
- } else if (aType instanceof GenericArrayType) {
- GenericArrayType gt = (GenericArrayType) aType;
- Type componentType = gt.getGenericComponentType();
+ } else if (type instanceof GenericArrayType) {
+ GenericArrayType genericArrayType = (GenericArrayType) type;
+ Type componentType = genericArrayType.getGenericComponentType();
return UnresolvedType.makeArray(fromType(componentType), 1).resolve(getWorld());
}
return ResolvedType.MISSING;