{"record":{"id":"5529b07476a22f78","repo":"java-native-access/jna","slug":"the-query-s-property-enum-has-no-values","errorCode":null,"errorMessage":"The query's property enum has no values.","messagePattern":"The query's property enum has no values\\.","errorType":"validation","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"contrib/platform/src/com/sun/jna/platform/win32/COM/WbemcliUtil.java","lineNumber":180,"sourceCode":"        /**\n         * Query WMI for values, with a specified timeout.\n         *\n         * @param timeout\n         *            Number of milliseconds to wait for results before timing\n         *            out. If {@link IEnumWbemClassObject#WBEM_INFINITE} (-1),\n         *            will always wait for results. If a timeout occurs, throws\n         *            a {@link TimeoutException}.\n         *\n         * @return a WmiResult object containing the query results, wrapping an\n         *         EnumMap\n         *\n         * @throws TimeoutException\n         *             if the query times out before completion\n         */\n        public WmiResult<T> execute(int timeout) throws TimeoutException {\n            // Idiot check\n            if (getPropertyEnum().getEnumConstants().length < 1) {\n                throw new IllegalArgumentException(\"The query's property enum has no values.\");\n            }\n\n            // Connect to the server\n            IWbemServices svc = connectServer(getNameSpace());\n\n            // Send query\n            try {\n                IEnumWbemClassObject enumerator = selectProperties(svc, this);\n\n                try {\n                    return enumerateProperties(enumerator, getPropertyEnum(), timeout);\n                } finally {\n                    // Cleanup\n                    enumerator.Release();\n                }\n            } finally {\n                // Cleanup\n                svc.Release();","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/java-native-access/jna/blob/d036ad9781adad4b66693e8fa7098e4ac665e0a3/contrib/platform/src/com/sun/jna/platform/win32/COM/WbemcliUtil.java#L162-L198","documentation":"WbemcliUtil.WmiQuery.execute(int) validates that the query's generic property enum has at least one constant before connecting to WMI. If the enum class is empty, an IllegalArgumentException is thrown as an \"idiot check\" to fail fast on a malformed query definition.","triggerScenarios":"Creating a WmiQuery<T> where T is an enum with zero constants, then calling execute()/execute(timeout).","commonSituations":"Defining an empty enum placeholder while scaffolding code; generating the enum from a template or WMI class metadata that produced no fields; deleting all enum constants during refactoring.","solutions":["Define at least one enum constant matching a WMI query property you select.","Check that your WQL SELECT clause and the enum constants correspond.","Validate the enum at startup if queries are configured dynamically.","Catch IllegalArgumentException around execute() when query definitions come from external input."],"exampleFix":"// before\nenum Result {} // empty\nnew WbemcliUtil.WmiQuery<>(\"ROOT\\\\CIMV2\", \"SELECT * FROM Win32_OperatingSystem\", Result.class).execute();\n// after\nenum Result { CAPTION, VERSION }\nnew WbemcliUtil.WmiQuery<>(\"ROOT\\\\CIMV2\", \"SELECT Caption,Version FROM Win32_OperatingSystem\", Result.class).execute();","handlingStrategy":"validation","validationCode":"if (query.getPropertyEnum().getEnumConstants().length == 0) {\n    throw new IllegalStateException(\"Query enum must define at least one property\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    query.execute();\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"no values\")) { /* fix enum definition */ }\n}","preventionTips":["Never ship placeholder empty enums","Keep enum constants in sync with WQL SELECT columns","Validate query definitions at startup"],"tags":["windows","wmi","jna","enum"],"backgroundTag":"empty-required-field","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"}