JetBrains/intellij-community · error · EvaluateException
Cannot construct wrapper object for value of type {}: Unable
Error message
Cannot construct wrapper object for value of type {}: Unable to find either valueOf() or constructor method What it means
Thrown by BoxingEvaluator.convertToWrapper when it tries to box a primitive value into its wrapper type (e.g. int to Integer) but can find neither a static valueOf(primitive) method nor a constructor with matching signature on the wrapper class in the debuggee VM. This happens on very old or non-standard JVM class libraries where the wrapper API differs.
Source
Thrown at java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/BoxingEvaluator.java:55
if (primitiveType != null) {
return convertToWrapper(context, primitiveValue, primitiveType.getBoxedTypeName());
}
}
return value;
}
private static Value convertToWrapper(EvaluationContextImpl context, PrimitiveValue value, String wrapperTypeName) throws
EvaluateException {
final DebugProcessImpl process = context.getDebugProcess();
final ClassType wrapperClass = (ClassType)process.findClass(context, wrapperTypeName, null);
final String methodSignature = "(" + JVMNameUtil.getPrimitiveSignature(value.type().name()) + ")L" + wrapperTypeName.replace('.', '/') + ";";
Method method = DebuggerUtils.findMethod(wrapperClass, "valueOf", methodSignature);
if (method == null) { // older JDK version
method = DebuggerUtils.findMethod(wrapperClass, JVMNameUtil.CONSTRUCTOR_NAME, methodSignature);
}
if (method == null) {
throw new EvaluateException("Cannot construct wrapper object for value of type " + value.type() + ": Unable to find either valueOf() or constructor method");
}
Method finalMethod = method;
List<PrimitiveValue> args = Collections.singletonList(value);
return context.computeAndKeep(() -> process.invokeMethod(context, wrapperClass, finalMethod, args, true));
}
}
View on GitHub (pinned to be881553f2)
Solutions
- Run the debuggee on a standard modern JDK where java.lang wrappers define valueOf
- Rewrite the evaluated expression to call Integer.valueOf(x) explicitly or use the primitive type directly
- Avoid mixing primitive and wrapper types in the evaluated expression
Example fix
// before (evaluation input): Integer x = 5; // after (evaluation input): int x = 5;
Defensive patterns
Strategy: validation
Validate before calling
Method m = DebuggerUtils.findMethod(wrapperClass, "valueOf", sig);
if (m == null) m = DebuggerUtils.findMethod(wrapperClass, "<init>", sig);
if (m == null) {
// skip boxing: use the primitive value directly or a modern JVM
} Try / catch
try {
return process.invokeMethod(context, wrapperClass, finalMethod, args, true);
} catch (EvaluateException e) {
// fall back to primitive arithmetic without boxing
} Prevention
- Debug on a standard JDK whose java.lang wrappers define valueOf
- Keep evaluated expressions in primitive types to avoid implicit boxing
When it happens
Trigger: An evaluation assigns a primitive to a variable/parameter of wrapper type (autoboxing), forcing BoxingEvaluator to look up 'valueOf' or '<init>' with signature '(X)Ljava/lang/Integer;' on the loaded wrapper class; DebuggerUtils.findMethod returns null for both lookups on old JDK versions.
Common situations: Evaluating expressions that rely on autoboxing while debugging on JDK 1.4/1.5-era runtimes or exotic JVMs; debugging a debuggee whose java.lang wrapper classes are stubs (Android early versions, some embedded JVMs).
Related errors
- Interface method invocation is not supported in JVM {}. Use
- Cannot convert to primitive value of type
- Variable ''{0}'' is already declared
- Local variable declarations are not supported here.
- Invalid declaration : {0} Only local variable declarations a
AI-assisted analysis of JetBrains/intellij-community@be881553f2 (2026-08-14).
Data as JSON: /api/errors/bb3a6d547aa6a8d2.
Report an issue: GitHub.