instanceof not working with aspects in Spring

844 views Asked by At

I have a Spring Bean obtained from a factory, say,

private ObjectFactory<GoodStudent> studentFactory;

public void somemethod() {
    IStudent astudent = studentFactory.getObject();
    System.out.println(astudent instanceof GoodStudent); // prints false.
}

Does this happen because of Aspects? Because, I have a method in GoodStudent that is augmented using Aspects(around aspect), like,

public class GoodStudent implements IStudent { ...
    @UsesAspect
    public void logStudent() {....}

Is this a limitation in Spring or am I missing something?

Note : System.out.println(astudent instanceof IStudent); // prints true

0

There are 0 answers