The siblingsComparator in sun.lwawt.macosx.CPlatformWindow violates the contract if one of the windows is not visible and therefore has no peer:

    private final Comparator<Window> siblingsComparator = (w1, w2) -> {
        if (w1 == w2) {
            return 0;
        }
        ComponentAccessor componentAccessor = AWTAccessor.getComponentAccessor();
        Object p1 = componentAccessor.getPeer(w1);
        Object p2 = componentAccessor.getPeer(w2);
        if (p1 instanceof LWWindowPeer && p2 instanceof LWWindowPeer) {
            return Long.compare(
                    ((CPlatformWindow) (((LWWindowPeer) p1).getPlatformWindow())).lastBecomeMainTime,
                    ((CPlatformWindow) (((LWWindowPeer) p2).getPlatformWindow())).lastBecomeMainTime);
        }
        return 0;
    };

java.lang.IllegalArgumentException: Comparison method violates its general contract!
at java.base/java.util.TimSort.mergeHi(TimSort.java:903)
at java.base/java.util.TimSort.mergeAt(TimSort.java:520)
at java.base/java.util.TimSort.mergeForceCollapse(TimSort.java:461)
at java.base/java.util.TimSort.sort(TimSort.java:254)
at java.base/java.util.Arrays.sort(Arrays.java:1441)
at java.desktop/sun.lwawt.macosx.CPlatformWindow.orderAboveSiblingsImpl(CPlatformWindow.java:1227)
at java.desktop/sun.lwawt.macosx.CPlatformWindow.orderAboveSiblings(CPlatformWindow.java:1218)
at java.desktop/sun.lwawt.macosx.CPlatformWindow.checkBlockingAndOrder(CPlatformWindow.java:1168)
at java.desktop/sun.lwawt.macosx.CPlatformWindow.setModalBlocked(CPlatformWindow.java:973)
at java.desktop/sun.lwawt.LWWindowPeer.setModalBlocked(LWWindowPeer.java:461)
at java.desktop/sun.lwawt.LWWindowPeer.blockWindows(LWWindowPeer.java:652)

Reply via email to