Community
Participate
Working Groups
I've defined an AspectJ InPath with a JAR file. I get the following exception: Error 2005-08-20 15:51:46.823 NullPointerException thrown: null java.lang.NullPointerException at org.aspectj.weaver.ResolvedType.addAndRecurse(ResolvedType.java:246) at org.aspectj.weaver.ResolvedType.addAndRecurse(ResolvedType.java:257) at org.aspectj.weaver.ResolvedType.addAndRecurse(ResolvedType.java:263) at org.aspectj.weaver.ResolvedType.getMethodsWithoutIterator(ResolvedType.java:241) at org.aspectj.weaver.ResolvedType.lookupResolvedMember(ResolvedType.java:332) at org.aspectj.weaver.ResolvedMemberImpl.accumulateMembersMatching(ResolvedMemberImpl.java:213) at org.aspectj.weaver.ResolvedMemberImpl.getJoinPointSignatures(ResolvedMemberImpl.java:167) at org.aspectj.weaver.MemberImpl.getJoinPointSignatures(MemberImpl.java:917) at org.aspectj.weaver.patterns.SignaturePattern.matches(SignaturePattern.java:150) at org.aspectj.weaver.patterns.KindedPointcut.matchInternal(KindedPointcut.java:112) at org.aspectj.weaver.patterns.Pointcut.match(Pointcut.java:151) at org.aspectj.weaver.patterns.AndPointcut.matchInternal(AndPointcut.java:61) at org.aspectj.weaver.patterns.Pointcut.match(Pointcut.java:151) at org.aspectj.weaver.ShadowMunger.match(ShadowMunger.java:62) at org.aspectj.weaver.Advice.match(Advice.java:102) at org.aspectj.weaver.bcel.BcelClassWeaver.match(BcelClassWeaver.java:1724) at org.aspectj.weaver.bcel.BcelClassWeaver.matchInvokeInstruction(BcelClassWeaver.java:1713) at org.aspectj.weaver.bcel.BcelClassWeaver.match(BcelClassWeaver.java:1526) at org.aspectj.weaver.bcel.BcelClassWeaver.match(BcelClassWeaver.java:1355) at org.aspectj.weaver.bcel.BcelClassWeaver.weave(BcelClassWeaver.java:381) at org.aspectj.weaver.bcel.BcelClassWeaver.weave(BcelClassWeaver.java:96) at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1368) at org.aspectj.weaver.bcel.BcelWeaver.weaveWithoutDump(BcelWeaver.java:1333) at org.aspectj.weaver.bcel.BcelWeaver.weaveAndNotify(BcelWeaver.java:1110) at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:997) at org.aspectj.ajdt.internal.compiler.AjCompilerAdapter.weave(AjCompilerAdapter.java:286) at org.aspectj.ajdt.internal.compiler.AjCompilerAdapter.afterCompiling(AjCompilerAdapter.java:165) 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:728) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.doBuild(AjBuildManager.java:207) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.doBuild(AjBuildManager.java:167) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.incrementalBuild(AjBuildManager.java:148) at org.aspectj.ajde.internal.CompilerAdapter.compile(CompilerAdapter.java:116) at org.aspectj.ajde.internal.AspectJBuildManager$CompilerThread.run(AspectJBuildManager.java:191)
Can you provide a testcase? Also, what is the full version ID of the AJDT build you are using?
(In reply to comment #1) > Can you provide a testcase? > Also, what is the full version ID of the AJDT build you are using? > Unfortunately, no. It seems to be sporadic. I'll work on it, though. The version is 1.3.0.20050824130753
The exception is down in the weaver, so passing over to AspectJ.
if the bug is sporadic, that suggests an incremental compilation type issue - does a full build always resolve the issue? Looking at the line of code involved, this NPE can only happen when the getSuperclass() call on a ResolvedType is returning null. This may be caused by a superclass type that cannot be found on the classpath (resolving to a ResolvedType.Missing, which if then asked for *it's* superclass will return null). I'm going to put in some extra defences to catch that situation and put out a "can't find type" message. It probably shouldn't be that the type can't be found - that's the underlying incremental bug I suspect, but at least this will give a non-crashing build and a sensible error message that further problems could be diagnosed from.
Extra defences checked in. Compiler will now give a normal error message in this situation saying that the supertype of {0} could not be found. I'm going to assign the bug the "REMIND" status as there is some underlying problem here that still needs to be resolved. If you see any unexpected "can't find type" messages after picking up and AJDT with this fix in, please attach the details to this bug and reopen it. Thanks, A.
Now that I understand more about the error, it occurs to me that the following may be the problem: I am libraries for which I only have the binary jar files. These libraries have references to types that aren't available on my classpath. This doesn't affect normal Java operations because I don't execute the codepaths requiring the missing types. However, AspectJ seems to need a complete closure over types. This manifests in all sorts of warning/errors in the Problems view and I bet this is somehow related to the NullPointerException. It would be very nice if AspectJ didn't need all the types. Right now, I create stubbed types just to make it happy.
That makes sense. We would very much like to reduce the number of situations in which AspectJ tries to find all types in the world (or at least it feels like that ;) ), and it's something we continually try to chip away at....
LATER/REMIND bugs are being automatically reopened as P5 because the LATER and REMIND resolutions are deprecated.