From 3417cbe70eb77243767e59f9fd181b989c8cefb6 Mon Sep 17 00:00:00 2001 From: aclement Date: Thu, 4 Jun 2009 15:43:11 +0000 Subject: [PATCH] 279120: rewritten not to rely on javaClass being non-null - use the already unpacked annotations --- .../org/aspectj/weaver/bcel/BcelObjectType.java | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java b/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java index 6051277d4..484e54d0e 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java @@ -21,6 +21,7 @@ import java.util.Collection; import java.util.Collections; import java.util.Iterator; import java.util.List; +import java.util.Set; import org.aspectj.apache.bcel.classfile.AttributeUtils; import org.aspectj.apache.bcel.classfile.Field; @@ -28,9 +29,7 @@ import org.aspectj.apache.bcel.classfile.JavaClass; import org.aspectj.apache.bcel.classfile.Method; import org.aspectj.apache.bcel.classfile.Signature; import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen; -import org.aspectj.apache.bcel.classfile.annotation.ArrayElementValueGen; import org.aspectj.apache.bcel.classfile.annotation.ElementNameValuePairGen; -import org.aspectj.apache.bcel.classfile.annotation.ElementValueGen; import org.aspectj.apache.bcel.classfile.annotation.EnumElementValueGen; import org.aspectj.bridge.IMessageHandler; import org.aspectj.bridge.MessageUtil; @@ -609,16 +608,14 @@ public class BcelObjectType extends AbstractReferenceTypeDelegate { // @Target annotation hasn't been used List targetKinds = new ArrayList(); if (isAnnotation()) { - AnnotationGen[] annotationsOnThisType = javaClass.getAnnotations(); + AnnotationAJ[] annotationsOnThisType = getAnnotations(); for (int i = 0; i < annotationsOnThisType.length; i++) { - AnnotationGen a = annotationsOnThisType[i]; + AnnotationAJ a = annotationsOnThisType[i]; if (a.getTypeName().equals(UnresolvedType.AT_TARGET.getName())) { - ArrayElementValueGen arrayValue = (ArrayElementValueGen) ((ElementNameValuePairGen) a.getValues().get(0)) - .getValue(); - ElementValueGen[] evs = arrayValue.getElementValuesArray(); - if (evs != null) { - for (int j = 0; j < evs.length; j++) { - String targetKind = ((EnumElementValueGen) evs[j]).getEnumValueString(); + Set targets = a.getTargets(); + if (targets != null) { + for (Iterator iterator = targets.iterator(); iterator.hasNext();) { + String targetKind = (String) iterator.next(); if (targetKind.equals("ANNOTATION_TYPE")) { targetKinds.add(AnnotationTargetKind.ANNOTATION_TYPE); } else if (targetKind.equals("CONSTRUCTOR")) { -- 2.39.5