Search code examples
javaglassfishjava-11payarapayara-micro

The warning happens when starting Payara 6 Micro: An illegal reflective access operation has occurred


I am using the latest version of payara-micro-6.2023.8 with openjdk 11.0.20.1 inside of a docker container. When starting the server I get the following warning:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.glassfish.pfl.basic.reflection.Bridge$1 (file:/opt/domain/runtime/pfl-basic.jar) to method java.io.ObjectInputStream.latestUserDefinedLoader()
WARNING: Please consider reporting this to the maintainers of org.glassfish.pfl.basic.reflection.Bridge$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

The warning comes from the class org.glassfish.pfl.basic.reflection.Bridge and is a result of an unsuccessful refraction call. The library and the resources are compiled in Java 8 which does not mean anything yet:

private Method getLatestUserDefinedLoaderMethod() {
    return (Method)AccessController.doPrivileged(new PrivilegedAction<Method>() {
        public Method run() {
            try {
                Class io = ObjectInputStream.class;
                Method result = io.getDeclaredMethod("latestUserDefinedLoader");
                result.setAccessible(true);
                return result;
            } catch (NoSuchMethodException var3) {
                throw new Error("java.io.ObjectInputStream latestUserDefinedLoader " + var3, var3);
            }
        }
    });
}

The question is what is this library used for and is it compatible with Java 11 and Payara 6 or was it simply forgotten?


Solution

  • The warning comes from the class org.glassfish.pfl.basic.reflection.Bridge and is a result of an unsuccessful refraction call.

    No, it is associated with a successful reflective access. If the access had failed then an exception would have been thrown. Note well from the warning message: "All illegal access operations will be denied in a future release [of Java]" (emphasis added).

    The question is what is this library used for

    org.glassfish.pfl.basic.reflection.Bridge is part of Glassfish, the primary open-source Java EE implementation. It is apparently bundled with Payara, presumably along with many other Glassfish classes. From its API docs:

    This class provides the methods for fundamental JVM operations needed in the ORB that are not part of the public Java API.

    It is an infrastructure class on which Glassfish depends for implementing Java EE behavior.

    and is it compatible with Java 11 and Payara 6 or was it simply forgotten?

    It is apparently part of Payara 6. You should consult the Payara documentation for supported Java versions, but I don't see anything in what you presented that makes me think there's an incompatibility with Java 11.