概述
static {
try {
AccessController.doPrivileged(new PrivilegedExceptionAction() {
public Object run() throws Exception {
Class cl = Class.forName("java.lang.ClassLoader");
defineClass1 = cl.getDeclaredMethod("defineClass", new Class[]{
String.class, byte[].class, int.class, int.class});
defineClass2 = cl.getDeclaredMethod("defineClass", new Class[]{
String.class, byte[].class, int.class, int.class,ProtectionDomain.class});
definePackage = cl.getDeclaredMethod("definePackage", new Class[]{
String.class, String.class, String.class, String.class, String.class, String.class, String.class,
java.net.URL.class});
Field f = Unsafe.class.getDeclaredField("theUnsafe"); // Internal reference
f.setAccessible(true);
unSafe = (Unsafe) f.get(null); return null; }
}); }
catch (PrivilegedActionException pae) {
throw new RuntimeException("cannot initialize ClassPool", pae.getException());
}
最后
以上就是可靠灰狼为你收集整理的ClassLoader 动态加载定义的全部内容,希望文章能够帮你解决ClassLoader 动态加载定义所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复