JDK-8215200 : IllegalArgumentException in sun.lwawt.macosx.CPlatformWindow
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 10,11,12
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: os_x
  • CPU: x86
  • Submitted: 2018-12-05
  • Updated: 2019-11-16
  • Resolved: 2018-12-19
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11 JDK 13
11.0.6-oracleFixed 13 b03Fixed
Related Reports
Relates :  
Description
ADDITIONAL SYSTEM INFORMATION :
Max OS X/Java 11.0.1

A DESCRIPTION OF THE PROBLEM :
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)


FREQUENCY : occasionally



Comments
Fix request (11u) I want to downport this for parity with 11.0.6-oracle. Applies clean.
15-11-2019

[~prr] looks like this is not critical for 12, so retargeting to 13 unless justified and non-risky-to-fix for 12
14-12-2018

Reported with mac OS, as per description, the "siblingsComparator" in sun.lwawt.macosx.CPlatformWindow violates the contract if one of the windows is not visible and therefore has no peer. From the provided details, it appears that the comparator has to be corrected in the class "sun.lwawt.macosx.CPlatformWindow", the comparator must not simply return 0 if p1 or p2 is null, but not both. Reference: http://hg.openjdk.java.net/jdk/jdk/file/4aa8fe00ace9/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java#l262
11-12-2018