什么加载java系统类加载器? [英] What loads the java system classloader?

查看:205
本文介绍了什么加载java系统类加载器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们知道我们可以覆盖系统 classloader with:

We know that we can override the System classloader with:

java -Djava.system.class.loader=com.test.MyClassLoader xxx

然后,因为 com.test.MyClassLoader 本身就是一个类,由谁来加载?

Then, since com.test.MyClassLoader itself is a class, by whom is it loaded?

我们如何获得这个meta类加载器的类文件?

How do we get the class file of this "meta" classloader?

推荐答案

来自Javadoc的 ClassLoader.getSystemClassLoader

From the Javadoc for ClassLoader.getSystemClassLoader:


如果系统属性首先调用此方法时定义java.system.class.loader,然后将该属性的值作为将作为系统类加载器返回的类的名称。 使用默认的系统类加载器加载类,并且必须定义一个公共构造函数,该构造函数接受一个类型为ClassLoader的参数,该参数用作委托父级。

If the system property "java.system.class.loader" is defined when this method is first invoked then the value of that property is taken to be the name of a class that will be returned as the system class loader. The class is loaded using the default system class loader and must define a public constructor that takes a single parameter of type ClassLoader which is used as the delegation parent.

默认的系统类加载器本身特定于JVM实现。

The default system class loader itself is specific to the JVM implementation.

这篇关于什么加载java系统类加载器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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