JDK-6356118 : CTE_REGTEST/Generic/4347545 fails on Solaris
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • OS: solaris
  • CPU: sparc
  • Submitted: 2005-11-28
  • Updated: 2019-12-17
  • Resolved: 2019-12-17
Related Reports
Relates :  
Relates :  
Description
This is is open for the failure on Solaris as suggested by Oleg Semenov <###@###.###>. 

Please see CR# 6337388 for complete background of this defect.

Here's Dmitri Trembovetski's simplified test shows the same bug:

****************************
import java.awt.Canvas;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.GraphicsConfiguration;
import java.awt.Window;


class AWTRenderingContents extends Canvas {

    public AWTRenderingContents(GraphicsConfiguration gc) {
        super(gc);
    }

    public void paint (Graphics g) {
    }
    
    public static void main (String args[]) {
        for (int i = 0; i < 20; i++) {
            Frame f = new Frame("AWTRenderingContents");
            f.setSize(400, 400);
            f.setLocation(10, 10);
            f.add(new AWTRenderingContents(f.getGraphicsConfiguration()));
            f.addWindowListener(new java.awt.event.WindowAdapter() {
                public void windowClosing(java.awt.event.WindowEvent we) {
                    Window w = (Window) we.getSource();
                    w.dispose();
                    System.gc();
                    System.runFinalization();
                    System.gc();
                    System.runFinalization();
                    System.gc();
                    System.runFinalization();
                    System.gc();
                    System.runFinalization();
                }
            });
            f.setVisible(true);
        }
    }
}
******************************

Dmitri and Oleg 's analyses can be found in CR# 6337388

Comments
EVALUATION Fixed in jdk7 and jdk8.
12-07-2011

SUGGESTED FIX As the cursor state makes sense only for the visible components, they are those which have peer which has a strong reference to the target. This means that the reference from cursor can be weak. *** /tmp/geta13068.K13071 2005-12-14 16:22:03.805326832 +0300 --- XGlobalCursorManager.java 2005-12-14 16:21:36.797432656 +0300 *************** *** 10,15 **** --- 10,16 ---- import java.awt.*; import java.lang.reflect.Field; import java.lang.reflect.Method; + import java.lang.ref.WeakReference; import sun.awt.GlobalCursorManager; import sun.awt.GlobalCursorManager.*; *************** *** 32,41 **** } } - // cached nativeContainer ! private Component nativeContainer; /** * The XGlobalCursorManager is a singleton. --- 33,55 ---- } } // cached nativeContainer ! private WeakReference<Component> nativeContainer; + private Component getCachedContainer() { + WeakReference<Component> nativeContainer = this.nativeContainer; + if (nativeContainer != null) { + return nativeContainer.get(); + } else { + return null; + } + } + + private void setCachedContainer(Component comp) { + if (comp != null) { + nativeContainer = new WeakReference<Component>(comp); + } + } /** * The XGlobalCursorManager is a singleton. *************** *** 66,76 **** Cursor cur = useCache ? cursor : getCapableCursor(comp); ! Component nc = useCache ? nativeContainer : getNativeContainer(comp); if (nc != null && nc.isDisplayable() && (nc.getPeer() instanceof XComponentPeer)) { ! nativeContainer = nc; ! ((XComponentPeer)nc.getPeer()).pSetCursor(cur); } } --- 80,89 ---- Cursor cur = useCache ? cursor : getCapableCursor(comp); ! Component nc = useCache ? getCachedContainer() : getNativeContainer(comp); if (nc != null && nc.isDisplayable() && (nc.getPeer() instanceof XComponentPeer)) { ! setCachedContainer(nc); ((XComponentPeer)nc.getPeer()).pSetCursor(cur); } }
14-12-2005

EVALUATION I was able to reproduce the problem on Linux (SuSE 9.1), KDE, 6.0-b61 using the test from the description. I see similar track - from XGlobalCursorManager.nativeContainer. Looking at the code it can be said that this field is getting set but is never cleared: if (nc != null && nc.isDisplayable() && (nc.getPeer() instanceof XComponentPeer)) { nativeContainer = nc; This is the only assignment to nativeContainer, and the assigned value is never null because of this "if".
14-12-2005