loadClass(String name)和loadClass(String name,boolean resolve)之间的区别 [英] Difference between loadClass(String name) and loadClass(String name, boolean resolve)

查看:127
本文介绍了loadClass(String name)和loadClass(String name,boolean resolve)之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

loadClass(String name) loadClass(String name,boolean resolve)

我知道的唯一区别是 loadClass(字符串名称,布尔值解析)调用findLoadedClass(String )如果 resolve 参数为true?

The only difference I know is loadClass(String name, boolean resolve) calls findLoadedClass(String) if the resolve parameter is true?

那么当true或false传递给时解析参数?

我在这两个函数之间感到很困惑。

So when is true or false passed to resolve parameter ?
I'm confused a lot between this two functions.

谢谢。

推荐答案

resolve参数控制是否链接了已加载的类。在链接期间,初始化静态常量并分配其内存。此外,该类已经过验证是否正确,并且可能会解析其他类的链接。

The resolve parameter controls whether the class that's loaded is linked or not. During linking, static constants are initialized and have their memory allocated. Additionally, the class is verified for correctness, and possibly links to other classes will be resolved.

这可能很有用,例如,如果你想加载一个新的可能存在格式错误的类,并且不希望JVM在类错误的情况下抛出验证错误。

This could be useful, for example, if you wanted to load in a new class that may be malformed and don't want the JVM to throw verification errors in the event that the class is buggy.

这篇关于loadClass(String name)和loadClass(String name,boolean resolve)之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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