8319563: Reformat code in the FFM API

Reviewed-by: mcimadamore
This commit is contained in:
Per Minborg 2023-11-07 11:39:41 +00:00
parent ac0ee20a38
commit 42f43c520c
3 changed files with 12 additions and 5 deletions

View file

@ -875,7 +875,8 @@ public sealed interface MemoryLayout permits SequenceLayout, GroupLayout, Paddin
static SequenceLayout sequenceLayout(long elementCount, MemoryLayout elementLayout) { static SequenceLayout sequenceLayout(long elementCount, MemoryLayout elementLayout) {
MemoryLayoutUtil.requireNonNegative(elementCount); MemoryLayoutUtil.requireNonNegative(elementCount);
Objects.requireNonNull(elementLayout); Objects.requireNonNull(elementLayout);
Utils.checkElementAlignment(elementLayout, "Element layout size is not multiple of alignment"); Utils.checkElementAlignment(elementLayout,
"Element layout size is not multiple of alignment");
return Utils.wrapOverflow(() -> return Utils.wrapOverflow(() ->
SequenceLayoutImpl.of(elementCount, elementLayout)); SequenceLayoutImpl.of(elementCount, elementLayout));
} }

View file

@ -1297,7 +1297,9 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl {
@ForceInline @ForceInline
static void copy(MemorySegment srcSegment, long srcOffset, static void copy(MemorySegment srcSegment, long srcOffset,
MemorySegment dstSegment, long dstOffset, long bytes) { MemorySegment dstSegment, long dstOffset, long bytes) {
copy(srcSegment, ValueLayout.JAVA_BYTE, srcOffset, dstSegment, ValueLayout.JAVA_BYTE, dstOffset, bytes); copy(srcSegment, ValueLayout.JAVA_BYTE, srcOffset,
dstSegment, ValueLayout.JAVA_BYTE, dstOffset,
bytes);
} }
/** /**
@ -1354,7 +1356,9 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl {
Objects.requireNonNull(srcElementLayout); Objects.requireNonNull(srcElementLayout);
Objects.requireNonNull(dstSegment); Objects.requireNonNull(dstSegment);
Objects.requireNonNull(dstElementLayout); Objects.requireNonNull(dstElementLayout);
AbstractMemorySegmentImpl.copy(srcSegment, srcElementLayout, srcOffset, dstSegment, dstElementLayout, dstOffset, elementCount); AbstractMemorySegmentImpl.copy(srcSegment, srcElementLayout, srcOffset,
dstSegment, dstElementLayout, dstOffset,
elementCount);
} }
/** /**

View file

@ -228,7 +228,8 @@ public interface SymbolLookup {
@CallerSensitive @CallerSensitive
@Restricted @Restricted
static SymbolLookup libraryLookup(String name, Arena arena) { static SymbolLookup libraryLookup(String name, Arena arena) {
Reflection.ensureNativeAccess(Reflection.getCallerClass(), SymbolLookup.class, "libraryLookup"); Reflection.ensureNativeAccess(Reflection.getCallerClass(),
SymbolLookup.class, "libraryLookup");
if (Utils.containsNullChars(name)) { if (Utils.containsNullChars(name)) {
throw new IllegalArgumentException("Cannot open library: " + name); throw new IllegalArgumentException("Cannot open library: " + name);
} }
@ -256,7 +257,8 @@ public interface SymbolLookup {
@CallerSensitive @CallerSensitive
@Restricted @Restricted
static SymbolLookup libraryLookup(Path path, Arena arena) { static SymbolLookup libraryLookup(Path path, Arena arena) {
Reflection.ensureNativeAccess(Reflection.getCallerClass(), SymbolLookup.class, "libraryLookup"); Reflection.ensureNativeAccess(Reflection.getCallerClass(),
SymbolLookup.class, "libraryLookup");
return libraryLookup(path, RawNativeLibraries::load, arena); return libraryLookup(path, RawNativeLibraries::load, arena);
} }