Java ClassLoader setPackageAssertionStatus()方法與示例

ClassLoader類setPackageAssertionStatus()方法 (ClassLoader Class setPackageAssertionStatus() method)

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

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

  • setPackageAssertionStatus() method is used to sets the package assertion status for the named package and this default status determines the classes instantiated in the future belong to named package or any of its child package.

    setPackageAssertionStatus()方法用于設置命名程序包的程序包斷言狀態,此默認狀態確定將來實例化的類屬于命名程序包或其任何子程序包。

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

    setPackageAssertionStatus()方法是一個非靜態方法,只能使用類對象訪問,如果嘗試使用類名稱訪問該方法,則會收到錯誤消息。

  • setPackageAssertionStatus() method does not throw an exception at the time of the set assertion status of the package.

    setPackageAssertionStatus()方法在設置包的聲明狀態時不會引發異常。

Syntax:

句法:

    public void setPackageAssertionStatus (String pack_name, boolean status);

Parameter(s):

參數:

  • String pack_name – represents the name of the package whose default assertion status is to be set.

    字符串pack_name –表示要設置其默認斷言狀態的程序包的名稱。

  • boolean status – It sets true when class loaded by this loader and belongs to the given named package will have assertion true by default otherwise it returns false.

    布爾狀態 –當此加載器加載的,屬于給定命名包的類默認為true時,設置為true,否則返回false。

Return value:

返回值:

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

此方法的返回類型為void ,不返回任何內容。

Example:

例:

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

Output

輸出量

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

翻譯自: https://www.includehelp.com/java/classloader-setpackageassertionstatus-method-with-example.aspx

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/542597.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/542597.shtml
英文地址,請注明出處:http://en.pswp.cn/news/542597.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

java上傳kafka的方法_哪種方法是將所有數據從Kafka主題復制到接收器(文件或Hive表)的最佳方法?...

我正在使用Kafka Consumer API將所有數據從Kafka主題復制到Hive表 . 為此,我使用HDFS作為中間步驟 . 我使用唯一的組ID并將偏移重置為“最早”,以便從頭開始獲取所有數據,并在執行后忽略提交 . 然后我遍歷Kafka主題中的記錄,并將每…

openstack nova-network 的小bug的排錯經歷

環境是 nova-network vmwareflatdhcp錯誤表現為 開出來的虛擬機有一定幾率獲取不到dhcp地址,手工賦予ip則正常,用flat模式注入的ip正常,下面是排錯過程1首先找網絡防火墻已經把 dnsmasq對應的端口已經打開抓包結果:可以看到虛擬機…

anaconda base環境_anaconda中安裝packages:pip還是conda install?

conda install我就不說了,這都不會別學了就。Using command:$ which -a pip, the terminal will return:This indicates two different pip path to install packages[1].在tf23環境中pip install在base環境中pip install在windows下powershell內,進入到…

Java ClassLoader setDefaultAssertionStatus()方法與示例

ClassLoader類setDefaultAssertionStatus()方法 (ClassLoader Class setDefaultAssertionStatus() method) setDefaultAssertionStatus() method is available in java.lang package. setDefaultAssertionStatus()方法在java.lang包中可用。 setDefaultAssertionStatus() metho…

【風馬一族_xml】xmlp之dtd1

什么是XML約束?在xml技術里,可以編寫一個文檔來約束一個xml文檔的寫法,這稱之為xml約束 2. 為什么要使用xml約束? 參看提示欄 3. xml約束的作用? 約束xml的寫法對xml進行校驗4. 常見的xml約束技術 xml dtdxml Schema…

java ssm框架 緩存_SSM框架之MyBatis3專題4:查詢緩存

查詢緩存的使用,主要是為了提高查詢訪問速度。將用戶對同一數據的重復查詢過程簡化,不再每次均從數據庫中查詢獲取結果數據,從而提高訪問速度。MyBatis的查詢緩存機制,根據緩存區的作用域(聲明周期)可劃分為兩種:一級查…

matplotlib畫圖_漂亮,超詳細的matplotlib畫圖基礎

來自 | 逐夢erhttps://zhumenger.blog.csdn.net/article/details/106530281本文僅作技術交流,如有侵權,請聯系后臺刪除。數據可視化非常重要,因為錯誤或不充分的數據表示方法可能會毀掉原本很出色的數據分析工作。matplotlib 庫是專門用于開發…

c# 2維數組 取一維_C#| 不同類型的一維數組聲明

