From 438eb9301014ffb63bbcbae4df684a2907ac91d5 Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Fri, 6 Jan 2023 01:20:55 +0100 Subject: No more compiler errors for implicitly static inner aspects of interfaces Fixes #162. Contains regression test Bugs1919Tests.testInterfaceInnerAspectImplicitlyStatic. Signed-off-by: Alexander Kriegisch --- .../org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java | 7 ++++++- .../compiler/ast/ValidateAtAspectJAnnotationsVisitor.java | 8 +++++++- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'org.aspectj.ajdt.core') 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; -- cgit v1.2.3