[Issue] Play 2.6.12 and Java 9

I got this big warning when I run Play project with java 9.

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by play.runsupport.classloader.DelegatingClassLoader (file:/Users/meyer_t/.ivy2/cache/com.typesafe.play/run-support_2.12/jars/run-support_2.12-2.6.12.jar) to method java.lang.ClassLoader.findResource(java.lang.String)
WARNING: Please consider reporting this to the maintainers of play.runsupport.classloader.DelegatingClassLoader
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

Can you give more details about what you’re doing to get the error?

See also this issue which discusses a few Java 9 issues and workarounds: https://github.com/playframework/playframework/issues/7879

Hi @richdougherty,

Yes, I have already fixed missing class errors by adding removed jars:

val java9LibraryDependencies: Seq[sbt.ModuleID] =
    if (System.getProperty("java.version").startsWith("9.")) {
        Seq(
            "com.sun.activation" % "javax.activation" % "1.2.0",
            "javax.xml.bind" % "jaxb-api" % "2.3.0",
            "com.sun.xml.bind" % "jaxb-core" % "2.3.0",
            "com.sun.xml.bind" % "jaxb-impl" % "2.3.0"
        )
    } else {
        Seq.empty
    }

libraryDependencies ++= Seq(
    guice,
    ws,
    "commons-io" % "commons-io" % "2.6",
    // ... //
) ++ java9LibraryDependencies

The problem here is related to the library "run-support" from Typesafe who use illegal access with reflection. This warning is show when I run the project with "sbt run".

Since the run command runs in sbt’s JVM instance you may need to supply some more JRE arguments when you launch sbt. I’m a bit rusty on this but I think you’re going to need to add an --add-opens option to stop the warning.

The offending code is here:

And it is only used in dev mode because we do some classloading tricks to have hot reload. I’m not sure we have a good alternative on short-term here. What do you think?

@0xbaadf00d can you confirm if you see this when running in production mode?

Best.

Hello,

I see this message in production, but it due to “com.google.inject.guice-4.1.0.jar” not “com.typesafe.*” relative packages.

Thanks

On that front I think Guice was recently updated to have Java 9 support. I think we’ve already merged it into Play? Not sure if in master or on the stable branch though.

@richdougherty master branch.

We can’t update on 2.6.x branch because of binary compatibility. But it is possible to add it to your project if you want.