Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java 17 #10819

Closed
wants to merge 17 commits into from
Closed

Java 17 #10819

wants to merge 17 commits into from

Conversation

mkurz
Copy link
Member

@mkurz mkurz commented Apr 12, 2021

👉 If you are looking for a way run Play 2.8.x with Java 17... Yes, that is possible since Play 2.8.15: https://github.com/playframework/playframework/releases/tag/2.8.15


Let's see how well Play plays with Java 16 17.
The goal here is to make Play work with upcoming Java 17 (release date: 2021/09/14) as early as possible, because just like Java 11, Java 17 will be a LTS version.

  • validate (see below)
  • compile
  • publishLocal
  • tests
  • integration tests (see below)
  • scripted tests

WIP: ---add-exports

scripted tests:
https://travis-ci.com/github/playframework/playframework/jobs/498243543#L5170-L5174


Microbenchmark and integration tests with akka's http2 endpoint fail

Failed Integration tests: https://travis-ci.com/github/playframework/playframework/jobs/498389129
See all the java.net.SocketTimeoutExceptions, http2 does not start. Also see the bottom of the logs, you will see the InaccessibleObjectExceptions.

Failed microbenchmarks: https://travis-ci.com/github/playframework/playframework/jobs/498367902#L1934-L1942

Error log
...
[info] # JMH version: 1.25
[info] # VM version: JDK 16, OpenJDK 64-Bit Server VM, 16+36
[info] # VM invoker: /home/travis/.jabba/jdk/1.16.0-custom/bin/java
[info] # VM options: --add-exports=java.base/sun.security.x509=ALL-UNNAMED -XX:MaxMetaspaceSize=384m -Xmx512m -Xms128m
[info] # Warmup: <none>
[info] # Measurement: 1 iterations, 10 s each
[info] # Timeout: 10 min per iteration
[info] # Threads: 1 thread, will synchronize iterations
[info] # Benchmark mode: Throughput, ops/time
[info] # Benchmark: play.microbenchmark.it.HelloWorldBenchmark.helloWorld
[info] # Parameters: (endpoint = ak-20-enc, reqsPerConn = 5)
[info] # Run progress: 88.89% complete, ETA 00:00:13
[info] # Fork: 1 of 1
[info] Picked up JAVA_TOOL_OPTIONS: --add-exports=java.base/sun.security.x509=ALL-UNNAMED
[info] Iteration   1: ERROR a.a.OneForOneStrategy - Unable to make public void sun.security.ssl.SSLEngineImpl.setHandshakeApplicationProtocolSelector(java.util.function.BiFunction) accessible: module java.base does not "opens sun.security.ssl" to unnamed module @5a2e4553
[info] akka.actor.ActorInitializationException: akka://application/system/Materializers/StreamSupervisor-0/TLS-for-flow-1-1: exception during creation
[info] 	at akka.actor.ActorInitializationException$.apply(Actor.scala:196)
[info] Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make public void sun.security.ssl.SSLEngineImpl.setHandshakeApplicationProtocolSelector(java.util.function.BiFunction) accessible: module java.base does not "opens sun.security.ssl" to unnamed module @5a2e4553
[info] 	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:357)
...
  • Will this be fixed when upgrading to akka-http 10.2.x? The problem is okhttp.
  • Workaround for now: --add-opens=java.base/sun.security.ssl=ALL-UNNAMED

Validate docs fail (but not relevant for now)
https://travis-ci.com/github/playframework/playframework/jobs/497685525#L4256

