📜  Java.lang.ClassLoader类

📅  最后修改于: 2020-11-15 02:59:14             🧑  作者: Mango


介绍

java.lang.ClassLoader类是负责加载类的对象。此类是一个抽象类。安全管理者可以使用它来指示安全域。

类声明

以下是java.lang.ClassLoader类的声明-

public abstract class ClassLoader
   extends Object

类的构造函数

Sr.No. Constructor & Description
1

protected ClassLoader()

This creates a new class loader using the ClassLoader returned by the method getSystemClassLoader() as the parent class loader.

2

protected ClassLoader(ClassLoader parent)

This creates a new class loader using the specified parent class loader for delegation.

类方法

Sr.No. Method & Description
1 void clearAssertionStatus()

This method sets the default assertion status for this class loader to false and discards any package defaults or class assertion status settings associated with the class loader.

2

protected Class defineClass(String name, byte[] b, int off, int len)

This method converts an array of bytes into an instance of class Class.

3

protected Class defineClass(String name, byte[] b, int off, int len, ProtectionDomain protectionDomain)

This method converts an array of bytes into an instance of class Class, with an optional ProtectionDomain

4

protected Class defineClass(String name, ByteBuffer b, ProtectionDomain protectionDomain)

This method converts a ByteBuffer into an instance of class Class, with an optional ProtectionDomain.

5

protected Package definePackage(String name, String specTitle, String specVersion, String specVendor, String implTitle, String implVersion, String implVendor, URL sealBase)

This method defines a package by name in this ClassLoader.

6

protected Class findClass(String name)

This method finds the class with the specified binary name.

7

protected String findLibrary(String libname)

This method returns the absolute path name of a native library.

8

protected Class findLoadedClass(String name)

This method returns the class with the given binary name if this loader has been recorded by the Java virtual machine as an initiating loader of a class with that binary name.

9

protected URL findResource(String name)

This method Finds the resource with the given name.

10

protected Enumeration findResources(String name)

This method returns an enumeration of URL objects representing all the resources with the given name.

11

protected Class findSystemClass(String name)

This method finds a class with the specified binary name, loading it if necessary.

12

protected Package getPackage(String name)

This method returns a Package that has been defined by this class loader or any of its ancestors.

13

protected Package[] getPackages()

This method returns all of the Packages defined by this class loader and its ancestors.

14 ClassLoader getParent()

This method returns the parent class loader for delegation.

15 URL getResource(String name)

This method finds the resource with the given name.

16 InputStream getResourceAsStream(String name)

This method returns an input stream for reading the specified resource.

17

Enumeration getResources(String name)

This method finds all the resources with the given name.

18

static ClassLoader getSystemClassLoader()

This method returns the system class loader for delegation.

19 static URL getSystemResource(String name)

This method find a resource of the specified name from the search path used to load classes.

20 static InputStream getSystemResourceAsStream(String name)

This method is open for reading, a resource of the specified name from the search path used to load classes.

21

static Enumeration getSystemResources(String name)

This method finds all resources of the specified name from the search path used to load classes.

22

Class loadClass(String name)

This method loads the class with the specified binary name.

23

protected Class loadClass(String name, boolean resolve)

This method loads the class with the specified binary name.

24

protected void resolveClass(Class c)

This method links the specified class.

25 void setClassAssertionStatus(String className, boolean enabled)

This method sets the desired assertion status for the named top-level class in this class loader and any nested classes contained therein.

26 void setDefaultAssertionStatus(boolean enabled)

This method sets the default assertion status for this class loader.

27 void setPackageAssertionStatus(String packageName, boolean enabled)

This method sets the package default assertion status for the named package.

28

protected void setSigners(Class c, Object[] signers)

This method sets the signers of a class.

方法继承

此类从以下类继承方法-

  • java.lang.Object