本文介绍了字节码操作模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

字节码操作有哪些合法用途,人们在实践中如何实现基于字节码操作的解决方案?

What legitimate uses are there for bytecode manipulation and how people implement those bytecode manipulation based solutions in practice?

更新:我应该更清楚地表明,这个问题确实与人们在字节码操纵的帮助下使用什么模式和技术来使代码运行有关。

Update: I should have made it more clear that this question really is about what patterns and techniques people use to make their code fly with the help of bytecode manipulation.

类似于面向方面编程的东西

Something like aspect oriented programming that was already mentioned or building proxy objects on the fly and similar techniques.

推荐答案

字节码操作可让您实现任意复杂(有趣的)程序转换,例如:

Bytecode manipulation lets you implement arbitrarily complex (and interesting) program transformations, such as:


  • 选定功能的进入/退出记录代码

  • 存根的安全转换排除对某些API的访问权限

  • API替代,例如在测试工具中运行代码。

范围是无限的;这只是一个小样本。

The scope is endless; this is just a small sampling.

关于通常的完成方式,请启动。

As for how this is typically done, start here.

这篇关于字节码操作模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 23:16