Guest User

Untitled

a guest
Nov 1st, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 1.52 KB | None | 0 0
  1. public aspect WHEEEE {
  2.     pointcut hurr(int x, Object k, Object d) : call(* *.*(int)) && args(x) && target(k) && this(d);
  3.    
  4.     before(int x, Object k, Object d): hurr(x, k, d){
  5.         System.out.println(d.toString() + " calls: "+new Integer(x).toString()+" being applied to "+k);
  6.     }
  7. }
  8.  
  9. public class Harness {
  10.     public static Test1 t1;
  11.     public static Test2 t2;
  12.     static {
  13.         t1 = new Test1();
  14.         t2 = new Test2();
  15.     }
  16.    
  17.     public static void main(String[] args) {   
  18.         t1.derp(10);
  19.         t2.doop(1, 4);
  20.         t2.floop(45);
  21.     }
  22. }
  23.  
  24.  
  25. class Test2 {
  26.     public Test1 t1 = new Test1();
  27.     public void doop(int y, int x){
  28.         t1.derp(y);
  29.         t1.flerp(x);
  30.     }
  31.    
  32.     public String floop(int j){
  33.         return "" + j;
  34.     }
  35. }
  36.  
  37. class Test1 {
  38.     public void flerp(int x){
  39.         System.out.println("flerp "+x);
  40.     }
  41.    
  42.     public void derp(int k){
  43.         System.out.println("derp " +k);
  44.         flerp(k);
  45.     }
  46. }
  47.  
  48. /************************* OUTPUT *************************
  49. Test1@558ee9d6 calls: 10 being applied to derp
  50. derp 10
  51. Test1@558ee9d6 calls: 10 being applied to Test1@558ee9d6
  52. Test1@558ee9d6 calls: 10 being applied to flerp
  53. flerp 10
  54. Test2@199a0c7c calls: 1 being applied to Test1@50a9ae05
  55. Test1@50a9ae05 calls: 1 being applied to derp
  56. derp 1
  57. Test1@50a9ae05 calls: 1 being applied to Test1@50a9ae05
  58. Test1@50a9ae05 calls: 1 being applied to flerp
  59. flerp 1
  60. Test2@199a0c7c calls: 4 being applied to Test1@50a9ae05
  61. Test1@50a9ae05 calls: 4 being applied to flerp
  62. flerp 4
  63. Test2@199a0c7c calls: 45 being applied to
  64. ************************** OUTPUT ************************/
Add Comment
Please, Sign In to add comment