apache/druid · error · UnsupportedOperationException

No VM class, cannot do memory check.

Error message

No VM class, cannot do memory check.

What it means

Thrown by RuntimeInfo.getDirectMemorySizeBytes when Class.forName("jdk.internal.misc.VM") fails with ClassNotFoundException, meaning the current JVM does not expose the JDK-internal VM class. Wrapped in UnsupportedOperationException because Druid cannot introspect direct memory on such a runtime.

Solutions

  1. Use a supported JDK (Java 11+ OpenJDK/HotSpot) where jdk.internal.misc.VM exists
  2. As a workaround on Java 8, set druid.processing buffer/direct size config explicitly instead of relying on runtime detection
  3. Verify the runtime JDK with java -version and switch container base images accordingly

Example fix

// before
FROM openjdk:8-jre
// after
FROM eclipse-temurin:11-jre
Defensive patterns

Strategy: try-catch

Validate before calling

boolean vmClassAvailable;
try { Class.forName("jdk.internal.misc.VM"); vmClassAvailable = true; }
catch (ClassNotFoundException e) { vmClassAvailable = false; }
if (!vmClassAvailable) { /* use config-based direct memory instead */ }

Type guard

static boolean supportsVmIntrospection() {
  try { Class.forName("jdk.internal.misc.VM"); return true; }
  catch (ClassNotFoundException e) { return false; }
}

Try / catch

try {
  long direct = runtimeInfo.getMaxDirectMemory();
} catch (UnsupportedOperationException e) {
  log.warn("No VM class on this JDK ({}), using configured direct size", e.getCause());
  long direct = configuredDirectSize;
}

Prevention

When it happens

Trigger: Calling getDirectMemorySizeBytes() (via maxDirectMemory, Memory, buffer init, or MiddleManager/Indexer tuning) on a JVM lacking jdk.internal.misc.VM - notably Java 8, where the class lives in sun.misc.VM instead, or other non-OpenJDK runtimes.

Common situations: Running Druid on Java 8 or an unsupported JVM distribution, container images with stripped/down-level JDKs, switching JDK vendors without checking Druid's supported matrix.

Related errors


AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07). Data as JSON: /api/errors/a2e9f83971d2ea3f. Report an issue: GitHub.

Appendix: source

Thrown at processing/src/main/java/org/apache/druid/utils/RuntimeInfo.java:63

  public long getFreeHeapSizeBytes()
  {
    return Runtime.getRuntime().freeMemory();
  }

  public long getDirectMemorySizeBytes()
  {
    try {
      Class<?> vmClass = Class.forName("jdk.internal.misc.VM");
      Object maxDirectMemoryObj = vmClass.getMethod("maxDirectMemory").invoke(null);

      if (maxDirectMemoryObj == null || !(maxDirectMemoryObj instanceof Number)) {
        throw new UOE("Cannot determine maxDirectMemory from [%s]", maxDirectMemoryObj);
      } else {
        return ((Number) maxDirectMemoryObj).longValue();
      }
    }
    catch (ClassNotFoundException e) {
      throw new UnsupportedOperationException("No VM class, cannot do memory check.", e);
    }
    catch (NoSuchMethodException e) {
      throw new UnsupportedOperationException("VM.maxDirectMemory doesn't exist, cannot do memory check.", e);
    }
    catch (InvocationTargetException e) {
      throw new UnsupportedOperationException("static method shouldn't throw this", e);
    }
    catch (IllegalAccessException e) {
      throw new UnsupportedOperationException("public method, shouldn't throw this", e);
    }
  }
}

View on GitHub (pinned to 9b90983fd2)