java-native-access/jna · warning · IllegalStateException
NOT IMPLEMENTED: getValue
Error message
NOT IMPLEMENTED: getValue(%s) (Array: %b, Count: %d)
What it means
This IllegalStateException is thrown by Winevt.EVT_VARIANT.setValue when setValue() is called on a variant whose EvtVarType falls into a branch the library has not implemented for writing — file time, event handle, SYSTEMTIME, GUID, SID, size_t, or the default catch-all. The message includes the type, whether the variant is an array, and the count to aid diagnosis. It signals an incomplete library feature, not bad input per se.
Solutions
- Do not call setValue() on these variant types — restructure code so the value is set through the native API (e.g. EvtSetChannelConfigProperty with a properly built EVT_VARIANT) or leave the property unchanged
- Convert the value to a supported representation (e.g. byte[]) only if the type branch actually supports it; otherwise avoid the write
- Upgrade JNA to the newest version to check whether write support for the type was added
- Catch IllegalStateException around setValue to detect unsupported types at runtime and skip/logging the property
Example fix
// before
if (prop.type == EvtVarTypeGuid) { variant.setValue(guid); }
// after
if (prop.type == EvtVarTypeGuid) {
throw new UnsupportedOperationException("Writing GUID-valued properties is not supported by EVT_VARIANT.setValue");
} Defensive patterns
Strategy: validation
Validate before calling
switch (variant.type) {
case Winevt.EvtVarTypeFileTime:
case Winevt.EvtVarTypeEvtHandle:
case Winevt.EvtVarTypeSysTime:
case Winevt.EvtVarTypeGuid:
case Winevt.EvtVarTypeSid:
case Winevt.EvtVarTypeSizeT:
throw new IllegalStateException("setValue not supported for " + variant.type);
} Type guard
boolean isSettable(EVT_VARIANT v) {
switch (v.type) {
case Winevt.EvtVarTypeFileTime: case Winevt.EvtVarTypeEvtHandle:
case Winevt.EvtVarTypeSysTime: case Winevt.EvtVarTypeGuid:
case Winevt.EvtVarTypeSid: case Winevt.EvtVarTypeSizeT:
return false;
default: return true;
}
} Try / catch
try {
variant.setValue(val);
} catch (IllegalStateException e) {
log.info("Skipping unsupported variant write: " + e.getMessage());
} Prevention
- Check EvtVarType before any setValue call
- Never round-trip read values of exotic types back through setValue
- Track JNA releases for expanded EVT_VARIANT write support
When it happens
Trigger: Calling setValue() on an EVT_VARIANT whose type is EvtVarTypeFileTime, EvtVarTypeEvtHandle, EvtVarTypeSysTime, EvtVarTypeGuid, EvtVarTypeSid, EvtVarTypeSizeT or any unhandled type, whether scalar or array (isArray()/Count are echoed in the message).
Common situations: Attempting to modify channel/config properties that hold GUIDs or timestamps; writing back values read from event XML that were rendered as WinNT.HANDLE, FILETIME or GUID structures; running a JNA version where write support for these types was never added.
Related errors
- Maximum argument count is
- must be set from BOOL/BOOL[]
- must be set from byte[]
- must be set from byte/byte[]
- must be set from double/double[]
AI-assisted analysis of java-native-access/jna@d036ad9781 (2026-09-12).
Data as JSON: /api/errors/a3c6cbb4e065ca97.
Report an issue: GitHub.
Appendix: source
Thrown at contrib/platform/src/com/sun/jna/platform/win32/Winevt.java:459
if (value.getClass().isArray() && value.getClass().getComponentType() == byte.class) {
Type = type.ordinal();
Memory mem = new Memory(((byte[]) value).length * 1);
mem.write(0, (byte[]) value, 0, ((byte[]) value).length);
holder = mem;
Count = 0;
field1.writeField("pointerValue", mem);
} else {
throw new IllegalArgumentException(type.name() + " must be set from byte[]");
}
break;
case EvtVarTypeFileTime:
case EvtVarTypeEvtHandle:
case EvtVarTypeSysTime:
case EvtVarTypeGuid:
case EvtVarTypeSid:
case EvtVarTypeSizeT:
default:
throw new IllegalStateException(String.format("NOT IMPLEMENTED: getValue(%s) (Array: %b, Count: %d)", type, isArray(), Count));
}
}
write();
}
/**
* @return value contained in the EVT_VARIANT
*/
public Object getValue() {
EVT_VARIANT_TYPE type = getVariantType();
switch (type) {
case EvtVarTypeAnsiString:
return isArray() ? field1.getPointer().getPointer(0).getStringArray(0, Count) : field1.getPointer().getPointer(0).getString(0);
case EvtVarTypeBoolean:
if (isArray()) {
int[] rawValue = field1.getPointer().getPointer(0).getIntArray(0, Count);
WinDef.BOOL[] result = new WinDef.BOOL[rawValue.length];
for (int i = 0; i < result.length; i++) {View on GitHub (pinned to d036ad9781)