Community
Participate
Working Groups
(Example classes below) When calling with a null argument for the array parameter the *first* time it is called, the "thisStaticJoinPoint" signature reports "ClassNotFoundException" as the type of that parameter, also for the next call where the argument is not null. However, if I *switch* the calls, so the first call is with a non-null argument, then the static join point correctly reports the array type, also for the next call. Tested with both AspectJ 1.1 and 1.2 from command line and AJDT 1.1.11 from Eclipse 3. It seems to be a bug in the runtime classes (no Component for that?) Example classes: --- Main.java --- package dk.infimum.aspectjtest; public class Main { public static void main(String[] args) { Main obj = new Main(); // swap following lines to change behavior obj.test(null, null); obj.test(null, new Main[]{}); } void test(Main dummy, Main[] dummy2) {} } --- end Main.java --- and --- MainAspect.aj --- import org.aspectj.lang.reflect.MethodSignature; public aspect MainAspect { pointcut testcall(): execution(* test*(..)); before(): testcall() { MethodSignature sig = (MethodSignature) thisJoinPointStaticPart.getSignature(); System.out.println(sig); Class[] params = sig.getParameterTypes(); for(int i=0;i<params.length;i++) { Class cls = params[i]; System.out.println(" - " + cls.getName()); } } } --- end MainAspect.aj --- The output from running Main is: --- void dk.infimum.aspectjtest.Main.test(Main, ClassNotFoundException) - dk.infimum.aspectjtest.Main - java.lang.ClassNotFoundException void dk.infimum.aspectjtest.Main.test(Main, ClassNotFoundException) - dk.infimum.aspectjtest.Main - java.lang.ClassNotFoundException --- However, if I swap the calls to test, the output becomes: --- void dk.infimum.aspectjtest.Main.test(Main, Main[]) - dk.infimum.aspectjtest.Main - [Ldk.infimum.aspectjtest.Main; void dk.infimum.aspectjtest.Main.test(Main, Main[]) - dk.infimum.aspectjtest.Main - [Ldk.infimum.aspectjtest.Main; ---
marked as target 1.2.1
Turns out I only *said* I was marking this for 1.2.1 last time, but I didn't actually do it. this time I really have so we should get a fix in soon.
This bug appears to be due to a problem of us using loadClass() rather than Class.forName() to get hold of the array type. The raiser says that this fails: obj.test(null, null); obj.test(null, new Main[]{}); and this works: obj.test(null, new Main[]{}); obj.test(null, null); However, this also works: Main m[] = new Main[3]; obj.test(null, null); obj.test(null, null); Basically using Class.forName() will attempt to bring the type into existence (i.e. it understands "[Lblahblah;" is an array type that needs dynamically creating) whereas the loadClass() method that we use right now will just look around for it - if it doesn't find it then it throws a ClassNotFoundException. That's why it works if someone else has referred to the array type earlier on - they will have caused it to be dynamically created for loadClass() to find. I'm about to stick in a fix for it...
Fix checked in - waiting for build (sorry about working on a bug assigned to you Adrian!).
Fix available: BUILD COMPLETE - build.364 Date of build: 08/27/2004 22:17:38 Time to build: 95 minutes 15 seconds Last changed: 08/27/2004 17:02:18 Latest good AspectJ jar available at: download.eclipse.org/technology/ajdt/dev/aspectj-DEVELOPMENT.jar
Fix released as part of AspectJ 1.2.1