Java SE version migration

Under the Java Code Review set of rules, Java SE Migration category contains rules for migrating from J2SE 5.0, Java SE 6, Java SE 7, Java SE 8 or Java SE 11 or Java SE 17. Java migration targets are Java SE 8, 11, 17 and 21.

The Sun to IBM Java compatibility impacts category provides a set of rules to migrate Sun APIs that are not available on the IBM Java Runtime Environment. Where possible, the rules migrate the code to use javax.net or com.ibm.net.ssl classes.

The specific rules selected depends on your selection of the source Java Runtime Environment that your application previously used and the version of WebSphere you are migrating to. For Liberty, you can choose Java SE 8, 11, 17 or 21 as your target. For WebSphere traditional, you must migrate to Java SE 8.

Quick fixes are available where possible. Rules without quick fixes flag the rule violations so you can evaluate their usage and migrate the code manually if needed.

Java SE 21 compatibility impacts

Java 21 is supported on Liberty 23.0.0.10 and later. The Java SE 21 compatibility impacts include all the compatibility impacts from Java SE versions 17 to 21.

Table 1. Java SE 21 compatibility impacts
Rule Name Rule Description Automated Fix
Java SE 21 general information and potential issues This rule contains links to information on the changes in Java SE 21, as well as the previous non-LTS (long term support) Java versions that have been released since Java SE 21. java-version-21.yml
org.openrewrite.java.migrate.UpgradeToJava17
Avoid using default charset when the output stream is a PrintStream This rule flags the java.io.PrintStream, java.io.PrintWriter, and java.io.OutputStreamWriter Java class constructors that take a java.io.OutputStream and no charset. No
Avoid using the deprecated getSubject(), doAs() methods in javax.security.auth.Subject This rule flags the use of getSubject() and doAs() methods in the javax.security.auth.Subject class. The getSubject() method is deprecated from Java SE 17 and marked forRemoval = true. The doAs() method is deprecated from Java SE 18 and marked forRemoval = true. java-version-21.yml
org.openrewrite.java.migrate.RemovedSubjectMethods
The default value of the java.security.manager system property has been changed to disallow This rule flags the use of setSecurityManager(SecurityManager()) method in java.lang.System. No
Do not use the java.lang.Compiler class This rule flags the use of use of java.lang.Compiler class. This class has been removed in Java SE 21. No
Avoid using Thread.stop(), Thread.resume(), and Thread.suspend() methods This rule flags the use of the Thread.stop(), Thread.suspend(), and Thread.resume() methods. These methods have been terminally deprecated in Java SE 19 and have been updated to always throw an UnsupportedOperationException. The method will eventually be degraded and removed in a future release as it is inherently unsafe and has been deprecated since Java 1.2. No
Do not use the ThreadGroup.allowThreadSuspension method This rule flags the use of the ThreadGroup.allowThreadSuspension method. This method was used for low memory handling in JDK 1.1 but was never fully specified. It was deprecated and changed to "do nothing" in JDK 1.2 (1998). This method has been removed in Java 21 release. No
The ObjectInputStream.GetField.get(name, object) method was changed to throw a ClassNotFoundException This rule flags the use of the get(String name, Object val) method in java.io.ObjectInputStream.GetField. No
Do not use the RMIIIOPServerImpl class This rule flags the use of the javax.management.remote.rmi.RMIIIOPServerImpl class which was removed in Java SE 21. No
Avoid using Legacy PlainSocketImpl and PlainDatagramSocketImpl implementation This rule flags the use of the constructors java.net.Socket(Proxy proxy), java.net.DatagramSocket(SocketAddress bindaddr) and java.net.MulticastSocket(SocketAddress bindaddr) No
Avoid using the deprecated empty finalize() method in java.desktop This rule flags the use of the finalize() method in the java.awt.color.ICC_Profile, java.awt.image.ColorModel and java.awt.image.IndexColorModel classes. java-version-21.yml
org.openrewrite.java.migrate.DeleteDeprecatedFinalize
Avoid using the degraded ThreadGroup methods This rule flags the use of the ThreadGroup.setDaemon, ThreadGroup.isDaemon, ThreadGroup.destroy and ThreadGroup.isDestroyed methods. No

Java SE 17 compatibility impacts

Java 17 is supported on Liberty 21.0.0.10 and later. The Java SE 17 compatibility impacts include all the compatibility impacts from Java SE versions 12 to 17.

