I upgraded to Java 9 - Part II

A few weeks ago, I wrote about migrating an existing Spring-application to Java 9. When I finished, two things remained to be investigated:

  1. Code coverage for unit tests.
  2. A bunch of warnings when running the application in Tomcat.

Code coverage for unit tests

As Alan Bateman pointed out, upgrading JaCoCo to its latest version should resolve the issue about the $jacocoData field. In fact, I thought I had done that, but somehow I kept on getting the same error every single time. But when I tried (again) last week, it somehow disappeared. No error to be seen, all tests green, and a nice coverage report from JaCoCo. I’m a happy developer, again!

Warnings when running in Tomcat

This one was also pretty easy to resolve. Turns out that the classes in Tomcat that access sun.misc.GC have either been refactored or removed in Tomcat 9. Running my application in Tomcat 9 instead of 8 is a no-brainer. Installing the latest version of Tomcat (9.0.4 at the time of writing) and copying the WAR and configuration files was all. This time, starting the application doesn’t complain about sun.misc.GC anymore. Again: hurray!