Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] VerifyError on mockito woven class, despite pointcut ignoring it

I am getting a VerifyError on a dynamically generated class which is a mock of one of my types.  I don't want to weave mockito generated classes.  I turned on weaver options -verbose and -showWeaveInfo and saw that the mockito generated classes were being woven.  So I added elements to the pointcut to skip these cglib/mockito generated classes.  Here is my aop.xml pointcut:

myTypes is: 
within(com.argodata..*) AND call(* *..*(..)) AND !within(*..*EnhancerBy*) AND !within(*..*CGLIB*)

When I added the !within for classes with "EnhancedBy" then (as expected) the classes generated by Mockito didn't show up anymore in the ShowWeaveInfo output.  So you would think its not weaving them... but it is!  If I turn on <dump> I get before and afters for the mockito class and the after has advice woven in!  I've attached the before and afters.

Here is my aspect:

@Pointcut("")
  public abstract void myTypes();

  @Pointcut("cflow(adviceexecution() && within(ExceptionAspect))")
  public void thisAdvice() {
  }

  @Pointcut("cflow(within(junit..*))")
  public void frameworkCode() {
  }

  @Pointcut("myTypes() && within(java.lang.Object+) && !handler(*)")
  public void eligibleTypes() {
  }

  @AfterThrowing(pointcut = "eligibleTypes() && !frameworkCode() && !thisAdvice()", throwing = "e")
  public void afterThrown(Exception e) {
    Bushwhacker.tryForDefault().handle(e);
  }

So I want all  calls within my code to go through this custom exception handling stuff.

The verify error I get is:

Caused by: java.lang.VerifyError: (class: com/argodata/fraud/commons/database/dao/AmlTranTypeDao$$EnhancerByMockitoWithCGLIB$$e76ea9ca, method: loadAllDetached signature: ()Ljava/lang/Iterable;) Inconsistent stack height 1 != 0
at sun.reflect.GeneratedSerializationConstructorAccessor5.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.objenesis.instantiator.sun.SunReflectionFactoryInstantiator.newInstance(SunReflectionFactoryInstantiator.java:40)
at org.objenesis.ObjenesisBase.newInstance(ObjenesisBase.java:59)

I have attached a zip (rename .piz to .zip) of the before and after woven class and the complete output of LTW with ShowWeaveInfo.

I'm at a loss here as to why its still weaving when my pointcut says no (and the ShowWeaveInfo seems to agree!).  The verifyError is obvously the real problem, I guess, but I don't really care about weaving mockito generated classes.  I'd prefer to just work around this by ignoring them.



Attachment: aj_weave_problem.piz
Description: Binary data


Back to the top