summaryrefslogtreecommitdiffstats
path: root/weaver/src
diff options
context:
space:
mode:
authoraclement <aclement>2009-08-24 18:07:09 +0000
committeraclement <aclement>2009-08-24 18:07:09 +0000
commitb6649690748b44544a361e39510a10e0bf83ca46 (patch)
treec6b13ff39c2b43091a75efdffe82f4563cd3708f /weaver/src
parent447cdc9d31a9e85f754eba3d0b4e461e60dc999d (diff)
downloadaspectj-b6649690748b44544a361e39510a10e0bf83ca46.tar.gz
aspectj-b6649690748b44544a361e39510a10e0bf83ca46.zip
287315: re-entrancy
Diffstat (limited to 'weaver/src')
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java69
1 files changed, 55 insertions, 14 deletions
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java b/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java
index 484e54d0e..f6e46ad97 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java
@@ -113,6 +113,8 @@ public class BcelObjectType extends AbstractReferenceTypeDelegate {
private static final int DISCOVERED_DECLARED_SIGNATURE = 0x0010;
private static final int DISCOVERED_WHETHER_ANNOTATION_STYLE = 0x0020;
+ private static final int ANNOTATION_UNPACK_IN_PROGRESS = 0x0100;
+
private static final String[] NO_INTERFACE_SIGS = new String[] {};
/*
@@ -552,11 +554,32 @@ public class BcelObjectType extends AbstractReferenceTypeDelegate {
}
public boolean hasAnnotation(UnresolvedType ofType) {
+ // Due to re-entrancy we may be in the middle of unpacking the annotations already... in which case use this slow
+ // alternative until the stack unwinds itself
+ if (isUnpackingAnnotations()) {
+ AnnotationGen annos[] = javaClass.getAnnotations();
+ if (annos == null || annos.length == 0) {
+ return false;
+ } else {
+ String lookingForSignature = ofType.getSignature();
+ for (int a = 0; a < annos.length; a++) {
+ AnnotationGen annotation = annos[a];
+ if (lookingForSignature.equals(annotation.getTypeSignature())) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
ensureAnnotationsUnpacked();
for (int i = 0; i < annotationTypes.length; i++) {
- ResolvedType ax = annotationTypes[i];
- if (ax.equals(ofType))
+ UnresolvedType ax = annotationTypes[i];
+ if (ax == null) {
+ throw new RuntimeException("Annotation entry " + i + " on type " + this.getResolvedTypeX().getName() + " is null!");
+ }
+ if (ax.equals(ofType)) {
return true;
+ }
}
return false;
}
@@ -647,21 +670,39 @@ public class BcelObjectType extends AbstractReferenceTypeDelegate {
// --- unpacking methods
+ private boolean isUnpackingAnnotations() {
+ return (bitflag & ANNOTATION_UNPACK_IN_PROGRESS) != 0;
+ }
+
private void ensureAnnotationsUnpacked() {
+ if (isUnpackingAnnotations()) {
+ throw new BCException("Re-entered weaver instance whilst unpacking annotations on " + this.className);
+ }
if (annotationTypes == null) {
- AnnotationGen annos[] = javaClass.getAnnotations();
- if (annos == null || annos.length == 0) {
- annotationTypes = ResolvedType.NONE;
- annotations = AnnotationAJ.EMPTY_ARRAY;
- } else {
- World w = getResolvedTypeX().getWorld();
- annotationTypes = new ResolvedType[annos.length];
- annotations = new AnnotationAJ[annos.length];
- for (int i = 0; i < annos.length; i++) {
- AnnotationGen annotation = annos[i];
- annotationTypes[i] = w.resolve(UnresolvedType.forSignature(annotation.getTypeSignature()));
- annotations[i] = new BcelAnnotation(annotation, w);
+ try {
+ bitflag |= ANNOTATION_UNPACK_IN_PROGRESS;
+ AnnotationGen annos[] = javaClass.getAnnotations();
+ if (annos == null || annos.length == 0) {
+ annotationTypes = ResolvedType.NONE;
+ annotations = AnnotationAJ.EMPTY_ARRAY;
+ } else {
+ World w = getResolvedTypeX().getWorld();
+ annotationTypes = new ResolvedType[annos.length];
+ annotations = new AnnotationAJ[annos.length];
+ for (int i = 0; i < annos.length; i++) {
+ AnnotationGen annotation = annos[i];
+ String typeSignature = annotation.getTypeSignature();
+ ResolvedType rType = w.resolve(UnresolvedType.forSignature(typeSignature));
+ if (rType == null) {
+ throw new RuntimeException("Whilst unpacking annotations on '" + getResolvedTypeX().getName()
+ + "', failed to resolve type '" + typeSignature + "'");
+ }
+ annotationTypes[i] = rType;
+ annotations[i] = new BcelAnnotation(annotation, w);
+ }
}
+ } finally {
+ bitflag &= ~ANNOTATION_UNPACK_IN_PROGRESS;
}
}
}