-
Enhancement
-
Resolution: Fixed
-
P5
-
7
-
b28
-
generic
-
generic
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8056496 | emb-9 | Sergey Bylokhov | P5 | Resolved | Fixed | master |
JDK-8063933 | 8u45 | Sergey Bylokhov | P5 | Resolved | Fixed | b01 |
JDK-8062444 | 8u40 | Sergey Bylokhov | P5 | Resolved | Fixed | b13 |
JDK-8070016 | emb-8u47 | Sergey Bylokhov | P5 | Resolved | Fixed | team |
-
JFrame.processWindowEvent() contains the following 'switch' operator:
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
switch(defaultCloseOperation) {
case HIDE_ON_CLOSE:
setVisible(false);
break;
case DISPOSE_ON_CLOSE:
dispose();
break;
case DO_NOTHING_ON_CLOSE:
default:
break;
case EXIT_ON_CLOSE:
// This needs to match the checkExit call in
// setDefaultCloseOperation
System.exit(0);
break;
}
}
Notice that the code is intricate. The 'default:' label is not the last one, but it is just after 'DO_NOTHING_ON_CLOSE:' label. Despite the code works properly, it should be rewritten in the following way:
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
switch(defaultCloseOperation) {
case HIDE_ON_CLOSE:
setVisible(false);
break;
case DISPOSE_ON_CLOSE:
dispose();
break;
case DO_NOTHING_ON_CLOSE:
break;
case EXIT_ON_CLOSE:
// This needs to match the checkExit call in
// setDefaultCloseOperation
System.exit(0);
break;
default:
break;
}
}
JFrame.processWindowEvent() contains the following 'switch' operator:
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
switch(defaultCloseOperation) {
case HIDE_ON_CLOSE:
setVisible(false);
break;
case DISPOSE_ON_CLOSE:
dispose();
break;
case DO_NOTHING_ON_CLOSE:
default:
break;
case EXIT_ON_CLOSE:
// This needs to match the checkExit call in
// setDefaultCloseOperation
System.exit(0);
break;
}
}
Notice that the code is intricate. The 'default:' label is not the last one, but it is just after 'DO_NOTHING_ON_CLOSE:' label. Despite the code works properly, it should be rewritten in the following way:
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
switch(defaultCloseOperation) {
case HIDE_ON_CLOSE:
setVisible(false);
break;
case DISPOSE_ON_CLOSE:
dispose();
break;
case DO_NOTHING_ON_CLOSE:
break;
case EXIT_ON_CLOSE:
// This needs to match the checkExit call in
// setDefaultCloseOperation
System.exit(0);
break;
default:
break;
}
}
- backported by
-
JDK-8056496 A switch operator in JFrame.processWindowEvent() should be rewritten
-
- Resolved
-
-
JDK-8062444 A switch operator in JFrame.processWindowEvent() should be rewritten
-
- Resolved
-
-
JDK-8063933 A switch operator in JFrame.processWindowEvent() should be rewritten
-
- Resolved
-
-
JDK-8070016 A switch operator in JFrame.processWindowEvent() should be rewritten
-
- Resolved
-