Project: AspectJ
Bug 67774 Nullpointer-exception in pointcuts using withincode() clause
Reported: 2004-06-18 04:54:37 | Status: resolved fixed

Hi, I am getting null-pointer-exceptions whenever I try to specify a pointcut with a "withincode(Signature)" clause. E.g.: public aspect DetectSystemOutErrorUsage { pointcut allSystemOutAndSystemErrAccesses(): (get(* System.out) || get(* System.err)) ; declare warning: allSystemOutAndSystemErrAccesses() && !adviceexecution() && !within(com.tivoli.act..Test*) && !within(com.tivoli.act.log..*) && !execution(* com.tivoli.act..*.main(..)) && !execution(* com.tivoli.act..*.usage()) // && !withincode(* com.tivoli.act..*.main(..)) // && !withincode(* com.tivoli.act..*.usage()) : "Warning: use of System.out or System.err - consider logging instead!"; } In the above example excluding main() and usage() methods from the pointcut using an execution(...)-clause (shows) works but using a withincode()-clause (as commented) always yields an NPE: trouble in: null java.lang.NullPointerException at org.aspectj.weaver.patterns.SignaturePattern.matches (SignaturePattern.java:87) at org.aspectj.weaver.patterns.WithincodePointcut.match (WithincodePointcut.java:42) at org.aspectj.weaver.patterns.NotPointcut.match(NotPointcut.java:45) at org.aspectj.weaver.patterns.AndPointcut.match(AndPointcut.java:42) at org.aspectj.weaver.patterns.AndPointcut.match(AndPointcut.java:42) at org.aspectj.weaver.patterns.AndPointcut.match(AndPointcut.java:42) at org.aspectj.weaver.patterns.AndPointcut.match(AndPointcut.java:42) at org.aspectj.weaver.patterns.AndPointcut.match(AndPointcut.java:42) at org.aspectj.weaver.patterns.AndPointcut.match(AndPointcut.java:42) at org.aspectj.weaver.patterns.AndPointcut.match(AndPointcut.java:42) at org.aspectj.weaver.ShadowMunger.match(ShadowMunger.java:62) at org.aspectj.weaver.Checker.match(Checker.java:48) at org.aspectj.weaver.bcel.BcelClassWeaver.match (BcelClassWeaver.java:1121) at org.aspectj.weaver.bcel.BcelClassWeaver.matchInit (BcelClassWeaver.java:895) at org.aspectj.weaver.bcel.BcelClassWeaver.match (BcelClassWeaver.java:793) at org.aspectj.weaver.bcel.BcelClassWeaver.weave (BcelClassWeaver.java:343) at org.aspectj.weaver.bcel.BcelClassWeaver.weave (BcelClassWeaver.java:80) at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:724) at org.aspectj.weaver.bcel.BcelWeaver.weaveWithoutDump (BcelWeaver.java:689) at org.aspectj.weaver.bcel.BcelWeaver.weaveAndNotify (BcelWeaver.java:615) at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:563) at org.aspectj.ajdt.internal.compiler.AjCompilerAdapter.weave (AjCompilerAdapter.java:239) at org.aspectj.ajdt.internal.compiler.AjCompilerAdapter.afterCompiling (AjCompilerAdapter.java:114) at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:376) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilation (AjBuildManager.java:601) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.doBuild (AjBuildManager.java:160) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild (AjBuildManager.java:94) at org.aspectj.ajde.internal.CompilerAdapter.compile (CompilerAdapter.java:108) at org.aspectj.ajde.internal.AspectJBuildManager$CompilerThread.run (AspectJBuildManager.java:165) !SESSION Jun 18, 2004 10:49:48.666 --------------------------------------------- eclipse.buildId=I200406110010 java.version=1.4.2_03 java.vendor=Sun Microsystems Inc. BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=de_CH !ENTRY org.eclipse.ajdt.ui 4 0 Jun 18, 2004 10:49:48.666 !MESSAGE NullPointerException thrown: null !STACK 0 java.lang.NullPointerException at org.aspectj.weaver.patterns.SignaturePattern.matches (SignaturePattern.java:87) at org.aspectj.weaver.patterns.WithincodePointcut.match (WithincodePointcut.java:42) at org.aspectj.weaver.patterns.NotPointcut.match(NotPointcut.java:45) at org.aspectj.weaver.patterns.AndPointcut.match(AndPointcut.java:42) at org.aspectj.weaver.patterns.AndPointcut.match(AndPointcut.java:42) at org.aspectj.weaver.patterns.AndPointcut.match(AndPointcut.java:42) at org.aspectj.weaver.patterns.AndPointcut.match(AndPointcut.java:42) at org.aspectj.weaver.patterns.AndPointcut.match(AndPointcut.java:42) at org.aspectj.weaver.patterns.AndPointcut.match(AndPointcut.java:42) at org.aspectj.weaver.patterns.AndPointcut.match(AndPointcut.java:42) at org.aspectj.weaver.ShadowMunger.match(ShadowMunger.java:62) at org.aspectj.weaver.Checker.match(Checker.java:48) at org.aspectj.weaver.bcel.BcelClassWeaver.match (BcelClassWeaver.java:1121) at org.aspectj.weaver.bcel.BcelClassWeaver.matchInit (BcelClassWeaver.java:895) at org.aspectj.weaver.bcel.BcelClassWeaver.match (BcelClassWeaver.java:793) at org.aspectj.weaver.bcel.BcelClassWeaver.weave (BcelClassWeaver.java:343) at org.aspectj.weaver.bcel.BcelClassWeaver.weave (BcelClassWeaver.java:80) at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:724) at org.aspectj.weaver.bcel.BcelWeaver.weaveWithoutDump (BcelWeaver.java:689) at org.aspectj.weaver.bcel.BcelWeaver.weaveAndNotify (BcelWeaver.java:615) at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:563) at org.aspectj.ajdt.internal.compiler.AjCompilerAdapter.weave (AjCompilerAdapter.java:239) at org.aspectj.ajdt.internal.compiler.AjCompilerAdapter.afterCompiling (AjCompilerAdapter.java:114) at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:376) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilation (AjBuildManager.java:601) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.doBuild (AjBuildManager.java:160) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild (AjBuildManager.java:94) at org.aspectj.ajde.internal.CompilerAdapter.compile (CompilerAdapter.java:108) at org.aspectj.ajde.internal.AspectJBuildManager$CompilerThread.run (AspectJBuildManager.java:165) Michael

Files changed in fix:
tests/bugs/WithincodeNPE01.java weaver/src/org/aspectj/weaver/bcel/BcelShadow.java