public class SecureClassLoader extends ClassLoader
| Modifier | Constructor and Description |
|---|---|
protected |
SecureClassLoader()
使用默认的父类加载器创建一个新的SecureClassLoader进行委派。
|
protected |
SecureClassLoader(ClassLoader parent)
使用指定的父类加载器创建新的SecureClassLoader进行委派。
|
| Modifier and Type | Method and Description |
|---|---|
protected 类<?> |
defineClass(String name, byte[] b, int off, int len, CodeSource cs)
将字节数组转换为类Class的实例,并具有可选的CodeSource。
|
protected 类<?> |
defineClass(String name, ByteBuffer b, CodeSource cs)
一个转换 ByteBuffer成类的实例类 ,使用可选的CodeSource。
|
protected PermissionCollection |
getPermissions(CodeSource codesource)
返回给定CodeSource对象的权限。
|
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findResources, findSystemClass, getClassLoadingLock, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, loadClass, registerAsParallelCapable, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSignersprotected SecureClassLoader(ClassLoader parent)
如果有一个安全管理器,这个方法首先调用安全管理器的checkCreateClassLoader方法来确保允许创建一个类加载器。
parent - 父类加载器
SecurityException - 如果安全管理器存在,并且其
checkCreateClassLoader方法不允许创建类加载器。
SecurityManager.checkCreateClassLoader()
protected SecureClassLoader()
如果有一个安全管理器,这种方法首先调用安全管理器的checkCreateClassLoader方法,以确保允许创建一个类加载器。
SecurityException - 如果安全管理器存在,并且其
checkCreateClassLoader方法不允许创建类加载器。
SecurityManager.checkCreateClassLoader()
protected final 类<?> defineClass(String name, byte[] b, int off, int len, CodeSource cs)
如果提供非空CodeSource,则构造ProtectionDomain并与正在定义的类相关联。
name - 类的预期名称,如果不知道, null ,使用'。'
而不是'/'作为分隔符,没有尾随的“.class”后缀。
b - 构成类数据的字节。
位置off至off+len-1的字节应具有由The Java™ Virtual Machine Specification定义的有效类文件的格式。
off - 类数据中的起始偏移量为
b
len - 类数据的长度
cs - 相关的CodeSource,如果没有,
null
类对象,以及可选的CodeSource。
ClassFormatError - 如果数据不包含有效的类
IndexOutOfBoundsException - 如果
off或
len为负数,或者如果
off+len大于
b.length 。
SecurityException - 如果尝试将此类添加到包含由不同于该类的不同证书集签名的类的包中,或者类名以“java”开头。
protected final 类<?> defineClass(String name, ByteBuffer b, CodeSource cs)
ByteBuffer成类的实例类 ,使用可选的CodeSource。
在课堂可以使用之前,必须解决。
如果提供非空CodeSource,则构造ProtectionDomain并与正在定义的类相关联。
name - 该类的预期名称,如果不知道, null ,使用'。'
而不是'/'作为分隔符,没有尾随的“.class”后缀。
b - 构成类数据的字节。
位置b.position()至b.position() + b.limit() -1的字节应具有由The Java™ Virtual Machine Specification定义的有效类文件的格式。
cs - 相关的CodeSource,如果没有,
null
类对象,以及可选的CodeSource。
ClassFormatError - 如果数据不包含有效的类
SecurityException - 如果尝试将此类添加到包含由不同于该类的不同证书集签名的类的包中,或者类名以“java”开头。
protected PermissionCollection getPermissions(CodeSource codesource)
该方法由defineClass方法调用,该方法在为正在定义的类构造ProtectionDomain时,将CodeSource作为参数。
codesource - 代码源。
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.