I'm wondering if I compile in Java 6, but someone runs the program on Java 7, will the Java 6 or 7 version of Arrays.sort be used?
It's important because the new mergesort throws an IllegalArgumentException, and the old one doesn't (see Comparison method violates its general contract! Java 7 only)
Now, it's possible to compile in Java 7 using Arrays.useLegacyMergeSort, but obviously that flag isn't available for Java 6 - and we want to be compatible on Mac OS Snow Leopard (which uses 6).
For some reason (see http://madbean.com/2006/target14/) the -target compiler flag doesn't seem to produce compatible code, so we'd rather compile in Java 6.
Any suggestions?
try to set system property
java -Djava.util.Arrays.useLegacyMergeSort=true ...
Note that it's not from Arrays public API but from src
/**
* Old merge sort implementation can be selected (for
* compatibility with broken comparators) using a system property.
* Cannot be a static boolean in the enclosing class due to
* circular dependencies. To be removed in a future release.
*/
static final class LegacyMergeSort {
private static final boolean userRequested =
java.security.AccessController.doPrivileged(
new sun.security.action.GetBooleanAction(
"java.util.Arrays.useLegacyMergeSort")).booleanValue();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With