Table 2. Java SE 17 compatibility impacts
Rule Name Rule Description Automated Fix
Behavior change in Properties.loadFromXML method for non-compliant XML documents This rule flags java.util.Properties.loadFromXML​(java.io.InputStream) method calls. The method throws an exception for non-compliant XML documents in Java SE 12. No
Behavior change for the user.timezone system property This rule flags System.getProperty method calls with the user.timezone property value. The method may return null in Java SE 12. No
Check for a behavior change in regular expression pattern matching The rule flags calls invocations of the methods where the regular expression provided contains an intersection, followed by a nested character class, followed by a non-nested character class. No
Do not use the removed FileInputStream.finalize() and FileOutputStream.finalize() methods The java.io.FileInputStream.finalize() and java.io.FileOutputStream.finalize() methods were removed from Java SE 12. java-version-17.yml
org.openrewrite.java.migrate.RemovedFileIOFinalizeMethods
Do not use the com.sun.awt.SecurityWarning class The com.sun.awt.SecurityWarning class was removed from Java SE 12. No
Do not use the removed ZipFile.finalize(), Inflater.finalize() and Deflater.finalize() methods The java.util.zip.ZipFile.finalize(), java.util.zip.Inflater.finalize() and java.util.zip.Deflater.finalize() methods were removed from Java SE 12. java-version-17.yml
org.openrewrite.java.migrate.RemovedZipFinalizeMethods
Do not use the removed Runtime.traceInstructions(boolean) and Runtime.traceMethodCalls(boolean) methods The java.lang.Runtime.traceInstructions(boolean) and java.lang.Runtime.traceMethodCalls(boolean) methods were removed from Java SE 13. java-version-17.yml
org.openrewrite.java.migrate.RemovedRuntimeTraceMethods
The java.util.jar.Pack200 APIs were removed The java.util.jar.Pack200 class was removed in addition to its java.util.jar.Pack200.Packer and java.util.jar.Pack200.Unpacker interfaces. No
The sun.nio.cs.map system property was removed The sun.nio.cs.map system property was removed in Java SE 14. This rule flags string literal references to "sun.nio.cs.map" No
The java.security.acl package was removed The java.security.acl package was removed in Java SE 14, the java.security.Policy classes should be used instead. No
Weak named curves have been removed Weak named curves have been removed from the SunEC provider in Java SE 16. This rule flags references to any of the weak named curves. No
Check for a namespace clash with the new java.lang.Record class The java.lang.Record class has been added in Java SE 14. To avoid a namespace clash, ensure that any other class named "Record" is imported using a single-type import (for example: "com.foo.Record") instead of a wild-card import (for example: "com.foo.*"). No
The netscape.javascript.JSObject.getWindow(Applet) method has been removed The netscape.javascript.JSObject.getWindow(Applet) method was removed in Java SE 14. Since the method was only used with Java Plugins, which have also been removed, there is no replacement for this method. No
Check for a behavior change on the DatagramPacket.getPort() method The default return value for the DatagramPacket.getPort() method was changed from -1 to 0 in Java SE 15. No
The RMIConnectorServer.CREDENTIAL_TYPES constant was removed The RMIConnectorServer.CREDENTIAL_TYPES constant was removed in Java SE 15. java-version-17.yml
org.openrewrite.java.migrate.RemovedRMIConnectorServerCredentialTypesConstant
The SSLSession.getPeerCertificateChain() method implementation has been removed The default SSLSession.getPeerCertificateChain() method implementation has been removed in Java SE 15. java-version-17.yml
org.openrewrite.java.migrate.RemovedSSLSessionGetPeerCertificateChainMethodImpl
The Modifier() and ConstantBootstraps() constructors have been removed The Modifier() and ConstantBootstraps() constructors have been removed in Java SE 15. java-version-17.yml
org.openrewrite.java.migrate.RemovedModifierAndConstantBootstrapsConstructors
The SO_FLOW_SLA Solaris socket option has been removed The SO_FLOW_SLA Solaris socket option and related SocketFlow and SocketFlow.Status classes have been removed in Java SE 15. No
The com.sun.net.ssl.internal.ssl.Provider provider name was removed The com.sun.net.ssl.internal.ssl.Provider legacy SunJSSE provider name has been removed in Java SE 15. It should be replaced with the SunJSSE provider name. java-version-17.yml
org.openrewrite.java.migrate.RemovedLegacySunJSSEProviderName
Check for the isEmpty() default method on the java.lang.CharSequence interface A default isEmpty() method has been added to the java.lang.CharSequence interface in Java SE 15. Classes that implement java.lang.CharSequence and another interface that defines a default isEmpty() method might need to be updated. No
Java SE 17 general information and potential issues General information on the changes in Java SE 17 and potential migration issues that are not detected by this tool. java-version-17.yml
org.openrewrite.java.migrate.Java8toJava11
The ToolProvider() constructor has been removed The ToolProvider constructor has been removed in Java SE 16. java-version-17.yml
org.openrewrite.java.migrate.RemovedToolProviderConstructor
The com.sun.net.ssl package was removed The internal API com.sun.net.ssl was removed. The package was intended for internal use only and replacement APIs can be found in the javax.net.ssl package. java-version-17.yml
org.openrewrite.java.migrate.SunNetSslPackageUnavailable
Avoid using the deprecated methods in java.lang.ThreadGroup and java.lang.Thread The suspend and resume methods within java.lang.Thread and the suspend, resume, and allowThreadSuspension methods within java.lang.ThreadGroup were deprecated in Java SE 14. The stop, destroy, isDestroyed, setDaemon and isDaemon methods within java.lang.ThreadGroup were deprecated in Java SE 16. No
Check for the toList() default method on the java.util.stream.Stream interface A default toList() method has been added to the java.util.stream.Stream interface in Java SE 16. Classes that implement java.util.stream.Stream and another interface that defines a default toList() method might need to be updated. No
Check for a behavior change on the HttpPrincipal.getName() method The value returned by the HttpPrincipal.getName() method was changed in Java SE 16. No
Check for a behavior change in the java.io.LineNumberReader class The definition of line terminator in the java.io.LineNumberReader class was changed in Java SE 16. No
Avoid using the deprecated java.security.cert APIs The getIssuerDN, getSubjectDN, getIssuerDN, setIssuer, setSubject, getIssuerAsString, getSubjectAsString, and addIssuerName methods within java.security.cert.X509Certificate, java.security.cert.X509CRL, java.security.cert.X509CertSelector, and java.security.cert.X509CRLSelector were deprecated in Java SE 16. No
Avoid using the deprecated methods in java.util.logging.LogRecord The getThreadID and setThreadID methods within java.util.logging.LogRecord were deprecated in Java SE 16. java-version-17.yml
org.openrewrite.java.migrate.DeprecatedLogRecordThreadID
Avoid using deprecated primitive wrapper class constructors Primitive wrapper class constructors were deprecated in Java SE 16. No
The javax.security.cert package has been deprecated for removal

