java-native-access/jna · error · java.lang.IllegalArgumentException
The query's property enum has no values.
Error message
The query's property enum has no values.
What it means
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.
Source
Thrown at contrib/platform/src/com/sun/jna/platform/win32/COM/WbemcliUtil.java:180
/**
* Query WMI for values, with a specified timeout.
*
* @param timeout
* Number of milliseconds to wait for results before timing
* out. If {@link IEnumWbemClassObject#WBEM_INFINITE} (-1),
* will always wait for results. If a timeout occurs, throws
* a {@link TimeoutException}.
*
* @return a WmiResult object containing the query results, wrapping an
* EnumMap
*
* @throws TimeoutException
* if the query times out before completion
*/
public WmiResult<T> execute(int timeout) throws TimeoutException {
// Idiot check
if (getPropertyEnum().getEnumConstants().length < 1) {
throw new IllegalArgumentException("The query's property enum has no values.");
}
// Connect to the server
IWbemServices svc = connectServer(getNameSpace());
// Send query
try {
IEnumWbemClassObject enumerator = selectProperties(svc, this);
try {
return enumerateProperties(enumerator, getPropertyEnum(), timeout);
} finally {
// Cleanup
enumerator.Release();
}
} finally {
// Cleanup
svc.Release();View on GitHub (pinned to d036ad9781)
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.
Example fix
// before
enum Result {} // empty
new WbemcliUtil.WmiQuery<>("ROOT\\CIMV2", "SELECT * FROM Win32_OperatingSystem", Result.class).execute();
// after
enum Result { CAPTION, VERSION }
new WbemcliUtil.WmiQuery<>("ROOT\\CIMV2", "SELECT Caption,Version FROM Win32_OperatingSystem", Result.class).execute(); Defensive patterns
Strategy: validation
Validate before calling
if (query.getPropertyEnum().getEnumConstants().length == 0) {
throw new IllegalStateException("Query enum must define at least one property");
} Try / catch
try {
query.execute();
} catch (IllegalArgumentException e) {
if (e.getMessage().contains("no values")) { /* fix enum definition */ }
} Prevention
- Never ship placeholder empty enums
- Keep enum constants in sync with WQL SELECT columns
- Validate query definitions at startup
When it happens
Trigger: Creating a WmiQuery<T> where T is an enum with zero constants, then calling execute()/execute(timeout).
Common situations: 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.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- Got a WMI timeout when infinite wait was specified. This sho
- No results after <timeout> ms.
- Failed to enumerate results.
- Failed to create WbemLocator object.
- Could not set proxy blanket.
AI-assisted analysis of java-native-access/jna@d036ad9781 (2026-09-12).
Data as JSON: /api/errors/5529b07476a22f78.
Report an issue: GitHub.