pinpoint-apm/pinpoint · error · IllegalStateException

bootstrapClassLoader access fail Caused by:

Error message

bootstrapClassLoader access fail Caused by:

What it means

After locating the bootstrap classloader Field, J9BootLoader calls setAccessible(true) and Field.get. An IllegalAccessException here (field not accessible due to access restrictions/module rules) is wrapped as IllegalStateException 'bootstrapClassLoader access fail Caused by:...'.

Source

Thrown at agent-module/bootstraps/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/classloader/J9BootLoader.java:59

        findResources = getMethod(abstractClassLoader, "findResources", String.class);
    }

    private static ClassLoader findBootstrapClassLoader() {
        Field bootstrapClassLoader;
        try {
            bootstrapClassLoader = ClassLoader.class.getDeclaredField("bootstrapClassLoader");
        } catch (NoSuchFieldException e) {
            try {
                bootstrapClassLoader = ClassLoader.class.getDeclaredField("systemClassLoader");
            } catch (NoSuchFieldException e2) {
                throw new IllegalStateException("bootstrapClassLoader not found Caused by:" + e.getMessage() + ", and " + e2.getMessage(), e2);
            }
        }
        try {
            bootstrapClassLoader.setAccessible(true);
            return (ClassLoader) bootstrapClassLoader.get(ClassLoader.class);
        } catch (IllegalAccessException e) {
            throw new IllegalStateException("bootstrapClassLoader access fail Caused by:" + e.getMessage(), e);
        }
    }

    private static Class<?> getAbstractClassLoader(String className) {
        try {
            return Class.forName(className, false, Object.class.getClassLoader());
        } catch (ClassNotFoundException e) {
            throw new IllegalStateException(className + " not found Caused by:" + e.getMessage(), e);
        }
    }


    private static Method getMethod(Class<?> bootstrapClassLoader, String methodName, Class<?>... parameterTypes) {
        try {
            Method declaredMethod = bootstrapClassLoader.getDeclaredMethod(methodName, parameterTypes);
            declaredMethod.setAccessible(true);
            return declaredMethod;
        } catch (NoSuchMethodException e) {

View on GitHub (pinned to 744c3d3075)

Solutions

  1. Add JVM flags to permit deep reflection (--add-opens java.base/java.lang=ALL-UNNAMED)
  2. Run on the JDK version the agent supports (typically Java 8 for this code path)
  3. Grant ReflectPermission/suppressSecurityManager if one is installed
  4. Read the Caused-by to confirm access vs presence of the field

Example fix

// before
java -javaagent:pinpoint-bootstrap.jar ...
// after (Java 9+)
java --add-opens java.base/java.lang=ALL-UNNAMED -javaagent:pinpoint-bootstrap.jar ...
Defensive patterns

Strategy: try-catch

Validate before calling

// JPMS check before reflective access
Module module = ClassLoader.class.getModule();
if (!module.isOpen("java.lang", J9BootLoader.class.getClassLoader().getModule == null ? null : J9BootLoader.class.getClassLoader().getModule())) {
  throw new IllegalStateException("Add --add-opens java.base/java.lang=ALL-UNNAMED");
}

Try / catch

try { ClassLoader bcl = j9BootLoader.getBootstrap(); } catch (IllegalStateException e) { if (e.getMessage().startsWith("bootstrapClassLoader access fail")) { log.error("Grant access: --add-opens java.base/java.lang=ALL-UNNAMED"); } throw e; }

Prevention

When it happens

Trigger: JVM module system (JPMS) or a SecurityManager denies reflective access to the ClassLoader internal field when findBootstrapClassLoader completes its get() call.

Common situations: Java 9+ strong encapsulation blocking setAccessible on java.lang internals, SecurityManager policy without ReflectPermission, or J9 restrictions differing from HotSpot.

Understand the failure class

Background: Permission denied / not authorized / 403 Forbidden: access-control rejections when the caller lacks the required role, grant, or ownership — this error's family across 18 libraries.

Related errors


AI-assisted analysis of pinpoint-apm/pinpoint@744c3d3075 (2026-09-07). Data as JSON: /api/errors/8707d4f918ab8e04. Report an issue: GitHub.