Community
Participate
Working Groups
Build Identifier: Version: Indigo Service Release 1, Build id: 20110916-0149, Version: 2.1.3.e37x-20110628-1900, AspectJ version: 1.6.12.20110613132200 ClassCastException is thrown due to that AspectJ seems to confuse argument for cross-cut method and for @DeclareMixing inter-type. For an example, by the following definitions, the ClassCastException is thrown as the stack traces appended below. public static class MixeeClass1 extends ForDeclareMixin { public MixeeClass1( String omStr) { super(); this.omStr = omStr; } } public static class MixinClass implements MixinInterface { ForDeclareMixin forDeclareMixin = null; public MixinClass( ForDeclareMixin forDeclareMixin) { this.forDeclareMixin = forDeclareMixin; } public void mixinInterfaceMethod() { } } @DeclareMixin( value="aspectJTest.DeclareMixinAspect.MixeeClass1") public static MixinInterface addMixinInterfaceInterface( Object instance) { return new MixinClass( (MixeeClass1)instance); } @Around( value="execution( * aspectJTest.ForDeclareMixin+.setOmStr( java.lang.String)) " + "&& this( mixinInterface)" ) public Object aroundAdvisedOMethod( ProceedingJoinPoint proceedingJoinPoint, MixinInterface mixinInterface) { try { return proceedingJoinPoint.proceed( proceedingJoinPoint.getArgs()); } catch( Throwable throwable) { if ( throwable instanceof RuntimeException) { throw (RuntimeException)throwable; } else { throw new RuntimeException( throwable); } } } java.lang.ClassCastException: java.lang.String cannot be cast to aspectJTest.ForDeclareMixin at aspectJTest.ForDeclareMixin.setOmStr_aroundBody1$advice(ForDeclareMixin.java:66) at aspectJTest.ForDeclareMixin.setOmStr(ForDeclareMixin.java:1) at aspectJTest.DeclareMixingTest.testDeclareMixing(DeclareMixingTest.java:31) Reproducible: Always Steps to Reproduce: 1. Import DeclareMixingClassCastExceptionTest project from attached DeclareMixingClassCastExceptionTest.zip file 2. Run testDeclareMixing test method in DeclareMixingTest class.
Created attachment 210952 [details] Sample project to reproduce problem