Error log
[error] java.lang.RuntimeException: Error creating extended parser class: Could not determine whether class 'play.doc.CodeReferenceParser$$parboiled' has already been loaded
[error] 	at org.parboiled.Parboiled.createParser(Parboiled.java:58)
[error] 	at org.pegdown.plugins.PegDownPlugins$Builder.withPlugin(PegDownPlugins.java:126)
[error] 	at com.typesafe.play.docs.sbtplugin.PlayDocsValidation$.parseMarkdownFile$1(PlayDocsValidation.scala:125)
[error] 	at com.typesafe.play.docs.sbtplugin.PlayDocsValidation$.$anonfun$generateMarkdownRefReportTask$3(PlayDocsValidation.scala:209)
[error] 	at scala.collection.Iterator.foreach(Iterator.scala:943)
[error] 	at scala.collection.Iterator.foreach$(Iterator.scala:943)
[error] 	at scala.collection.AbstractIterator.foreach(Iterator.scala:1431)
[error] 	at scala.collection.IterableLike.foreach(IterableLike.scala:74)
[error] 	at scala.collection.IterableLike.foreach$(IterableLike.scala:73)
[error] 	at scala.collection.AbstractIterable.foreach(Iterable.scala:56)
[error] 	at com.typesafe.play.docs.sbtplugin.PlayDocsValidation$.$anonfun$generateMarkdownRefReportTask$1(PlayDocsValidation.scala:209)
[error] 	at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] 	at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62)
[error] 	at sbt.std.Transform$$anon$4.work(Transform.scala:68)
[error] 	at sbt.Execute.$anonfun$submit$2(Execute.scala:282)
[error] 	at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:23)
[error] 	at sbt.Execute.work(Execute.scala:291)
[error] 	at sbt.Execute.$anonfun$submit$1(Execute.scala:282)
[error] 	at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error] 	at sbt.CompletionService$$anon$2.call(CompletionService.scala:64)
[error] 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] 	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
[error] 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
[error] 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
[error] 	at java.base/java.lang.Thread.run(Thread.java:831)
[error] Caused by: java.lang.RuntimeException: Could not determine whether class 'play.doc.CodeReferenceParser$$parboiled' has already been loaded
[error] 	at org.parboiled.transform.AsmUtils.findLoadedClass(AsmUtils.java:213)
[error] 	at org.parboiled.transform.ParserTransformer.transformParser(ParserTransformer.java:35)
[error] 	at org.parboiled.Parboiled.createParser(Parboiled.java:54)
[error] 	at org.pegdown.plugins.PegDownPlugins$Builder.withPlugin(PegDownPlugins.java:126)
[error] 	at com.typesafe.play.docs.sbtplugin.PlayDocsValidation$.parseMarkdownFile$1(PlayDocsValidation.scala:125)
[error] 	at com.typesafe.play.docs.sbtplugin.PlayDocsValidation$.$anonfun$generateMarkdownRefReportTask$3(PlayDocsValidation.scala:209)
[error] 	at scala.collection.Iterator.foreach(Iterator.scala:943)
[error] 	at scala.collection.Iterator.foreach$(Iterator.scala:943)
[error] 	at scala.collection.AbstractIterator.foreach(Iterator.scala:1431)
[error] 	at scala.collection.IterableLike.foreach(IterableLike.scala:74)
[error] 	at scala.collection.IterableLike.foreach$(IterableLike.scala:73)
[error] 	at scala.collection.AbstractIterable.foreach(Iterable.scala:56)
[error] 	at com.typesafe.play.docs.sbtplugin.PlayDocsValidation$.$anonfun$generateMarkdownRefReportTask$1(PlayDocsValidation.scala:209)
[error] 	at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] 	at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62)
[error] 	at sbt.std.Transform$$anon$4.work(Transform.scala:68)
[error] 	at sbt.Execute.$anonfun$submit$2(Execute.scala:282)
[error] 	at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:23)
[error] 	at sbt.Execute.work(Execute.scala:291)
[error] 	at sbt.Execute.$anonfun$submit$1(Execute.scala:282)
[error] 	at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error] 	at sbt.CompletionService$$anon$2.call(CompletionService.scala:64)
[error] 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] 	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
[error] 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
[error] 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
[error] 	at java.base/java.lang.Thread.run(Thread.java:831)
[error] Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.findLoadedClass(java.lang.String) accessible: module java.base does not "opens java.lang" to unnamed module @79600226
[error] 	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:357)
[error] 	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
[error] 	at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199)
[error] 	at java.base/java.lang.reflect.Method.setAccessible(Method.java:193)
[error] 	at org.parboiled.transform.AsmUtils.findLoadedClass(AsmUtils.java:206)
[error] 	at org.parboiled.transform.ParserTransformer.transformParser(ParserTransformer.java:35)
[error] 	at org.parboiled.Parboiled.createParser(Parboiled.java:54)
[error] 	at org.pegdown.plugins.PegDownPlugins$Builder.withPlugin(PegDownPlugins.java:126)
[error] 	at com.typesafe.play.docs.sbtplugin.PlayDocsValidation$.parseMarkdownFile$1(PlayDocsValidation.scala:125)
[error] 	at com.typesafe.play.docs.sbtplugin.PlayDocsValidation$.$anonfun$generateMarkdownRefReportTask$3(PlayDocsValidation.scala:209)
[error] 	at scala.collection.Iterator.foreach(Iterator.scala:943)
[error] 	at scala.collection.Iterator.foreach$(Iterator.scala:943)
[error] 	at scala.collection.AbstractIterator.foreach(Iterator.scala:1431)
[error] 	at scala.collection.IterableLike.foreach(IterableLike.scala:74)
[error] 	at scala.collection.IterableLike.foreach$(IterableLike.scala:73)
[error] 	at scala.collection.AbstractIterable.foreach(Iterable.scala:56)
[error] 	at com.typesafe.play.docs.sbtplugin.PlayDocsValidation$.$anonfun$generateMarkdownRefReportTask$1(PlayDocsValidation.scala:209)
[error] 	at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] 	at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62)
[error] 	at sbt.std.Transform$$anon$4.work(Transform.scala:68)
[error] 	at sbt.Execute.$anonfun$submit$2(Execute.scala:282)
[error] 	at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:23)
[error] 	at sbt.Execute.work(Execute.scala:291)
[error] 	at sbt.Execute.$anonfun$submit$1(Execute.scala:282)
[error] 	at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error] 	at sbt.CompletionService$$anon$2.call(CompletionService.scala:64)
[error] 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] 	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
[error] 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
[error] 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
[error] 	at java.base/java.lang.Thread.run(Thread.java:831)
[error] (generateMarkdownRefReport) Error creating extended parser class: Could not determine whether class 'play.doc.CodeReferenceParser$$parboiled' has already been loaded

