Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
import com.sun.jna.Pointer;

public final class MemFDUnixWriterJNA extends MemFDUnixWriter {
private final LibC libc = Native.load("c", LibC.class);
private static final class Lazy {
static final LibC LIBC = Native.load("c", LibC.class);
}

private interface LibC extends Library {
long syscall(long number, Object... args);
Expand All @@ -19,19 +21,19 @@ private interface LibC extends Library {

@Override
protected long syscall(long number, String name, int flags) {
return libc.syscall(number, name, flags);
return Lazy.LIBC.syscall(number, name, flags);
}

@Override
protected long write(int fd, byte[] payload) {
Memory buf = new Memory(payload.length);
buf.write(0, payload, 0, payload.length);
return libc.write(fd, buf, new NativeLong(payload.length)).longValue();
return Lazy.LIBC.write(fd, buf, new NativeLong(payload.length)).longValue();
}

@Override
protected int fcntl(int fd, int cmd, int arg) {
return libc.fcntl(fd, cmd, arg);
return Lazy.LIBC.fcntl(fd, cmd, arg);
}

@Override
Expand Down