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
}
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
}
--- /dev/null
+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
* 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) {
<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 -->