Do not rely on NPE's in MathContext.

Change-Id: Ie1326fbba561eb03fefb6ca87b6365499e262b58
Review-Link: https://gwt-review.googlesource.com/#/c/13987/
diff --git a/user/super/com/google/gwt/emul/java/math/MathContext.java b/user/super/com/google/gwt/emul/java/math/MathContext.java
index a1bf062..fec0b4d 100644
--- a/user/super/com/google/gwt/emul/java/math/MathContext.java
+++ b/user/super/com/google/gwt/emul/java/math/MathContext.java
@@ -140,8 +140,12 @@
   public MathContext(String val) {
     checkNotNull(val, "null string");
 
+    String[] extractedValues = parseValue(val);
+    if (extractedValues == null || extractedValues.length != 3) {
+      throw new IllegalArgumentException("bad string format");
+    }
+
     try {
-      String[] extractedValues = parseValue(val);
       this.precision = Integer.parseInt(extractedValues[1]);
       // Can use RoundingMode.valueOf here because it is blacklisted in enum obfuscation.
       this.roundingMode = RoundingMode.valueOf(extractedValues[2]);