junixsocket
junixsocket copied to clipboard
SocketException in graalvm environment
I can't find what configuration item is missing. I have tried countless configuration adjustments, but still can't solve it. I am using Spring-Boot-Native and junixsocket2.5.0 in my project. It works fine under jvm, but when packaged as native-image, an exception will be thrown:
java.net.SocketException: Socket is closed
at org.newsclub.net.unix.NativeUnixSocket.bind(NativeUnixSocket.java)
at org.newsclub.net.unix.AFSocketImpl.bind(AFSocketImpl.java:319)
at org.newsclub.net.unix.AFServerSocket.bind(AFServerSocket.java:256)
at [email protected]/java.net.ServerSocket.bind(ServerSocket.java:349)
at org.newsclub.net.unix.server.SocketServer.listen(SocketServer.java:282)
at org.newsclub.net.unix.server.SocketServer.access$000(SocketServer.java:50)
at org.newsclub.net.unix.server.SocketServer$1.run(SocketServer.java:218)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:709)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.windows.WindowsPlatformThreads.osThreadStartRoutine(WindowsPlatformThreads.java:143)
AOT Hits:
// for junixsocket
@TypeHint(
typeNames = {
"org.newsclub.net.unix.AFSelector$PollFd",
},
access = {
TypeAccess.DECLARED_CONSTRUCTORS,
TypeAccess.JNI
}
)
@TypeHint(
types = {
IllegalStateException.class,
ClosedChannelException.class,
AbstractSelectableChannel.class,
Socket.class,
DatagramSocket.class,
AFUNIXSocket.class,
AFUNIXDatagramSocket.class
},
access = {
TypeAccess.PUBLIC_CONSTRUCTORS,
TypeAccess.JNI
}
)
@TypeHint(
types = {
NarMetadata.class,
AFUNIXSelectorProvider.class,
AFUNIXSocketAddress.class,
},
access = TypeAccess.DECLARED_CONSTRUCTORS
)
@TypeHint(
typeNames = {"org.newsclub.net.unix.AFUNIXSocketImpl"},
access = {
TypeAccess.DECLARED_METHODS
},
methods = {
@MethodHint(name = "connect", parameterTypes = {SocketAddress.class, int.class})
}
)
@ResourceHint(patterns = {
"lib/.*",
})
static class UnixSocketReflect {
}
// for jni
@TypeHint(
typeNames = {
"com.sun.jna.Native",
"java.lang.Class",
"java.lang.reflect.Method",
"java.lang.String",
"java.nio.Buffer",
"java.nio.ByteBuffer",
"java.nio.CharBuffer",
"java.nio.ShortBuffer",
"java.nio.IntBuffer",
"java.nio.LongBuffer",
"java.nio.FloatBuffer",
"java.nio.DoubleBuffer",
"com.sun.jna.Structure$ByValue",
"com.sun.jna.WString",
"com.sun.jna.NativeMapped",
"com.sun.jna.NativeMapped",
"com.sun.jna.IntegerType",
"com.sun.jna.PointerType",
"com.sun.jna.JNIEnv",
"com.sun.jna.Native$ffi_callback",
"com.sun.jna.FromNativeConverter",
"com.sun.jna.Callback",
"com.sun.jna.CallbackReference$AttachOptions",
"com.sun.jna.CallbackReference",
"com.sun.jna.Structure$FFIType",
"com.sun.jna.NativeLong",
"com.sun.jna.ptr.PointerByReference",
},
access = {
TypeAccess.JNI,
TypeAccess.DECLARED_CONSTRUCTORS,
TypeAccess.DECLARED_METHODS
}
)
@TypeHint(
typeNames = "com.sun.jna.Structure$FFIType$FFITypes",
access = {
TypeAccess.JNI,
TypeAccess.DECLARED_CONSTRUCTORS,
TypeAccess.DECLARED_METHODS
},
fields = {
@FieldHint(name = "ffi_type_void", allowWrite = true),
@FieldHint(name = "ffi_type_float", allowWrite = true),
@FieldHint(name = "ffi_type_double", allowWrite = true),
@FieldHint(name = "ffi_type_longdouble", allowWrite = true),
@FieldHint(name = "ffi_type_uint8", allowWrite = true),
@FieldHint(name = "ffi_type_sint8", allowWrite = true),
@FieldHint(name = "ffi_type_uint16", allowWrite = true),
@FieldHint(name = "ffi_type_sint16", allowWrite = true),
@FieldHint(name = "ffi_type_uint32", allowWrite = true),
@FieldHint(name = "ffi_type_sint32", allowWrite = true),
@FieldHint(name = "ffi_type_uint64", allowWrite = true),
@FieldHint(name = "ffi_type_sint64", allowWrite = true),
@FieldHint(name = "ffi_type_pointer", allowWrite = true)
}
)
@TypeHint(
typeNames = "com.sun.jna.IntegerType",
access = {
TypeAccess.JNI,
TypeAccess.DECLARED_CONSTRUCTORS,
TypeAccess.DECLARED_METHODS
},
fields = @FieldHint(name = "value", allowWrite = true)
)
@TypeHint(
typeNames = "com.sun.jna.PointerType",
access = {
TypeAccess.JNI,
TypeAccess.DECLARED_CONSTRUCTORS,
TypeAccess.DECLARED_METHODS
},
fields = @FieldHint(name = "pointer", allowWrite = true)
)
@TypeHint(
typeNames = "java.lang.Void",
access = {
TypeAccess.JNI,
TypeAccess.DECLARED_CONSTRUCTORS,
TypeAccess.DECLARED_METHODS
},
fields = @FieldHint(name = "TYPE")
)
@TypeHint(
typeNames = {
"java.lang.Boolean",
"java.lang.Byte",
"java.lang.Character",
"java.lang.Short",
"java.lang.Integer",
"java.lang.Long",
"java.lang.Float",
"java.lang.Double",
},
access = {
TypeAccess.JNI,
TypeAccess.DECLARED_CONSTRUCTORS,
TypeAccess.DECLARED_METHODS
},
fields = {
@FieldHint(name = "TYPE"),
@FieldHint(name = "value", allowWrite = true),
}
)
@TypeHint(
typeNames = "com.sun.jna.Pointer",
access = {
TypeAccess.JNI,
TypeAccess.DECLARED_CONSTRUCTORS,
TypeAccess.DECLARED_METHODS
},
fields = @FieldHint(name = "peer", allowWrite = true)
)
@TypeHint(
typeNames = "com.sun.jna.Structure",
access = {
TypeAccess.JNI,
TypeAccess.DECLARED_CONSTRUCTORS,
TypeAccess.DECLARED_METHODS
},
fields = {
@FieldHint(name = "memory", allowWrite = true),
@FieldHint(name = "typeInfo", allowWrite = true)
},
methods = {
@MethodHint(name = "newInstance", parameterTypes = {Class.class, Pointer.class}),
@MethodHint(name = "newInstance", parameterTypes = {Class.class, long.class}),
@MethodHint(name = "newInstance", parameterTypes = {Class.class}),
}
)
@ResourceHint(
patterns = {
"com/sun/jna/.*jni.*",
"META-INF/services/jdk.*"
}
)
@TypeHint(
typeNames = {
"com.sun.jna.CallbackReference",
"com.sun.jna.Klass",
"com.sun.jna.Native",
"com.sun.jna.NativeLong",
"com.sun.jna.ptr.PointerByReference",
"com.sun.jna.ptr.IntByReference",
"java.util.Base64$Decoder",
},
access = {
TypeAccess.DECLARED_CONSTRUCTORS
}
)
@TypeHint(
typeNames = "com.sun.jna.Structure",
access = {
TypeAccess.DECLARED_CONSTRUCTORS
},
fields = {
@FieldHint(name = "memory", allowWrite = true),
@FieldHint(name = "typeInfo")
},
methods = {
@MethodHint(name = "newInstance", parameterTypes = {Class.class, Pointer.class}),
@MethodHint(name = "newInstance", parameterTypes = {Class.class, long.class}),
@MethodHint(name = "newInstance", parameterTypes = {Class.class}),
}
)
@JdkProxyHint(types = {
com.sun.jna.Library.class,
com.sun.jna.Callback.class
})
static class JNIAccess {
}
Environment (please complete the following information):
- OS: windows10
- JVM: graalvm-ce-java11-22.1.0
I need help please. thanks