Migrate to Java 11

MSAL

This recipe will apply changes commonly needed when upgrading to Java 11. Specifically, for those applications that are built on Java 8, this recipe will update and add dependencies on J2EE libraries that are no longer directly bundled with the JDK. This recipe will also replace deprecated API with equivalents when there is a clear migration strategy. Build files will also be updated to use Java 11 as the target/source and plugins will also be upgraded to versions that are compatible with Java 11.

org.openrewrite.java.migrate.Java8toJava11
mod run . --recipe=org.openrewrite.java.migrate.Java8toJava11

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.

Recipe list

It runs these recipes, in this order.

  1. Migrate to Java 8
  2. Rename _ identifier to __
  3. Prefer java.util.Base64 instead of sun.misc
  4. Remove explicit casts on Arrays.asList(..).toArray()
  5. Add explicit JAXB API dependencies and runtime
  6. Add explicit JAX-WS dependencies
  7. Migrate the JAX-WS Maven plugin
  8. Add explicit Inject dependencies
  9. Add explicit Common Annotations dependencies
  10. BigDecimal rounding constants to RoundingMode enums
  11. Use primitive wrapper valueOf method
  12. Use try-with-resources
  13. Use modernized java.util.concurrent APIs
  14. Use modernized java.lang APIs
  15. Remove method invocations java.lang.Runtime runFinalizersOnExit(boolean)
  16. Remove method invocations java.lang.System runFinalizersOnExit(boolean)
  17. Use modernized java.util.logging APIs
  18. Migrate Lombok to a Java 11 compatible version
  19. Use modernized java.net APIs
  20. Replace Paths.get with Path.of
  21. Remove redundant StandardCharsets.UTF_8 from java.nio.file.Files method calls
  22. Use modernized java.sql APIs
  23. Use modernized javax.lang.model.util APIs
  24. Use modernized javax.management.monitor APIs
  25. Use modernized javax.xml.stream APIs
  26. Remove Cobertura Maven plugin
  27. Replace KeyStore.getDefaultType() with "jks"
  28. Upgrade build to Java 11
  29. Prefer Optional.isEmpty()
  30. Prefer Optional.isPresent()
  31. Replace filter(Optional::isPresent).map(Optional::get) with flatMap(Optional::stream)
  32. Prefer Predicate.not(..) over casting to Predicate and calling negate()
  33. Use com.sun.xml.bind.* instead of com.sun.xml.internal.bind.*
  34. Replace deprecated methods in SecurityManager
  35. Upgrade plugins to Java 11 compatible versions
  36. Replace javax.security.auth.Policy with java.security.Policy
  37. Replace java.lang.ref.Reference.clone() with constructor call
  38. Remove Thread.destroy() and Thread.stop(Throwable)
  39. Replace AWT getPeer() method
  40. Use modernized java.awt APIs
  41. Migrate to Scala 2.12.+
  42. Replace com.sun.awt.AWTUtilities static method invocations
  43. Replace getLocalizedInputStream and getLocalizedOutputStream with direct assignment
  44. Catch TypeNotPresentException thrown by Class.getAnnotation()
  45. Replace IllegalArgumentException with AlreadyConnectedException in DatagramChannel.send() method