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