The javax.security.cert has been deprecated in Java SE 13 and marked for removal. The classes in this package should no longer be used. The java.security.cert package contains suitable replacements.

java-version-17.yml
org.openrewrite.java.migrate.DeprecatedJavaxSecurityCert
The Thread.countStackFrames() method was changed to unconditionally throw an UnsupportedOperationException

The terminally deprecated method Thread.countStackFrames() has been changed to unconditionally throw an UnsupportedOperationException in Java SE 14.

java-version-17.yml
org.openrewrite.java.migrate.DeprecatedCountStackFramesMethod
Avoid using the removed RMI Activation package

The java.rmi.activation package was deprecated in Java SE 15 and removed in Java SE 17.

No
The Socket Implementation Factory Mechanism has been deprecated The following methods used to set the system-wide socket implementation factories have been deprecated in Java SE 17: static void ServerSocket.setSocketFactory(SocketImplFactory fac), static void Socket.setSocketImplFactory(SocketImplFactory fac), static void DatagramSocket.setDatagramSocketImplFactory(DatagramSocketImplFactory fac). No
Check for a behavior change on HttpClient.newHttpClient and HttpClient.Builder.build The pattern matching behavior changed for some regular expressions using intersections in Java SE 17. No
The defineAnonymousClass method from sun.misc.Unsafe has been removed The defineAnonymousClass method from sun.misc.Unsafe has been removed in Java SE 17. No
Check for a behavior change in Java agents Java agent premain and agentmain methods must be public in Java SE 17. java-version-17.yml
org.openrewrite.java.migrate.Jre17AgentMainPreMainPublic
The Applet API has been deprecated for removal The Applet API has been deprecated for removal in Java SE 17. No
JARs signed with SHA-1 algorithms are now restricted JARs signed with SHA-1 algorithms are now restricted by default and treated as if they were unsigned in Java SE 17. No
Remote EJB calls might fail on Java SE 17 Due to stricter module access enforcement, remote EJB calls might fail on Java SE 17. No

Java SE 11 compatibility impacts

Java 11 is supported on Liberty v19.0.0.1 and later.

