{"record":{"id":"01ed0403c6ae3619","repo":"apache/flink","slug":"cannot-retrieve-platform-classloader-on-java-9","errorCode":null,"errorMessage":"Cannot retrieve platform classloader on Java 9+","messagePattern":"Cannot retrieve platform classloader on Java 9\\+","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"critical","filePath":"flink-core/src/main/java/org/apache/flink/core/classloading/ComponentClassLoader.java","lineNumber":297,"sourceCode":"    // ----------------------------------------------------------------------------------------------\n\n    private static String[] convertPackagePrefixesToPathPrefixes(String[] packagePrefixes) {\n        return Arrays.stream(packagePrefixes)\n                .map(packageName -> packageName.replace('.', '/'))\n                .toArray(String[]::new);\n    }\n\n    static {\n        ClassLoader platformLoader = null;\n        try {\n            platformLoader =\n                    (ClassLoader)\n                            ClassLoader.class.getMethod(\"getPlatformClassLoader\").invoke(null);\n        } catch (NoSuchMethodException e) {\n            // on Java 8 this method does not exist, but using null indicates the bootstrap\n            // loader that we want to have\n        } catch (Exception e) {\n            throw new IllegalStateException(\"Cannot retrieve platform classloader on Java 9+\", e);\n        }\n        PLATFORM_OR_BOOTSTRAP_LOADER = platformLoader;\n        ClassLoader.registerAsParallelCapable();\n    }\n}\n","sourceCodeStart":279,"sourceCodeEnd":303,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/core/classloading/ComponentClassLoader.java#L279-L303","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"String spec = System.getProperty(\"java.specification.version\");\nif (Integer.parseInt(spec.split(\"\\\\.\")[0]) >= 9) {\n    try {\n        ClassLoader.class.getMethod(\"getPlatformClassLoader\").invoke(null);\n    } catch (Exception e) {\n        throw new IllegalStateException(\"JVM does not support getPlatformClassLoader\", e);\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["classloading","jvm","reflection","startup"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}