{"record":{"id":"42d96833be457020","repo":"java-native-access/jna","slug":"must-be-set-from-double-double","errorCode":null,"errorMessage":" must be set from double/double[]","messagePattern":" must be set from double/double\\[\\]","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"contrib/platform/src/com/sun/jna/platform/win32/Winevt.java","lineNumber":437,"sourceCode":"                            field1.writeField(\"floatValue\", value);\n                        } else {\n                            throw new IllegalArgumentException(type.name() + \" must be set from float/float[]\");\n                        }\n                        break;\n                    case EvtVarTypeDouble:\n                        if (value.getClass().isArray() && value.getClass().getComponentType() == double.class) {\n                            Type = type.ordinal() | EVT_VARIANT_TYPE_ARRAY;\n                            Memory mem = new Memory(((double[]) value).length * 4);\n                            mem.write(0, (double[]) value, 0, ((double[]) value).length);\n                            holder = mem;\n                            Count = 0;\n                            field1.writeField(\"pointerValue\", mem);\n                        } else if (value.getClass() == double.class) {\n                            Type = type.ordinal();\n                            Count = 0;\n                            field1.writeField(\"doubleVal\", value);\n                        } else {\n                            throw new IllegalArgumentException(type.name() + \" must be set from double/double[]\");\n                        }\n                        break;\n                    case EvtVarTypeBinary:\n                        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:","sourceCodeStart":419,"sourceCodeEnd":455,"githubUrl":"https://github.com/java-native-access/jna/blob/d036ad9781adad4b66693e8fa7098e4ac665e0a3/contrib/platform/src/com/sun/jna/platform/win32/Winevt.java#L419-L455","documentation":"For EvtVarTypeDouble, setValue requires a primitive double (getClass() == double.class, stored in doubleVal) or a double[] array. Other types raise IllegalArgumentException '<TypeName> must be set from double/double[]'.","triggerScenarios":"setValue(EVT_VARIANT_TYPE.EvtVarTypeDouble, floatValue) — a float passed for a double field; or a Float/BigDecimal wrapper whose class fails the exact getClass() == double.class check.","commonSituations":"Values from Float.parseFloat or float math; BigDecimal values from JSON/decimal parsing; boxed numbers from collections passed via Object.","solutions":["Cast to double: (double) floatValue — widening is lossless","Convert BigDecimal with bigDecimal.doubleValue(), Float with floatVal.doubleValue() (or pass primitive)","Convert Float[]/List<Float> to double[] with element-wise casting"],"exampleFix":"// before\nvariant.setValue(EVT_VARIANT_TYPE.EvtVarTypeDouble, floatValue); // Float wrapper\n// after\nvariant.setValue(EVT_VARIANT_TYPE.EvtVarTypeDouble, floatValue.doubleValue());","handlingStrategy":"type-guard","validationCode":"if (value instanceof Float) value = (double) ((Float) value).floatValue();\nelse if (value instanceof BigDecimal) value = ((BigDecimal) value).doubleValue();","typeGuard":"boolean isDoubleVariant(Object v) {\n    return v != null && (v.getClass() == double.class || v.getClass() == double[].class);\n}","tryCatchPattern":"try {\n    variant.setValue(EVT_VARIANT_TYPE.EvtVarTypeDouble, value);\n} catch (IllegalArgumentException e) {\n    variant.setValue(EVT_VARIANT_TYPE.EvtVarTypeDouble, ((Number) value).doubleValue());\n}","preventionTips":["Widen floats to double explicitly before setting EvtVarTypeDouble","Convert BigDecimal via doubleValue() before the call","Convert boxed Float/Double collections to primitive double[]"],"tags":["windows-eventlog","jna","type-mismatch"],"backgroundTag":"type-mismatch","analyzedSha":"d036ad9781adad4b66693e8fa7098e4ac665e0a3","analyzedAt":"2026-09-12T06:50:59.239Z","contentChangedAt":"2026-09-12T06:50:59.239Z","schemaVersion":2},"datasetVersion":"2026-09-19T12:17:13.211Z"}