Table 3. Java SE 11 compatibility impacts
Rule Name Rule Description Automated Fix
Avoid using the deprecated RMIIIOPServerImpl class This rule flags the use of the RMIIIOPServerImpl class. This class was deprecated in Java SE 11. No
Behavior change in default locale data The Unicode Consortium's Common Locale Data Repository (CLDR) is enabled as the default locale data in Java 11. In previous releases, the default was JRE, which is now known as COMPAT. Code that uses locale-sensitive services such as date, time, and number formatting may produce different results with the CLDR locale data. No
Behavior change in exceptions when calling the Class.getAnnotation() method In Java 11, the java.lang.Class.getAnnotation() method throws a java.lang.TypeNotPresentException instead of java.lang.ArrayStoreException if the annotation has an array value that references a missing class. java-version-11.yml
org.openrewrite.java.migrate.ArrayStoreExceptionToTypeNotPresentException
Behavior change in java.util.concurrent.ThreadPoolExecutor.finalize() method In Java 11, the java.util.concurrent.ThreadPoolExecutor.finalize() method no longer shuts down the thread pool. No
Behavior change in the java.lang.invoke.MethodHandles.filterArguments method This rule flags applications that use the java.lang.invoke.MethodHandles.filterArguments method. No
Behavior change in the javax.management.MBeanOperationInfo constructor This rule flags applications that use the javax.management.MBeanOperationInfo constructor if the impact provided is not one of INFO, ACTION, ACTION_INFO, or UNKNOWN No
Behavior change on java.xml API methods with raw types In Java 11, the java.xml APIs containing method declarations with raw types were updated to add a type parameter. No
Check for a behavior change on the Selector select and selectNow methods This rule flags the java.nio.channels.Selector.select() and java.nio.channels.Selector.selectNow() methods. The methods behavior has changed in JDK 11. No
Check for behavior changes related to the separation of blocking and non-blocking code paths for I/O channels In Java 11, separate blocking and non-blocking code paths were created for I/O channels to increase performance and reliability. This rule flags API calls that might be impacted by the behavior change. No
Check for configuration changes related to the com.ibm.security.auth.module.Krb5LoginModule class This rule flags any reference to com.ibm.security.auth.module.Krb5LoginModule related classes that might require configuration changes when migrating to Java 11. No
Detect default keystore change In Java 11 the default keystore was updated from JKS to PKCS12. As a result, applications relying on KeyStore.getDefaultType() may encounter issues after migrating, unless their JKS keystore has been converted to PKCS12. java-version-11.yml
org.openrewrite.java.migrate.ChangeDefaultKeyStore
Check for removed methods on Pack200.Packer and Pack200.Unpacker interfaces The addPropertyChangeListener and removePropertyChangeListener are no longer defined on the Pack200.Packer and Pack200.Unpacker interfaces in Java 11. No
Do not use APIs from the com.sun.image.codec.jpeg package The com.sun.image.codec.jpeg API is not available in Java SE 11. No
Do not use APIs from the com.sun.xml.internal.bind.* packages The APIs in com.sun.xml.internal.bind.* packages are no longer available in Java SE 11. java-version-11.yml
org.openrewrite.java.migrate.InternalBindPackages
Do not use APIs from the sun.* packages The sun.* APIs are unsupported, JDK-internal APIs, and may go away at any time. No
Do not use BASE64Encoder/Decoder APIs from the sun.* packages The sun.misc.BASE64Encoder and sun.misc.BASE64Decoder have been removed in Java SE 11. java-version-11.yml
org.openrewrite.java.migrate.UseJavaUtilBase64
Do not use JCEKS Keystore format This rule detects and flags the use of KeyStore.getInstance("JCEKS"). Developers should update their applications to use PKCS12 for compatibility. No
Do not use javax.security.auth.Policy class The javax.security.auth.Policy Class is not available in Java SE 11. This rule flags any reference to the javax.security.auth.Policy Class. java-version-11.yml
org.openrewrite.java.migrate.RemovedPolicy
Do not use removed com.sun classes This rule flags com.sun classes that are not available in Java SE 11. No
Do not use removed runFinalizersOnExit methods The java.lang.Runtime.runFinalizersOnExit and java.lang.System.runFinalizersOnExit methods were removed from Java SE 11. No
Do not use com.sun.awt.AWTUtilities static method invocations The com.sun.awt.AWTUtilities.isTranslucencySupported(), com.sun.awt.AWTUtilities.setWindowOpacity(), com.sun.awt.AWTUtilities.getWindowOpacity(), com.sun.awt.AWTUtilities.getWindowShape(), com.sun.awt.AWTUtilities.isWindowOpaque(), com.sun.awt.AWTUtilities.isTranslucencyCapable() , and com.sun.awt.AWTUtilities.setComponentMixingCutoutShape() methods were removed from Java SE 11. java-version-11.yml
org.openrewrite.java.migrate.ReplaceComSunAWTUtilitiesMethods
Do not use the com.ibm.security.auth.module.Krb5LoginModule class The com.ibm.security.auth.module.Krb5LoginModule class is not available in Java SE 11. ibm-java.yml
org.openrewrite.java.migrate.Krb5LoginModuleClass
Do not use the getPeer method All methods in the Java SE API that return a class from the java.awt.peer package have been removed from Java 11. To see if a peer has been set yet, use the Component.isDisplayable() method. To test if a component is lightweight, use the Component.isLightWeight() method. java-version-11.yml
org.openrewrite.java.migrate.ReplaceAWTGetPeerMethod
Do not use the java.lang.ref.Reference clone method The java.lang.ref.Reference clone method is no longer supported in Java 11. java-version-11.yml
org.openrewrite.java.migrate.ReferenceCloneMethod
Do not use the netdoc URL protocol The netdoc protocol handler has been removed in Java 11. No
Do not use the removed com.sun.java.browser.plugin2.DOM and sun.plugin.dom.DOMObject APIs The com.sun.java.browser.plugin2.DOM and sun.plugin.dom.DOMObject APIs are not available in Java SE 11. No
Do not use the removed com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel or apple.laf.AquaLookAndFeel Swing LookAndFeel The com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel and apple.laf.AquaLookAndFeel Swing LookAndFeels are no longer supported by the javax.swing.UIManager.setLookAndFeel method in Java SE 11. No
Do not use the removed java.lang.Thread.destroy() or java.lang.Thread.stop(java.lang.Throwable) methods The java.lang.Thread.destroy() and java.lang.Thread.stop(java.lang.Throwable) methods have been removed in Java SE 11. java-version-11.yml
org.openrewrite.java.migrate.ThreadStopDestroy
Do not use the removed javax.crypto.ExemptionMechanism.finalize() method The javax.crypto.ExemptionMechanism.finalize() method was removed from Java SE 11. No
Do not use the removed jdk.Exported annotation The jdk.Exported annotation is not available in Java SE 11. No
Do not use the removed methods addPropertyChangeListener or removePropertyChangeListener from LogManager The addPropertyChangeListener and removePropertyChangeListener methods are not available on the java.util.logging.LogManager class in Java 11. No
Do not use the removed Runtime.getLocalizedInputStream and Runtime.getLocalizedOutputStream methods The Runtime.getLocalizedInputStream and Runtime.getLocalizedOutputStream methods were removed from Java SE 11. java-version-11.yml
org.openrewrite.java.migrate.ReplaceLocalizedStreamMethods
Do not use the SecurityManager removed methods This rule flags methods that were removed from the java.lang.SecurityManager class in Java SE 11. No
Do not use the SecurityManager removed methods (with automated fix) This rule flags methods that were removed from the java.lang.SecurityManager class in Java SE 11. This rule has an automated fix to update the method call. java-version-11.yml
org.openrewrite.java.migrate.RemovedSecurityManagerMethods
Java 11 version number format change Java 11 marks the beginning of a new version number naming convention. The version numbers format changed from 1.8 (Java 8) to 11 (Java 11). No
Review resource cleanup on FileInputStream and FileOutputStream overridden close method This rule flags the close() method on subclasses of java.io.FileInputStream and java.io.FileOutputStream. No
Run the Java class dependency analyzer tool (JDeps) The JDK ships a command line utility called jdeps that analyzes class dependencies. The tool can be used to identify jdk internal packages that are no longer available in JDK 11. No
The java.awt.peer and java.awt.dnd.peer packages are not accessible All methods in the Java SE API that refer to types defined in the java.awt.peer and java.awt.dnd.peer packages have been removed from Java 11. Code that calls a method that previously accepted or returned a type defined in these packages no longer compiles or runs in Java 11. No
The java.nio.channels.DatagramChannel.send() method throws AlreadyConnectedException instead of IllegalArgumentException When the address passed to the java.nio.channels.DatagramChannel. send(ByteBuffer,SocketAddress) method is different than the connected address, this method throws an AlreadyConnectedException instead of an IllegalArgumentException in Java SE 11. java-version-11.yml
org.openrewrite.java.migrate.IllegalArgumentExceptionToAlreadyConnectedException
The java.nio.channels.Selector and java.nio.channels.SelectableChannel classes can be used in concurrent threads safely The java.nio.channels.Selector and java.nio.channels.SelectableChannel classes have been updated to be used in concurrent threads safely in Java SE 11. No
The java.transaction module was removed from JDK 11 This rule flags applications that use packages in the javax.transaction module. No
The java.xml.bind and java.activation modules were removed from JDK 11 (Custom Implementation) This rule flags applications that use packages in the java.xml.bind or java.activation modules and package their own JAXB implementation. ibm-java.yml
org.openrewrite.java.migrate.RemovedJaxBModuleProvided
The java.xml.bind and java.activation modules were removed from JDK 11 (Default Implementation) This rule flags applications that use packages in the java.xml.bind or java.activation modules and use the WebSphere default JAXB implementation. No
The JavaFX modules were removed from JDK 11 The JavaFX modules are not available in Java SE 11. No
URLClassLoader constructors and newInstance() calls throw a NullPointerException when the array contains a null element URLClassLoader constructors and newInstance() calls throw a NullPointerException when the URL array contains a null element in Java SE 11. No
The Java Web Start technology was removed from JDK 11 The Java Web Start technology is not available in JDK 11. This rule flags jnlp files in an application. No
Behavior change for the ForkJoinPool common pool class loader This rule flags methods that may behave differently based on the thread context class loader propagation for an application. No
Java SE 11 general information and potential issues This rule contains links to information on the changes in Java SE 11, as well as the previous non-LTS (long term support) Java versions that have been released since Java SE 11. java-version-11.yml
org.openrewrite.java.migrate.UpgradeToJava8
 

