diff options
-rw-r--r-- | tests/bugs150/PR118149.aj | 23 | ||||
-rw-r--r-- | tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java | 3 | ||||
-rw-r--r-- | tests/src/org/aspectj/systemtest/ajc150/ajc150.xml | 4 | ||||
-rw-r--r-- | weaver/src/org/aspectj/weaver/patterns/IfPointcut.java | 7 |
4 files changed, 37 insertions, 0 deletions
diff --git a/tests/bugs150/PR118149.aj b/tests/bugs150/PR118149.aj new file mode 100644 index 000000000..99bd27537 --- /dev/null +++ b/tests/bugs150/PR118149.aj @@ -0,0 +1,23 @@ +public aspect PR118149 { + + public pointcut pc1(String s) + : execution(* C.*()) && args(s) && if(s != null); + + public pointcut pc2(String s) + : execution(C.new(String,..)) + && args(s,..) && if(s != null); + + public pointcut pcOR(String s) : pc1(s) || pc2(s); + + before(String s) : pcOR(s) { + } + +} + + +class C { + + public C(String s, boolean b) { + } + +} diff --git a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java index b85273404..42df7f208 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java @@ -793,6 +793,9 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase { runTest("no NPE when inaccessible method is called within itd"); } + public void testNoNPEWithOrPointcutAndMoreThanOneArgs_pr118149() { + runTest("no NPE with or pointcut and more than one args"); + } // helper methods..... diff --git a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml index bd09fbaf7..17c763d7f 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml @@ -1276,6 +1276,10 @@ <run class="foo.ITDWithACall"/> </ajc-test> + <ajc-test dir="bugs150" title="no NPE with or pointcut and more than one args"> + <compile files="PR118149.aj"/> + </ajc-test> + <!-- ============================================================================ --> <!-- ============================================================================ --> diff --git a/weaver/src/org/aspectj/weaver/patterns/IfPointcut.java b/weaver/src/org/aspectj/weaver/patterns/IfPointcut.java index eb92d66b0..9b8d5b6af 100644 --- a/weaver/src/org/aspectj/weaver/patterns/IfPointcut.java +++ b/weaver/src/org/aspectj/weaver/patterns/IfPointcut.java @@ -175,8 +175,15 @@ public class IfPointcut extends Pointcut { residueSource.findResidue(shadow, myState); + // pr118149 + // It is possible for vars in myState (which would normally be set + // in the call to residueSource.findResidue) to not be set (be null) + // in an Or pointcut with if expressions in both branches, and where + // one branch is known statically to not match. In this situation we + // simply return Test. for (int i=0; i < baseArgsCount; i++) { Var v = myState.get(i); + if (v == null) continue; // pr118149 args.add(v); ret = Test.makeAnd(ret, Test.makeInstanceof(v, |