It also has something to do with the version of JDK. The implementation method in JDK 7 has been changed for which you are violating one of the 3 rules of compareTo method contract.
Look at this:
Description: The sorting algorithm used by java.util.Arrays.sort and (indirectly) by java.util.Collections.sort has been replaced. The new sort implementation may throw an IllegalArgumentException if it detects a Comparable that violates the Comparable contract. The previous implementation silently ignored such a situation. If the previous behaviour is desired, you can use the new system property, java.util.Arrays.useLegacyMergeSort, to restore previous mergesort behaviour.
System.setProperty("java.util.Arrays.useLegacyMergeSort", "true");
It also has something to do with the version of JDK.
If it does well in JDK6, maybe it will have the problem in JDK 7 described by you, because the implementation method in jdk 7 has been changed.
Look at this:
Description: The sorting algorithm used by `java.util.Arrays.sort` and (indirectly) by `java.util.Collections.sort` has been replaced. The new sort implementation may throw an `IllegalArgumentException` if it detects a `Comparable` that violates the `Comparable` contract. The previous implementation silently ignored such a situation. If the previous behavior is desired, you can use the new system property, `java.util.Arrays.useLegacyMergeSort`, to restore previous mergesort behaviour.
I don't know the exact reason. However, if you add the code before you use sort. It will be OK.
System.setProperty("java.util.Arrays.useLegacyMergeSort", "true");