2017-04-01ãã1ã¶æéã®è¨äºä¸è¦§
ã¯ããã« ååããè²ã ã¨è§¦ã£ã¦ãã Byte Buddyã¨ããã©ã¤ãã©ãªã§ãããèªåã®é ã®æ´çã®ããã« ããã«ç°¡åã«ã¾ã¨ãã¦ããã Byte Buddyã¯ãã¤ãã³ã¼ãæä½ç¨ã®ã©ã¤ãã©ãªããã ãã®ä¸ã«Adviceã¨ããAPIãåå¨ããã ãã®APIã§ã¯ãã¡ã½ããã®å é ãæå¾ã«â¦
ã¯ããã« ååã¯ãã ãã£ã¼ã«ãã追å ããã ãã®ã³ã¼ããæ¸ãã¾ããã ãªãã®ã²ãããããã¾ããã progret.hatenadiary.com ããã¦ä»åã¯ã¡ã½ããã®æåã¨æå¾ã«ãã®ã³ã°å¦çã追å ãã¾ãã ä»åã¯ç°¡ååã®ãããæ¨æºåºåã«åºåãã¾ãã ä»åã®è¨äºã§ã¯Javaâ¦
ãã¤ãã³ã¼ãæä½ã使ã£ã¦ æ¬è¨äºã§ã¯ããã£ã¼ã«ãã追å ãã¦ã¿ã¾ãã 対象ã¯ã©ã¹ãAfterã®ãããªå½¢ã«æä½ãã¦ã¿ã¾ãã ï¼ãã¹ãã§ã¯staticãªå é¨ã¯ã©ã¹ï¼ // Before class Some{} // After class Some{ private String foo; } Javassistã§ãã£ã¼ã«ãã追å â¦
ä»æ¥ã¯ããã®ã¨ãããã£ã¨èª¿ã¹ã¦ããã©ã ãå¼ãããã³ã¡ã½ããåç §ã«ã¤ãã¦èª¿ã¹ã¦ãã¾ããã®ã§ ããããã®è¨äºã§ã¾ã¨ãããã¨æãã¾ãã ã¾ãã¯ããã«ã ããã«ããã¹ãã³ã¼ããå«ããã©ã ãå¼ããã³ãã®ä»ã®ã³ã¼ããããããã3種é¡ã®ã³ã¼ããç¨æããã ãâ¦
åãã« ä»ååºã¦ããã®ã¯ãã®è¾º MethodHandles (Java Platform SE 8) MethodType (Java Platform SE 8) MethodHandle (Java Platform SE 8) MethodHandles.Lookup (Java Platform SE 8) MethodHandleã®æã¯Lookupãªãã¸ã§ã¯ããä½ããã¨ããå§ã¾ãã Lookup â¦