用Java自修改代码 [英] Self modifying code in Java

查看:150
本文介绍了用Java自修改代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您是否曾在Java中创建或遇到自修改代码
如果是,那么请发布链接或只是发布代码。

Have you ever created or encountered a self modifying code in Java? If yes, then please post the link or simply post the code.

推荐答案

忽略悲伤的世界你可以通过自修改代码(!)引起自己,在我看来有3个选项:

Ignoring the world of grief you could be causing yourself via self-modifying code(!), it seems to me there are 3 options:


  1. 使用Java的内置编译器支持6,编写/重新编译/重新加载类

  2. 使用Apache BCEL 直接编写类的字节码操作库

  3. 利用Java 6的内置脚本支持(或使用Apache BSF )用您选择的JVM脚本语言编写方法,并执行这些

  1. use the inbuilt compiler support of Java 6 and write/recompile/reload classes
  2. use the Apache BCEL bytecode manipulation library to write your class directly
  3. make use of Java 6's inbuilt scripting support (or use Apache BSF) to write methods in your JVM scripting language of choice, and execute these



<在上面三个中,我最初的选择(在没有要求的情况下)将是看看选项3.我怀疑这是最难以开始的方式。我已经使用了上述所有内容 - 遗憾的是我无法发布客户端代码的链接。

Of the three above, my initial choice (in the absence of requirements) would be to take a look at option 3. I suspect it's the least painful way to start. I've used all of the above - unfortunately I can't post links to client code.

这篇关于用Java自修改代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