Skip to content

Spring AOP doesn't process generics correctly [SPR-3556] #8239

@spring-projects-issues

Description

@spring-projects-issues

Andrei Stefan opened SPR-3556 and commented

I made two tests:

  • one with AspectJ support;
  • one with Spring's AspectJ support.

The tests involve two interfaces: Base<T> and DerivedInterface<T> extends Base<T>.
A Before pointcut matching all methods from Base and DerivedInterface is defined: @Before("execution(* example.Base+.*(..))")
In AspectJ a test creating an instance of a class implementing DerivedInterface: DerivedInterface<String> obj = new DerivedString(); and then calling methods on both interfaces demonstrates advice being applied on both methods.
The same test in Spring getting a bean instance from ApplicationContext like DerivedInterface<String> bean = (DerivedInterface<String>) context.getBean("myBean"); and calling methods on both interfaces, the advice is not applied to methods receiving as parameter the generic type <T>.

Methods like method(<T>) don't get the advice applied, but method2() have the advice applied.


Affects: 2.0.5, 2.1 M3

Attachments:

Issue Links:

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: coreIssues in core modules (aop, beans, core, context, expression)type: bugA general bug

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions