]> source.dussan.org Git - aspectj.git/commitdiff
Fix and tests for PR94167: NPE in reflection API. Fix submitted by Ron Bodkin.
authoraclement <aclement>
Tue, 7 Jun 2005 12:17:30 +0000 (12:17 +0000)
committeraclement <aclement>
Tue, 7 Jun 2005 12:17:30 +0000 (12:17 +0000)
lib/aspectj/lib/aspectjrt.jar
lib/test/aspectjrt.jar
runtime/src/org/aspectj/runtime/reflect/AdviceSignatureImpl.java
runtime/src/org/aspectj/runtime/reflect/MethodSignatureImpl.java
tests/bugs150/PR94167.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java
tests/src/org/aspectj/systemtest/ajc150/ajc150.xml

index 0f28a7e197bb3650b3faf5fdac8518871101090d..03cb6fba145013c0785f85d466ad46edf585133d 100644 (file)
Binary files a/lib/aspectj/lib/aspectjrt.jar and b/lib/aspectj/lib/aspectjrt.jar differ
index cae13dcf08924e3f2e4c8ca7d62f5f40bd7a32da..03cb6fba145013c0785f85d466ad46edf585133d 100644 (file)
Binary files a/lib/test/aspectjrt.jar and b/lib/test/aspectjrt.jar differ
index e814a5add1c0322e785a9e670cf6011bd2c0969c..6bf899a2201da07ad089cef45a326ca537ebc15b 100644 (file)
@@ -62,7 +62,7 @@ class AdviceSignatureImpl extends CodeSignatureImpl implements AdviceSignature {
        public Method getAdvice() {
                if (adviceMethod == null) {
                        try {
-                               adviceMethod = declaringType.getDeclaredMethod(getName(),getParameterTypes());
+                               adviceMethod = getDeclaringType().getDeclaredMethod(getName(),getParameterTypes());
                        } catch (Exception ex) {
                                ; // nothing we can do, caller will see null
                        }
index 3331df08ddfe375f2c1a7f833d3f12911fcc5cdb..612d0ca0e23fe8d64b1696182e5116ba2b50e801 100644 (file)
@@ -60,7 +60,7 @@ class MethodSignatureImpl extends CodeSignatureImpl implements MethodSignature {
        public Method getMethod() {
                if (method == null) {
                        try {
-                               method = declaringType.getDeclaredMethod(getName(),getParameterTypes());
+                               method = getDeclaringType().getDeclaredMethod(getName(),getParameterTypes());
                        } catch (NoSuchMethodException nsmEx) {
                                ; // nothing we can do, user will see null return
                        }
diff --git a/tests/bugs150/PR94167.java b/tests/bugs150/PR94167.java
new file mode 100644 (file)
index 0000000..b71f3dd
--- /dev/null
@@ -0,0 +1,26 @@
+package reflect;
+
+import org.aspectj.lang.*;
+import org.aspectj.lang.reflect.*;
+import java.lang.reflect.*;
+
+aspect Test {
+    before() : call(* *(..)) && !within(Test) {
+       MethodSignature sig = (MethodSignature)thisJoinPoint.getSignature();
+       //sig.getDeclaringType(); // uncomment to work-around
+       Method method = sig.getMethod();
+   }
+}
+
+public class PR94167 {
+    public static void main(String args[]) {
+       try {
+           Inner.foo();
+       } catch (Throwable t) {
+           t.printStackTrace();
+       }
+    }
+    public static class Inner {
+       public static void foo() {}
+    }
+}
\ No newline at end of file
index 919621e8004c6ebbad7f0ee23cea2c9522c9fc74..7ee575f190aa7677ae7a18908292e19595b0fa0e 100644 (file)
@@ -170,10 +170,14 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
    * IfPointcut.findResidueInternal() was modified to make this test complete in a short amount
    * of time - if you see it hanging, someone has messed with the optimization.
    */
-  public void testIfEvaluationExplosiion_PR94086() {
+  public void testIfEvaluationExplosion_pr94086() {
          runTest("Exploding compile time with if() statements in pointcut");
   }
   
+  public void testReflectNPE_pr94167() {
+         runTest("NPE in reflect implementation");
+  }
+  
   // helper methods.....
   
   public SyntheticRepository createRepos(File cpentry) {
index 94994b90a5f693dfbe5b48149c7a4e5287f1e81f..863c39daed18e3b37153d15cffd08033be601e32 100644 (file)
        <message kind="warning" line="7" text="advice defined in AnAspect has not been applied [Xlint:adviceDidNotMatch]"/>
      </compile>
   </ajc-test>
+   
+  <ajc-test dir="bugs150" title="NPE in reflect implementation" pr="94167">
+     <compile files="PR94167.java"/>
+     <run class="reflect.PR94167"/>
+  </ajc-test>
 
    <!-- ======================================================================================= -->
    <!--               annotated aspect members                                                  -->