void clearAssertionStatus()
描述 (Description)
java.lang.ClassLoader.clearAssertionStatus()方法将此类加载器的默认断言状态设置为false,并丢弃与类加载器关联的任何包默认值或类断言状态设置。
提供此方法是为了使类加载器可以忽略任何命令行或持久断言状态设置,并start with a clean slate 。
声明 (Declaration)
以下是java.lang.ClassLoader.clearAssertionStatus()方法的声明
public void clearAssertionStatus()
参数 (Parameters)
NA
返回值 (Return Value)
此方法不返回任何值。
异常 (Exception)
NA
例子 (Example)
以下示例显示了java.lang.ClassLoader.clearAssertionStatus()方法的用法。
package com.iowiki;
import java.lang.*;
public class ClassLoaderDemo {
public static void main(String[] args) throws Exception {
Class cls = Class.forName("ClassLoaderDemo");
// returns the ClassLoader object associated with this Class
ClassLoader cLoader = cls.getClassLoader();
System.out.println(cLoader.getClass());
// returns the parent ClassLoader
System.out.println(cLoader.getParent());
// sets the default assertion status to false
cLoader.clearAssertionStatus();
}
}
让我们编译并运行上面的程序,这将产生以下结果 -
class sun.misc.Launcher$AppClassLoader
sun.misc.Launcher$ExtClassLoader@35ce36