Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] error can't determine superclass of missing type

Hi David.

Would you mind providing a reproduceable example, e.g. a little GitHub project, complete with pom.xml etc.? A minimal example would also make it easier for the maintainers to create a regression test in case this proves to be a bug.

Thanks
-- 
Alexander Kriegisch
https://scrum-master.de

> Am 20.12.2016 um 06:56 schrieb David Wright <david.wright_713@xxxxxxxxxxxx>:
> 
> I have an aspect with pointcuts like:
> call(* java.util.concurrent.Executor+.execute(Runnable)) && args(r) &&
> within(myapp..*)
> 
> Unfortunately, the application tests (run by surefire plugin in a maven
> build) also use  Mockito <http://site.mockito.org/>   for mocking.
> 
> I have code that looks like:
> SomeInterface amock = Mockito.mock(SomeInterface.class)
> Then, the class under test is instantiated as:
> MyClass c = new MyClass(amock)
> My test may invoke something like
> c.doStuff(),
> and c.doStuff() calls amock.otherStuff() (You could say we're running amock
> )
> 
> When running this test, I get a warning displayed:
> error can't determine superclass of missing type
> myapp.somepackage.SomeInterface$MockitoMock$1883234141$auxiliary$Ke7g6xEG
> when weaving type myapp.somepackage.SomeInterface$MockitoMock$1883234141
> when weaving classes 
> when weaving 
> 
> Using a bit of reflection, I found that the class hierarchy for the mock
> instance (the 'amock' above) looks like:
> Class myapp.somepackage.SomeInterface$MockitoMock$1883234141
> implements interfaces myapp.somepackage.SomeInterface and
> org.mockito.internal.creation.bytebuddy.MockAccess.
> The superclass of myapp.somepackage.SomeInterface$MockitoMock$1883234141 is
> Object.
> 
> The warning message appears to reference an inner class of the mock class,
> and the weaver can't find this inner class??
> 
> So, I tried modifying the pointcut to
> !cflow(call(* org.mockito.internal.creation.bytebuddy.MockAccess+.*(..))) &&
> call(* java.util.concurrent.Executor+.execute(Runnable)) && args(r) &&
> within(myapp..*)
> in an attempt to exclude any joinpoints that occur within the scope of
> executing any method of the mock instance.
> 
> No effect - same warning appeared. Ideally, the pointcut that resolves this
> issue would not include cflow, for the sake of performance. I believe that
> cflow is handled by checking a value of a ThreadLocal, but I would still
> prefer to not have that overhead.
> 
> By the way, I'm using AspectJ 1.8.9, and have to use the @AspectJ syntax
> with load-time weaving, instead of using the ajc compiler. My aop.xml file
> looks like:
> <aspectj>
>    <aspects>
>        <aspect name="myapp.TroubleAspect"/>
>    </aspects>
> 
>    <weaver options="-XnoInline">
>        <include within="myapp..*"/>
>    </weaver>
> </aspectj>
> 
> *Note that the aspect works as it is supposed to*. The purpose for the
> aspect is not related to invoking methods on mock objects. We anticipate
> making fairly extensive use of Mockito, though, and I would prefer to avoid
> the resultant flurry of warning messages.
> 
> Any ideas?
> 
> 
> 
> 
> 
> 
> --
> View this message in context: http://aspectj.2085585.n4.nabble.com/error-can-t-determine-superclass-of-missing-type-tp4652184.html
> Sent from the AspectJ - users mailing list archive at Nabble.com.
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or unsubscribe from this list, visit
> https://dev.eclipse.org/mailman/listinfo/aspectj-users

Attachment: smime.p7s
Description: S/MIME cryptographic signature


Back to the top