Sorry I didn't reply earlier, I was at eclipsecon. I tried to scaffold your situation but it just works for me. Are you loadtime weaving or compile time weaving? Here is my complete code:
package com.foo.bar;
public class CiaWebThreadFactory {
public static void main(String []argv) {
new CiaWebThreadGroup().foo();
System.out.println("works");
}
static class CiaWebThreadGroup {
public void foo() {
Loggable cwtg = ((Loggable)new CiaWebThreadGroup());
cwtg.log("hello");
}
}
}
=== Loggable.java
package com.foo.bar;
interface Loggable {
void log(String msg);
}
=== ServantLogger.java
package com.foo.bar;
class ServantLogger implements Loggable {
public ServantLogger(Class clazz) {
System.out.println("ServantLogger for "+clazz.getName());
}
public void log(String message) { System.out.println(message);}
}
=== LoggingConcurrentBehaviour.java
package com.foo.bar;
import org.aspectj.lang.annotation.*;
@Aspect
class LoggingConcurrentBehaviour {
//works: @DeclareMixin("com.foo.bar.CiaWebThreadFactory.CiaWebThreadGroup")
@DeclareMixin("com.foo.bar.CiaWebThreadFactory.*")
public static Loggable createLoggerDelegate(Object o) {
return new ServantLogger(o.getClass());
}
}
===
ajc -1.5 *.java -d . -showWeaveInfo
Mixing interface 'com.foo.bar.Loggable' (LoggingConcurrentBehaviour.java) into type 'com.foo.bar.CiaWebThreadFactory$CiaWebThreadGroup' (CiaWebThreadFactory.java)
Type 'com.foo.bar.CiaWebThreadFactory$CiaWebThreadGroup' (CiaWebThreadFactory.java) has intertyped method from 'com.foo.bar.LoggingConcurrentBehaviour' (LoggingConcurrentBehaviour.java:'void com.foo.bar.Loggable.log(java.lang.String)')
and then when I run it:
java com.foo.bar.CiaWebThreadFactory
ServantLogger for com.foo.bar.CiaWebThreadFactory$CiaWebThreadGroup
hello
works
In terms of mixin pattern matching I was using:
@DeclareMixin("com.foo.bar.CiaWebThreadFactory.*")
and that was fine (as you can see from the weave info messages).
I tried AspectJ 1.7.2 and 1.6.12 - worked on both.
If you can perhaps edit my code to be more representative of your failing sample, I could investigate further. I wouldn't be surprised if there were inner class problems (I half expected my code to fail) but at the moment I'm not having luck finding problems.
cheers
Andy