Skip to content

feat(java): support Spring AOP (@Aspect/@Around/@Before) via pointcut-based CALLS edges #592

Description

@YutenC

Summary

Spring AOP uses @Aspect classes with pointcut expressions to intercept method calls at runtime. These relationships are currently invisible in CRG.

@Aspect
@Component
public class LoggingAspect {
    @Around("execution(* com.example.service.*.*(..))")
    public Object logAround(ProceedingJoinPoint joinPoint) throws Throwable {
        // wraps every method in com.example.service
    }
}

Proposed approach

Emit CALLS edges from aspect methods to matched target methods by parsing AspectJ pointcut expressions.

Parse phase:

  • Detect @Aspect class
  • Extract pointcut strings from @Around / @Before / @After / @AfterReturning / @AfterThrowing
  • Parse the AspectJ execution() pattern and match against method nodes in the graph

Complexity considerations

AspectJ pointcut expressions are a rich DSL (wildcards, boolean operators, annotations, named references). Options:

  1. Regex approximation — handle execution() pattern covering ~80% of real-world cases; explicitly unsupported for call(), within(), named pointcuts
  2. External library — depend on an AspectJ parsing library if license compatible
  3. Metadata-only — emit a node ASPECT::LoggingAspect with the pointcut string in extra, no CALLS edges; lets users query via get_knowledge_gaps

Option 1 is the most pragmatic starting point and suitable as a PR. Happy to implement if the maintainers are interested in this direction.

Related PRs (same Spring annotation series)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions