JDK-7133207 : Regression: ClassCastException thrown from Component.setFocusTraversalKeys_NoIDCheck instead of IAE
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 8
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows
  • CPU: generic
  • Submitted: 2012-01-25
  • Updated: 2012-06-04
  • Resolved: 2012-06-04
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 8
8Resolved
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
The problem described in CR#6195828 is back.

PASSES: JDK7b147, JDK7u2, JDK8b14
FAILS: JDK8 b20 (exact build number when the regression was introduced is unknown)
Platform: was reproduced on Windows

Please see the following minimized testcase:

---
import java.awt.*;
import java.awt.event.KeyEvent;
import java.util.HashSet;

public class SetFocusTraversalKeys {

    public static void main(String[] args) {

        Component button = new Component() {};
        AWTKeyStroke key = AWTKeyStroke.getAWTKeyStrokeForEvent(
                new KeyEvent(button, KeyEvent.KEY_PRESSED, 0, 0, KeyEvent.VK_UNDEFINED, 'a'));
        HashSet set = new HashSet();
        set.add(key);
        set.add(new Object());

        try {
            button.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, set);
        } catch(Exception e) {
            if (e instanceof IllegalArgumentException) {
                System.out.println("Component: OKAY");
            } else {
                e.printStackTrace();
                System.out.println("Component: unexpected " + e + " thrown instead of IAE");
            }
        }
    }

}
---

For 8b20 the ouput is:

java.lang.ClassCastException: java.lang.Object cannot be cast to java.awt.AWTKeyStroke
	at java.awt.Component.setFocusTraversalKeys_NoIDCheck(Component.java:7251)
	at java.awt.Component.setFocusTraversalKeys(Component.java:7200)
	at bugs.SetFocusTraversalKeys.main(SetFocusTraversalKeys.java:19)
Component: unexpected java.lang.ClassCastException: java.lang.Object cannot be cast to java.awt.AWTKeyStroke thrown instead of IAE
The following JCK testcases fails due to this issue:

api/java_awt/awt_focus_subsystem/focus_traversal/index.html#FocusTraversal3[FocusTraversal3_hw_0005]
api/java_awt/awt_focus_subsystem/focus_traversal/index.html#FocusTraversal3[FocusTraversal3_lw_0006]

Comments
EVALUATION It is a regression of wraning cleanup day. See CR 7117334.
02-02-2012