系统类加载器是否加载了类路径中的所有类,即使它们实际上没有被使用? [英] Does system classloader load all classes in classpath even if they're not actually used?

查看:104
本文介绍了系统类加载器是否加载了类路径中的所有类,即使它们实际上没有被使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JDK 1.6来运行一个小应用程序。但是我设置了一个非常庞大的类路径,其中包含很多类。

I'm using JDK 1.6 to run a small application. However I set a very massive classpath which includes a lot of classes.

当我运行应用程序时,类加载器中的所有类都已加载,即使它们实际上没有被使用在我的申请?如果没有,如何强制类加载器这样做,如果是,如何避免它?谢谢!

When I run the application will all classes in the classloader been loaded even if they're not actually used in my application? If not, how to force the classloader do so, and if yes, how to avoid it? Thanks!

例如,我正在使用ant 1.7来运行我的应用程序。

E.g.,I'm using ant 1.7 to run my application.

最好的问候,
Robert Ji

Best Regards, Robert Ji

推荐答案

否,ClassLoader在内存中需要类时加载类。它不会立即加载所有类,因为它可能会耗尽内存。

No, The ClassLoader loads the class when the class is needed in memory. It doesn't load all classes at once as it can run out of memory.

这篇关于系统类加载器是否加载了类路径中的所有类,即使它们实际上没有被使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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