From: aclement Date: Wed, 1 Sep 2010 04:19:01 +0000 (+0000) Subject: 318899: null to instanceof X-Git-Tag: V1_6_10RC1~6 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=2a8d684a678b1761acbe081bc1ddad3d3c9c405e;p=aspectj.git 318899: null to instanceof --- diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/reflect/ShadowMatchImpl.java b/org.aspectj.matcher/src/org/aspectj/weaver/reflect/ShadowMatchImpl.java index f9adcbdcc..350a77ba9 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/reflect/ShadowMatchImpl.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/reflect/ShadowMatchImpl.java @@ -147,8 +147,12 @@ public class ShadowMatchImpl implements ShadowMatch { Object value = v.getBindingAtJoinPoint(thisObject, targetObject, args); World world = v.getType().getWorld(); ResolvedType desiredType = instanceofTest.getType().resolve(world); - ResolvedType actualType = world.resolve(value.getClass().getName()); - matches = desiredType.isAssignableFrom(actualType); + if (value == null) { + matches = false; + } else { + ResolvedType actualType = world.resolve(value.getClass().getName()); + matches = desiredType.isAssignableFrom(actualType); + } } public void visit(MatchingContextBasedTest matchingContextTest) { diff --git a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/ThisOrTargetTestCase.java b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/ThisOrTargetTestCase.java index c2bb0a5d0..6c8d70be8 100644 --- a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/ThisOrTargetTestCase.java +++ b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/ThisOrTargetTestCase.java @@ -38,8 +38,9 @@ public class ThisOrTargetTestCase extends TestCase { /** this condition can occur on the build machine only, and is way too complex to fix right now... */ private boolean needToSkipPointcutParserTests() { - if (!LangUtil.is15VMOrGreater()) + if (!LangUtil.is15VMOrGreater()) { return false; + } try { Class.forName("org.aspectj.weaver.reflect.Java15ReflectionBasedReferenceTypeDelegate", false, this.getClass() .getClassLoader());// ReflectionBasedReferenceTypeDelegate.class.getClassLoader()); @@ -64,8 +65,9 @@ public class ThisOrTargetTestCase extends TestCase { } public void testMatchJP() throws Exception { - if (needToSkip) + if (needToSkip) { return; + } PointcutParser parser = PointcutParser .getPointcutParserSupportingAllPrimitivesAndUsingSpecifiedClassloaderForResolution(this.getClass().getClassLoader()); @@ -94,8 +96,9 @@ public class ThisOrTargetTestCase extends TestCase { } public void testBinding() throws Exception { - if (needToSkip) + if (needToSkip) { return; + } PointcutParser parser = PointcutParser .getPointcutParserSupportingAllPrimitivesAndUsingSpecifiedClassloaderForResolution(this.getClass().getClassLoader()); PointcutParameter ex = parser.createPointcutParameter("ex", Exception.class); @@ -111,7 +114,10 @@ public class ThisOrTargetTestCase extends TestCase { ShadowMatch sMatch = thisEx.matchesMethodCall(toString, toString); Exception exceptionParameter = new Exception(); IOException ioExceptionParameter = new IOException(); - JoinPointMatch jpMatch = sMatch.matchesJoinPoint(exceptionParameter, null, null); + JoinPointMatch jpMatch = null; + jpMatch = sMatch.matchesJoinPoint(null, null, null);// 318899 + assertFalse(jpMatch.matches()); + jpMatch = sMatch.matchesJoinPoint(exceptionParameter, null, null); assertTrue("should match", jpMatch.matches()); PointcutParameter[] bindings = jpMatch.getParameterBindings(); assertEquals("one binding", 1, bindings.length); @@ -147,11 +153,11 @@ public class ThisOrTargetTestCase extends TestCase { // DataOutputStream out = new DataOutputStream(bo); // p.write(out); // out.close(); - // + // // ByteArrayInputStream bi = new ByteArrayInputStream(bo.toByteArray()); // DataInputStream in = new DataInputStream(bi); // Pointcut newP = Pointcut.read(in, null); - // + // // assertEquals("write/read", p, newP); // } }