What is cglib?A Byte Code Generation Library which is high level API to generate and transform Java byte code. It is used in various scenarios such as AOP, testing, data access frameworks to generate dynamic proxy objects and intercept field access. In debugger you can find that the variable in line 17 is mocked by CGLIB: Its byte code is generated dynamically and stored in variable byte[] b in line 217. Let's see another example of injecting pre-exit and post-exit ( which ABAPers are very familiar with ) into a given method via dynamic proxy generated by CGLIB: The pre-exit and post-exit are defined in class JerryEnhancement which implements interface MethodInterceptor defined in CGLIB library. The original method is generated in line 14, with pre-exit before it ( line 13 ) and post-exit after it ( line 15 ). Execute result: How can CGLIB be implemented in ABAP?See my implementation here |
|