Upgrade process from java 8 to java 21

Hello everyone,

I’m opening this thread to suggest a process to upgrade from Java 8 to 21.

@Serrof already started with Introduction of record but i would like to go a step further with this thread.

The idea would be to let Migrate to Java 21 | OpenRewrite Docs do the heavy lifting. It works using “Recipe” which can be group of smaller “Recipes”. We could create a dedicated branch and push a commit for each unitary “Recipe” performed and validated.

Feel free to add any suggestions or say what you think about this approach.

Cheers,
Vincent

2 Likes

Hi Vincent,

thanks for your help with the planning.

If you feel confident with using this tool, go ahead.
I know IntelliJ can already do a lot (run Java langage migration help as code inspection).

After records, one of the big thing is the switches that are much better with 21 w.r.t. 8.
And of course the getFirst and getLast on List.

Anyway, I’ve tried and failed miserably at locally creating a branch running with JDK 21. IntelliJ does not want to compile it. So if you want to do that for issue 1805, please do.

Cheers,
Romain.

+1 for using OpenRewrite @Vincent !

Actually there is another thing we need to talk about. It’s var. I find it very useful to have the code “breathe” a little bit.
I think we should at least use it when declaring variables, as it’s readily available what class the instance is. For Field stuff in particular, it would avoid the long diamond operators.
What do you think?

Cheers,
Romain.

I do agree with this, especially with Field as you mentioned. Java is already verbose enough ! This could be a dedicated commit and i think there is already a Recipe for this in OpenRewrite.

Hello everyone,

This message to let you know that i have started the upgrade process, you can check the progress here : Draft: Resolve "Upgrade to Java 21" (!948) · Merge requests · Orekit / Orekit · GitLab

Feel free to suggest additional modifications.

Cheers,
Vincent

2 Likes

Hi folks,

As I said in another thread, I strongly suggest that we switch to java 21 on the develop branch now that 13.1.5 is out.

Cheers,
Romain.

1 Like

Hey !

I’m all for it, the process is ready but i did not want to mess with @luc ongoing work ? If you all agree, i can do it tomorrow.

Cheers,
Vincent

Don’t worry about me, I will catch up when I can.

1 Like

I’ll provide a quick guide to do the heavy lifting using openrecipe :ok_hand:

It crossed my mind that we should have the Orekit tutorials and performance run first in java 21 otherwise the library itself is going to have red pipelines when we switch

1 Like

I’m (re)starting the migration process to java 21, i’m rebasing the current migation branch on develop because too many changes happened since first experiment (as expected).

Little update everyone, i think i have done most of the work for the migration to Java 21 for both orekit and the tutorials.

I contacted @sdinot to add a new container image for java 21 to the orekit registry and then i’ll be able to test my branches on the repo.

I’ll wrap this up tomorrow morning if that’s alright with you.

EDIT: orekit performances is almost ready as well, waiting for the new image on the registry to be done

Cheers,
Vincent

1 Like

Ok, so orekit-tutorials and orekit-performances have been upgraded to Java 21. I’m now getting a SonarQube failure due to insufficient coverage on Orekit (93.5% instead of the required 95%), mainly on condition coverage. This might be related to SonarQube behavior rather than an actual regression.