Sfoglia il codice sorgente

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

tags/PRE_ANDY
aclement 19 anni fa
parent
commit
3824b1c247

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


BIN
lib/test/aspectjrt.jar Vedi File


+ 1
- 1
runtime/src/org/aspectj/runtime/reflect/AdviceSignatureImpl.java Vedi 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
}

+ 1
- 1
runtime/src/org/aspectj/runtime/reflect/MethodSignatureImpl.java Vedi 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
}

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

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

+ 5
- 1
tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java Vedi 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) {

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

@@ -1065,6 +1065,11 @@
<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 -->

Loading…
Annulla
Salva