Generator-jhipster: Upgrade to JDK 11 while keeping JDK8 compatibility

Created on 29 Jan 2019  路  27Comments  路  Source: jhipster/generator-jhipster

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 :

  • [x] Travis/Azure builds, mix between jdk8 and jdk11 builds
  • [聽] Base docker image

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:

  • [聽] The jhipster/jhipster docker image
  • [x] Update the docs with instructions for installing JDK 11, either with SDKman or with AdoptOpenJDK (eg. brew tap AdoptOpenJDK/openjdk && brew cask install adoptopenjdk)
  • [ ] Heroku
  • [ ] GAE
  • [ ] Cloudfoundry
  • [ ] AWS
  • [ ] CI-CD where applicable
Motivation for or Use Case

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

Related issues or PR

8689, #8573

  • [X] Checking this box is mandatory (this is just to show you read everything)
area java v6

Most helpful comment

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

All 27 comments

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 ?

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

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

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

@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.

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)

@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.

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

@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

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

@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" ????

@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.

@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.

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

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

@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.

@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.

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

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

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

@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.

@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.

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

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

Thanks @mraible !

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:

  • [x] Update the docs with instructions for installing JDK 11, either with SDKman or with AdoptOpenJDK (eg. brew tap AdoptOpenJDK/openjdk && brew cask install adoptopenjdk)
  • [ ] Heroku with JDK11 (docs needed?)
  • [ ] GAE with JDK11 (docs needed?)
  • [ ] Cloudfoundry with JDK11 (docs needed?)
  • [ ] AWS with JDK11 (docs needed?)
  • [ ] CI-CD with JDK11 (docs needed?)

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chegola picture chegola  路  4Comments

ahmedeldeeb25 picture ahmedeldeeb25  路  3Comments

RizziCR picture RizziCR  路  3Comments

pascalgrimaud picture pascalgrimaud  路  3Comments

edvjacek picture edvjacek  路  3Comments