Project: AspectJ
Bug 141956 Null Pointer Exception when trying to skip Parent Mungers.
Reported: 2006-05-16 05:12:06 | Status: resolved fixed

I don't know much about the internal workings of aspectJ but this bug keeps popping up so I went through the trouble of checking of trying to debug it so that I could hopefully provide enough information to get it fixed. This happens while using eclipse AJDT. It never happens if I fully do a clean before rebuild. It only seems to happen when doing incrmental builds (using the project->build automatically setting). The error happens in the iterator that recursively builds a list of methods to return for matching. The error is triggered here: // we need to know if it is an interface from Parent kind munger // as those are used for @AJ ITD and we precisely want to skip those boolean shouldSkip = false; for (int j = 0; j < rtx.interTypeMungers.size(); j++) { ConcreteTypeMunger munger = (ConcreteTypeMunger) rtx.interTypeMungers.get(j); if (munger.getMunger().getKind() == ResolvedTypeMunger.Parent) { shouldSkip = true; break; } } munger.getMunger() returns null because the munger instance is a BcelPerClauseAspectAdder. My naive fix would be to check munger.getMunger() == null or check munger.getKind(). I'm assuming that BcelPerClausAspectAdder is one that should be skipped since it is related to @AJ ??? Again, I don't know very much about the internal architecture of the weaver magic so I hope this is enough information. I would appreciate it if someone who knows more of the internals could speculate as to why this bug would never pop up on a clean build but only on incremental builds? Also it's not on all incremental builds and I haven't been able to isolate what kind of changes or compiles it triggers this, although it seems that once I got the exception once, I keep getting it on every build until I do a clean. java.lang.NullPointerException at org.aspectj.weaver.ResolvedType.addAndRecurse(ResolvedType.java:288) at org.aspectj.weaver.ResolvedType.getMethodsWithoutIterator(ResolvedType.java:257) at org.aspectj.weaver.ResolvedType.lookupResolvedMember(ResolvedType.java:378) at org.aspectj.weaver.JoinPointSignatureIterator.findSignaturesFromSupertypes(JoinPointSignatureIterator.java:178) at org.aspectj.weaver.JoinPointSignatureIterator.hasNext(JoinPointSignatureIterator.java:69) at org.aspectj.weaver.patterns.SignaturePattern.matches(SignaturePattern.java:287) at org.aspectj.weaver.patterns.KindedPointcut.matchInternal(KindedPointcut.java:103) at org.aspectj.weaver.patterns.Pointcut.match(Pointcut.java:144) at org.aspectj.weaver.patterns.AndPointcut.matchInternal(AndPointcut.java:51) at org.aspectj.weaver.patterns.Pointcut.match(Pointcut.java:144) at org.aspectj.weaver.ShadowMunger.match(ShadowMunger.java:64) at org.aspectj.weaver.Advice.match(Advice.java:109) at org.aspectj.weaver.bcel.BcelAdvice.match(BcelAdvice.java:104) at org.aspectj.weaver.bcel.BcelClassWeaver.match(BcelClassWeaver.java:2210) at org.aspectj.weaver.bcel.BcelClassWeaver.match(BcelClassWeaver.java:1752) at org.aspectj.weaver.bcel.BcelClassWeaver.weave(BcelClassWeaver.java:479) at org.aspectj.weaver.bcel.BcelClassWeaver.weave(BcelClassWeaver.java:109) at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1574) at org.aspectj.weaver.bcel.BcelWeaver.weaveWithoutDump(BcelWeaver.java:1525) at org.aspectj.weaver.bcel.BcelWeaver.weaveAndNotify(BcelWeaver.java:1305) at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1127) at org.aspectj.ajdt.internal.compiler.AjCompilerAdapter.weave(AjCompilerAdapter.java:321) at org.aspectj.ajdt.internal.compiler.AjCompilerAdapter.afterCompiling(AjCompilerAdapter.java:192) at org.aspectj.ajdt.internal.compiler.CompilerAdapter.ajc$afterReturning$org_aspectj_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:862) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.doBuild(AjBuildManager.java:269) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.incrementalBuild(AjBuildManager.java:168) at org.aspectj.ajde.internal.CompilerAdapter.compile(CompilerAdapter.java:117) at org.aspectj.ajde.internal.AspectJBuildManager$CompilerThread.run(AspectJBuildManager.java:191)

Files changed in fix:
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java tests/multiIncremental/PR141956/base/A.java tests/multiIncremental/PR141956/base/C.java tests/multiIncremental/PR141956/inc1/C.java tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java weaver/src/org/aspectj/weaver/ResolvedType.java