Table 4. Java SE 11 compatibility impacts (not Liberty Core)
Rule Name Rule Description Automated Fix
The java.corba module was removed from JDK 11 This rule flags applications that use packages in the java.corba module. No
The java.xml.ws module was removed from JDK 11 (Custom Implementation) This rule flags applications that use packages in the java.xml.ws module and package their own JAX-WS implementation. ibm-java.yml
org.openrewrite.java.migrate.RemovedJavaXMLWSModuleProvided
The java.xml.ws module was removed from JDK 11 (Default Implementation) This rule flags applications that use packages in the java.xml.ws module and use the WebSphere default JAX-WS implementation. No

The IBM XML implementation is removed in Java 11. See Determining application compatibility: XML for more information.

Table 5. Java SE 11 IBM XML implementation compatibility impacts
Rule Name Rule Description Automated Fix
Detected dependencies on internal packages of the IBM XML implementation This rule flags references to IBM XML internal packages. No
Detected string literal references to IBM XML implementation specific configuration parameters This rule flags string literal references to IBM XML implementation specific configuration parameters. No
Detected string literal references to internals of the IBM XML implementation This rule flags string literal references to the IBM XML implementation. No

Java SE 8 compatibility impacts

Java 8 is supported on Liberty and WebSphere Application Server traditional V8.5.5.9 and later.

