-
Notifications
You must be signed in to change notification settings - Fork 98
Open
Description
Possibly related to mojohaus/aspectj-maven-plugin#222 (now #338).
Problem
If an inheriting aspect declares @Override on a method/pointcut it overrides and is in src/test or in a different module importing the parent from a library, the compiler errors (during test-compile and compile respectively):
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.13.0:compile (default-compile)
on project aspect-override-method-from-module: Compilation failure
[ERROR] /home/runner/work/aspectj-issue-reproducers/aspectj-issue-reproducers/issue-override-method
/aspect-override-method-from-module/src/main/java/com/example/InheritingAspectInOtherModule.java:[9,5]
method does not override or implement a method from a supertype
If the same inheriting aspect is in src/main, it compiles without error.
Code
Example project: https://github.com/stendler/aspectj-issue-reproducers/tree/main/issue-override-method
GitHub action with the error message: https://github.com/stendler/aspectj-issue-reproducers/actions/runs/14665672762/job/41159742585#step:4:1132
Parent aspect:
package com.example;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
@Aspect
public abstract class AbstractAspect {
@Pointcut
public abstract void pointCut();
@Around("isEnabled() && pointCut()")
public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
System.out.println("advising...");
var ret = joinPoint.proceed();
System.out.println("advised!");
return ret;
}
}Inheriting aspect:
package com.example;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
@Aspect
public class InheritingAspectInTest extends AbstractAspect {
@Override
@Pointcut("!cflow(adviceexecution()) && call(* com.example..*(..))")
public void pointCut() {};
}Workaround
Remove the @Override annotation
Metadata
Metadata
Assignees
Labels
No labels