Class NativeStringParser

java.lang.Object
net.jrodolfo.java_evolution.java22.foreign_function.NativeStringParser

public class NativeStringParser extends Object
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 Details

    • NativeStringParser

      public NativeStringParser()
  • Method Details

    • parseInteger

      public ForeignFunctionCallResult parseInteger(String text) throws Throwable
      Parses an integer by calling native atoi.
      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