{"record":{"id":"a3c6cbb4e065ca97","repo":"java-native-access/jna","slug":"not-implemented-getvalue-s-array-b-count-d","errorCode":null,"errorMessage":"NOT IMPLEMENTED: getValue(%s) (Array: %b, Count: %d)","messagePattern":"NOT IMPLEMENTED: getValue\\((.+?)\\) \\(Array: %b, Count: (.+?)\\)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"warning","filePath":"contrib/platform/src/com/sun/jna/platform/win32/Winevt.java","lineNumber":459,"sourceCode":"                        if (value.getClass().isArray() && value.getClass().getComponentType() == byte.class) {\n                            Type = type.ordinal();\n                            Memory mem = new Memory(((byte[]) value).length * 1);\n                            mem.write(0, (byte[]) value, 0, ((byte[]) value).length);\n                            holder = mem;\n                            Count = 0;\n                            field1.writeField(\"pointerValue\", mem);\n                        } else {\n                            throw new IllegalArgumentException(type.name() + \" must be set from byte[]\");\n                        }\n                        break;\n                    case EvtVarTypeFileTime:\n                    case EvtVarTypeEvtHandle:\n                    case EvtVarTypeSysTime:\n                    case EvtVarTypeGuid:\n                    case EvtVarTypeSid:\n                    case EvtVarTypeSizeT:\n                    default:\n                        throw new IllegalStateException(String.format(\"NOT IMPLEMENTED: getValue(%s) (Array: %b, Count: %d)\", type, isArray(), Count));\n                }\n            }\n            write();\n        }\n\n        /**\n         * @return value contained in the EVT_VARIANT\n         */\n        public Object getValue() {\n            EVT_VARIANT_TYPE type = getVariantType();\n            switch (type) {\n                case EvtVarTypeAnsiString:\n                    return isArray() ? field1.getPointer().getPointer(0).getStringArray(0, Count) : field1.getPointer().getPointer(0).getString(0);\n                case EvtVarTypeBoolean:\n                    if (isArray()) {\n                        int[] rawValue = field1.getPointer().getPointer(0).getIntArray(0, Count);\n                        WinDef.BOOL[] result = new WinDef.BOOL[rawValue.length];\n                        for (int i = 0; i < result.length; i++) {","sourceCodeStart":441,"sourceCodeEnd":477,"githubUrl":"https://github.com/java-native-access/jna/blob/d036ad9781adad4b66693e8fa7098e4ac665e0a3/contrib/platform/src/com/sun/jna/platform/win32/Winevt.java#L441-L477","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"// before\nif (prop.type == EvtVarTypeGuid) { variant.setValue(guid); }\n// after\nif (prop.type == EvtVarTypeGuid) {\n    throw new UnsupportedOperationException(\"Writing GUID-valued properties is not supported by EVT_VARIANT.setValue\");\n}","handlingStrategy":"validation","validationCode":"switch (variant.type) {\n    case Winevt.EvtVarTypeFileTime:\n    case Winevt.EvtVarTypeEvtHandle:\n    case Winevt.EvtVarTypeSysTime:\n    case Winevt.EvtVarTypeGuid:\n    case Winevt.EvtVarTypeSid:\n    case Winevt.EvtVarTypeSizeT:\n        throw new IllegalStateException(\"setValue not supported for \" + variant.type);\n}","typeGuard":"boolean isSettable(EVT_VARIANT v) {\n    switch (v.type) {\n        case Winevt.EvtVarTypeFileTime: case Winevt.EvtVarTypeEvtHandle:\n        case Winevt.EvtVarTypeSysTime: case Winevt.EvtVarTypeGuid:\n        case Winevt.EvtVarTypeSid: case Winevt.EvtVarTypeSizeT:\n            return false;\n        default: return true;\n    }\n}","tryCatchPattern":"try {\n    variant.setValue(val);\n} catch (IllegalStateException e) {\n    log.info(\"Skipping unsupported variant write: \" + e.getMessage());\n}","preventionTips":["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"],"tags":["jna","windows-eventlog","not-implemented","unsupported-operation"],"backgroundTag":"method-not-implemented","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"}