Line that causes the exception.
Problem: play-docs depends on unmaintained pegdown 1.6.0 (which is discussed here already), which depends on outdated parboiled-java 1.1.7, which depends on outdated ASM version 5.0.3 that has no support for newer JDKs. Even current parboiled 1.3.1 (which is the latest versions as time of this writing) only includes ASM 7.1, which still does not support Java 16. Only parboiled's master branch already depends on latest ASM 9.1.
However, this problem is not urgent and does not block Play from supporting Java 17, because this is "just" about "Validate docs (links, sample code, etc.)". We can and will continue running this jobs with Java 8, and even if ditch Java 8, we will probably only move the Java 11 as next step which will still work. So I think we are good for a couple more years (I mean in theory, we can even run this validation jobs with Java 8/11 forever).
We could also try to just override the ASM dependency, maybe that would be enough(?)

@aelgn
Copy link

aelgn commented May 14, 2021

It seems like a big problem is the deeply transitive dependency on cglib via guice. cglib is a discontinued project using a ton of illegal access reflection, which is by default denied in java 16.
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @4f9a18bd

Adding VM arg --illegal-access=warn is a temporary work around that will be removed in a future JVM release.

The new guice release 5.0.1 removes cglib and fixes various illegal access problems.
google/guice#1133

For this and other reasons I do think it is imperative that play framework migrates to guice 5.
https://github.com/google/guice/wiki/Guice501#guice-core

@mkurz
Copy link
Member Author

mkurz commented May 14, 2021

