8287748: Fix issues in java.lang.foreign package javadoc

Reviewed-by: jvernee
This commit is contained in:
Maurizio Cimadamore 2022-06-03 00:17:45 +00:00
parent deb06539b0
commit ba9ee8cb28

View file

@ -106,15 +106,16 @@
* we can use the following code:
*
* {@snippet lang=java :
* var linker = Linker.nativeLinker();
* Linker linker = Linker.nativeLinker();
* SymbolLookup stdlib = linker.defaultLookup();
* MethodHandle strlen = linker.downcallHandle(
* linker.lookup("strlen").get(),
* stdlib.lookup("strlen").get(),
* FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)
* );
*
* try (var session = MemorySession.openConfined()) {
* var cString = MemorySegment.allocateNative(5 + 1, session);
* cString.setUtf8String("Hello");
* try (MemorySession session = MemorySession.openConfined()) {
* MemorySegment cString = MemorySegment.allocateNative(5 + 1, session);
* cString.setUtf8String(0, "Hello");
* long len = (long)strlen.invoke(cString); // 5
* }
* }