Table 6. Java SE 8 compatibility impacts
Rule Name Rule Description Automated Fix
Behavior change in exceptions when setting AWT focus traversal keys In Java 8, the java.awt.Component setFocusTraversalKeys and the java.awt.KeyboardFocusManager setDefaultFocusTraversalKeys methods throw ClassCastException instead of IllegalArgumentException if any passed keystroke object is not an AWTKeyStroke. No
Behavior change in java.lang.String and java.util.regex.Pattern split methods In Java 8, the behavior of the split methods could lead to the removal of the empty String that is present at the beginning of the returning array. No
Behavior change in month name formatting for some languages In Java 8, when formatting date-time values using the DateFormat and SimpleDateFormat classes, context-sensitive month names are supported for languages that have different date formatting and standalone forms of month names. You might see a difference in the month name returned in strings formatted by the DateFormat or SimpleDateFormat classes or by methods on the DateFormatSymbols class. No
Behavior change in most Collection.removeAll and Collection.retainAll implementations Prior to Java 8, most implementations of Collection.removeAll(Collection) and retainAll(Collection) return false and ignore a null parameter if the collection itself is empty. In Java 8, collections throw a NullPointerException if null is provided as the parameter. No
Behavior change in new instance creation for non-public interfaces In Java 8, a code change is required to create a proxy instance for non-public interfaces located in a different package using the Proxy.getProxyClass and Constructor.newInstance methods. No
Behavior change in rounding in NumberFormat and DecimalFormat format methods In Java 8, the rounding behavior of the NumberFormat and DecimalFormat format methods changed to match the rounding of the binary representation of the number. No
Behavior change in the BigDecimal stripTrailingZeros method for a zero value Java 8 introduces a behavior change when java.math.BigDecimal stripTrailingZeros operates on a zero value with a nonzero scale. No
Behavior change in the construction of dynamic proxy classes In Java 8, calling java.lang.reflect.Proxy(InvocationHandler) with a null parameter throws a NullPointerException. Prior to Java 8, the constructor returns a proxy, but any method calls on that proxy throw a NullPointerException. No
Classes that implement the TypeVisitor interface must implement the TypeVisitor.visitIntersection() method This rule detects and flags Java classes that implement this interface but do not implement the visitIntersection(IntersectionType t, P p) method. Any class without the visitIntersection method that directly implements this Java interface will not compile. No
DatagramPacket constructor with SocketAddress no longer throws SocketException In Java 8, java.net.DatagramPacket constructors were changed to remove the SocketException declaration. This rule flags java.net.DatagramPacket constructors that accept a java.net.SocketAddress argument when the constructors are within a try block that catches either a java.net.SocketException or its superclass java.io.IOException. No
Detect registered or instantiated MBeans and MXBeans This rule flags MBean or MXBean interfaces that are not public, as required by Java 8. It also flags registerMBean or createMBean calls to highlight potential issues with interface visibility. No
Differences in class loading for JAXP service providers Java 8 includes Java API for XML Processing (JAXP) 1.6, which handles class loading for service providers differently than previous versions. No
MBean and MXBean interfaces must be public Java 8 enforces the requirement that MBean and MXBean management interfaces be public. Non-public interfaces are not allowed to expose the management functionality. This specification requirement was not enforced in Java 7 and prior versions. java-version-8.yml
org.openrewrite.java.migrate.MXBeanRule
New methods in java.util.concurrent.ConcurrentHashMap In Java 8, the ConcurrentHashMap class introduced over 30 new methods. If you extend the java.util.concurrent.ConcurrentHashMap class, your class might need changes. No
The mechanism to select a locale service provider changed In Java 8, the mechanism to select a locale service provider changed. A new method in the LocaleServiceProvider class allows implementations to determine whether the given locale is supported. No
Do not use APIs from the sun.io package The sun.io.* APIs have been removed in Java SE 8. Replace or remove this API. No
java.lang.Thread.stop(java.lang.Throwable) is disabled This rule flags java.lang.Thread.stop(java.lang.Throwable) method invocations.When you invoke this method, it now throws an UnsupportedOperationException. No

