harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Oliver Deakin (JIRA)" <j...@apache.org>
Subject [jira] Closed: (HARMONY-2622) [classlib][swing] Compatibility: javax.swing.JMenuBar.processKeyBinding() for incorrect parameterds throws NPE on Harmony instead of IllegalArgumentException on RI
Date Tue, 09 Jan 2007 10:32:27 GMT

     [ https://issues.apache.org/jira/browse/HARMONY-2622?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Oliver Deakin closed HARMONY-2622.
----------------------------------


Verified by Vasily.

> [classlib][swing] Compatibility: javax.swing.JMenuBar.processKeyBinding() for incorrect
parameterds throws NPE on Harmony instead of IllegalArgumentException on RI
> -------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-2622
>                 URL: https://issues.apache.org/jira/browse/HARMONY-2622
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Ilya Okomin
>         Assigned To: Oliver Deakin
>            Priority: Minor
>         Attachments: Harmony-2622-Test.patch, Harmony-2622.patch
>
>
> Method javax.swing.JMenuBar.processKeyBinding(KeyStroke ks, KeyEvent e, int condition,
boolean pressed) with params set (e ==null) && !(condition == JComponent.WHEN_IN_FOCUSED_WINDOW
|| JComponent.WHEN_FOCUSED || Component.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) throws NPE on
Harmony while IllegalArgumentException is thrown on RI. 
> Spec keeps silence about any exception for this method.
> Test to reproduce:
> ---------------test.java---------------
> import java.awt.event.KeyEvent;
> import javax.swing.JMenuBar;
> import javax.swing.KeyStroke;
> import junit.framework.TestCase;
> import junit.textui.TestRunner;
> public class test extends TestCase {
>     public static void main(String args[]) {
>         TestRunner.run(test.class);
>     }
>     private class MyJMenuBar extends JMenuBar {
>         public boolean processKeyBinding(KeyStroke ks, KeyEvent e,
>                 int condition, boolean pressed) {
>             return super.processKeyBinding(ks, e, condition, pressed);
>         }
>     }
>     public void testNullEvent() {
>         MyJMenuBar jm = new MyJMenuBar();
>         KeyStroke ks = (KeyStroke) KeyStroke.getKeyStroke('x');
>         try {
>             System.out.println("pass: result = "
>                     + jm.processKeyBinding(ks, null, -1, true));
>             fail("IllegalArgumentException expected but wasn't thrown!");
>         } catch (IllegalArgumentException e) {
>             // expected exception
>         }
>     }
> }
> ------------------------------
> Output RI:
> ========
> .
> Time: 1,172
> OK (1 test)
> Output Harmony:
> ==============
> .E
> Time: 2.173
> There was 1 error:
> 1) testNullEvent(test)java.lang.NullPointerException
> 	at javax.swing.JMenuBar.processKeyBinding(JMenuBar.java:191)
> 	at test$MyJMenuBar.processKeyBinding(test.java)
> 	at test.testNullEvent(test.java:26)
> 	at java.lang.reflect.VMReflection.invokeMethod(Native Method)
> 	at test.main(test.java:12)
> FAILURES!!!
> Tests run: 1,  Failures: 0,  Errors: 1
> I would like to add: in case, when condition is one of the appropriate values and event
is null - RI works silently and Harmony throws NPE. But combination of incorrect params that
was shown in the head should be taken into account to be compatible in order of thrown exceptions.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message