]> source.dussan.org Git - aspectj.git/commitdiff
318899: null to instanceof
authoraclement <aclement>
Wed, 1 Sep 2010 04:19:01 +0000 (04:19 +0000)
committeraclement <aclement>
Wed, 1 Sep 2010 04:19:01 +0000 (04:19 +0000)
org.aspectj.matcher/src/org/aspectj/weaver/reflect/ShadowMatchImpl.java
org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/ThisOrTargetTestCase.java

index f9adcbdccacdad798f2cff8a8d65874fb3a5b38f..350a77ba9af4fe5910b80dc663b8ac5956944831 100644 (file)
@@ -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) {
index c2bb0a5d0d37a4d5b8191d7ba914db0379be581a..6c8d70be876f5e95c50b0418c8197f9938ef599d 100644 (file)
@@ -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);
        // }
 }