{"record":{"id":"fc19b14d8d925597","repo":"java-native-access/jna","slug":"cannot-get-prop-name-property","errorCode":null,"errorMessage":"Cannot get <prop_name> property.","messagePattern":"Cannot get <prop_name> property\\.","errorType":"exception","errorClass":"X11Exception","httpStatus":null,"severity":"error","filePath":"contrib/x11/src/jnacontrib/x11/api/X.java","lineNumber":1018,"sourceCode":"            X11.AtomByReference xa_ret_type_ref = new X11.AtomByReference();\n            IntByReference ret_format_ref = new IntByReference();\n            NativeLongByReference ret_nitems_ref = new NativeLongByReference();\n            NativeLongByReference ret_bytes_after_ref = new NativeLongByReference();\n            PointerByReference ret_prop_ref = new PointerByReference();\n\n            NativeLong long_offset = new NativeLong(0);\n            NativeLong long_length = new NativeLong(MAX_PROPERTY_VALUE_LEN / 4);\n\n            /* MAX_PROPERTY_VALUE_LEN / 4 explanation (XGetWindowProperty manpage):\n             *\n             * long_length = Specifies the length in 32-bit multiples of the\n             *               data to be retrieved.\n             */\n            if (x11.XGetWindowProperty(display.x11Display, x11Window, xa_prop_name, long_offset, long_length, false,\n                    xa_prop_type, xa_ret_type_ref, ret_format_ref,\n                    ret_nitems_ref, ret_bytes_after_ref, ret_prop_ref) != X11.Success) {\n                String prop_name = x11.XGetAtomName(display.x11Display, xa_prop_name);\n                throw new X11Exception(\"Cannot get \" + prop_name + \" property.\");\n            }\n\n            X11.Atom xa_ret_type = xa_ret_type_ref.getValue();\n            Pointer ret_prop = ret_prop_ref.getValue();\n\n            if (xa_ret_type == null) {\n                //the specified property does not exist for the specified window\n                return null;\n            }\n\n            if( xa_ret_type == null ){\n                //the specified property does not exist for the specified window\n                return null;\n            }\n\n            if( xa_ret_type == null ){\n                //the specified property does not exist for the specified window\n                return null;","sourceCodeStart":1000,"sourceCodeEnd":1036,"githubUrl":"https://github.com/java-native-access/jna/blob/d036ad9781adad4b66693e8fa7098e4ac665e0a3/contrib/x11/src/jnacontrib/x11/api/X.java#L1000-L1036","documentation":"Window.getProperty is the core XGetWindowProperty wrapper. When the X call itself fails (return code != Success), the method resolves the property atom's name via XGetAtomName and throws this X11Exception naming the property whose value could not be retrieved.","triggerScenarios":"Any property read (getIntProperty, getStringProperty, getUtf8ListProperty, etc.) where XGetWindowProperty returns a non-Success status: bad window handle, invalid/unknown atom, or X connection errors.","commonSituations":"Querying a property atom that doesn't exist on the target window, using a stale Window/x11Window id after the window was closed, or an X server that has dropped the connection.","solutions":["Verify the atom exists with xprop or xwininfo -tree before querying","Re-fetch the window handle; the target window may have been destroyed","Use XInternAtom to confirm the atom name is spelled correctly (case-sensitive)","Catch X11Exception per property so a missing optional property doesn't abort the whole flow"],"exampleFix":"// before\nString name = win.getStringProperty(x11.XInternAtom(display, \"_NET_WM_NAME\", false));\n// after\nString name;\ntry {\n    name = win.getStringProperty(x11.XInternAtom(display, \"_NET_WM_NAME\", false));\n} catch (X11Exception e) {\n    name = \"\"; // property unavailable on this window\n}","handlingStrategy":"try-catch","validationCode":"// confirm the property exists on the window before reading\nProcess p = Runtime.getRuntime().exec(new String[]{\"xprop\",\"-id\", String.valueOf(winid), propName});\nboolean exists = p.waitFor() == 0;","typeGuard":null,"tryCatchPattern":"try {\n    value = win.getStringProperty(atom);\n} catch (X11Exception e) {\n    if (e.getMessage().contains(\"Cannot get\")) {\n        value = null; // property not present on this window\n    } else {\n        throw e;\n    }\n}","preventionTips":["Refresh window handles before property reads; windows get destroyed","Spell atom names exactly (case-sensitive)","Treat missing properties as expected for non-EWMH WMs","Check X connection health before batch property reads"],"tags":["x11","xgetwindowproperty","property","badatom"],"backgroundTag":"api-error-response","analyzedSha":"d036ad9781adad4b66693e8fa7098e4ac665e0a3","analyzedAt":"2026-09-12T06:50:59.239Z","contentChangedAt":"2026-09-12T06:50:59.239Z","schemaVersion":2},"datasetVersion":"2026-09-19T12:17:13.211Z"}