You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Instrumentation.aj 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import java.lang.reflect.Field;
  2. import org.aspectj.lang.reflect.*;
  3. public aspect Instrumentation {
  4. /**
  5. * Instrument field reads.
  6. */
  7. pointcut getField() : get(* *) && !within(Instrumentation);
  8. after() : getField() {
  9. final FieldSignature signature = (FieldSignature) thisJoinPointStaticPart
  10. .getSignature();
  11. final Field field = signature.getField();
  12. final SourceLocation sl = thisJoinPointStaticPart.getSourceLocation();
  13. if (field == null) {
  14. throw new IllegalStateException(
  15. "See pr172107: get FieldSignature#getField()==null in "
  16. + sl.getFileName() + " at line " + sl.getLine());
  17. }
  18. }
  19. /**
  20. * Instrument field reads.
  21. */
  22. pointcut setField() : set(* *) && !within(Instrumentation);
  23. after() : setField() {
  24. final FieldSignature signature = (FieldSignature) thisJoinPointStaticPart
  25. .getSignature();
  26. final Field field = signature.getField();
  27. final SourceLocation sl = thisJoinPointStaticPart.getSourceLocation();
  28. if (field == null) {
  29. throw new IllegalStateException(
  30. "See pr172107: set FieldSignature#getField()==null in "
  31. + sl.getFileName() + " at line " + sl.getLine());
  32. }
  33. }
  34. }