You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Vasily Zakharov (JIRA)" <ji...@apache.org> on 2007/01/07 14:11:29 UTC

[jira] Commented: (HARMONY-2622) [classlib][swing] Compatibility: javax.swing.JMenuBar.processKeyBinding() for incorrect parameterds throws NPE on Harmony instead of IllegalArgumentException on RI

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

Vasily Zakharov commented on HARMONY-2622:
------------------------------------------

I'll look into this issue.


> [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
>            Priority: Minor
>
> 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