Bug 113368 - null value for thisJoinPointStaticPart
Summary: null value for thisJoinPointStaticPart
Status: RESOLVED INVALID
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: DEVELOPMENT   Edit
Hardware: PC Windows XP
: P2 critical (vote)
Target Milestone: 1.5.0RC1   Edit
Assignee: Adrian Colyer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-10-21 12:11 EDT by Ron Bodkin CLA
Modified: 2005-11-22 11:56 EST (History)
0 users

See Also:


Attachments
patch to test case that reproduces the problem (1.67 KB, patch)
2005-11-21 23:38 EST, Ron Bodkin CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ron Bodkin CLA 2005-10-21 12:11:27 EDT
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) {
...
Comment 1 Ron Bodkin CLA 2005-10-24 03:09:22 EDT
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
Comment 2 Ron Bodkin CLA 2005-11-14 11:12:49 EST
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).
Comment 3 Andrew Clement CLA 2005-11-14 11:21:03 EST
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.
Comment 4 Andrew Clement CLA 2005-11-14 11:29:33 EST
fix checked in for stack trace in comment #1.
Comment 5 Andrew Clement CLA 2005-11-15 06:42:00 EST
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?
Comment 6 Adrian Colyer CLA 2005-11-21 10:38:33 EST
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...
Comment 7 Ron Bodkin CLA 2005-11-21 23:38:03 EST
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....
Comment 8 Ron Bodkin CLA 2005-11-21 23:38:54 EST
Created attachment 30360 [details]
patch to test case that reproduces the problem
Comment 9 Adrian Colyer CLA 2005-11-22 04:51:27 EST
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..........
Comment 10 Adrian Colyer CLA 2005-11-22 05:40:29 EST
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??
Comment 11 Ron Bodkin CLA 2005-11-22 11:56:09 EST
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.