aboutsummaryrefslogtreecommitdiffstats
path: root/weaver/src
diff options
context:
space:
mode:
authorAlexander Kriegisch <Alexander@Kriegisch.name>2022-12-04 16:16:37 +0100
committerAlexander Kriegisch <Alexander@Kriegisch.name>2022-12-21 20:57:39 +0700
commit65f1ec72c2fc9446a162780dc3f6dee625704c02 (patch)
tree2ed8eedb386b22f65b29c44ec90c9d33eb8ba64d /weaver/src
parentb08d7d2a31f6d6444e4fea980a7d85f2944055b3 (diff)
downloadaspectj-65f1ec72c2fc9446a162780dc3f6dee625704c02.tar.gz
aspectj-65f1ec72c2fc9446a162780dc3f6dee625704c02.zip
Fix #366085 concerning declared annotations with source retention
See https://bugs.eclipse.org/bugs/show_bug.cgi?id=366085. See https://stackoverflow.com/q/74618269/1082681. The issue described in the Bugzilla issue is about 'declare @type', but similar issues also existed for 'declare @field', 'declare @method', 'declare @constructor'. This fix is rather superficial and leaves things to be desired, because it is rather hacky and simply ignores errors source retention annotation declarations during weaving. A better fix would drop the corresponding declarations while parsing and also issue compiler warnings in each case. Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Diffstat (limited to 'weaver/src')
-rw-r--r--weaver/src/main/java/org/aspectj/weaver/bcel/BcelClassWeaver.java10
1 files changed, 8 insertions, 2 deletions
diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelClassWeaver.java b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelClassWeaver.java
index 6a71640ca..450a49189 100644
--- a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelClassWeaver.java
+++ b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelClassWeaver.java
@@ -1023,7 +1023,12 @@ class BcelClassWeaver implements IClassWeaver {
if (annotationsToAdd == null) {
annotationsToAdd = new ArrayList<>();
}
- AnnotationGen a = ((BcelAnnotation) decaM.getAnnotation()).getBcelAnnotation();
+ BcelAnnotation decaMAnnotation = (BcelAnnotation) decaM.getAnnotation();
+ if (decaMAnnotation == null) {
+ unusedDecams.remove(decaM);
+ continue;
+ }
+ AnnotationGen a = decaMAnnotation.getBcelAnnotation();
AnnotationGen ag = new AnnotationGen(a, clazz.getConstantPool(), true);
annotationsToAdd.add(ag);
mg.addAnnotation(decaM.getAnnotation());
@@ -1423,7 +1428,8 @@ class BcelClassWeaver implements IClassWeaver {
// go through all the declare @field statements
for (DeclareAnnotation decaf : decafs) {
if (decaf.getAnnotation() == null) {
- return false;
+ unusedDecafs.remove(decaf);
+ continue;
}
if (decaf.matches(field, world)) {
if (decaf.isRemover()) {