java-native-access/jna · error · RuntimeException
Unsupported type:
Error message
Unsupported type:
What it means
registryGetValues enumerates each value, switches on the type reported by RegQueryValueEx, and decodes REG_SZ/REG_EXPAND_SZ, REG_DWORD, REG_QWORD, REG_BINARY and REG_MULTI_SZ into Java objects. A value whose type falls outside this set (e.g. REG_LINK, REG_RESOURCE_LIST, REG_FULL_RESOURCE_DESCRIPTOR, REG_RESOURCE_REQUIREMENTS_LIST) hits the default branch and throws this RuntimeException naming the numeric type. The library refuses to guess a decoding for unknown registry types.
Source
Thrown at contrib/platform/src/com/sun/jna/platform/win32/Advapi32Util.java:2230
s = byteData.getString(offset);
offset += s.length();
offset += 1;
}
if (s.length() == 0) {
// A sequence of null-terminated strings,
// terminated by an empty string (\0).
// => The first empty string terminates the
break;
} else {
result.add(s);
}
}
keyValues.put(nameString, result.toArray(new String[0]));
break;
}
default:
throw new RuntimeException("Unsupported type: "
+ lpType.getValue());
}
}
return keyValues;
}
/**
* Get a table of registry values.
*
* @param root
* Registry root.
* @param keyPath
* Regitry key path.
* @return Table of values.
*/
public static TreeMap<String, Object> registryGetValues(HKEY root,
String keyPath) {
return registryGetValues(root, keyPath, 0);View on GitHub (pinned to d036ad9781)
Solutions
- Catch RuntimeException around registryGetValues per key and skip/log keys containing unsupported types.
- Read individual values with registryGetValue and only the names you expect, avoiding unknown types.
- Use Advapi32.registryQueryInfoKey yourself to inspect types and handle unsupported ones explicitly before decoding.
- Update JNA - newer versions handle more registry types during enumeration.
Example fix
// before
TreeMap<String, Object> vals = Advapi32Util.registryGetValues(root, key); // throws on REG_RESOURCE_LIST
// after
TreeMap<String, Object> vals;
try {
vals = Advapi32Util.registryGetValues(root, key);
} catch (RuntimeException e) {
LOG.debug("Key {} has values with unsupported types, skipping", key);
vals = new TreeMap<>();
} Defensive patterns
Strategy: try-catch
Validate before calling
// pre-check each value's type with RegQueryValueEx and skip unsupported ones:
Memory lpData = new Memory(4); IntByReference lpcb = new IntByReference(0);
IntByReference lpType = new IntByReference();
Advapi32.INSTANCE.RegQueryValueEx(hKey, valueName, 0, lpType, (Pointer) null, lpcb);
boolean supported = lpType.getValue() == WinNT.REG_SZ || lpType.getValue() == WinNT.REG_EXPAND_SZ
|| lpType.getValue() == WinNT.REG_MULTI_SZ || lpType.getValue() == WinNT.REG_DWORD
|| lpType.getValue() == WinNT.REG_QWORD || lpType.getValue() == WinNT.REG_BINARY; Try / catch
try { return Advapi32Util.registryGetValues(root, key, 0); }
catch (RuntimeException e) { log.debug("Skipping key {} with unsupported value types", key); return Collections.emptyMap(); } Prevention
- Skip known-problematic keys (Services subkeys, hardware Enum) during hive walks
- Decode value-by-value with registryGetValue and handle unknown types per name
- Log the numeric type from the message for diagnosis
- Keep JNA updated; newer versions extend the supported type set
When it happens
Trigger: Calling Advapi32Util.registryGetValues(key) or registryGetValues(root, key, samDesiredExtra) on a key that contains a non-empty value of a type not in the supported set (REG_LINK, REG_RESOURCE_LIST, REG_FULL_RESOURCE_DESCRIPTOR, REG_RESOURCE_REQUIREMENTS_LIST, or vendor-defined types).
Common situations: Bulk-enumerating HKLM\SYSTEM\CurrentControlSet\Services or hardware Enum keys that commonly store resource-descriptor values; reading keys written by drivers or OEM tools using private types; security-scanning scripts walking whole hives.
Related errors
- Unsupported empty type:
- Unexpected registry type + lpType.getValue() + , expected RE
- Unexpected registry type {}, expected REG_SZ
- Unexpected registry type {}, expected REG_BINARY
- Unexpected registry type {}, expected REG_DWORD
AI-assisted analysis of java-native-access/jna@d036ad9781 (2026-09-12).
Data as JSON: /api/errors/96d824d15f1e62d0.
Report an issue: GitHub.