{"record":{"id":"c0bed0c186313f61","repo":"openjdk/jdk","slug":"couldn-t-find-x-input-context","errorCode":null,"errorMessage":"Couldn't find X Input Context\n","messagePattern":"Couldn't find X Input Context\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/java.desktop/aix/native/libawt_xawt/awt/awt_InputMethod.c","lineNumber":338,"sourceCode":"\n    if (pX11IMData->callbacks)\n        free((void *)pX11IMData->callbacks);\n\n    if (env) {\n        (*env)->DeleteGlobalRef(env, pX11IMData->x11inputmethod);\n    }\n\n    free((void *)pX11IMData);\n}\n\n/*\n * Sets or unsets the focus to the given XIC.\n */\nstatic void\nsetXICFocus(XIC ic, unsigned short req)\n{\n    if (ic == NULL) {\n        (void)fprintf(stderr, \"Couldn't find X Input Context\\n\");\n        return;\n    }\n    if (req == 1)\n        XSetICFocus(ic);\n    else\n        XUnsetICFocus(ic);\n}\n\n/*\n * Sets the focus window to the given XIC.\n */\nstatic void\nsetXICWindowFocus(XIC ic, Window w)\n{\n    if (ic == NULL) {\n        (void)fprintf(stderr, \"Couldn't find X Input Context\\n\");\n        return;\n    }","sourceCodeStart":320,"sourceCodeEnd":356,"githubUrl":"https://github.com/openjdk/jdk/blob/88dfb74bbeefcf2b0aa11835183bcd949998fc8f/src/java.desktop/aix/native/libawt_xawt/awt/awt_InputMethod.c#L320-L356","documentation":"X11 input-method support in AWT (libawt_xawt, AIX build): setXICFocus was called with a null XIC (X Input Context). The function cannot set or unset input-method focus without a context, so it prints this to stderr and returns — the result is that input-method focus handling silently does nothing for that component.","triggerScenarios":"An AWT/X11 component calls setXICFocus before its XIC was created (XCreateIC failed or has not run yet), or after the XIC was destroyed (when X11InputMethod.dispose runs) — e.g. focus events racing with input-method activation/deactivation, or the XIM server (e.g. ibus/fcitx) being unavailable so XCreateIC returned null.","commonSituations":"Running Java GUI apps on X11 with a missing or crashing input-method framework (XMODIFIERS unset or pointing to a dead IM server); focus changes arriving during IM teardown; AWT/XAWT-specific bugs in focus listeners calling setXICFocus on a disposed peer.","solutions":["Ensure a working X input method server is running and XMODIFIERS is set correctly (e.g. @im=ibus) before starting the Java app","Check that focus listeners / custom peers do not call setXICFocus after the component's input context is disposed (null-check the XIC before calling)","If not using input methods, unset XMODIFIERS or use GDK/QT-independent env so AWT does not attempt XIC creation at all","Upgrade the JDK: known AWT races around XIC creation/focus have been fixed over time; report persistent occurrences with a repro to the JDK/XIM stack"],"exampleFix":"// before ( JNI focus path )\nsetXICFocus(pX11IMData->current_ic, 1);\n\n// after\nif (pX11IMData != NULL && pX11IMData->current_ic != NULL) {\n    setXICFocus(pX11IMData->current_ic, 1);\n}","handlingStrategy":"validation","validationCode":"// Guard every focus call against a missing input context:\nif (pX11IMData != NULL && pX11IMData->current_ic != NULL) {\n    setXICFocus(pX11IMData->current_ic, req);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only call setXICFocus after XCreateIC succeeded (activateInputContext confirmed)","Run with a working IM server and correct XMODIFIERS, or unset XMODIFIERS when IMEs are not needed"],"tags":["java-desktop","awt","x11","input-method","xim"],"backgroundTag":null,"analyzedSha":"88dfb74bbeefcf2b0aa11835183bcd949998fc8f","analyzedAt":"2026-08-14T11:45:09.665Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}