{"record":{"id":"76658fc5f78798d6","repo":"JetBrains/intellij-community","slug":"error-during-class","errorCode":null,"errorMessage":"Error during class ","messagePattern":"Error during class ","errorType":"exception","errorClass":"EvaluateException","httpStatus":null,"severity":"error","filePath":"java/debugger/impl/src/com/intellij/debugger/impl/ClassLoadingUtils.java","lineNumber":75,"sourceCode":"      try {\n        context.getDebugProcess().invokeInstanceMethod(context, classLoader, Objects.requireNonNull(defineMethod),\n                                                       Arrays.asList(nameString,\n                                                                     byteArray,\n                                                                     proxy.mirrorOf(0),\n                                                                     proxy.mirrorOf(bytes.length)),\n                                                       MethodImpl.SKIP_ASSIGNABLE_CHECK,\n                                                       true);\n      }\n      finally {\n        enableCollection(nameString);\n        enableCollection(byteArray);\n      }\n    }\n    catch (VMDisconnectedException e) {\n      throw e;\n    }\n    catch (Exception e) {\n      throw new EvaluateException(\"Error during class \" + name + \" definition: \" + e, e);\n    }\n  }\n\n  /**\n   * Finds and if necessary defines helper class\n   * May modify class loader in evaluationContext\n   */\n  public static @Nullable ClassType getHelperClass(Class<?> cls, EvaluationContextImpl evaluationContext,\n                                                   String... additionalClassesToLoad) {\n    for (JdiHelperClassLoader loader : JdiHelperClassLoader.getLoaders(evaluationContext)) {\n      try {\n        ClassType classType = loader.getHelperClass(cls, evaluationContext, additionalClassesToLoad);\n        if (classType != null) {\n          return classType;\n        }\n      }\n      catch (EvaluateException ex) {\n        String message = String.format(\"Failed to load '%s' with %s\", cls.getName(), loader.getClass().getName());","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/JetBrains/intellij-community/blob/be881553f2a76ac8b4ea53950d93f0de78295c19/java/debugger/impl/src/com/intellij/debugger/impl/ClassLoadingUtils.java#L57-L93","documentation":"Thrown by ClassLoadingUtils.defineClass when the debugger fails to define (load) a generated helper class into the debuggee's evaluation class loader via the reflective defineClass(String, byte[], int, int) call. The class name is included in the message. This is the mechanism that pushes bytecode synthesized by the compiling evaluator into the debuggee VM.","triggerScenarios":"After getClassLoader succeeds, defineClass looks up 'defineClass' on the loader's reference type, creates a StringReference mirror of the name and a byte-array mirror of the bytecode, and invokes the method inside computeAndKeep with SKIP_ASSIGNABLE_CHECK; any failure (LinkageError/duplicate class, InvocationException, class format mismatch due to bytecode version, classloader-visible signature mismatch) other than VMDisconnectedException is wrapped as EvaluateException('Error during class ' + name + ' definition: ' + e).","commonSituations":"Debuggee JVM older than the bytecode version the IDE generates (e.g. evaluating records/pattern-matching code on an old JDK); duplicate class definition after a partially failed prior evaluation; memory pressure preventing the byte-array allocation; modular runtime hiding java.lang.ClassLoader.defineClass.","solutions":["Match the project bytecode target / language level to a debuggee JVM that supports it (run debuggee on a JDK >= the features used)","Simplify the evaluated expression to avoid generating helper classes (avoid lambdas/anonymous classes in evaluation)","Restart the debug session to get a clean evaluation class loader if a duplicate-class error persists","Free memory / raise debuggee heap if allocation of the class bytes fails"],"exampleFix":"// before (evaluation input): list.stream().map(x -> x + 1).collect(...)\n\n// after (evaluation input): simpler loop-free expression without lambdas","handlingStrategy":"fallback","validationCode":"// check the debuggee JVM can load the class format before defining\nVersion targetVmVersion = debuggeeJavaVersion();\nif (bytecodeVersionOf(helperClass) > targetVmVersion) {\n  // skip defining; use interpreter-style evaluation instead\n}","typeGuard":null,"tryCatchPattern":"try {\n  ClassLoadingUtils.defineClass(name, bytes, context, classLoader);\n} catch (EvaluateException e) {\n  // retry with a simplified fragment that needs no helper classes\n}","preventionTips":["Run the debuggee on a JDK at least as new as the language features used in evaluations","Avoid lambdas/streams/anonymous classes inside evaluated fragments","Restart the debug session after repeated class-definition failures to clear duplicate classes"],"tags":["debugger","class-loading","bytecode","evaluation"],"backgroundTag":null,"analyzedSha":"be881553f2a76ac8b4ea53950d93f0de78295c19","analyzedAt":"2026-08-14T14:13:06.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}