{"record":{"id":"f79de720ab8f445e","repo":"java-native-access/jna","slug":"unsupported-empty-type","errorCode":null,"errorMessage":"Unsupported empty type: ","messagePattern":"Unsupported empty type: ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"contrib/platform/src/com/sun/jna/platform/win32/Advapi32Util.java","lineNumber":2173,"sourceCode":"                    case WinNT.REG_BINARY: {\n                        keyValues.put(nameString, new byte[0]);\n                        break;\n                    }\n                    case WinNT.REG_SZ:\n                    case WinNT.REG_EXPAND_SZ: {\n                        keyValues.put(nameString, new char[0]);\n                        break;\n                    }\n                    case WinNT.REG_MULTI_SZ: {\n                        keyValues.put(nameString, new String[0]);\n                        break;\n                    }\n                    case WinNT.REG_NONE: {\n                        keyValues.put(nameString, null);\n                        break;\n                    }\n                    default:\n                        throw new RuntimeException(\"Unsupported empty type: \"\n                            + lpType.getValue());\n                }\n                continue;\n            }\n\n            switch (lpType.getValue()) {\n                case WinNT.REG_QWORD: {\n                    keyValues.put(nameString, byteData.getLong(0));\n                    break;\n                }\n                case WinNT.REG_DWORD: {\n                    keyValues.put(nameString, byteData.getInt(0));\n                    break;\n                }\n                case WinNT.REG_SZ:\n                case WinNT.REG_EXPAND_SZ: {\n                    if (W32APITypeMapper.DEFAULT == W32APITypeMapper.UNICODE) {\n                        keyValues.put(nameString, byteData.getWideString(0));","sourceCodeStart":2155,"sourceCodeEnd":2191,"githubUrl":"https://github.com/java-native-access/jna/blob/d036ad9781adad4b66693e8fa7098e4ac665e0a3/contrib/platform/src/com/sun/jna/platform/win32/Advapi32Util.java#L2155-L2191","documentation":"When enumerating all values of a key (registryGetValues), the library handles the case where lpcbData is 0 (an empty value). For an empty value whose type is one of the known string/number kinds it returns a default empty object, and WinNT.REG_NONE maps to null; any other type with zero-length data reaches the default branch and throws this RuntimeException. It signals the value is empty AND of a type the library does not know how to represent emptily.","triggerScenarios":"Calling Advapi32Util.registryGetValues(key) or registryGetValues(root, key, samDesiredExtra) on a key containing a zero-byte value whose type is not one of REG_SZ/REG_EXPAND_SZ/REG_BINARY(most types accepted)/REG_DWORD/REG_QWORD/REG_MULTI_SZ/REG_NONE - e.g. an exotic or corrupted type like REG_LINK or REG_RESOURCE_LIST with zero data.","commonSituations":"Enumerating driver/hardware keys (HKLM\\SYSTEM\\CurrentControlSet\\Enum) that contain REG_RESOURCE_LIST / REG_FULL_RESOURCE_DESCRIPTOR values; keys created by third-party tools writing unusual types; corrupted registry entries.","solutions":["Catch RuntimeException per key when enumerating, log the offending value name/type, and continue with the remaining values.","Read only the specific values you need with typed getters instead of enumerating the whole key.","If you control the writer, use standard types (REG_SZ, REG_DWORD, REG_BINARY) and avoid exotic types like REG_LINK.","Update JNA - support for additional registry types in enumeration has improved in later releases."],"exampleFix":"// before\nTreeMap<String, Object> all = Advapi32Util.registryGetValues(root, key); // throws on exotic empty type\n\n// after\ntry {\n    TreeMap<String, Object> all = Advapi32Util.registryGetValues(root, key);\n} catch (RuntimeException e) {\n    LOG.warn(\"Skipping key with unsupported empty value type: {}\", key, e);\n}","handlingStrategy":"try-catch","validationCode":"// inspect value types before bulk enumeration\nAdvapi32Util.InfoKey info = Advapi32Util.registryQueryInfoKey(key, 0); // max value len/type info\n// per-value type check:\n// IntByReference lpType from Advapi32.INSTANCE.RegQueryValueEx(...) then compare against known types","typeGuard":null,"tryCatchPattern":"try { return Advapi32Util.registryGetValues(key); }\ncatch (RuntimeException e) { log.warn(\"Unsupported empty value type in {}: {}\", key, e.getMessage()); return Collections.emptyMap(); }","preventionTips":["Avoid hardware/Enum keys with resource-descriptor values when enumerating","Enumerate value names via registryGetKeys/RegEnumValue and decode selectively","Whitelist the value names you consume instead of trusting the whole key","Keep JNA updated for wider type coverage"],"tags":["windows-registry","unsupported-type","reg-none","jna"],"backgroundTag":"unsupported-enum-value","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"}