jhipster / generator-jhipster

JHipster is a development platform to quickly generate, develop, & deploy modern web applications & microservice architectures.
https://www.jhipster.tech
Apache License 2.0
21.45k stars 4.02k forks source link

Upgrade to JDK 11 while keeping JDK8 compatibility #9145

Closed PierreBesson closed 5 years ago

PierreBesson commented 5 years ago
Overview of the feature request

After merging the Spring-boot 2.1 branch, we will be able to fully support JDK 11. As discussed on the mailing list java 11 thread, we are going to keep JDK 8 through 11 compatibility for now, however we can upgrade to JDK 11 as default for :

For the docker image, we can use :

I'm recommending that we switch to adoptopenjdk as this is my understanding that AdoptOpenJDK jdk 11 docker images provide LTS while the official openjdk image does not (@mraible please correct me if I'm wrong). The official openjdk image also does not offer an alpine version.

Alternative: use the distroless java11 image (https://github.com/GoogleContainerTools/distroless/pull/285) once it becomes available:

Motivation for or Use Case

Use the latest JDK while adding integration tests for compatibility with JDK8.

Related issues or PR

8689, #8573

PierreBesson commented 5 years ago

On the current master, we use openjdk:11-slim as the base docker image. I believe this will stop receiving updates when jdk12 will be released so I would recommend switching to either adoptopenjdk/openjdk11:alpine-slim (242MB) or gcr.io/distroless/java:11 from google (189MB). @jhipster/developers What do you think ?

pascalgrimaud commented 5 years ago

So no 'official' image ? Which one has the most download ? Which one is the most active ?

PierreBesson commented 5 years ago

Yes there is an official openjdk11 image from Oracle but support will end in march 2019 even though jdk11 is supposed to be LTS : https://developer.okta.com/blog/2019/01/16/which-java-sdk

cbornet commented 5 years ago

The docker openjdk image is based on the Debian package so won't it get updates from Debian ?

PierreBesson commented 5 years ago

@cbornet it seems that you are right that it is based on the version present in the debian repo https://github.com/docker-library/openjdk/blob/master/11/jdk/slim/Dockerfile So the openjdk image might be a valid choice after all... It's really a headache, all stemming from the fact that the openjdk project doesn't do it's own distribution which doesn't make any sense to me.

cremich commented 5 years ago

Interesting fact: I tried to install openjdk-11 in an ubuntu:bionic container. The openjdk-11 is in fact an openjdk-10 fake :confused: ?

root@254e905d3823:~# apt show openjdk-11-jdk 
Package: openjdk-11-jdk
Version: 10.0.2+13-1ubuntu0.18.04.4

root@254e905d3823:~# java --version
openjdk 10.0.2 2018-07-17
OpenJDK Runtime Environment (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.4)
OpenJDK 64-Bit Server VM (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.4, mixed mode)
PierreBesson commented 5 years ago

@cremich Indeed it does seem to be the case : https://packages.ubuntu.com/uk/bionic/openjdk-11-jdk

@pascalgrimaud This will affect the jhipster/jhipster image.

cremich commented 5 years ago

@PierreBesson i would like to help migrating to jdk11. is there an open pull-request or branch i can contribute to?

PierreBesson commented 5 years ago

@cremich Please PR directly to master 😉, initial work has already been merged. Docs can be contributed to : https://github.com/jhipster/jhipster.github.io Additional CI builds can be contributed to : https://github.com/hipster-labs/jhipster-daily-builds

cremich commented 5 years ago

Interesting fact: I tried to install openjdk-11 in an ubuntu:bionic container. The openjdk-11 is in fact an openjdk-10 fake ?

root@254e905d3823:~# apt show openjdk-11-jdk 
Package: openjdk-11-jdk
Version: 10.0.2+13-1ubuntu0.18.04.4

root@254e905d3823:~# java --version
openjdk 10.0.2 2018-07-17
OpenJDK Runtime Environment (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.4)
OpenJDK 64-Bit Server VM (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.4, mixed mode)

Ubuntu cosmic looks better :)

root@8c6567b93912:/# apt show openjdk-11-jdk
Package: openjdk-11-jdk
Version: 11.0.1+13-3ubuntu3.18.10.1
cremich commented 5 years ago

@PierreBesson just in case i understand this issue right: do you plan to set the JAVA_VERSION constant by default to 11? or what do you mean by "we are going to keep JDK 8 through 11 compatibility for now" ????

PierreBesson commented 5 years ago

@cremich My idea is not to force the user's version to be java 11. Leave the user the capability to use any version between 8 and 11 for the time being. This means that we are not going to generate code using new java features for now and we also need to setup CI builds with java 8 to keep compatibility.

cremich commented 5 years ago

@PierreBesson ok got it. Thank you very much. I was wondering if my first throw in https://github.com/jhipster/generator-jhipster/pull/9346 was the right choice. I think the version should be set to 11 in order to allow the user to build his application with the new java features. I understand, that the generated jhipster files should be compatible with java 8.

akiroussama commented 5 years ago

Hello Pierre, Thanks for this great jobt, any date please for jhipster version that support java 11 ?

jdubois commented 5 years ago

@akiroussama we never commit on release dates as most of the job is done during our free time

jdubois commented 5 years ago

@PierreBesson from the original issue (as there are have been side-discussions here), I believe we should use adoptopenjdk/openjdk11:slim as it's TCK-certified.

So the plan is just to use JDK 11 everywhere? We also need to update our root Dockerfile at https://github.com/jhipster/generator-jhipster/blob/master/Dockerfile to use JDK 11.

For me this is top priority for JHipster 6.

PierreBesson commented 5 years ago

@jdubois Basically we can either use adoptopenjdk/openjdk which do their own builds based on ubuntu or keep using openjdk which is based on the debian package. Both should get updates anyway.

jdubois commented 5 years ago

Well, I don't know the difference between openjdk and adoptopenjdk to be honest

PierreBesson commented 5 years ago

OK, so let's keep using the openjdk docker image.

clakech commented 5 years ago

Hello, do you know when JHipster v6 will be released on average ?

PierreBesson commented 5 years ago

@clakech sorry we can't answer you. We are doing our best to make a new release as soon as possible. We will probably release a beta version in the coming weeks.

ganeshkrishnan1 commented 5 years ago

@jdubois, afaik openjdk provides the source and adoptopenjdk compiles them for various architectures. Technically they are the same as adoptopenjdk just uses openjdk source upstream.

mraible commented 5 years ago

What is there left to do for Java 11 (or 12) compatibility?

mraible commented 5 years ago

I believe this can be closed since the current master branch works with Java 11 and 12.

jdubois commented 5 years ago

Thanks @mraible !

PierreBesson commented 5 years ago

I'm reopening this issue because I'm reconsidering keeking the default openjdk docker image. I think we should migrate to adoptopenjdk as it is more secure according to several people I have discussed this with.

Also we have not really been through this checklist:

Evertude commented 4 years ago

Is it possible to adapt the Heroku JDK to the one used in the project? When I update the java.version property in the pom file, it still installs JDK 1.8 on Heroku which causes the app to crash.

There are two ways to achieve this:

I tested the first approach and it works but I would highly prefer the second approach.