c# 2維數組 取一維In the below example, we are declaring an integer array (one dimensional) with following styles: 在下面的示例中,我們聲明具有以下樣式的整數數組(一維) : 1) One dimensional Array declaration with initialization (without…

Java編程經典10道_Java經典編程題50道之十二

企業發放的獎金根據利潤提成:利潤(I)低于或等于10萬元時,獎金可提10%;利潤高于10萬元,低于20萬元時,低于10萬元的部分按10%提成, 高于10萬元的部分 ,可提成7.5%;20萬到40萬之間時&am…

RHEL7 單獨安裝圖形 X11

RHEL7 默認是最小化安裝(Minimal Install),沒有圖形界面, 我們應該選擇Server with GUI。若已錯過此步驟,我們采用以下方式補充安裝GUI界面。 先配置yum源可以參考我的這篇文章http://blog.itpub.net/27771627/viewspa…

android recycleview長按多選_UI設計中Android和IOS設計差異總結

由于設計師、產品經理使用的移動設備大部分是iPhone,所以在做設計時,容易忽略Android和iOS的差異,按照iOS的規范進行設計,兩端只做一套。只做一套的會存在兩個問題:1、安卓用戶的使用習慣不太適應iOS的設計&#xff0c…

Kotlin程序用于打印JVM版本的Kotlin(打印Java屬性)

Here, we will create a Kotlin program to print Kotlin, JVM version (printing Java properties). As Kotlin can be seen as an upgrade of Java, so we will get all versions of java (JVM) using Kotlin also. 在這里,我們將創建一個Kotlin程序以打印JVM版本…

自定義動畫屬性java_創建酷炫動畫效果的10個JavaScript庫

原標題:創建酷炫動畫效果的10個JavaScript庫1) Dynamics.jsDynamics.js是設計基于物理規律的動畫的重要Java庫。它可以賦予生命給所有包含CSS 和SVG屬性的DOM(文本對象模型)元素,換句話說,Dynamics.js適用于所有Java對象以及一系列其它的元素…

php xlsx里插入圖片_常見的 PHP 面試題和答案分享

如何直接將輸出顯示給瀏覽器&#xff1f;將輸出直接顯示給瀏覽器&#xff0c;我們必須使用特殊標記 <&#xff1f;and&#xff1f;>。PHP 是否支持多重繼承&#xff1f;PHP 只支持單繼承。PHP 的類使用關鍵字 extends 繼承另一個類獲取圖片屬性&#xff08;size, width, …

java調用構造函數中某一個值_Java如何在枚舉的構造函數中調用另一個枚舉值

Java中的枚舉(enum)是一種存儲一組常量值的數據類型。您可以使用枚舉來存儲固定值&#xff0c;例如一周中的天&#xff0c;一年中的月等。您可以使用關鍵字 enum定義枚舉&#xff0c;后跟枚舉的名稱為-enum Days {SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATUR…

python 示例_Python日歷類| yeardatescalendar()方法與示例

python 示例Python Calendar.yeardatescalendar()方法 (Python Calendar.yeardatescalendar() Method) Calendar.yeardatescalendar() method is an inbuilt method of the Calendar class of calendar module in Python. It uses an instance of this class and returns a lis…

js:插入節點appendChild insertBefore使用方法

首先 從定義來理解 這兩個方法&#xff1a; appendChild() 方法&#xff1a;可向節點的子節點列表的末尾添加新的子節點。語法&#xff1a;appendChild(newchild) insertBefore() 方法&#xff1a;可在已有的子節點前插入一個新的子節點。語法 &#xff1a;insertBefore(newchi…

pandas concat_pandas-數據合并-concat(最全參數解釋,含代碼和實例)

pandas中的concat的功能&#xff1a;假設你現在需要將多個數據合并&#xff0c;前提是&#xff1a;這幾個文件列名都一致&#xff0c;也就是說這幾個文件格式完全一樣&#xff0c;只是數據不太一樣&#xff0c;類似于合并多個文件這種&#xff0c;實際數據分析中也會遇到這種情…

java中的de是什么_【轉】java中main函數解析

源地址&#xff1a;http://www.cnblogs.com/xwdreamer/archive/2012/04/09/2438845.html從寫java至今&#xff0c;寫的最多的可能就是主函數public static void main(String[] args) {}但是以前一直都沒有問自己&#xff0c;為什么要這么寫&#xff0c;因為在c語言中就沒有這樣…