Browse Source

Fix and tests for PR94167: NPE in reflection API. Fix submitted by Ron Bodkin.

tags/PRE_ANDY
aclement 19 years ago
parent
commit
3824b1c247

BIN
lib/aspectj/lib/aspectjrt.jar View File


BIN
lib/test/aspectjrt.jar View File


+ 1
- 1
runtime/src/org/aspectj/runtime/reflect/AdviceSignatureImpl.java View File

public Method getAdvice() { public Method getAdvice() {
if (adviceMethod == null) { if (adviceMethod == null) {
try { try {
adviceMethod = declaringType.getDeclaredMethod(getName(),getParameterTypes());
adviceMethod = getDeclaringType().getDeclaredMethod(getName(),getParameterTypes());
} catch (Exception ex) { } catch (Exception ex) {
; // nothing we can do, caller will see null ; // nothing we can do, caller will see null
} }

+ 1
- 1
runtime/src/org/aspectj/runtime/reflect/MethodSignatureImpl.java View File

public Method getMethod() { public Method getMethod() {
if (method == null) { if (method == null) {
try { try {
method = declaringType.getDeclaredMethod(getName(),getParameterTypes());
method = getDeclaringType().getDeclaredMethod(getName(),getParameterTypes());
} catch (NoSuchMethodException nsmEx) { } catch (NoSuchMethodException nsmEx) {
; // nothing we can do, user will see null return ; // nothing we can do, user will see null return
} }

+ 26
- 0
tests/bugs150/PR94167.java View File

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() {}
}
}

+ 5
- 1
tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java View File

* IfPointcut.findResidueInternal() was modified to make this test complete in a short amount * 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. * 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"); runTest("Exploding compile time with if() statements in pointcut");
} }
public void testReflectNPE_pr94167() {
runTest("NPE in reflect implementation");
}
// helper methods..... // helper methods.....
public SyntheticRepository createRepos(File cpentry) { public SyntheticRepository createRepos(File cpentry) {

+ 5
- 0
tests/src/org/aspectj/systemtest/ajc150/ajc150.xml View File

<message kind="warning" line="7" text="advice defined in AnAspect has not been applied [Xlint:adviceDidNotMatch]"/> <message kind="warning" line="7" text="advice defined in AnAspect has not been applied [Xlint:adviceDidNotMatch]"/>
</compile> </compile>
</ajc-test> </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 --> <!-- annotated aspect members -->

Loading…
Cancel
Save