Community
Participate
Working Groups
In the glassbox inspector I'm seeing a new bug (not present in dev builds from say last week or earlier). I get a null value for thisJoinPointStaticPart. From the stack trace, it should be statically determinable that this pointcut would never match, and maybe the pointcut rules are for the first time evaluating out of order (I gather from Matthew Webster that AspectJ is now taking the policy that pointcuts will not be evaluated left to right, which seems like a bad idea to mean). JmxManagement.ajc$if_1(JmxManagement$ManagedBean, JoinPoint$StaticPart) line: 41 JdbcStatementMonitor(AbstractResourceMonitor).<init>() line: 18 JdbcStatementMonitor.<init>() line: 28 JdbcStatementMonitor.ajc$postClinit() line: not available JdbcStatementMonitor.<clinit>() line: 28 JdbcStatementMonitor.aspectOf() line: not available SimpleConfig.doConfig() line: 65 SimpleConfig.ajc$before$glassbox_inspector_config_SimpleConfig$1 $81249c3e_aroundBody0(SimpleConfig) line: 151 SimpleConfig$AjcClosure1.run(Object[]) line: 1 ErrorHandling.ajc$around$glassbox_inspector_error_ErrorHandling$1 $ed5f19b0proceed(AroundClosure) line: not available ErrorHandling.ajc$around$glassbox_inspector_error_ErrorHandling$1$ed5f19b0 (AroundClosure, JoinPoint$StaticPart) line: 50 SimpleConfig.ajc$before$glassbox_inspector_config_SimpleConfig$1$81249c3e() line: 1 The operative code is: public interface ManagedBean { /** Define a JMX operation name for this bean. Not to be confused with a Web request operation. */ // Map getAttributes(); String getOperationName(); /** Returns the underlying JMX MBean that provides management information for this bean (POJO).. */ Object getMBean(); /** Get assembler used to assemble a model bean as the management interface */ MBeanInfoAssembler getAssembler(); } private pointcut managedBeanConstruction(ManagedBean bean) : execution(ManagedBean+.new(..)) && this(bean); //NPE's on the if pointcut below private pointcut topLevelManagedBeanConstruction(ManagedBean bean) : managedBeanConstruction(bean) && if(thisJoinPointStaticPart.getSignature ().getDeclaringType() == bean.getClass()); after(ManagedBean bean) returning: topLevelManagedBeanConstruction(bean) { ...
I am also seeing this stack trace when incrementally compiling in AJDT. I would guess that it's caused by the same bug. java.lang.NullPointerException at org.aspectj.weaver.patterns.IfPointcut.equals(IfPointcut.java:127) at org.aspectj.weaver.patterns.PointcutEvaluationExpenseComparator.compare (PointcutEvaluationExpenseComparator.java:65) at java.util.TreeMap.compare(TreeMap.java:1093) at java.util.TreeMap.put(TreeMap.java:465) at java.util.TreeSet.add(TreeSet.java:210) at org.aspectj.weaver.patterns.PointcutRewriter.collectAndNodes (PointcutRewriter.java:239) at org.aspectj.weaver.patterns.PointcutRewriter.collectAndNodes (PointcutRewriter.java:232) at org.aspectj.weaver.patterns.PointcutRewriter.simplifyAnd (PointcutRewriter.java:190) at org.aspectj.weaver.patterns.PointcutRewriter.simplifyAnds (PointcutRewriter.java:182) at org.aspectj.weaver.patterns.PointcutRewriter.rewrite (PointcutRewriter.java:35) at org.aspectj.weaver.bcel.BcelWeaver.rewritePointcuts(BcelWeaver.java:480) at org.aspectj.weaver.bcel.BcelWeaver.prepareForWeave(BcelWeaver.java:437) at org.aspectj.ajdt.internal.compiler.AjCompilerAdapter.weave (AjCompilerAdapter.java:283) at org.aspectj.ajdt.internal.compiler.AjCompilerAdapter.afterCompiling (AjCompilerAdapter.java:178) at org.aspectj.ajdt.internal.compiler.CompilerAdapter.ajc$afterReturning$org_aspect j_ajdt_internal_compiler_CompilerAdapter$2$f9cc9ca0(CompilerAdapter.aj:70) at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile (Compiler.java:367) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilation (AjBuildManager.java:759) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.doBuild (AjBuildManager.java:249) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.incrementalBuild (AjBuildManager.java:158) at org.aspectj.ajde.internal.CompilerAdapter.compile(CompilerAdapter.java:117) at org.aspectj.ajde.internal.AspectJBuildManager$CompilerThread.run (AspectJBuildManager.java:191) NullPointerException thrown: null
From further investigation, I think the second stack trace is unrelated. I was seeing this bug in a recent dev build on pointcuts like this protected pointcut isMonitorEnabled() : if(aspectOf().isEnabled()); I uncommented them all out (to be within(*)) and it worked. I then restored them and things now seem to be working?! So the stack trace from the second comment in this bug is fixed, although I don't think the first bug is fixed (I am hitting yet another bug that is preventing me from testing to see if the first part has been fixed yet but presumably not).
I'm about to check in a fix for the stack trace in comment #1. This could possibly affect the other problem ... but I'm not all that confident. I've no idea whats happening in comment #2.
fix checked in for stack trace in comment #1.
fix available for problem reported in comment #1 - does it make any difference for your other scenarios ron or do you need for an AJDT before you can check?
I've added a compile-and-run test for bugs150/Pr113368.aj in the tests module. This replicates the failing glassbox inspector logic and is passing for me. Are you still seeing the original problem Ron? It's hard to tell from the comments whether everything reported in this bug is now fixed or not...
The original bug is still failing... it took some work to narrow it down, but here's a patch to the test case that fails for me with the same error inside the test harness....
Created attachment 30360 [details] patch to test case that reproduces the problem
Great - thanks Ron. I can reproduce the failure now with your patch to the test case. Now all I have to do is figure out why..........
OK, the test case fails, but not in the way that you originally reported, and in a way that is "correct". This test fails for me with an org.aspectj.lang.NoAspectBoundException: ManagedSubBean as the root cause of the ExceptionInInitializer. This is the expected behaviour as seen by following the chain of reasoning: The execution of hook() causes ManagedSubBean.aspectOf to be called. This causes the staticinitialization of ManagedBean Which causes the execution of the AutoStart advice Which calls ManagedSubBean.aspectOf() ..... .... which fails (correctly) with a NoAspectBoundException because there is no aspect bound until the staticinitializers and constructors have run. If I remove any of the components of the test to try and get around this, it passes again.... Are you seeing NoAspectBound with this test case? Or do you get the NPE??
I didn't see the chained exception from the test output so I assumed it was the same NPE error I was seeing. However, the original code that does generate the NPE is failing in the same way: it is trying to access the thisJoinPointStaticPart field before staticinitialization is completed. So this bug is invalid.