Field visibility and aspect
mane81 Oct 24, 2008 7:39 AMHi,
if I have a class with an enclosed class like this
Class POJO {
private String aField;
...
class AnotherClass {
public void someMethod() {
aField = "something";
}
}
}
and I add an aspect at runtime through these instructions:
AdviceBinding binding = new AdviceBinding("execution(public boolean Pojo>getCond())", null);
binding.addInterceptor(SimpleAspect.class);
AspectManager.instance().addBinding(binding);
An exception is thrown:
Exception in thread "main" java.lang.NullPointerException
at org.jboss.aop.pointcut.MethodMatcher.(MethodMatcher.java:72)
at org.jboss.aop.pointcut.ExecutionMethodMatcher.(ExecutionMethodMatcher.java:53)
at org.jboss.aop.pointcut.PointcutExpression.matchesExecution(PointcutExpression.java:118)
at org.jboss.aop.Advisor.resolveMethodPointcut(Advisor.java:1333)
at org.jboss.aop.GeneratedClassAdvisor.resolveMethodPointcut(GeneratedClassAdvisor.java:309)
at org.jboss.aop.ClassAdvisor.resolvePointcuts(ClassAdvisor.java:751)
at org.jboss.aop.ClassAdvisor.doRebuildInterceptorsForAddedBinding(ClassAdvisor.java:1160)
at org.jboss.aop.ClassAdvisor$RebuildInterceptorsAction$2.rebuildInterceptorsForAddedBinding(ClassAdvisor.java:2348)
at org.jboss.aop.ClassAdvisor.rebuildInterceptorsForAddedBinding(ClassAdvisor.java:1139)
at org.jboss.aop.GeneratedClassAdvisor.access$1501(GeneratedClassAdvisor.java:65)
at org.jboss.aop.GeneratedClassAdvisor$ClassAdvisorStrategy.rebuildInterceptorsForAddedBinding(GeneratedClassAdvisor.java:1538)
at org.jboss.aop.GeneratedClassAdvisor.rebuildInterceptorsForAddedBinding(GeneratedClassAdvisor.java:244)
at org.jboss.aop.Advisor.newBindingAdded(Advisor.java:1124)
at org.jboss.aop.AspectManager.updateAdvisorsForAddedBinding(AspectManager.java:1498)
at org.jboss.aop.AspectManager.updateAdvisorsForAddedBinding(AspectManager.java:1521)
at org.jboss.aop.AspectManager.addBinding(AspectManager.java:1456)
at Caller.run(Caller.java:36)
at Caller.main(Caller.java:57)
If the field visibility is public the exception is not thrown anymore.
Can someone tell me why?