openjdk/jdk · error · NullPointerException
Failed to retrieve atom name.
Error message
Failed to retrieve atom name.
What it means
XlibWrapper.XGetAtomName called XGetAtomName() and got NULL back — the X server does not know an atom with that numeric ID. The code prints 'Atom was <n>' to stderr and throws java.lang.NullPointerException('Failed to retrieve atom name.') to Java. Atoms exist only while the server keeps them; an unknown ID means the atom was never interned on this display or was created on a different server.
Source
Thrown at src/java.desktop/unix/native/libawt_xawt/xawt/XlibWrapper.c:1698
}
/*
* Class: sun_awt_X11_XlibWrapper
* Method: XGetAtomName
* Signature: (JJ)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL
Java_sun_awt_X11_XlibWrapper_XGetAtomName(JNIEnv *env, jclass clazz,
jlong display, jlong atom)
{
jstring string = NULL;
char* name;
AWT_CHECK_HAVE_LOCK_RETURN(NULL);
name = (char*) XGetAtomName((Display*)jlong_to_ptr(display), atom);
if (name == NULL) {
fprintf(stderr, "Atom was %d\n", (int)atom);
JNU_ThrowNullPointerException(env, "Failed to retrieve atom name.");
return NULL;
}
string = (*env)->NewStringUTF(env, (const char *)name);
XFree(name);
return string;
}
/*
* Class: sun_awt_X11_XlibWrapper
* Method: XMaxRequestSize
* Signature: (J)J
*/
JNIEXPORT jlong JNICALL
Java_sun_awt_X11_XlibWrapper_XMaxRequestSize(JNIEnv *env, jclass clazz,
jlong display) {View on GitHub (pinned to 88dfb74bbe)
Solutions
- Do not cache atom IDs across connections: re-intern with XInternAtom (XAtom.get()/XlibWrapper.XInternAtom) per display/session
- Validate the atom ID is nonzero and came from the same Display connection before calling XGetAtomName
- Catch the NullPointerException at the call site and degrade gracefully (treat property/atom as absent)
- Check for a stale DISPLAY / reconnected SSH X11 forwarding and restart the app against the current server
Example fix
// before
String name = XlibWrapper.XGetAtomName(display, atom); // may NPE if atom unknown
// after
String name = null;
try {
name = XlibWrapper.XGetAtomName(display, atom);
} catch (NullPointerException e) {
// atom not interned on this display — recover
} Defensive patterns
Strategy: try-catch
Validate before calling
// intern the name instead of trusting a cached numeric atom id long atom = XlibWrapper.XInternAtom(display, "_MY_PROPERTY", false); // creates-or-finds, never unknown
Try / catch
String name;
try {
name = XlibWrapper.XGetAtomName(display, atom);
} catch (NullPointerException npe) {
name = null; // atom not interned on this display — treat as absent
} Prevention
- Never cache atom IDs across Display connections or X server restarts
- Prefer XInternAtom over stored numeric values
- Re-derive atoms after DISPLAY changes or X11 forwarding reconnects
When it happens
Trigger: Java_sun_awt_X11_XlibWrapper_XGetAtomName being invoked with an atom value that came from a stale/closed display, was read from a property of another client that has exited (its atoms may be unregistered), or is simply garbage (uninitialized long). Xlib APIs like XGetAtomName return NULL for never-interned IDs.
Common situations: Debugging tools that cache atom IDs across display reconnects (X restart, ssh -X reconnection); window-manager interactions where the WM exited and its private atoms vanished; passing XA_* predefined values works, but custom names misspelled when interning earlier. The NPE surfaces in X11-based AWT internals or XlibWrapper users.
Related errors
- Couldn't find X Input Context\n
- Couldn't find X Input Context
- %s\n
- java.lang.instrument/-javaagent: unknown error\n
- Error: Out of memory in ADLC\n
AI-assisted analysis of openjdk/jdk@88dfb74bbe (2026-08-14).
Data as JSON: /api/errors/424b4717dbf26a74.
Report an issue: GitHub.