From: aclement Date: Tue, 7 Jun 2005 12:17:30 +0000 (+0000) Subject: Fix and tests for PR94167: NPE in reflection API. Fix submitted by Ron Bodkin. X-Git-Tag: PRE_ANDY~235 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3824b1c24717b79d48bd5f965bd2d34569dc2195;p=aspectj.git Fix and tests for PR94167: NPE in reflection API. Fix submitted by Ron Bodkin. --- diff --git a/lib/aspectj/lib/aspectjrt.jar b/lib/aspectj/lib/aspectjrt.jar index 0f28a7e19..03cb6fba1 100644 Binary files a/lib/aspectj/lib/aspectjrt.jar and b/lib/aspectj/lib/aspectjrt.jar differ diff --git a/lib/test/aspectjrt.jar b/lib/test/aspectjrt.jar index cae13dcf0..03cb6fba1 100644 Binary files a/lib/test/aspectjrt.jar and b/lib/test/aspectjrt.jar differ diff --git a/runtime/src/org/aspectj/runtime/reflect/AdviceSignatureImpl.java b/runtime/src/org/aspectj/runtime/reflect/AdviceSignatureImpl.java index e814a5add..6bf899a22 100644 --- a/runtime/src/org/aspectj/runtime/reflect/AdviceSignatureImpl.java +++ b/runtime/src/org/aspectj/runtime/reflect/AdviceSignatureImpl.java @@ -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 } diff --git a/runtime/src/org/aspectj/runtime/reflect/MethodSignatureImpl.java b/runtime/src/org/aspectj/runtime/reflect/MethodSignatureImpl.java index 3331df08d..612d0ca0e 100644 --- a/runtime/src/org/aspectj/runtime/reflect/MethodSignatureImpl.java +++ b/runtime/src/org/aspectj/runtime/reflect/MethodSignatureImpl.java @@ -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 index 000000000..b71f3dd59 --- /dev/null +++ b/tests/bugs150/PR94167.java @@ -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 diff --git a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java index 919621e80..7ee575f19 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java @@ -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) { diff --git a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml index 94994b90a..863c39dae 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml @@ -1065,6 +1065,11 @@ + + + + +