Community
Participate
Working Groups
In the attached aspect (don't worry, it's generated code, I did not write it myself :-)), I get the warning, that the Type "Formula$1" cannot be found on any within-pointcut. However, "Formula$1" is the aspect type itself, thus IMO it should be found. When I fully qualify the type with a package name, it works.
Created attachment 21199 [details] The test case
I had a look at this... but as I can't get the test case to compile due to dependencies, and it has some huge lines of code it's rather tricky to work out what's going on.. could you attatch the dependencies (or attatch a version without the dependencies but where the bug still occurs) and also say what exactly the warning message was?
Hi. I think there is no need for this. I had a further look and I saw that the '$' character in the class name is the problem. I think, AspectJ misinteprets this as separator for an inner class or something like this. Usage of '$' is indeed discouraged in class IDs, however it *is* legal in Java so AspectJ should obey this IMHO. Hope that helps.
Interesting.. Inner classes in java get put in classfiles called className$1.class, className$2.class, etc. After screwing around a bit with dollar signs I discovered this... /////////////////// In the following code: interface A$1 {} class A{ public A$1 a(){ return new A$1() {}; } } ////////////////////////////////////////// javac produces: A$1.class A$2.class A.class ajc produces this: java.lang.StackOverflowError at java.util.HashMap.hash(HashMap.java:264) at java.util.HashMap.get(HashMap.java:320) at org.aspectj.weaver.World$TypeMap.get(World.java:518) at org.aspectj.weaver.World.resolve(World.java:123) at org.aspectj.weaver.World.resolve(World.java:108) at org.aspectj.weaver.World.resolve(World.java:146) at org.aspectj.weaver.bcel.BcelWeaver.weaveParentsFor(BcelWeaver.java:963) at org.aspectj.weaver.bcel.BcelWeaver.weaveParentsFor(BcelWeaver.java:974) at org.aspectj.weaver.bcel.BcelWeaver.weaveParentsFor(BcelWeaver.java:974) at org.aspectj.weaver.bcel.BcelWeaver.weaveParentsFor(BcelWeaver.java:974) at org.aspectj.weaver.bcel.BcelWeaver.weaveParentsFor(BcelWeaver.java:974) ... etc Lovely! I think the problem I've found is to do with ajc trying to call both the anonymous inner class and the interface "A$1" (javac calls the anon. inner class "A$2")
On further investigation my above problem isn't a bug in ajc as such... it's a bug in jdt... //////////////////////// in the following code interface B {void hello();} class Main$1 {} public class Main{ public static B a(){ return new B() {public void hello(){System.out.println("hello");}}; } public static void main(String [] args){ a().hello(); } } ////////////////////////////////////////////// javac produces the files: B.class Main$1.class Main$2.class Main.class and when ran says "hello" jdt in Eclipse 3.1M6 produces the files: B.class Main$1.class Main.class and when ran says: Exception in thread "main" java.lang.IncompatibleClassChangeError at Main.main(Main.java:11) I'm going to check if this still happens in the latest version of Eclipse, and if it does raise it as a bug on jdt. Perhaps if this bug gets fixed the original one (Formula$1) will go away too when ajc uses the latest jdt.
It is still there in Eclipse 3.1RC1, so I've reported that as jdt bug 98120
Created attachment 22410 [details] error detecting patch This patch makes AspectJ print an error and state what happened (and the workaround) when jdt passes the messed up data to AspectJ.
Andy, please can you apply patch... Thks :)
I'm worried about the performance of the algorithm in the patch - and unfortunately the JDT guys haven't fixed the bug in 3.1 final compiler. I'm going to delay this to M4 to give us a chance to prod them on the compiler bug, maybe for them to fix it in 3.1.1 - and to rework the algorithm if that doesnt work.
moved to 1.5.1 since we're not fully happy with the patch, and really want to pick up the JDT fix... but JDT haven't fixed it in their 3.1.1 final compiler on which AJ 5 is based, and we're not going to move to a pre- release JDT compiler for AJ 5 even if they do fix it now. Hopefully they will have something we can pick up for 1.5.1
nothing happening with the eclipse bug for this...