mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8287748: Fix issues in java.lang.foreign package javadoc
Reviewed-by: jvernee
This commit is contained in:
parent
deb06539b0
commit
ba9ee8cb28
1 changed files with 6 additions and 5 deletions
|
@ -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
|
||||
* }
|
||||
* }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue