From: acolyer Date: Tue, 6 Dec 2005 03:20:59 +0000 (+0000) Subject: tests and fix for pr118149 X-Git-Tag: V1_5_0RC1~56 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d43e74b5c919ebaef67a4b7551a464b8db3b289a;p=aspectj.git tests and fix for pr118149 --- 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 @@ + + + + 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,