Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-dev] Static join point with null arguments for array type parameter (ClassNotFoundException).

I have a simple example program with an aspect (included 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 from command line and AJDT 1.1.11 from Eclipse 3.

I *think* it is a bug. At least, it's annoying, since I have to make sure that
all calls are with non-null arguments :)

--- 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 dummy, 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;
---

Please help :)
Regards
/L
--
Lasse R. Nielsen - atwork@xxxxxxxxxx
 'Faith without judgement merely degrades the spirit divine'



Back to the top