{"record":{"id":"56d48ff9e05e27c7","repo":"pinpoint-apm/pinpoint","slug":"unexpected-argument","errorCode":null,"errorMessage":"Unexpected argument: ","messagePattern":"Unexpected argument: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"warning","filePath":"agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/util/TypeUtils.java","lineNumber":48,"sourceCode":"        } else if (primitive == byte.class) {\n            return Byte.class;\n        } else if (primitive == char.class) {\n            return Character.class;\n        } else if (primitive == short.class) {\n            return Short.class;\n        } else if (primitive == int.class) {\n            return Integer.class;\n        } else if (primitive == long.class) {\n            return Long.class;\n        } else if (primitive == float.class) {\n            return Float.class;\n        } else if (primitive == double.class) {\n            return Double.class;\n        } else if (primitive == void.class) {\n            return Void.class;\n        }\n        \n        throw new IllegalArgumentException(\"Unexpected argument: \" + primitive);\n    }\n    \n    public static String[] toClassNames(Class<?>... classes) {\n        final int length = classes.length;\n        final String[] result = new String[length];\n        for (int i = 0; i < length; i++) {\n            result[i] = classes[i].getName();\n        }\n        \n        return result;\n    }\n        \n    public static <T extends Annotation> T findAnnotation(Annotation[] annotations, Class<T> type) {\n        for (Annotation a : annotations) {\n            if (a.annotationType() == type) {\n                return type.cast(a);\n            }\n        }","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/util/TypeUtils.java#L30-L66","documentation":"TypeUtils.getWrapperOf maps a primitive Class (int.class, void.class, ...) to its wrapper class. If passed a Class that is neither primitive nor any recognized primitive type, there is no wrapper and IllegalArgumentException is thrown.","triggerScenarios":"Calling TypeUtils.getWrapperOf(clazz) with a non-primitive Class (e.g. String.class) or an unrecognized primitive; the if/else chain covers all nine primitives, so anything else throws.","commonSituations":"Passing boxed classes or arbitrary parameter classes to getWrapperOf instead of checking Class.isPrimitive() first; generic signature-processing code that assumes primitives.","solutions":["Only call getWrapperOf when clazz.isPrimitive() is true","Add an isPrimitive() guard or use a switch on the primitive type before mapping","Handle non-primitive classes separately (they need no wrapper)"],"exampleFix":"// before\nClass<?> wrapper = TypeUtils.getWrapperOf(String.class); // throws\n// after\nClass<?> wrapper = clazz.isPrimitive() ? TypeUtils.getWrapperOf(clazz) : clazz;","handlingStrategy":"type-guard","validationCode":"if (!primitive.isPrimitive()) { throw new IllegalArgumentException(\"expected primitive: \" + primitive); }","typeGuard":"boolean isSupportedPrimitive(Class<?> c) { return c.isPrimitive() && c != void.class; }","tryCatchPattern":"try { wrapper = TypeUtils.getWrapperOf(c); } catch (IllegalArgumentException e) { wrapper = c; }","preventionTips":["Check Class.isPrimitive() before calling getWrapperOf","Treat non-primitive classes as already boxed (no mapping needed)","Cover all nine primitives in any custom mapping switch"],"tags":["java","reflection","argument-validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"744c3d3075e595656abb1ae331ad2c0e4c9eb996","analyzedAt":"2026-09-07T18:48:45.289Z","contentChangedAt":"2026-09-07T18:48:45.289Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}