kohlschutter / junixsocket

Unix Domain Sockets in Java 7 and newer (AF_UNIX), AF_TIPC, AF_VSOCK, and more
Apache License 2.0
433 stars 114 forks source link

Question: what changed from 2.1.2 to 2.2.0? #60

Closed gesellix closed 5 years ago

gesellix commented 5 years ago

Please don't see this one as an issue, but more of a question.

In https://github.com/gesellix/gradle-testkit-junixsocket-issue I tried to find a minimal way of demonstrating an issue when using junixsocket 2.1.2. I suspected something along the way how Gradle Testkit performs functional tests. Using your recently published junixsocket 2.2.0 the issue had been fixed.

I would now like to find out what exactly changed in junixsocket to make the issue disappear, because I would like to understand whether there is still a risk of something being broken but unnoticed.

If you'd like to reproduce the issue, you can clone the linked repository and perform ./gradlew check --info --stacktrace. The build should fail with the following stacktrace:

   ...
    Caused by: java.io.IOException: Couldn't load native library
        at org.newsclub.net.unix.AFUNIXSocket.setIsCreated(AFUNIXSocket.java:50)
        at org.newsclub.net.unix.AFUNIXSocket.<init>(AFUNIXSocket.java:42)
        at org.newsclub.net.unix.AFUNIXSocket.newInstance(AFUNIXSocket.java:71)
        at org.newsclub.net.unix.AFUNIXSocket.newInstance(AFUNIXSocket.java:66)
        at org.newsclub.net.unix.AFUNIXSocket$newInstance$0.call(Unknown Source)
        at build_4ojtdta44r37re1bjs1dda4y8$_run_closure1$_closure3.doCall(/private/var/folders/sn/xz7ykkt14_q0gx1w_wc_4s8m0000gn/T/junit12501533989947753003/build.gradle:26)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:648)
        at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:621)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$4.run(ExecuteActionsTaskExecuter.java:338)
        ... 69 more
    Caused by: java.lang.UnsatisfiedLinkError: org.newsclub.net.unix.NativeUnixSocket.setCreated(Lorg/newsclub/net/unix/AFUNIXSocket;)V
        at org.newsclub.net.unix.NativeUnixSocket.setCreated(Native Method)
        at org.newsclub.net.unix.AFUNIXSocket.setIsCreated(AFUNIXSocket.java:48)
        ... 80 more

If you checkout the junixsocket-2.2.0 branch and repeat ./gradlew check --info --stacktrace, the build should succeed. The only difference is the dependency version changing from 2.1.2 to 2.2.0.

Do you have an idea whether something regarding the library loading mechanism has been changed? I've had a look into the recent commits, but don't really understand what exactly the issue was with 2.1.2.

gesellix commented 5 years ago

This one might even be related to #45

kohlschuetter commented 5 years ago

Yes, I've improved the loading mechanism in 2.2.0.

Moreover, most native libraries are now cross-compiled on macOS using clang (exceptions: macOS, which uses native clang, and Windows 10, which uses mingw-w64)