JetBrains/intellij-community · error · EvaluateException

Error during class

Error message

Error during class 

What it means

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.

Source

Thrown at java/debugger/impl/src/com/intellij/debugger/impl/ClassLoadingUtils.java:75

      try {
        context.getDebugProcess().invokeInstanceMethod(context, classLoader, Objects.requireNonNull(defineMethod),
                                                       Arrays.asList(nameString,
                                                                     byteArray,
                                                                     proxy.mirrorOf(0),
                                                                     proxy.mirrorOf(bytes.length)),
                                                       MethodImpl.SKIP_ASSIGNABLE_CHECK,
                                                       true);
      }
      finally {
        enableCollection(nameString);
        enableCollection(byteArray);
      }
    }
    catch (VMDisconnectedException e) {
      throw e;
    }
    catch (Exception e) {
      throw new EvaluateException("Error during class " + name + " definition: " + e, e);
    }
  }

  /**
   * Finds and if necessary defines helper class
   * May modify class loader in evaluationContext
   */
  public static @Nullable ClassType getHelperClass(Class<?> cls, EvaluationContextImpl evaluationContext,
                                                   String... additionalClassesToLoad) {
    for (JdiHelperClassLoader loader : JdiHelperClassLoader.getLoaders(evaluationContext)) {
      try {
        ClassType classType = loader.getHelperClass(cls, evaluationContext, additionalClassesToLoad);
        if (classType != null) {
          return classType;
        }
      }
      catch (EvaluateException ex) {
        String message = String.format("Failed to load '%s' with %s", cls.getName(), loader.getClass().getName());

View on GitHub (pinned to be881553f2)

Solutions

  1. Match the project bytecode target / language level to a debuggee JVM that supports it (run debuggee on a JDK >= the features used)
  2. Simplify the evaluated expression to avoid generating helper classes (avoid lambdas/anonymous classes in evaluation)
  3. Restart the debug session to get a clean evaluation class loader if a duplicate-class error persists
  4. Free memory / raise debuggee heap if allocation of the class bytes fails

Example fix

// before (evaluation input): list.stream().map(x -> x + 1).collect(...)

// after (evaluation input): simpler loop-free expression without lambdas
Defensive patterns

Strategy: fallback

Validate before calling

// check the debuggee JVM can load the class format before defining
Version targetVmVersion = debuggeeJavaVersion();
if (bytecodeVersionOf(helperClass) > targetVmVersion) {
  // skip defining; use interpreter-style evaluation instead
}

Try / catch

try {
  ClassLoadingUtils.defineClass(name, bytes, context, classLoader);
} catch (EvaluateException e) {
  // retry with a simplified fragment that needs no helper classes
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of JetBrains/intellij-community@be881553f2 (2026-08-14). Data as JSON: /api/errors/76658fc5f78798d6. Report an issue: GitHub.