Compile in Java 6, run in 7 - how to specify useLegacyMergeSort?

后端 未结 1 2070
执笔经年
执笔经年 2021-02-07 06:42

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 merge

相关标签:
1条回答
  • 2021-02-07 07:35

    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();
        }
    
    0 讨论(0)
提交回复
热议问题