JDK-6282388 : UnsatisfiedLinkError: InternAtom
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: linux
  • CPU: x86
  • Submitted: 2005-06-08
  • Updated: 2012-03-23
  • Resolved: 2005-08-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 6
6 b49Fixed
Related Reports
Relates :  
Description
Run the following simple test on Linux, 6.0b40+ workspace.  The following exception will be thrown:
Exception in thread "main" java.lang.UnsatisfiedLinkError: InternAtom
        at sun.awt.X11.XlibWrapper.InternAtom(Native Method)
        at sun.awt.X11.XAtom.<init>(XAtom.java:250)
        at sun.awt.X11.XAtom.<init>(XAtom.java:216)
        at sun.awt.X11.XAtom.get(XAtom.java:161)
        at sun.awt.X11.XToolkit.<clinit>(XToolkit.java:1783)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:163)
        at java.awt.Toolkit$2.run(Toolkit.java:816)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:808)
        at HeadlessAddAWTEventListenerTest.main(HeadlessAddAWTEventListenerTest.java:17)

Test:
import java.awt.*;
import java.awt.event.*;

public class HeadlessAddAWTEventListenerTest
{
    public static void main(String[] args)
    {
        System.setProperty("java.awt.headless", "true");
        Toolkit t = Toolkit.getDefaultToolkit();
    }
}

It works with b39.
###@###.### 2005-06-08 14:31:31 GMT

Comments
EVALUATION The problem mentioned in the description section has been already fixed in some previous Mustang builds. However, something more should be done. First, we need to ensure that proper toolkit is wrapped into HeadlessToolkit. Currently, if AWT_TOOLKIT env variable is set to MToolkit, then XToolkit is loaded anyway. That comes from the fact that when the native library is loaded, we check if the toolkit is headless or not and if it is - simply skip any environment variables values. Second, we need to ensure that any native method that can be called in Headless mode is presented in the native library (like XlibWrapper.InternAtom()). I have grepped java.awt, sun.awt and sun.awt.X11 packages and all the methods seem to be OK - either present in the native code or protected with something like `if (GraphicsEnvironment.isHeadless()) throw new HeadlessException()`. Also, I have found that some methods in XToolkit are not used at all (XToolkit.xGetDisplay(), XToolkit.makeColorModel()) and can be safely deleted.
05-08-2005

EVALUATION I've got a feeling that Headless toolkit never worked and doesn't work at all. For example, the following test which makes sense given the implementation of Headless toolkit (it has createCanvas method to create Canvas peer) throws the exception in all Linux toolkits on 1.5, 1.6, latest workspace (b40+). It does so with and without -Dawt.headless=true. import java.awt.*; public class Test { public static void main(String[] args) { Canvas canvas = new Canvas(); canvas.addNotify(); } } Looking at the Toolkit.getDefaultToolkit(), it seems the planned design was as follows: - have native toolkit backed by the native library headless/libmawt.so - the native toolkit is either MToolkit or XToolkit, depending on configuration - the method which make sense in that library are body-full, other are body-less - body-full are only the methods which do not require display or other libraries not available on X-less environment - this toolkit is wrapped into HeadlessToolkit, which protects body-less methods from being called by throwing HeadlessException Since headless toolkit was designed for MToolkit, not surprising it doesn't have entries for XToolkit. It seems like headless toolkit libmawt.so should contain the C files from XToolkit as well, since headless/libmawt.so is shared between headless versions of MToolkit/XToolkit. Also, it seems like XToolkit does native X-full calls even in headless mode, this must be fixed as well. The above design should be first confirmed by Windows behavior. ###@###.### 2005-06-08 15:00:06 GMT
08-06-2005