博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Java ClassLoader setDefaultAssertionStatus()方法与示例
阅读量:2531 次
发布时间:2019-05-11

本文共 2056 字,大约阅读时间需要 6 分钟。

ClassLoader类setDefaultAssertionStatus()方法 (ClassLoader Class setDefaultAssertionStatus() method)

  • setDefaultAssertionStatus() method is available in java.lang package.

    setDefaultAssertionStatus()方法在java.lang包中可用。

  • setDefaultAssertionStatus() method is used to sets the default assertion status for this class loader to load the class. If, we use class loaded by this class loader later will have assertion enabled or disabled by default.

    setDefaultAssertionStatus()方法用于设置此类加载器的默认声明状态,以加载该类。 如果,我们使用由该类加载器加载的类,则默认情况下将启用或禁用断言。

  • setDefaultAssertionStatus() 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.

    setDefaultAssertionStatus()方法是一个非静态方法,只能通过类对象访问,如果尝试使用类名称访问该方法,则会收到错误消息。

  • setDefaultAssertionStatus() method does not throw an exception at the time of set default assertion status of the class.

    在设置类的默认断言状态时, setDefaultAssertionStatus()方法不会引发异常。

Syntax:

句法:

public void setDefaultAssertionStatus(boolean status);

Parameter(s):

参数:

  • boolean status – represents the status of assertions it returns true when class loaded by this class loader will have assertion enabled by default.

    布尔状态 –表示断言的状态,当此类加载器加载的类将默认启用断言时,它返回true。

Return value:

返回值:

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

此方法的返回类型为void ,不返回任何内容。

Example:

例:

// Java program to demonstrate the example // of void setDefaultAssertionStatus () method of ClassLoader public class setDefaultAssertionStatusOfClassLoader {
public static void main(String[] args) throws Exception {
// Load a class Class cl = Class.forName("setDefaultAssertionStatusOfClassLoader"); // It returns the ClassLoader associated with the // class Object ClassLoader loader = cl.getClassLoader(); // Display loader System.out.println("loader Class: " + loader.getClass()); // By using setDefaultAssertionStatus() method is to set the //the default status loader.setDefaultAssertionStatus(true); }}

Output

输出量

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

翻译自:

转载地址:http://mwxzd.baihongyu.com/

你可能感兴趣的文章
学习笔记-模块之xml文件处理
查看>>
简单的栈和队列
查看>>
接口测试用例
查看>>
面试:用 Java 实现一个 Singleton 模式
查看>>
Sybase IQ导出文件的几种方式
查看>>
案例:手动输入一个字符串,打散放进一个列表,小写字母反序 大写字母保持不变...
查看>>
点语法
查看>>
IO之Socket网络编程
查看>>
PCRE demo【转】
查看>>
矩阵的SVD分解
查看>>
gitlab的配置
查看>>
linux访问ftp服务器命令
查看>>
ActiveMQ学习笔记之异常
查看>>
LuoguP4012 深海机器人问题(费用流)
查看>>
自动机
查看>>
java知识点
查看>>
WPF设计の画刷(Brush)
查看>>
HTML学习笔记
查看>>
selinux详解及配置文件
查看>>
性能优化之数据库优化
查看>>