Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6786238

api/javax_swing/DefaultDesktopManager/descriptions.html#xxxFrame Fails with NPE since 6u12 b02

    XMLWordPrintable

Details

    • b02
    • b03
    • generic
    • generic
    • Verified

    Backports

      Description

        JCK : JCK runtime 6b b24
        J2SE : FAIL - since jdk 6u12 build 02 (Passes with b01)
        Platform[s] : FAIL - Any (Found on linux and windows vista)
        Java options : FAIL - Any

        4 testcases of the test api/javax_swing/DefaultDesktopManager/descriptions.html#xxxFrame Fails with NPE since 6u12 b02
        This testcases are DefaultDesktopManager2012 DefaultDesktopManager2013
        DefaultDesktopManager2014 DefaultDesktopManager2015

        Please, see *.jtr file in comments.

        Steps to reproduce:
        1. Install JCK (for ex. to /export/JCK/JCK-runtime-6b/)
        2. Install JDK (for ex. to /export/jdk/jdk1.6.0_12)
        3. Run the simple script:
        #!/bin/bash -v

        export JAVA=/export/jdk/jdk1.6.0_12/bin/java
        export CLASSPATH="/export/JCK/JCK-runtime-6b/classes"

        OPTS=""
        TEST=javasoft.sqe.tests.api.javax.swing.DefaultDesktopManager.xxxFrameTests

        $JAVA -version
        $JAVA $TEST

        Test source could be reduced to
        import java.awt.*;
        import javax.swing.*;

        public class test {
            public static void main(String argv[]) {
                JComponent internalFrame = new JInternalFrame();
                JDesktopPane p = new JDesktopPane();

                p.add(internalFrame);

                DefaultDesktopManager c = new DefaultDesktopManager();
                p.setDesktopManager(c);

        // Uncomment one of the following lines to see NPE
                //c.beginResizingFrame( internalFrame, 10);
                //c.beginDraggingFrame( internalFrame);

                System.out.println("OK");
            }
        }

        When you execute this class exceptions would be:

        Exception in thread "main" java.lang.NullPointerException: The window argument should not be null.
                at com.sun.awt.AWTUtilities.isWindowOpaque(AWTUtilities.java:410)
                at javax.swing.DefaultDesktopManager.setupDragMode(DefaultDesktopManager.java:303)
                at javax.swing.DefaultDesktopManager.beginResizingFrame(DefaultDesktopManager.java:375)
                at test.main(test.java:14)

        Exception in thread "main" java.lang.NullPointerException: The window argument should not be null.
                at com.sun.awt.AWTUtilities.isWindowOpaque(AWTUtilities.java:410)
                at javax.swing.DefaultDesktopManager.setupDragMode(DefaultDesktopManager.java:303)
                at javax.swing.DefaultDesktopManager.beginDraggingFrame(DefaultDesktopManager.java:277)
                at test.main(test.java:19)

        Problematic function is setupDragMode since SwingUtilities.getWindowAncestor(f) according to specification could return NULL and this is not handled.

        public static Window getWindowAncestor(Component c)
        Returns:
          the first Window ancestor of c, or null if component is not contained inside a window

            private void setupDragMode(JComponent f) {
                JDesktopPane p = getDesktopPane(f);
                Container parent = f.getParent();
                dragMode = DEFAULT_DRAG_MODE;
                if (p != null) {
                    String mode = (String)p.getClientProperty("JDesktopPane.dragMode");
                    if (!AWTUtilities.isWindowOpaque(SwingUtilities.getWindowAncestor(f))) { // exception here
                        dragMode = DEFAULT_DRAG_MODE;
                    } else if (mode != null && mode.equals("outline")) {
                        dragMode = OUTLINE_DRAG_MODE;
                    } else if (mode != null && mode.equals("faster")
                            && f instanceof JInternalFrame
                            && ((JInternalFrame)f).isOpaque() &&
                               (parent == null || parent.isOpaque())) {
                        dragMode = FASTER_DRAG_MODE;
                    } else {
                        if (p.getDragMode() == JDesktopPane.OUTLINE_DRAG_MODE ) {
                            dragMode = OUTLINE_DRAG_MODE;
                        } else if ( p.getDragMode() == JDesktopPane.LIVE_DRAG_MODE
                                && f instanceof JInternalFrame
                                && ((JInternalFrame)f).isOpaque()) {
                            dragMode = FASTER_DRAG_MODE;
                        } else {
                            dragMode = DEFAULT_DRAG_MODE;
                        }
                    }
                }
            }

        It may be possible that this regression is introduced by fix for CR 6726866

        Attachments

          Issue Links

            Activity

              People

                alexp Alexander Potochkin (Inactive)
                ephilipp Evgeny Philippov (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: