Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法在内存中发出 Java 字节码并执行它?我知道有JavaCompiler课,但我问Reflection.Emit的是.NET平台之类的东西。
JavaCompiler
Reflection.Emit
.NET
你能看看下面的
您需要使用类加载器来动态加载某些类。关于这个主题有一些有趣的 SO 问题:
这是可能的,但这需要最终用户也安装JDK. 将字节码编译到内存并创建一个新的 java 进程并启动它。也可以java source直接执行。
JDK
java source
见Beanshell2。
Beanshell2