Home » Java programming language

Java ClassLoader clearAssertionStatus() method with example

ClassLoader Class clearAssertionStatus() method: Here, we are going to learn about the clearAssertionStatus() method of ClassLoader Class with its syntax and example.
Submitted by Preeti Jain, on November 24, 2019

ClassLoader Class clearAssertionStatus() method

  • clearAssertionStatus() method is available in java.lang package.
  • clearAssertionStatus() method is used to clear the assertion status settings and sets the assertion status for this class loader to false by default.
  • clearAssertionStatus() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.
  • clearAssertionStatus() method does not throw an exception at the time of clearing assertion status.

Syntax:

    public void clearAssertionStatus();

Parameter(s):

  • It does not accept any parameter.

Return value:

The return type of this method is void, it returns nothing.

Example:

// Java program to demonstrate the example 
// of void clearAssertionStatus() method of ClassLoader 

public class ClearAssertionStatusOfClassLoader {
 public static void main(String[] args) throws Exception {
  // Load a class
  Class cl = Class.forName("ClearAssertionStatusOfClassLoader");

  // It returns the ClassLoader associated with the
  // class Object
  ClassLoader loader = cl.getClassLoader();

  // Display loader
  System.out.println("loader Class: " + loader.getClass());

  // By using clearAssertionStatus() method is to clear the
  // previous status and sets the default status to false
  loader.clearAssertionStatus();
 }
}

Output

loader Class: class jdk.internal.loader.ClassLoaders$AppClassLoader


Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.