Java SE 7 compatibility impacts

Table 7. Java SE 7 compatibility impacts
Rule Name Rule Description Automated Fix
Check for a behavior change for an empty TreeSet add and TreeMap put methods This rule flags the use of java.util.TreeSet or java.util.TreeMap. Depending on the configuration of the rule, either the constructor or the add()/put() methods of these classes will get flagged. A new behavior is added in Java 7 for these methods. No
Check for a behavior change for AWT Exception Handler This rule flags the string literal sun.awt.exception.handler. A new exception handling mechanism is added in Java 7. No
Check for a behavior change for File setReadOnly, setWritable and canWrite methods This rule flags the methods java.io.File setReadOnly(), setWritable(boolean arg) and setWritable(boolean arg, boolean user). A new behavior is added in Java 7 for these methods. No
Check for a behavior change for URLConnection, HttpURLConnection getInputStream method This rule flags the getInputStream() method on URLConnection or HttpURLConnection. This method has a new behavior in Java 7. No
Check for a behavior change on DatagramChannel send, receive, and connect methods This rule flags calls to the java.nio.channels.DatagramChannel send, receive, and connect methods that have a new behavior in Java 7. No
Check for a behavior change on isLowerCase and isUpperCase methods This rule flags the isLowerCase and isUpperCase methods. There is a very slight chance that a behavior change in these methods could affect your application. No
Check for a behavior change on Locale getDefault method This rule flags calls to the java.util.Locale getDefault() method as it has a new behavior. No
Check for a behavior change on MouseEvent getButton method This rule flags instances of the java.awt.event.MouseEvent getButton() method as it has a new behavior. No
Check for a behavior change on ThreadGroup setMaxPriority method This rule flags the method setMaxPriority on a ThreadGroup object. The method behavior has changed in JDK 7. No
Check for a behavior change on Toolkit getPrintJob method This rule flags instances of the java.awt.Toolkit getPrintJob(...) method as it has a new behavior. No
Check for a behavior change on Window setBackground method This rule flags calls to the java.awt.Window setBackground() method because its behavior changed by throwing a new exception. No
Check for classes that implement the TypeVisitor interface This rule flags classes implementing the javax.lang.model.type.TypeVisitor interface. In Java SE 7, a new method was added to this interface. No
Check for new methods on JDBC interfaces This rule detects classes that implement the JDBC interfaces that added new methods. The interfaces include java.sql.Connection, java.sql.Driver, java.sql.Statement, and javax.sql.CommonDataSource. java-version-7.yml
org.openrewrite.java.migrate.JREJdbcInterfaceNewMethods
Do not define methods declared as final in java.lang.Throwable

