apache/flink · critical · IllegalStateException
Cannot retrieve platform classloader on Java 9+
Error message
Cannot retrieve platform classloader on Java 9+
What it means
Thrown during ComponentClassLoader static initialization if invoking ClassLoader.getPlatformClassLoader() via reflection throws an unexpected exception (not NoSuchMethodException, which is tolerated for Java 8). This means the JVM claims to be Java 9+ but the platform classloader method failed unexpectedly.
Solutions
- Use a standard, certified JDK (Temurin, Corretto, OpenJDK) at a supported version (11, 17, or 21).
- If a security manager is in play, grant reflect permission for ClassLoader methods.
- Reinstall or switch the JDK to eliminate a corrupted runtime.
Defensive patterns
Strategy: validation
Validate before calling
String spec = System.getProperty("java.specification.version");
if (Integer.parseInt(spec.split("\\.")[0]) >= 9) {
try {
ClassLoader.class.getMethod("getPlatformClassLoader").invoke(null);
} catch (Exception e) {
throw new IllegalStateException("JVM does not support getPlatformClassLoader", e);
}
} Prevention
- Use a certified JDK (Temurin, Corretto, OpenJDK 11/17/21).
- Avoid custom or stripped JVM builds for production Flink.
- Check for security manager policies blocking reflection.
When it happens
Trigger: Running on a non-standard or broken JVM where getPlatformClassLoader exists but throws. Extremely rare; the static initializer catches NoSuchMethodException for Java 8 but rethrows other reflective invocation failures.
Common situations: Corrupted or non-compliant JVM installation. Custom JVM forks that don't fully implement the Java 9+ ClassLoader API. Security manager blocking reflective access to ClassLoader internals.
Related errors
- Array type expected.
- Basic type expected.
- Basic type ' ' expected but was ' '.
- Can not register process function transformation translator.
- Cannot convert type to class
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/01ed0403c6ae3619.
Report an issue: GitHub.
Appendix: source
Thrown at flink-core/src/main/java/org/apache/flink/core/classloading/ComponentClassLoader.java:297
// ----------------------------------------------------------------------------------------------
private static String[] convertPackagePrefixesToPathPrefixes(String[] packagePrefixes) {
return Arrays.stream(packagePrefixes)
.map(packageName -> packageName.replace('.', '/'))
.toArray(String[]::new);
}
static {
ClassLoader platformLoader = null;
try {
platformLoader =
(ClassLoader)
ClassLoader.class.getMethod("getPlatformClassLoader").invoke(null);
} catch (NoSuchMethodException e) {
// on Java 8 this method does not exist, but using null indicates the bootstrap
// loader that we want to have
} catch (Exception e) {
throw new IllegalStateException("Cannot retrieve platform classloader on Java 9+", e);
}
PLATFORM_OR_BOOTSTRAP_LOADER = platformLoader;
ClassLoader.registerAsParallelCapable();
}
}
View on GitHub (pinned to 2f3c205e92)