JDK-8232097 : (sctp) SctpNet.init() results in java.lang.UnsatisfiedLinkError
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 13
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: linux
  • CPU: x86_64
  • Submitted: 2019-10-03
  • Updated: 2019-12-03
  • Resolved: 2019-11-21
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 14
14 b25Fixed
Related Reports
Relates :  
Description
ADDITIONAL SYSTEM INFORMATION :
Linux 64-bit, Red Hat Enterprise Linux Server release 7.6 (Maipo), 

java -version                                                                                           
openjdk version "13" 2019-09-17
OpenJDK Runtime Environment (build 13+33)
OpenJDK 64-Bit Server VM (build 13+33, mixed mode, sharing)


A DESCRIPTION OF THE PROBLEM :
Opening a SctpServerChannel always fails in Java 13 (also in Java 14 EA). The same operation works fine on Java 12.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and run this class:

import com.sun.nio.sctp.SctpServerChannel;

public class SctpBug {

  public static void main(String[] args) {
    try (SctpServerChannel serverChannel = SctpServerChannel.open()) {
      if (serverChannel.isOpen()) {
        System.out.println(" *** SCTP serverChannel is open");
        Thread.sleep(1000);
      }
    }
    catch (Exception e) {
      System.out.println(" unable to load *** SCTP *** :" + e.getMessage());
    }

    System.out.println(" *** SCTP serverChannel is closed");
  }
}

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
 *** SCTP serverChannel is open
 *** SCTP serverChannel is closed

ACTUAL -
Exception in thread "main" java.lang.UnsatisfiedLinkError: 'void sun.nio.ch.sctp.SctpNet.init()'
	at jdk.sctp/sun.nio.ch.sctp.SctpNet.init(Native Method)
	at jdk.sctp/sun.nio.ch.sctp.SctpNet.<clinit>(SctpNet.java:338)
	at jdk.sctp/sun.nio.ch.sctp.SctpServerChannelImpl.<init>(SctpServerChannelImpl.java:97)
	at jdk.sctp/com.sun.nio.sctp.SctpServerChannel.open(SctpServerChannel.java:106)
	at SctpBug.main(SctpBug.java:8)


---------- BEGIN SOURCE ----------
import com.sun.nio.sctp.SctpServerChannel;

public class SctpBug {

  public static void main(String[] args) {
    try (SctpServerChannel serverChannel = SctpServerChannel.open()) {
      if (serverChannel.isOpen()) {
        System.out.println(" *** SCTP serverChannel is open");
        Thread.sleep(1000);
      }
    }
    catch (Exception e) {
      System.out.println(" unable to load *** SCTP *** :" + e.getMessage());
    }

    System.out.println(" *** SCTP serverChannel is closed");
  }
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
<none>

FREQUENCY : always



Comments
URL: https://hg.openjdk.java.net/jdk/jdk/rev/7b10581e9632 User: chegar Date: 2019-11-21 12:33:06 +0000
21-11-2019

This is a regression in JDK 13 that arises when SctpServerChannel is the first SCTP channel type to be used. The refactoring of java.base/sun.nio.ch.Net via JDK-8220738 means the SctpServerChannel no longer has any native methods and this exposes a bug in SctpNet where it is missing a loadLibrary("sctp"). The loadLibrary in SctpMultiChannelImpl can probably be removed as part of this. A temporary workaround for this bug is to create a SctpChannel or SctpMultiChannel before creating a SctpServerChannel.
10-10-2019