{"record":{"id":"d2367cd37b38d9c8","repo":"java-native-access/jna","slug":"no-support-for-os","errorCode":null,"errorMessage":"No support for \" + os","messagePattern":"No support for \" \\+ os","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"critical","filePath":"contrib/platform/src/com/sun/jna/platform/WindowUtils.java","lineNumber":745,"sourceCode":"         * 1.4/X11 implementation.\n         */\n        public static boolean requiresVisible;\n        public static final NativeWindowUtils INSTANCE;\n        static {\n            if (Platform.isWindows()) {\n                INSTANCE = new W32WindowUtils();\n            }\n            else if (Platform.isMac()) {\n                INSTANCE = new MacWindowUtils();\n            }\n            else if (Platform.isX11()) {\n                INSTANCE = new X11WindowUtils();\n                requiresVisible = System.getProperty(\"java.version\")\n                                        .matches(\"^1\\\\.4\\\\..*\");\n            }\n            else {\n                String os = System.getProperty(\"os.name\");\n                throw new UnsupportedOperationException(\"No support for \" + os);\n            }\n        }\n    }\n\n    private static NativeWindowUtils getInstance() {\n        return Holder.INSTANCE;\n    }\n\n    private static class W32WindowUtils extends NativeWindowUtils {\n        private HWND getHWnd(Component w) {\n            HWND hwnd = new HWND();\n            hwnd.setPointer(Native.getComponentPointer(w));\n            return hwnd;\n        }\n\n        /**\n         * W32 alpha will only work if <code>sun.java2d.noddraw</code>\n         * is set","sourceCodeStart":727,"sourceCodeEnd":763,"githubUrl":"https://github.com/java-native-access/jna/blob/d036ad9781adad4b66693e8fa7098e4ac665e0a3/contrib/platform/src/com/sun/jna/platform/WindowUtils.java#L727-L763","documentation":"WindowUtils' static initializer creates the platform singleton: W32WindowUtils on Windows, X11WindowUtils on X11/Mac-style checks, and otherwise throws UnsupportedOperationException('No support for <os.name>'). This is a fail-fast at class load — the library genuinely has no window-utility implementation for the detected OS.","triggerScenarios":"Any first use of WindowUtils (WindowUtils.getInstance, setWindowAlpha, setWindowMask, getAllWindows, etc.) on an OS whose os.name is neither Windows nor matches the X11 branch — e.g. macOS under a JNA version with no Mac handling, or exotic platforms.","commonSituations":"Deploying Swing window-shape/transparency features to macOS on an older JNA; exotic embedded Linux without X11 properties detected; misreported os.name via -Djava.vendor/-Dos.name overrides; trying to use WindowUtils in a headless server environment.","solutions":["Run on a supported OS: Windows, or Linux/X11 as expected by your JNA version.","Upgrade contrib/platform / JNA version — newer releases may recognize your platform (e.g. newer Mac handling via X11).","Check os.name handling: ensure the JVM's os.name is not overridden unexpectedly (-Dos.name=...).","Wrap first WindowUtils use in try-catch for UnsupportedOperationException to fail gracefully on unsupported OSes.","Provide your own NativeWindowUtils subclass and avoid the platform singleton."],"exampleFix":"// before\nWindowUtils.setWindowMask(frame, area); // throws on macOS in old JNA\n// after\nif (Platform.isWindows() || Platform.isX11()) {\n    WindowUtils.setWindowMask(frame, area);\n} else {\n    // fall back to non-shaped window\n}","handlingStrategy":"try-catch","validationCode":"String os = System.getProperty(\"os.name\");\nboolean supported = os != null && (os.contains(\"Windows\") || os.contains(\"Linux\") || os.contains(\"SunOS\") || os.contains(\"FreeBSD\"));","typeGuard":null,"tryCatchPattern":"try { WindowUtils.setWindowAlpha(w, 0.8f); } catch (UnsupportedOperationException e) { // platform unsupported, skip window effects }","preventionTips":["Never remove -Dos.name overrides without checking WindowUtils' platform branches","Upgrade JNA when adding support for macOS or newer platforms","Fail gracefully at app startup if WindowUtils.getInstance() throws","Limit WindowUtils usage to the OSes your JNA version supports"],"tags":["java","jna","unsupported-platform","class-initialization"],"backgroundTag":"unsupported-platform","analyzedSha":"d036ad9781adad4b66693e8fa7098e4ac665e0a3","analyzedAt":"2026-09-12T06:50:59.239Z","contentChangedAt":"2026-09-12T06:50:59.239Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}