JDK-6571600 : JNI use results in UnsatisfiedLinkError looking for libmawt.so
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: other,linux
  • CPU: generic,x86
  • Submitted: 2007-06-20
  • Updated: 2014-06-05
  • Resolved: 2013-12-23
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.
Other JDK 6 JDK 7 JDK 8 JDK 9
5.0u65Fixed 6u75Fixed 7u55Fixed 8u20Fixed 9 b06Fixed
Description
FULL PRODUCT VERSION :
java version "1.6.0"
Java(TM) SE Runtime Environment (build 1.6.0-b105)
Java HotSpot(TM) Server VM (build 1.6.0-b105, mixed mode)

and

java version "1.6.0_01"
Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Linux 2.6.9-42.0.3.EL #1 Fri Oct 6 05:59:54 CDT 2006 i686 i686 i386 GNU/Linux

A DESCRIPTION OF THE PROBLEM :
When running inside a custom JNI library creating an instance of any awt class fails with an UnsatisfiedLinkError for libmawt.so.

The error was first seen with 1.6, but don't know if present in 1.5. Code which runs under 1.4.2 but will not run under 1.6.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile a C++ program which starts JNI. Inside the Java application, create a separate thread to instantiate awt classes, and then return. The first instantiation of any awt class fails with UnsatisfiedLinkError for libmawt.so.

Build the source by typing "./build.bash" on the Linux command line. The
example may be executed by typing "./run_oasis.bash". The "./clean.bash"
command cleans up the directory.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The application's Swing-based windows would be displayed on the screen. In the testcase a blank window should be displayed on the screen
ACTUAL -
Custom JNI library is found, but dependent library libmawt.so is not.
The following is output:
csh-3.00$ ./run_oasis.bash
callback from JNI
JavaJNIInt: initCPP() succeeded
JVM started in CPPJNIInt::init
Exception in thread "Thread-0" java.lang.UnsatisfiedLinkError: Can't
load library: /home/alink/sunbug/xawt/libmawt.so
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1650)
        at java.lang.Runtime.load0(Runtime.java:770)
        at java.lang.System.load(System.java:1005)
        at java.lang.ClassLoader$NativeLibrary.load(Native Method)
        at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1751)
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1668)
        at java.lang.Runtime.loadLibrary0(Runtime.java:823)
        at java.lang.System.loadLibrary(System.java:1030)
        at
sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:50)
        at java.security.AccessController.doPrivileged(Native Method)
        at
sun.awt.NativeLibLoader.loadLibraries(NativeLibLoader.java:38)
        at sun.awt.DebugHelper.<clinit>(DebugHelper.java:29)
        at java.awt.Component.<clinit>(Component.java:552)
        at JavaJNIInt.run(JavaJNIInt.java:41)
        at java.lang.Thread.run(Thread.java:619)


ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "Thread-0" java.lang.UnsatisfiedLinkError: Can't load library: /home/alink/alink_work3/Source/SimDesEng/exe/xawt/libmawt.so
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1650)
        at java.lang.Runtime.load0(Runtime.java:770)
        at java.lang.System.load(System.java:1005)
        at java.lang.ClassLoader$NativeLibrary.load(Native Method)
        at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1751)
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1668)
        at java.lang.Runtime.loadLibrary0(Runtime.java:823)
        at java.lang.System.loadLibrary(System.java:1030)
        at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:50)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.awt.Toolkit.loadLibraries(Toolkit.java:1594)
        at java.awt.Toolkit.<clinit>(Toolkit.java:1616)
        at java.awt.Color.<clinit>(Color.java:263)
        at MapBuilder.<init>(MapBuilder.java:71)
        at MapGraphics.<clinit>(MapGraphics.java:26)
        at cDataInterface.<clinit>(cDataInterface.java:245)
        at JavaJNIInt.run(JavaJNIInt.java:352)
        at java.lang.Thread.run(Thread.java:619)


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
Attached seperatly
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
No work around at this time, other than regressing to Java 1.4.2

Attempted work-arounds suggested by similar problem reported in Bug 6539705 with no improvement in behaviour.

Comments
Justification: Per earlier discussions - re-targeting to 7u55
06-01-2014

Solaris test case
26-12-2013

Linux test case
26-12-2013