Class NativeStringParser
java.lang.Object
net.jrodolfo.java_evolution.java22.foreign_function.NativeStringParser
Demonstrates a Java 22 foreign function call to the native
atoi
function.
The C atoi function parses an integer from a null-terminated C
string. Java creates that native string in a confined Arena, links the
native function with a FunctionDescriptor, and invokes it through a
MethodHandle.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionparseInteger(String text) Parses an integer by calling nativeatoi.
-
Constructor Details
-
NativeStringParser
public NativeStringParser()
-
-
Method Details
-
parseInteger
Parses an integer by calling nativeatoi.- Parameters:
text- the Java text copied into native memory- Returns:
- the native call result
- Throws:
Throwable- if the native function cannot be linked or invoked
-