English 中文(简体)
Java.lang - ClassLoader
  • 时间:2024-12-22

Java.lang.ClassLoader Class


Previous Page Next Page  

Introduction

The java.lang.ClassLoader class is an object that is responsible for loading classes. This class is an abstract class. It may be used by security managers to indicate security domains.

Class Declaration

Following is the declaration for java.lang.ClassLoader class −

pubpc abstract class ClassLoader
   extends Object

Class constructors

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.

Class methods

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 pbname)

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

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<URL> 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<URL> 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<URL> 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 pnks 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.

Methods inherited

This class inherits methods from the following classes −

    java.lang.Object

Advertisements