fix: use baeldung intellij formatter
This commit is contained in:
parent
a6330243e7
commit
c61004285c
|
@ -5,7 +5,6 @@ import java.lang.invoke.MethodHandle;
|
||||||
|
|
||||||
import static java.lang.foreign.ValueLayout.*;
|
import static java.lang.foreign.ValueLayout.*;
|
||||||
|
|
||||||
|
|
||||||
public class Greetings {
|
public class Greetings {
|
||||||
|
|
||||||
public static void main(String[] args) throws Throwable {
|
public static void main(String[] args) throws Throwable {
|
||||||
|
@ -24,10 +23,10 @@ public class Greetings {
|
||||||
.map(symbolSegment -> nativeLinker.downcallHandle(symbolSegment, descriptor))
|
.map(symbolSegment -> nativeLinker.downcallHandle(symbolSegment, descriptor))
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
|
|
||||||
|
|
||||||
if (methodHandle == null) {
|
if (methodHandle == null) {
|
||||||
throw new NoSuchMethodError("Method Handle was not found");
|
throw new NoSuchMethodError("Method Handle was not found");
|
||||||
};
|
}
|
||||||
|
;
|
||||||
|
|
||||||
try (MemorySession memorySession = MemorySession.openConfined()) {
|
try (MemorySession memorySession = MemorySession.openConfined()) {
|
||||||
MemorySegment greetingSegment = memorySession.allocateUtf8String(greeting);
|
MemorySegment greetingSegment = memorySession.allocateUtf8String(greeting);
|
||||||
|
|
|
@ -5,13 +5,10 @@ import java.lang.foreign.MemorySession;
|
||||||
import java.lang.foreign.ValueLayout;
|
import java.lang.foreign.ValueLayout;
|
||||||
import java.lang.foreign.SegmentAllocator;
|
import java.lang.foreign.SegmentAllocator;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class MemoryAllocation {
|
public class MemoryAllocation {
|
||||||
|
|
||||||
public static void main(String[] args) throws Throwable {
|
public static void main(String[] args) throws Throwable {
|
||||||
|
|
||||||
|
|
||||||
try (MemorySession session = MemorySession.openConfined()) {
|
try (MemorySession session = MemorySession.openConfined()) {
|
||||||
String[] greetingStrings = { "hello", "world", "panama", "baeldung" };
|
String[] greetingStrings = { "hello", "world", "panama", "baeldung" };
|
||||||
SegmentAllocator allocator = SegmentAllocator.implicitAllocator();
|
SegmentAllocator allocator = SegmentAllocator.implicitAllocator();
|
||||||
|
|
|
@ -10,18 +10,13 @@ import static java.lang.foreign.MemoryLayout.sequenceLayout;
|
||||||
import static java.lang.foreign.MemoryLayout.structLayout;
|
import static java.lang.foreign.MemoryLayout.structLayout;
|
||||||
import static java.lang.foreign.ValueLayout.*;
|
import static java.lang.foreign.ValueLayout.*;
|
||||||
|
|
||||||
|
|
||||||
public class MemoryLayout {
|
public class MemoryLayout {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
GroupLayout pointLayout = structLayout(
|
GroupLayout pointLayout = structLayout(JAVA_DOUBLE.withName("x"), JAVA_DOUBLE.withName("y"));
|
||||||
JAVA_DOUBLE.withName("x"),
|
|
||||||
JAVA_DOUBLE.withName("y")
|
|
||||||
);
|
|
||||||
|
|
||||||
SequenceLayout ptsLayout = sequenceLayout(10,
|
SequenceLayout ptsLayout = sequenceLayout(10, pointLayout);
|
||||||
pointLayout);
|
|
||||||
|
|
||||||
VarHandle xvarHandle = pointLayout.varHandle(PathElement.groupElement("x"));
|
VarHandle xvarHandle = pointLayout.varHandle(PathElement.groupElement("x"));
|
||||||
VarHandle yvarHandle = pointLayout.varHandle(PathElement.groupElement("y"));
|
VarHandle yvarHandle = pointLayout.varHandle(PathElement.groupElement("y"));
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.baeldung.java.panama.jextract;
|
||||||
|
|
||||||
import java.lang.foreign.MemorySegment;
|
import java.lang.foreign.MemorySegment;
|
||||||
import java.lang.foreign.MemorySession;
|
import java.lang.foreign.MemorySession;
|
||||||
// Generate JExtract bingings before uncommenting
|
// Generate JExtract bindings before uncommenting
|
||||||
// import static foreign.c.stdio_h.printf;
|
// import static foreign.c.stdio_h.printf;
|
||||||
|
|
||||||
public class Greetings {
|
public class Greetings {
|
||||||
|
|
Loading…
Reference in New Issue