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 null-terminated 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 null-terminated 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, zero-terminated 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
The span must include a terminating zero byte. 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 or dot-separated packages.
- 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.