diff options
author | Alexander Kriegisch <Alexander@Kriegisch.name> | 2023-01-06 01:20:55 +0100 |
---|---|---|
committer | Alexander Kriegisch <Alexander@Kriegisch.name> | 2023-01-06 01:42:01 +0100 |
commit | 438eb9301014ffb63bbcbae4df684a2907ac91d5 (patch) | |
tree | c1f8053093ea931a0b65355aa110490432b34ffb /org.aspectj.ajdt.core | |
parent | e0a1525ebd9f0f3b806c323223d4776c1275e899 (diff) | |
download | aspectj-438eb9301014ffb63bbcbae4df684a2907ac91d5.tar.gz aspectj-438eb9301014ffb63bbcbae4df684a2907ac91d5.zip |
No more compiler errors for implicitly static inner aspects of interfaces
Fixes #162. Contains regression test
Bugs1919Tests.testInterfaceInnerAspectImplicitlyStatic.
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Diffstat (limited to 'org.aspectj.ajdt.core')
2 files changed, 13 insertions, 2 deletions
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java index cb8b82dc3..a1e7d5cdf 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java @@ -155,7 +155,12 @@ public class AspectDeclaration extends TypeDeclaration { } if (this.enclosingType != null) { - if (!Modifier.isStatic(modifiers)) { + if ( + !Modifier.isStatic(modifiers) && + // Inner classes/aspects of interfaces are implicitly static, + // see https://github.com/eclipse/org.aspectj/issues/162 + (this.enclosingType.modifiers & ClassFileConstants.AccInterface) == 0 + ) { scope.problemReporter().signalError(sourceStart, sourceEnd, "inner aspects must be static"); ignoreFurtherInvestigation = true; return; diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/ValidateAtAspectJAnnotationsVisitor.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/ValidateAtAspectJAnnotationsVisitor.java index 8a63b153f..d27b2b62a 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/ValidateAtAspectJAnnotationsVisitor.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/ValidateAtAspectJAnnotationsVisitor.java @@ -36,6 +36,7 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.ast.SingleTypeReference; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.StringLiteral; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference; +import org.aspectj.org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.aspectj.org.eclipse.jdt.internal.compiler.impl.Constant; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.Binding; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.BlockScope; @@ -230,7 +231,12 @@ public class ValidateAtAspectJAnnotationsVisitor extends ASTVisitor { private void validateAspectDeclaration(TypeDeclaration typeDecl) { if (typeStack.size() > 1) { // it's a nested aspect - if (!Modifier.isStatic(typeDecl.modifiers)) { + if ( + !Modifier.isStatic(typeDecl.modifiers) && + // Inner classes/aspects of interfaces are implicitly static, + // see https://github.com/eclipse/org.aspectj/issues/162 + (typeDecl.enclosingType.modifiers & ClassFileConstants.AccInterface) == 0 + ) { typeDecl.scope.problemReporter().signalError(typeDecl.sourceStart, typeDecl.sourceEnd, "inner aspects must be static"); return; |