JniEnvironment.Types.TryFindClass Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
| Name | Description |
|---|---|
| TryFindClass(ReadOnlySpan<Byte>, JniObjectReference) |
Tries to find a Java class using a UTF-8 class name span.
Returns |
| TryFindClass(String, JniObjectReference) |
Attempts to find a Java class with a runtime-class-loader fallback. |
TryFindClass(ReadOnlySpan<Byte>, JniObjectReference)
Tries to find a Java class using a UTF-8 class name span.
Returns true if the class was found, false otherwise.
public static bool TryFindClass(ReadOnlySpan<byte> classname, out Java.Interop.JniObjectReference instance);
static member TryFindClass : ReadOnlySpan<byte> * JniObjectReference -> bool
Parameters
- classname
- ReadOnlySpan<Byte>
A nonempty class name encoded as modified UTF-8.
- instance
- JniObjectReference
On success, a local JNI class reference that the caller must release; otherwise, an invalid reference.
Returns
true if a valid class reference was found; otherwise, false.
Remarks
When the span is passed directly to JNI, the class name must be terminated in memory. The zero terminator can be inside the span or immediately after it, as with a u8 string literal. Lookup uses the runtime's class loader if the initial JNI lookup fails. Class lookup failure returns false, but invalid input and other runtime errors can still throw exceptions.
Applies to
TryFindClass(String, JniObjectReference)
Attempts to find a Java class with a runtime-class-loader fallback.
public static bool TryFindClass(string classname, out Java.Interop.JniObjectReference instance);
static member TryFindClass : string * JniObjectReference -> bool
Parameters
- classname
- String
A nonempty Java class name with slash-separated packages, such as java/lang/Object.
- instance
- JniObjectReference
On success, a local JNI class reference that the caller must release; otherwise, an invalid reference.
Returns
true if a valid class reference was found; otherwise, false.
Remarks
Class lookup failure returns false, but invalid input and other runtime errors can still throw exceptions.