diff options
Diffstat (limited to 'libjava/java/awt/AWTKeyStroke.java')
-rw-r--r-- | libjava/java/awt/AWTKeyStroke.java | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/libjava/java/awt/AWTKeyStroke.java b/libjava/java/awt/AWTKeyStroke.java index 53e64b7fb1b..977b3848d6d 100644 --- a/libjava/java/awt/AWTKeyStroke.java +++ b/libjava/java/awt/AWTKeyStroke.java @@ -1,5 +1,5 @@ /* AWTKeyStroke.java -- an immutable key stroke - Copyright (C) 2002, 2004 Free Software Foundation + Copyright (C) 2002, 2004, 2005 Free Software Foundation This file is part of GNU Classpath. @@ -63,7 +63,7 @@ import java.util.StringTokenizer; * instances of a subclass, using reflection, provided the subclass has a * no-arg constructor (of any accessibility). * - * @author Eric Blake <ebb9@email.byu.edu> + * @author Eric Blake (ebb9@email.byu.edu) * @see #getAWTKeyStroke(char) * @since 1.4 * @status updated to 1.4 @@ -393,15 +393,16 @@ public class AWTKeyStroke implements Serializable * </code> * * @param s the string to parse + * @throws IllegalArgumentException if s is null or cannot be parsed * @return the specified keystroke - * @throws NullPointerException if s is null - * @throws IllegalArgumentException if s cannot be parsed */ public static AWTKeyStroke getAWTKeyStroke(String s) { + if (s == null) + throw new IllegalArgumentException("null argument"); StringTokenizer t = new StringTokenizer(s, " "); if (! t.hasMoreTokens()) - throw new IllegalArgumentException(); + throw new IllegalArgumentException("no tokens '" + s + "'"); int modifiers = 0; boolean released = false; String token = null; @@ -432,7 +433,8 @@ public class AWTKeyStroke implements Serializable KeyEvent.VK_UNDEFINED, modifiers, false); } - throw new IllegalArgumentException(); + throw new IllegalArgumentException("Invalid 'typed' argument '" + + s + "'"); } else if ("pressed".equals(token)) { @@ -453,8 +455,11 @@ public class AWTKeyStroke implements Serializable while (t.hasMoreTokens()); // Now token contains the VK name we must parse. Integer code = (Integer) vktable.get(token); - if (code == null || t.hasMoreTokens()) - throw new IllegalArgumentException(); + if (code == null) + throw new IllegalArgumentException("Unknown token '" + token + + "' in '" + s + "'"); + if (t.hasMoreTokens()) + throw new IllegalArgumentException("Too many tokens: " + s); return getAWTKeyStroke(KeyEvent.CHAR_UNDEFINED, code.intValue(), modifiers, released); } |