{"record":{"id":"aa0dd8b883c0b29b","repo":"java-native-access/jna","slug":"unsupported-array-argument-type-componenttype","errorCode":null,"errorMessage":"Unsupported array argument type: <componentType>","messagePattern":"Unsupported array argument type: <componentType>","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/com/sun/jna/Function.java","lineNumber":624,"sourceCode":"            }\n            if (byRef) {\n                Structure.autoWrite(ss);\n                Pointer[] pointers = new Pointer[ss.length + 1];\n                for (int i=0;i < ss.length;i++) {\n                    pointers[i] = ss[i] != null ? ss[i].getPointer() : null;\n                }\n                return new PointerArray(pointers);\n            } else if (ss.length == 0) {\n                throw new IllegalArgumentException(\"Structure array must have non-zero length\");\n            } else if (ss[0] == null) {\n                Structure.newInstance((Class<? extends Structure>) type).toArray(ss);\n                return ss[0].getPointer();\n            } else {\n                Structure.autoWrite(ss);\n                return ss[0].getPointer();\n            }\n        } else if (argClass.isArray()){\n            throw new IllegalArgumentException(\"Unsupported array argument type: \"\n                                               + argClass.getComponentType());\n        } else if (allowObjects) {\n            return arg;\n        } else if (!Native.isSupportedNativeType(arg.getClass())) {\n            throw new IllegalArgumentException(\"Unsupported argument type \"\n                                               + arg.getClass().getName()\n                                               + \" at parameter \" + index\n                                               + \" of function \" + getName());\n        }\n        return arg;\n    }\n\n    private boolean isPrimitiveArray(Class<?> argClass) {\n        return argClass.isArray()\n            && argClass.getComponentType().isPrimitive();\n    }\n\n    /**","sourceCodeStart":606,"sourceCodeEnd":642,"githubUrl":"https://github.com/java-native-access/jna/blob/d036ad9781adad4b66693e8fa7098e4ac665e0a3/src/com/sun/jna/Function.java#L606-L642","documentation":"When an argument is a Java array whose component type is not one of the array types JNA can marshal (primitive arrays, Pointer arrays, String arrays, Structure arrays, etc.), JNA throws IllegalArgumentException naming the unsupported component type.","triggerScenarios":"Passing e.g. Object[], List[], or arrays of arbitrary POJOs as arguments to a native function invocation.","commonSituations":"Passing boxed arrays like Integer[] instead of int[]; passing arrays of enums or custom objects without a Structure/TypeMapper conversion; generated bindings leaking Java-only array types.","solutions":["Convert to a supported array type: primitive array, Pointer[], String[], or Structure[]","Use a Structure or Memory buffer to encode complex element types manually","Register a TypeMapper/converter for the element type via library options"],"exampleFix":"// before\nf(new Integer[]{1,2,3});\n// after\nf(new int[]{1,2,3});","handlingStrategy":"validation","validationCode":"Class<?> c = arg.getClass();\nif (c.isArray() && !c.getComponentType().isPrimitive()\n    && c.getComponentType() != Pointer.class\n    && c.getComponentType() != String.class\n    && !Structure.class.isAssignableFrom(c.getComponentType())) {\n    throw new IllegalStateException(\"unsupported array type \" + c.getComponentType());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use primitive arrays, Pointer[], String[], or Structure[] only for native array arguments","Convert boxed arrays (Integer[], Double[]) to primitive arrays before native calls","Register a TypeMapper for custom element types instead of passing raw object arrays"],"tags":["jna","array","unsupported-argument-type","illegal-argument"],"backgroundTag":"unsupported-operation","analyzedSha":"d036ad9781adad4b66693e8fa7098e4ac665e0a3","analyzedAt":"2026-09-12T06:50:59.239Z","contentChangedAt":"2026-09-12T06:50:59.239Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}