@aelgn we already upgraded Guice to 5.0.1 in the master branch (see #10724 and #10727). Therefore upcoming Play 2.9 will not show that warnings anymore. Also my goal is to fully support Java 17 with Play 2.9, which looks promising already.

@aelgn
Copy link

aelgn commented May 14, 2021

@mkurz that is great news! 🥇

@mkurz mkurz changed the title Java 16 Java 17 May 18, 2021
@mkurz mkurz force-pushed the jdk16 branch 2 times, most recently from 59cf282 to 5837515 Compare May 18, 2021 11:11
@mkurz
Copy link
Member Author

mkurz commented May 18, 2021

Blocked by travis-ci/travis-cookbooks#1092 (and I am too lazy for a workaround right now)
Fixed in Travis' edge channel as of May 31st 2021.

@mkurz
Copy link
Member Author

mkurz commented Mar 23, 2022

You can follow the 2.8.14 release here: playframework/play-meta#217
The 2.8.x cron build should start in like 1 hour: https://app.travis-ci.com/github/playframework/playframework/builds
Note sure if I have time this evening to do the release, if not the probably tomorrow.

@gokhanoner
Copy link
Contributor

Thanks @mkurz . Build seems successfully completed. Today or tomorrow, I'm fine & thanks for your quick reply 🙏🏽

@mkurz
Copy link
Member Author

mkurz commented Mar 25, 2022

Play 2.8.14 is now available 👍 Please give it a try if now Java 17 works for you, but be aware that you have to upgrade some dependencies yourself, see the notes here: #11206
Please let me know if something else makes problems, we might can fix it for 2.8.x, thanks!
I will announce the release early next week, it would be nice if you could give feedback if Java 17 works for you, so I can add it to the release announcements. Thanks!

@gokhanoner
Copy link
Contributor

@mkurz thank you very much, I'll do a build & update here.

@gokhanoner
Copy link
Contributor

gokhanoner commented Mar 25, 2022

@mkurz I just build my project & run unit + integrations tests with JDK 17. Everything works.
I tested with both ThisBuild / javacOptions ++= Seq("--release", "11") and ThisBuild / javacOptions ++= Seq("--release", "17").

Also, I was using guice 5.0.1 & I got some error. Apparetly they have a minor upgrade to support Java 17, https://github.com/google/guice/wiki/Guice510, you might want to update to that version for Play 2.9.

Once I deploy a test branch, I'll also update here regarding any runtime issues I've faced.

@mkurz
Copy link
Member Author

mkurz commented Mar 25, 2022

Great! (main is using Guice 5.1.0 already)

@francisdb
Copy link
Contributor

francisdb commented Mar 26, 2022

Just tried upgrading, is below expected? It pops up during our tests. I don't see it mentioned in the notes.

Should I create a ticket on sslconfig?

[info]   java.lang.IllegalAccessError: class com.typesafe.sslconfig.ssl.FakeKeyStore$ (in unnamed module @0x59505b48) cannot access class sun.security.x509.X509CertInfo (in module java.base) because module java.base does not export sun.security.x509 to unnamed module @0x59505b48
[info]   at com.typesafe.sslconfig.ssl.FakeKeyStore$.createSelfSignedCertificate(FakeKeyStore.scala:89)
[info]   at com.typesafe.sslconfig.ssl.FakeKeyStore$.generateKeyStore(FakeKeyStore.scala:79)
[info]   at play.core.server.SelfSigned$.x$1$lzycompute(SelfSigned.scala:24)
[info]   at play.core.server.SelfSigned$.x$1(SelfSigned.scala:23)
[info]   at play.core.server.SelfSigned$.sslContext$lzycompute(SelfSigned.scala:23)
[info]   at play.core.server.SelfSigned$.sslContext(SelfSigned.scala:23)
[info]   at play.core.server.SelfSignedSSLEngineProvider.sslContext(SelfSigned.scala:36)
[info]   at play.core.server.AkkaHttpServer.sslContext$lzycompute(AkkaHttpServer.scala:245)
[info]   at play.core.server.AkkaHttpServer.sslContext(AkkaHttpServer.scala:244)
[info]   at play.core.server.AkkaHttpServer.$anonfun$httpsServerBinding$1(AkkaHttpServer.scala:260)
[info]   ...

@gokhanoner
Copy link
Contributor

@francisdb it is mentioned. Apparently you're using self signed certificates. Try adding --add-opens=java.base/sun.security.ssl=ALL-UNNAMED to your startup.

@francisdb
Copy link
Contributor

francisdb commented Mar 26, 2022

@gokhanoner mind pointing me to where it is mentioned? We are not doing anything special with certificates, just testing with OneServerPerSuiteWithComponents

Created an issue to track this here: #11209

@gokhanoner
Copy link
Contributor

@francisdb under Microbenchmark and integration tests with akka's http2 endpoint fail in this ticket, check the Error logs. It shows a specific error, very similar to yours & I remember reading self-signed certificate related JDK17 issues mentioned by @mkurz. Let me check if I can find more details

@gokhanoner
Copy link
Contributor

gokhanoner commented Mar 26, 2022

Found it -> #10883 (comment)

@francisdb Also, pls keep in mind that this version, 2.8.14, doesn't officially support Java 17, its best effort.

@mkurz can you also point out where this issue is mentioned, if any, other than this comment?

@sleski
Copy link

sleski commented Mar 29, 2022

Maybe we can adjust this info in command line:

[info]   __              __
[info]   \ \     ____   / /____ _ __  __
[info]    \ \   / __ \ / // __ `// / / /
[info]    / /  / /_/ // // /_/ // /_/ /
[info]   /_/  / .___//_/ \__,_/ \__, /
[info]       /_/               /____/
[info]
[info] Version 2.8.14 running Java 17.0.1
[info]
[info] Play is run entirely by the community. Please consider contributing and/or donating:
[info] https://www.playframework.com/sponsors
[info]
[info] !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
[info]   Java version is 17. Play supports only 8 and 11.
[info] !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

@mkurz
Copy link
Member Author

mkurz commented Mar 31, 2022

@sleski See #11215

@mkurz
Copy link
Member Author

mkurz commented Apr 2, 2022

@gokhanoner
Copy link
Contributor

@mkurz you might want to upgrade to latest 5.3 (5.3.18 as of now) in master, which contains a fix for Spring vulnerability.

@mkurz
Copy link
Member Author

mkurz commented Apr 4, 2022

@gokhanoner scala-steward will do the upgrade for us 😉

@hedecai
Copy link

hedecai commented May 11, 2022

Hi,
We use play-ebean, the version 6.2.0-RC4 doesn't support java 17 since the Ebean version is 12.8.1.

@PromanSEW
Copy link
Contributor

@hedecai
Copy link

hedecai commented May 11, 2022

@hedecai see playframework/play-ebean#281

Thanks. Waiting for the new release of play-ebean.

@PromanSEW
Copy link
Contributor

@hedecai please check 6.2.0-RC6
Also see
playframework/play-ebean#278 (comment)
Do you have this IllegalStateException on start after update?

@hedecai
Copy link

hedecai commented May 14, 2022

@PromanSEW We upgrade from 6.2.0-RC4 to 6.2.0-RC6 has this exception "javax.persistence.PersistenceException: models.xx is NOT an Entity Bean registered with this server? " in production environment (using sbt clean; sbt dist).
In our development machine run our project using sbt run every thing is OK.
This project is using java 8 and play 2.8.15.
We googled this https://groups.google.com/g/ebean/c/sAAdMTU1520 .

Update:
We change Ebean.default = ["models.*"] to ebean.default = ["models.A", "model.B", "models.C", ...] as we set every Entity class name explicitly and it working.

@PromanSEW
Copy link
Contributor

@hedecai also see playframework/play-ebean#290

@hedecai
Copy link

hedecai commented May 15, 2022

@hedecai also see playframework/play-ebean#290

We don't has the IllegalStateException, our app use Ebean 12.16.1 as play-ebean version.
We change the application.conf Ebean.default = ["models.*"] to ebean.default = ["models.A", "model.B", "models.C", ...] not when compile but after package with sbt dist, so the Ebean enhance is OK. There something wrong when running the app, the app didn't register Entity to Ebean correct.
May there's something with this commit playframework/play-ebean@692ae03 ? @PromanSEW

@ruyconolly
Copy link

playframework/play-ebean#290

I'm facing the same problem but my project has more than 100 entities! 😢

@mkurz
Copy link
Member Author

mkurz commented Jun 7, 2022

@hedecai @ruyconolly Please try the latest, just released play-ebean version: https://github.com/playframework/play-ebean/releases/tag/6.2.0-RC7

@mkurz
Copy link
Member Author

mkurz commented Oct 3, 2022

Done in #11448, main branch in now Java 17 compatible out of the box (except the certifcate stuff from ssl-config, but that shouldn't really be a problem)

@mkurz mkurz closed this Oct 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet