public class SecureClassLoader
extends ClassLoader
java.lang.Object | ||
↳ | java.lang.ClassLoader | |
↳ | java.security.SecureClassLoader |
Known Direct Subclasses |
该类扩展了ClassLoader,额外支持定义具有相关代码源和权限的类,这些代码源和权限默认由系统策略检索。
Protected constructors |
|
---|---|
SecureClassLoader(ClassLoader parent) 使用指定的父类加载器为委派创建新的SecureClassLoader。 |
|
SecureClassLoader() 使用用于委派的默认父类加载器创建新的SecureClassLoader。 |
Protected methods |
|
---|---|
final Class<?> |
defineClass(String name, byte[] b, int off, int len, CodeSource cs) 使用可选的CodeSource将字节数组转换为类Class的实例。 |
final Class<?> |
defineClass(String name, ByteBuffer b, CodeSource cs) 使用可选的CodeSource将 |
PermissionCollection |
getPermissions(CodeSource codesource) 返回给定CodeSource对象的权限。 |
Inherited methods |
|
---|---|
From class java.lang.ClassLoader
|
|
From class java.lang.Object
|
SecureClassLoader (ClassLoader parent)
使用指定的父类加载器为委派创建新的SecureClassLoader。
如果存在安全管理器,则此方法首先调用安全管理器的方法 checkCreateClassLoader
以确保允许创建类加载器。
Parameters | |
---|---|
parent |
ClassLoader : the parent ClassLoader |
Throws | |
---|---|
SecurityException |
if a security manager exists and its checkCreateClassLoader method doesn't allow creation of a class loader. |
也可以看看:
SecureClassLoader ()
使用用于委派的默认父类加载器创建新的SecureClassLoader。
如果有安全管理器,则此方法首先调用安全管理器的 checkCreateClassLoader
方法以确保允许创建类加载器。
Throws | |
---|---|
SecurityException |
if a security manager exists and its checkCreateClassLoader method doesn't allow creation of a class loader. |
也可以看看:
Class<?> defineClass (String name, byte[] b, int off, int len, CodeSource cs)
使用可选的CodeSource将字节数组转换为类Class的实例。 在课程可以使用之前,必须解决。
如果提供了非空的CodeSource,则构造一个ProtectionDomain并将其与正在定义的类关联。
Parameters | |
---|---|
name |
String : the expected name of the class, or null if not known, using '.' and not '/' as the separator and without a trailing ".class" suffix. |
b |
byte : the bytes that make up the class data. The bytes in positions off through off+len-1 should have the format of a valid class file as defined by The Java™ Virtual Machine Specification. |
off |
int : the start offset in b of the class data |
len |
int : the length of the class data |
cs |
CodeSource : the associated CodeSource, or null if none |
Returns | |
---|---|
Class<?> |
the Class object created from the data, and optional CodeSource. |
Throws | |
---|---|
ClassFormatError |
if the data did not contain a valid class |
IndexOutOfBoundsException |
if either off or len is negative, or if off+len is greater than b.length . |
SecurityException |
if an attempt is made to add this class to a package that contains classes that were signed by a different set of certificates than this class, or if the class name begins with "java.". |
Class<?> defineClass (String name, ByteBuffer b, CodeSource cs)
使用可选的CodeSource将ByteBuffer
转换为类Class的实例。 在课程可以使用之前,必须解决。
如果提供了非空的CodeSource,则构造一个ProtectionDomain并将其与正在定义的类关联。
Parameters | |
---|---|
name |
String : the expected name of the class, or null if not known, using '.' and not '/' as the separator and without a trailing ".class" suffix. |
b |
ByteBuffer : the bytes that make up the class data. The bytes from positions b.position() through b.position() + b.limit() -1 should have the format of a valid class file as defined by The Java™ Virtual Machine Specification. |
cs |
CodeSource : the associated CodeSource, or null if none |
Returns | |
---|---|
Class<?> |
the Class object created from the data, and optional CodeSource. |
Throws | |
---|---|
ClassFormatError |
if the data did not contain a valid class |
SecurityException |
if an attempt is made to add this class to a package that contains classes that were signed by a different set of certificates than this class, or if the class name begins with "java.". |
PermissionCollection getPermissions (CodeSource codesource)
返回给定CodeSource对象的权限。
此方法由defineClass方法调用,该方法在为正在定义的类构造ProtectionDomain时将CodeSource作为参数。
Parameters | |
---|---|
codesource |
CodeSource : the codesource. |
Returns | |
---|---|
PermissionCollection |
the permissions granted to the codesource. |