Share via


ClassLoader.GetPackage(String) Method

Definition

Finds a package by name in this class loader and its ancestors.

[Android.Runtime.Register("getPackage", "(Ljava/lang/String;)Ljava/lang/Package;", "GetGetPackage_Ljava_lang_String_Handler")]
protected virtual Java.Lang.Package? GetPackage (string? name);
[<Android.Runtime.Register("getPackage", "(Ljava/lang/String;)Ljava/lang/Package;", "GetGetPackage_Ljava_lang_String_Handler")>]
abstract member GetPackage : string -> Java.Lang.Package
override this.GetPackage : string -> Java.Lang.Package

Parameters

name
String

The package name

Returns

The Package of the given name that has been defined by this class loader or its ancestors, or null if not found.

Attributes

Remarks

Finds a package by name in this class loader and its ancestors.

If this class loader defines a Package of the given name, the Package is returned. Otherwise, the ancestors of this class loader are searched recursively (parent by parent) for a Package of the given name.

This member is deprecated. If multiple class loaders delegate to each other and define classes with the same package name, and one such loader relies on the lookup behavior of getPackage to return a Package from a parent loader, then the properties exposed by the Package may not be as expected in the rest of the program. For example, the Package will only expose annotations from the package-info.class file defined by the parent loader, even if annotations exist in a package-info.class file defined by a child loader.

Added in 1.2.

Java documentation for java.lang.ClassLoader.getPackage(java.lang.String).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to