Java.lang.ClassLoader Class

Java.lang.ClassLoader Class

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:

public abstract class ClassLoader
  extends Object

Class constructors

S.N.Constructor & Description
1protected ClassLoader()

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

2protected ClassLoader(ClassLoader parent)

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

Class methods

S.N.Method & Description
1void 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.

2protected Class<?> defineClass(String name, byte[] b, int off, int len)

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

3protected 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

4protected Class<?> defineClass(String name, ByteBuffer b, ProtectionDomain protectionDomain)

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

5protected 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.

6protected Class<?> findClass(String name)

This method finds the class with the specified binary name.

7protected String findLibrary(String libname)

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

8protected 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.

9protected URL findResource(String name)

This method Finds the resource with the given name.

10protected Enumeration<URL> findResources(String name)

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

11protected Class<?> findSystemClass(String name)

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

12protected Package getPackage(String name)

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

13protected Package[] getPackages()

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

14ClassLoader getParent()

This method returns the parent class loader for delegation.

15URL getResource(String name)

This method finds the resource with the given name.

16InputStream getResourceAsStream(String name)

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

17Enumeration<URL> getResources(String name)

This method finds all the resources with the given name.

18static ClassLoader getSystemClassLoader()

This method returns the system class loader for delegation.

19static URL getSystemResource(String name)

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

20static InputStream getSystemResourceAsStream(String name)

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

21static Enumeration<URL> getSystemResources(String name)

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

22Class<?> loadClass(String name)

This method loads the class with the specified binary name.

23protected Class<?> loadClass(String name, boolean resolve)

This method loads the class with the specified binary name.

24protected void resolveClass(Class<?> c)

This method links the specified class.

25void 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.

26void setDefaultAssertionStatus(boolean enabled)

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

27void setPackageAssertionStatus(String packageName, boolean enabled)

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

28protected 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

Was this article helpful?

Related Articles

Leave A Comment?

You must be logged in to post a comment.