I wrote a very simple entity object which has a unique field called objectID.
public class CustomObject{ public Long objectID; public String field1; public String field2; }
public class CustomObjectFieldInterceptor{ if(invocation instanceof FieldReadInvocation){ FieldReadInvocation readInvocation = (FieldReadInvocation) invocation; CustomObject object1 = (CustomObject) readInvocation.getTarget(); Long objID = object1.objectID; } }
Long objID = object1.objectID;throws StackOverflowException because there is a recursive call.
I think making your CustomObjectFieldInterceptor implement org.jboss.aop.instrument.Untransformable should work. Classes implementing that interface are not woven, and thus field access should not get replaced