This rule detects class that extend java.lang.Throwable that implement methods addSuppressed and getSuppressed which were added as new final methods in Java 7.

java-version-7.yml
org.openrewrite.java.migrate.JREThrowableFinalMethods
Do not override the Path2D getPathIterator methods This rule flags the Path2D getPathIterator methods. These methods are now marked final in Java 7. No
Do not use removed class XSLTProcessorApplet This rule detects the use of the class org.apache.xalan.client.XSLTProcessorApplet. This class has been removed from JDK 7 release. No
Do not use the LinkedHashMap.Entry class This rules flags uses of the java.util.LinkedHashMap.Entry class as it is no longer accessible in Java SE 7. No

Java SE 6 compatibility impacts

Table 8. Java SE 6 compatibility impacts
Rule Name Rule Description Automated Fix
Check exception logic on calls to the EventHandler

In Java SE 6, the EventHandler constructor and create() methods require non-null parameters to be passed. This rule flags the constructor and create() method calls so that you can verify your logic handles a NullPointerException properly.

No
Check for Duration and XMLGregorianCalendar equals() method compatibility

Detect the use of Duration and XMLGregorianCalendar equals() method. Java 6 now returns false if the parameter passed is null. The exception, NullPointerException, was thrown previously.

No
Check for new methods on Java SQL interfaces

The java.sql.Wrapper interface was added as a superinterface to several Java SQL interfaces. When you move to Java 6, missing methods must be added to classes that implement the interfaces that added java.sql.Wrapper.

java-version-6.yml
org.openrewrite.java.migrate.JREWrapperInterface
Check for the OverlappingFileLockException for the FileChannel lock() method

In Java SE 6, the FileChannel.lock() method now throws OverlappingFileLockException. This rule flags the lock() method calls without a catch block for OverlappingFileLockException or without a throws declaration for OverlappingFileLockException on the method.

No
Remove use of double slashes in JMX ObjectName elements

Detect the use of the double-slash character string ("//") in JMX ObjectNames.

No

Oracle to IBM compatibility impacts

Run the following rules when you are migrating your application from an Oracle Java Runtime Environment to an IBM Java Runtime Environment. If you are running a Liberty server using an Oracle Java Runtime, do not run the quick fixes for these rules.

Table 9. Oracle to IBM compatibility impacts
Rule Name Rule Description Automated Fix
Detect com.sun.net.ssl.internal packages This rule flags import statements of certain com.sun.net.ssl.internal packages in Java files that are not available and should not be used. No
Do not use APIs from com.sun.net.ssl packages This rule detects the classes and interfaces in the com.sun.net.ssl package have been replaced by classes and interfaces in the javax.net.ssl package. ibm-java.yml
org.openrewrite.java.migrate.JREDoNotUseSunNetSslAPIs
Do not use com.sun.org.apache JAXP internal classes This rule flags internal Sun JAXP classes are not available in the IBM Java Runtime Environment. No
Do not use com.sun.org.apache JAXP package names in string literals This rule detects com.sun.org.apache JAXP 1.3 package names that are used in string literals. No
Do not use the com.sun.net.ssl.internal.ssl.Provider class This rule flags the class com.sun.net.ssl.internal.ssl.Provider should be replaced by com.ibm.jsse.IBMJSSEProvider. ibm-java.yml
org.openrewrite.java.migrate.JREDoNotUseSunNetSslInternalSslProvider
Do not use the com.sun.net.ssl.internal.www.protocol.https.Handler class This rule flags the com.sun.net.ssl.internal.www.protocol.https.Handler class that should be replaced by com.ibm.net.ssl.www2.protocol.https.Handler. ibm-java.yml
org.openrewrite.java.migrate.JREDoNotUseSunNetSslInternalWwwProtocolHttpsHandler
Do not use the com.sun.net.ssl.internal.www.protocol package This rule flags the com.sun.net.ssl.internal.www.protocol package references that should be replaced by com.ibm.net.ssl.www2.protocol. ibm-java.yml
org.openrewrite.java.migrate.JREDoNotUseSunNetSslInternalWwwProtocol

Sun internal APIs

Only run the following rules when you are migrating your application from an Oracle Java Runtime Environment to an IBM Java Runtime that contains the IBM class. For example, the HP-UX and Solaris Java Runtime Environment that ships with WebSphere Application Server does not contain the class. This rule is not selected automatically by any rule set.

Table 10. Sun internal APIs
Rule Name Rule Description Automated Fix
Do not use APIs from the sun.security.x509 package The classes and interfaces in the sun.security.x509 package are replaced by classes and interfaces in the com.ibm.security.x509 package on some operating systems. No