{"record":{"id":"5f4eec7a8b6d0a1b","repo":"JetBrains/intellij-community","slug":"evaluation-error-cannot-resolve-constructor","errorCode":"evaluation.error.cannot.resolve.constructor","errorMessage":"Cannot resolve constructor ''{0}''","messagePattern":"Cannot resolve constructor ''(.+?)''","errorType":"exception","errorClass":"EvaluateException","httpStatus":null,"severity":"error","filePath":"java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/EvaluatorBuilderImpl.java","lineNumber":1720,"sourceCode":"          new TypeEvaluator(JVMNameUtil.getJVMQualifiedName(expressionPsiType)),\n          dimensionEvaluator,\n          initializerEvaluator\n        );\n      }\n      else if (expressionPsiType instanceof PsiClassType) { // must be a class ref\n        PsiClass aClass = CompilingEvaluatorTypesUtil.getClass((PsiClassType)expressionPsiType);\n        if (aClass instanceof PsiAnonymousClass) {\n          throw unsupportedExpression(JavaDebuggerBundle.message(\"evaluation.error.anonymous.class.evaluation.not.supported\"));\n        }\n        PsiExpressionList argumentList = expression.getArgumentList();\n        if (argumentList == null) {\n          throw expressionInvalid(expression);\n        }\n        final PsiExpression[] argExpressions = argumentList.getExpressions();\n        final JavaResolveResult constructorResolveResult = expression.resolveMethodGenerics();\n        PsiMethod constructor = CompilingEvaluatorTypesUtil.getReferencedConstructor((PsiMethod)constructorResolveResult.getElement());\n        if (constructor == null && argExpressions.length > 0) {\n          throw new EvaluateRuntimeException(new EvaluateException(\n            JavaDebuggerBundle.message(\"evaluation.error.cannot.resolve.constructor\", expression.getText()), null));\n        }\n        Evaluator[] argumentEvaluators = new Evaluator[argExpressions.length];\n        // evaluate arguments\n        for (int idx = 0; idx < argExpressions.length; idx++) {\n          PsiExpression argExpression = argExpressions[idx];\n          argExpression.accept(this);\n          if (myResult != null) {\n            argumentEvaluators[idx] = DisableGC.create(myResult);\n          }\n          else {\n            throw expressionInvalid(argExpression);\n          }\n        }\n\n        if (constructor != null) {\n          processBoxingConversions(constructor.getParameterList().getParameters(), argExpressions, constructorResolveResult.getSubstitutor(), argumentEvaluators);\n        }","sourceCodeStart":1702,"sourceCodeEnd":1738,"githubUrl":"https://github.com/JetBrains/intellij-community/blob/be881553f2a76ac8b4ea53950d93f0de78295c19/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/EvaluatorBuilderImpl.java#L1702-L1738","documentation":"Thrown by EvaluatorBuilderImpl when evaluating a 'new Foo(...)' expression: resolveMethodGenerics() failed to resolve a constructor and at least one argument is present. The evaluator cannot synthesize a constructor call it cannot bind, so it reports the constructor as unresolvable with the full expression text.","triggerScenarios":"Visiting a PsiNewExpression with a PsiClassType whose resolveMethodGenerics() returns no PsiMethod (or a non-constructor element), while argumentList.getExpressions().length > 0; typical when the class is not on the debuggee's classpath, is ambiguous, or the argument types match no overload.","commonSituations":"Evaluating 'new Foo(bar)' where Foo comes from a library version different from the one the debuggee loaded; constructing inner (non-static) classes without an enclosing instance; evaluating constructors of classes compiled with newer bytecode than the debuggee's JVM understands.","solutions":["Use exact argument types matching an existing constructor (cast nulls: new Foo((String)null))","Verify the class and its version are on the runtime classpath of the debuggee, not just the IDE","For inner classes, qualify with the outer instance: outer.new Inner(args)","Fall back to a factory method call instead of a constructor expression"],"exampleFix":"// before: new Foo(null)\n\n// after: new Foo((String)null)","handlingStrategy":"validation","validationCode":"JavaResolveResult r = newExpr.resolveMethodGenerics();\nif (r.getElement() == null && newExpr.getArgumentList().getExpressions().length > 0) {\n  // disambiguate args with explicit casts or pick a factory method before evaluating\n}","typeGuard":null,"tryCatchPattern":"try {\n  evaluator.evaluate(context);\n} catch (EvaluateRuntimeException e) {\n  // if constructor unresolved: retry with null-argument casts, e.g. new Foo((String)null)\n}","preventionTips":["Cast null arguments to the exact parameter type to disambiguate overloads","Ensure the constructed class's version matches the debuggee classpath","Use outer.new Inner(...) for inner classes"],"tags":["debugger","evaluation","constructor","resolution"],"backgroundTag":null,"analyzedSha":"be881553f2a76ac8b4ea53950d93f0de78295c19","analyzedAt":"2026-08-14T14:13:06.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}