JDK 7 Compatibility Issues

Troubleshooting

Summary

Backwards incompatible behavioral changes in JDK 7 may result in IllegalArgumentExceptions and ClassCastException in some of yFiles for Java's layout algorithms for some but not all input graphs.
For a better user experience, please go to the integrated documentation viewer to read this article.

Description

In JDK 7, the Java development team has dropped the strict backwards compatibility policy known from previous releases in favor of small improvements to JDK tools and class library. Unfortunately, the incompatible behavior changes of two of these "improvements" may result in exceptions when using yFiles for Java layout algorithms.

Updated sort behavior for Arrays and Collections may throw an IllegalArgumentException

The sorting algorithm used by Arrays.sort has been changed to an implementation that cannot handle (i.e. throws an uncaught IllegalArgumentException for) some of the Comparator implementations used in yFiles for Java's layout algorithms. The affected algorithms are IncrementalHierarchicLayouter, SmartOrganicLayouter, the algorithms in package y.layout.orthogonal as well as the edge routing algorithms ChannelEdgeRouter and OrthogonalEdgeRouter.

The problem was fixed in yFiles for Java version 2.7.0.4, 2.8.0.4, 2.9, and newer. For older versions, the system property java.util.Arrays.useLegacyMergeSort may be used to force JDK 7 to use the previous, unproblematic sorting algorithm.
See Java SE 7 and JDK 7 Compatibility for additional information.

TreeMap and TreeSet may throw NullPointerException or ClassCastException when inserting first element

TreeMap has been changed to validate the first element inserted into the map with respect to the map's associated Comparator by comparing the element to itself. This new behavior may trigger an uncaught ClassCastException in yFiles for Java's PartialLayouter for some input graphs.

This problem was fixed in yFiles for Java version 2.7.0.4, 2.8.0.4, 2.9, and newer. No workaround is available.
See Java SE 7 Features and Enhancements for additional information.

Other issues

JDK 7's HotSpot virtual machine has broken optimization options enabled by default. These optimizations may result in erroneous results or even JVM crashes for computation intense algorithms (such as yFiles for Java's layout algorithms). Therefore, it is strongly recommended to refrain from using yFiles for Java with JDK 1.7.0 or JDK 1.7.0_01 in production environments.

These problems have been fixed for JDK 1.7.0_02 and newer.
See The real story behind the Java 7 GA bugs affecting Apache Lucene / Solr and Java SE 7 Features and Enhancements: Known Issues for additional information.

Categories this article belongs to:
yFiles for Java
Applies to:
yFiles for Java 2: 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8
Keywords:
JDK 7 - IllegalArgumentException - TimSort - ClassCastException TreeMap - HotSpot