Migrate to Java 11
MSALThis 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. Java8toJava11mod run . --recipe= org. openrewrite. java. migrate. Java8toJava11Install 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.
- Migrate to Java 8
- Rename
_identifier to__ - Prefer
java.util.Base64instead ofsun.misc - Remove explicit casts on
Arrays.asList(..).toArray() - Add explicit JAXB API dependencies and runtime
- Add explicit JAX-WS dependencies
- Migrate the JAX-WS Maven plugin
- Add explicit Inject dependencies
- Add explicit Common Annotations dependencies
BigDecimalrounding constants toRoundingModeenums- Use primitive wrapper
valueOfmethod - Use try-with-resources
- Use modernized
java.util.concurrentAPIs - Use modernized
java.langAPIs - Remove method invocations
java.lang.Runtime runFinalizersOnExit(boolean) - Remove method invocations
java.lang.System runFinalizersOnExit(boolean) - Use modernized
java.util.loggingAPIs - Migrate Lombok to a Java 11 compatible version
- Use modernized
java.netAPIs - Replace
Paths.getwithPath.of - Remove redundant
StandardCharsets.UTF_8fromjava.nio.file.Filesmethod calls - Use modernized
java.sqlAPIs - Use modernized
javax.lang.model.utilAPIs - Use modernized
javax.management.monitorAPIs - Use modernized
javax.xml.streamAPIs - Remove Cobertura Maven plugin
- Replace
KeyStore.getDefaultType()with"jks" - Upgrade build to Java 11
- Prefer
Optional.isEmpty() - Prefer
Optional.isPresent() - Replace
filter(Optional::isPresent).map(Optional::get)withflatMap(Optional::stream) - Prefer
Predicate.not(..)over casting toPredicateand callingnegate() - Use
com.sun.xml.bind.*instead ofcom.sun.xml.internal.bind.* - Replace deprecated methods in
SecurityManager - Upgrade plugins to Java 11 compatible versions
- Replace
javax.security.auth.Policywithjava.security.Policy - Replace
java.lang.ref.Reference.clone()with constructor call - Remove
Thread.destroy()andThread.stop(Throwable) - Replace AWT
getPeer()method - Use modernized
java.awtAPIs - Migrate to Scala 2.12.+
- Replace
com.sun.awt.AWTUtilitiesstatic method invocations - Replace
getLocalizedInputStreamandgetLocalizedOutputStreamwith direct assignment - Catch
TypeNotPresentExceptionthrown byClass.getAnnotation() - Replace
IllegalArgumentExceptionwithAlreadyConnectedExceptioninDatagramChannel.send()method