在注入JVM之前如何验证Java字节码? [英] How to verify Java Bytecode before injecting into the JVM?

查看:74
本文介绍了在注入JVM之前如何验证Java字节码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试验证即时"生成的字节码!

I'm trying to verify "on the fly" generated bytecode!

我已经进行了几次尝试,一次尝试是使用eclipse编译器在运行时编译我的类,另一次尝试是从内存中进行编译,如下所述:

I already had several attempts, one attempt was to compile my classes in runtime with the eclipse compiler another was to compile from memory as mentioned here:

从内存编译

最初的结果看起来还不错,但是我仍然不确定100%的验证过程是否符合JAVA 6准则和安全性度量以及正常的OOP模型.

First results looked okay but I'm still not a 100% sure if the verification process is truly valid according to the JAVA 6 guidelines and security measurements as well to normal OOP Models.

有没有更好的方法来验证字节码?

Any better way on how to verify bytecode?

推荐答案

如果使用标准类加载器加载生成的字节码,则JVM的字节码验证程序将进行验证(确保其进行类型检查,永远不会掉落边缘""等)的字节码.

If you load the generated bytecode using a standard class loader, the bytecode verifier of the JVM will verify (make sure it type checks, never falls of the "edge" of a method and so on) the bytecode for you.

这篇关于在注入JVM之前如何验证Java字节码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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