|
Quick Lists
|
|
Bug ID:
|
6786238
|
|
Votes
|
0
|
|
Synopsis
|
api/javax_swing/DefaultDesktopManager/descriptions.html#xxxFrame Fails with NPE since 6u12 b02
|
|
Category
|
java:classes_swing
|
|
Reported Against
|
|
|
Release Fixed
|
6u12(b03)
|
|
State
|
11-Closed,
Verified,
bug
|
|
Priority:
|
1-Very High
|
|
Related Bugs
|
6726866
|
|
Submit Date
|
17-DEC-2008
|
|
Description
|
JCK : JCK runtime 6b b24
J2SE : FAIL - since jdk 6u12 build customer (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
Posted Date : 2008-12-17 12:09:36.0
|
|
Work Around
|
N/A
|
|
Evaluation
|
The description gives all the informaiton about the problem
and the reason why it happens
The provided test illustrates a highly artificial situation
when beginResizingFrame() is called manually just for testing purposes
The beginResizingFrame() is called when the user draggs an internal frame
with the mouse which impies the fact that it is visible
However in the provided test case
the JDesktopPane is not added to a visible JFrame
Swing is not ready to this situation
a simple "new JFrame().add(p);" added before the c.beginResizingFrame()
eliminates the problem in the test
Posted Date : 2008-12-17 18:47:50.0
|
|
Comments
|
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|
|
|
 |