Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] AJDT throws NullPointerException after adding cflow.

If I add cflow(validate()) into @AfterReturning, AJDT throws NPE. I list the class and message here. The maven project is also attached.

My environment:

Eclipse 3.5 buildid: 20100218-1602
AJDT 2.0.2.e35x-20100105-0900

package org.foo;

import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;

@Aspect
public class CflowAspect {

@Pointcut("execution(boolean *..CflowExample.validateParameter(..))")
public void validate() {
}

@AfterReturning(pointcut = "call(boolean *..Properties.containsKey(Object)) && args(key) && cflow(validate())", returning = "existed")
public void afterCheckExistence(String key, boolean existed) {
System.out.println(key + " " + (existed ? "exists" : "doesn't exists"));
}

}

package org.foo;

import java.util.Properties;

public class CflowExample {
private boolean validateParameter(Properties config, String key) {
return config.containsKey(key);
}
public static void main(String[] args) {
Properties props = new Properties();
props.put("ABC", "data");
CflowExample example = new CflowExample();
example.validateParameter(props, "ABC");
example.validateParameter(props, "DEF");
}

}

java.lang.NullPointerException
at org.aspectj.weaver.bcel.BcelWorld.isAspectIncluded(BcelWorld.java:942)
at org.aspectj.weaver.ShadowMunger.match(ShadowMunger.java:80)
at org.aspectj.weaver.Advice.match(Advice.java:106)
at org.aspectj.weaver.bcel.BcelAdvice.match(BcelAdvice.java:149)
at org.aspectj.weaver.bcel.BcelClassWeaver.match(BcelClassWeaver.java:3108)
at org.aspectj.weaver.bcel.BcelClassWeaver.match(BcelClassWeaver.java:2562)
a ... Z
                    POP
                    RETURN   (line 18)
  end public static void main(String[])

end public class org.foo.CflowExample

Attachment: bar.tgz
Description: GNU Zip compressed data


Back to the top