Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

MissingImport.java 848B

12345678910111213141516171819202122
  1. import org.aspectj.lang.*;
  2. import org.aspectj.lang.reflect.*;
  3. import java.lang.reflect.Method;
  4. //import java.lang.reflect.InvocationTargetException; <- crash with this line commented out
  5. public aspect MissingImport {
  6. Object around() :
  7. call(* *(..)) && !within(ImposterProcessing+) {
  8. MethodSignature sig = (MethodSignature)thisJoinPoint.getSignature();
  9. try {
  10. Method meth = ImposterProcessing.class.getMethod("dynamicThrow", new Class[] { Throwable.class });
  11. meth.invoke(this, new Object[] { null });
  12. } catch (InvocationTargetException e) { // expect CE
  13. throw new RuntimeException("framework error in throwing test exception ", e);
  14. } catch (IllegalAccessException e) {
  15. throw new RuntimeException("framework error in throwing test exception (IllegalAccess)");
  16. }
  17. return null;
  18. }
  19. }
  20. class ImposterProcessing { }