Revert "Add change comments in DecimalFormat/NumberFormat."

This reverts commit f8dc36d04961d13ec0b0d2692fba6ca2dbd0a184.

Reason for revert: Breaks libcore tests:

    java.lang.NullPointerException: Attempt to invoke virtual method 'void android.icu.text.DecimalFormat.applyPattern(java.lang.String)' on a null object reference
    	at java.text.DecimalFormat.applyPattern(DecimalFormat.java:1289)
    	at java.text.DecimalFormat.readObject(DecimalFormat.java:1712)

Bug: 65669355
Change-Id: Ia3d82f4835fa7382533982e8edd73aa031a90860
Test: none
diff --git a/ojluni/src/main/java/java/text/DecimalFormat.java b/ojluni/src/main/java/java/text/DecimalFormat.java
index 411ed8a..17d5d41 100644
--- a/ojluni/src/main/java/java/text/DecimalFormat.java
+++ b/ojluni/src/main/java/java/text/DecimalFormat.java
@@ -381,12 +381,6 @@
  */
 public class DecimalFormat extends NumberFormat {
 
-    // Android-note: This class is heavily modified from upstream OpenJDK.
-    // Android's version delegates most of its work to android.icu.text.DecimalFormat. This is done
-    // to avoid code duplication and to stay compatible with earlier releases that used ICU4C/ICU4J
-    // to implement DecimalFormat.
-
-    // Android-added: ICU DecimalFormat to delegate to.
     private transient android.icu.text.DecimalFormat icuDecimalFormat;
 
     /**
@@ -408,7 +402,6 @@
     public DecimalFormat() {
         // Get the pattern for the default locale.
         Locale def = Locale.getDefault(Locale.Category.FORMAT);
-        // BEGIN Android-changed: Use ICU LocaleData.
         // try to get the pattern from the cache
         String pattern = cachedLocaleData.get(def);
         if (pattern == null) {  /* cache miss */
@@ -417,11 +410,8 @@
             /* update cache */
             cachedLocaleData.putIfAbsent(def, pattern);
         }
-        // END Android-changed: Use ICU LocaleData.
-        // Always applyPattern after the symbols are set
-        this.symbols = DecimalFormatSymbols.getInstance(def);
-        // Android-changed: use initPattern() instead of removed applyPattern(String, boolean).
-        initPattern(pattern);
+        this.symbols = new DecimalFormatSymbols(def);
+        init(pattern);
     }
 
 
@@ -445,10 +435,8 @@
      * @see java.text.NumberFormat#getPercentInstance
      */
     public DecimalFormat(String pattern) {
-        // Always applyPattern after the symbols are set
-        this.symbols = DecimalFormatSymbols.getInstance(Locale.getDefault(Locale.Category.FORMAT));
-        // Android-changed: use initPattern() instead of removed applyPattern(String, boolean).
-        initPattern(pattern);
+        this.symbols = new DecimalFormatSymbols(Locale.getDefault(Locale.Category.FORMAT));
+        init(pattern);
     }
 
 
@@ -476,69 +464,45 @@
     public DecimalFormat (String pattern, DecimalFormatSymbols symbols) {
         // Always applyPattern after the symbols are set
         this.symbols = (DecimalFormatSymbols)symbols.clone();
-        // Android-changed: use initPattern() instead of removed applyPattern(String, boolean).
-        initPattern(pattern);
+        init(pattern);
     }
 
-    // BEGIN Android-added: initPattern() and conversion methods between ICU and Java values.
-    /**
-     * Applies the pattern similarly to {@link #applyPattern(String)}, except it initializes
-     * {@link #icuDecimalFormat} in the process. This should only be called from constructors.
-     */
-    private void initPattern(String pattern) {
+    private void init(String pattern) {
         this.icuDecimalFormat =  new android.icu.text.DecimalFormat(pattern,
                 symbols.getIcuDecimalFormatSymbols());
         updateFieldsFromIcu();
     }
 
     /**
-     * Update local fields indicating maximum/minimum integer/fraction digit count from the ICU
-     * DecimalFormat. This needs to be called whenever a new pattern is applied.
-     */
-    private void updateFieldsFromIcu() {
-        // Imitate behaviour of ICU4C NumberFormat that Android used up to M.
-        // If the pattern doesn't enforce a different value (some exponential
-        // patterns do), then set the maximum integer digits to 2 billion.
-        if (icuDecimalFormat.getMaximumIntegerDigits() == DOUBLE_INTEGER_DIGITS) {
-            icuDecimalFormat.setMaximumIntegerDigits(2000000000);
-        }
-        maximumIntegerDigits = icuDecimalFormat.getMaximumIntegerDigits();
-        minimumIntegerDigits = icuDecimalFormat.getMinimumIntegerDigits();
-        maximumFractionDigits = icuDecimalFormat.getMaximumFractionDigits();
-        minimumFractionDigits = icuDecimalFormat.getMinimumFractionDigits();
-    }
-
-    /**
      * Converts between field positions used by Java/ICU.
      * @param fp The java.text.NumberFormat.Field field position
      * @return The android.icu.text.NumberFormat.Field field position
      */
     private static FieldPosition getIcuFieldPosition(FieldPosition fp) {
-        Format.Field fieldAttribute = fp.getFieldAttribute();
-        if (fieldAttribute == null) return fp;
+        if (fp.getFieldAttribute() == null) return fp;
 
         android.icu.text.NumberFormat.Field attribute;
-        if (fieldAttribute == Field.INTEGER) {
+        if (fp.getFieldAttribute() == Field.INTEGER) {
             attribute = android.icu.text.NumberFormat.Field.INTEGER;
-        } else if (fieldAttribute == Field.FRACTION) {
+        } else if (fp.getFieldAttribute() == Field.FRACTION) {
             attribute = android.icu.text.NumberFormat.Field.FRACTION;
-        } else if (fieldAttribute == Field.DECIMAL_SEPARATOR) {
+        } else if (fp.getFieldAttribute() == Field.DECIMAL_SEPARATOR) {
             attribute = android.icu.text.NumberFormat.Field.DECIMAL_SEPARATOR;
-        } else if (fieldAttribute == Field.EXPONENT_SYMBOL) {
+        } else if (fp.getFieldAttribute() == Field.EXPONENT_SYMBOL) {
             attribute = android.icu.text.NumberFormat.Field.EXPONENT_SYMBOL;
-        } else if (fieldAttribute == Field.EXPONENT_SIGN) {
+        } else if (fp.getFieldAttribute() == Field.EXPONENT_SIGN) {
             attribute = android.icu.text.NumberFormat.Field.EXPONENT_SIGN;
-        } else if (fieldAttribute == Field.EXPONENT) {
+        } else if (fp.getFieldAttribute() == Field.EXPONENT) {
             attribute = android.icu.text.NumberFormat.Field.EXPONENT;
-        } else if (fieldAttribute == Field.GROUPING_SEPARATOR) {
+        } else if (fp.getFieldAttribute() == Field.GROUPING_SEPARATOR) {
             attribute = android.icu.text.NumberFormat.Field.GROUPING_SEPARATOR;
-        } else if (fieldAttribute == Field.CURRENCY) {
+        } else if (fp.getFieldAttribute() == Field.CURRENCY) {
             attribute = android.icu.text.NumberFormat.Field.CURRENCY;
-        } else if (fieldAttribute == Field.PERCENT) {
+        } else if (fp.getFieldAttribute() == Field.PERCENT) {
             attribute = android.icu.text.NumberFormat.Field.PERCENT;
-        } else if (fieldAttribute == Field.PERMILLE) {
+        } else if (fp.getFieldAttribute() == Field.PERMILLE) {
             attribute = android.icu.text.NumberFormat.Field.PERMILLE;
-        } else if (fieldAttribute == Field.SIGN) {
+        } else if (fp.getFieldAttribute() == Field.SIGN) {
             attribute = android.icu.text.NumberFormat.Field.SIGN;
         } else {
             throw new IllegalArgumentException("Unexpected field position attribute type.");
@@ -557,43 +521,41 @@
      * @return Field converted to a java.text.NumberFormat.Field field.
      */
     private static Field toJavaFieldAttribute(AttributedCharacterIterator.Attribute icuAttribute) {
-        String name = icuAttribute.getName();
-        if (name.equals(Field.INTEGER.getName())) {
+        if (icuAttribute.getName().equals(Field.INTEGER.getName())) {
             return Field.INTEGER;
         }
-        if (name.equals(Field.CURRENCY.getName())) {
+        if (icuAttribute.getName().equals(Field.CURRENCY.getName())) {
             return Field.CURRENCY;
         }
-        if (name.equals(Field.DECIMAL_SEPARATOR.getName())) {
+        if (icuAttribute.getName().equals(Field.DECIMAL_SEPARATOR.getName())) {
             return Field.DECIMAL_SEPARATOR;
         }
-        if (name.equals(Field.EXPONENT.getName())) {
+        if (icuAttribute.getName().equals(Field.EXPONENT.getName())) {
             return Field.EXPONENT;
         }
-        if (name.equals(Field.EXPONENT_SIGN.getName())) {
+        if (icuAttribute.getName().equals(Field.EXPONENT_SIGN.getName())) {
             return Field.EXPONENT_SIGN;
         }
-        if (name.equals(Field.EXPONENT_SYMBOL.getName())) {
+        if (icuAttribute.getName().equals(Field.EXPONENT_SYMBOL.getName())) {
             return Field.EXPONENT_SYMBOL;
         }
-        if (name.equals(Field.FRACTION.getName())) {
+        if (icuAttribute.getName().equals(Field.FRACTION.getName())) {
             return Field.FRACTION;
         }
-        if (name.equals(Field.GROUPING_SEPARATOR.getName())) {
+        if (icuAttribute.getName().equals(Field.GROUPING_SEPARATOR.getName())) {
             return Field.GROUPING_SEPARATOR;
         }
-        if (name.equals(Field.SIGN.getName())) {
+        if (icuAttribute.getName().equals(Field.SIGN.getName())) {
             return Field.SIGN;
         }
-        if (name.equals(Field.PERCENT.getName())) {
+        if (icuAttribute.getName().equals(Field.PERCENT.getName())) {
             return Field.PERCENT;
         }
-        if (name.equals(Field.PERMILLE.getName())) {
+        if (icuAttribute.getName().equals(Field.PERMILLE.getName())) {
             return Field.PERMILLE;
         }
-        throw new IllegalArgumentException("Unrecognized attribute: " + name);
-    }
-    // END Android-added: initPattern() and conversion methods between ICU and Java values.
+        throw new IllegalArgumentException("Unrecognized attribute: " + icuAttribute.getName());
+   }
 
     // Overrides
     /**
@@ -652,17 +614,13 @@
     @Override
     public StringBuffer format(double number, StringBuffer result,
                                FieldPosition fieldPosition) {
-        // BEGIN Android-changed: Use ICU.
         FieldPosition icuFieldPosition = getIcuFieldPosition(fieldPosition);
         icuDecimalFormat.format(number, result, icuFieldPosition);
         fieldPosition.setBeginIndex(icuFieldPosition.getBeginIndex());
         fieldPosition.setEndIndex(icuFieldPosition.getEndIndex());
         return result;
-        // END Android-changed: Use ICU.
     }
 
-    // Android-removed: private StringBuffer format(double, StringBuffer, FieldDelegate).
-
     /**
      * Format a long to produce a string.
      * @param number    The long to format
@@ -677,17 +635,13 @@
     @Override
     public StringBuffer format(long number, StringBuffer result,
                                FieldPosition fieldPosition) {
-        // BEGIN Android-changed: Use ICU.
         FieldPosition icuFieldPosition = getIcuFieldPosition(fieldPosition);
         icuDecimalFormat.format(number, result, icuFieldPosition);
         fieldPosition.setBeginIndex(icuFieldPosition.getBeginIndex());
         fieldPosition.setEndIndex(icuFieldPosition.getEndIndex());
         return result;
-        // END Android-changed: Use ICU.
     }
 
-    // Android-removed: private StringBuffer format(long, StringBuffer, FieldDelegate).
-
     /**
      * Formats a BigDecimal to produce a string.
      * @param number    The BigDecimal to format
@@ -701,17 +655,13 @@
      */
     private StringBuffer format(BigDecimal number, StringBuffer result,
                                 FieldPosition fieldPosition) {
-        // BEGIN Android-changed: Use ICU.
         FieldPosition icuFieldPosition = getIcuFieldPosition(fieldPosition);
         icuDecimalFormat.format(number, result, fieldPosition);
         fieldPosition.setBeginIndex(icuFieldPosition.getBeginIndex());
         fieldPosition.setEndIndex(icuFieldPosition.getEndIndex());
         return result;
-        // END Android-changed: Use ICU.
     }
 
-    // Android-removed: private StringBuffer format(BigDecimal, StringBuffer, FieldDelegate).
-
     /**
      * Format a BigInteger to produce a string.
      * @param number    The BigInteger to format
@@ -725,17 +675,13 @@
      */
     private StringBuffer format(BigInteger number, StringBuffer result,
                                FieldPosition fieldPosition) {
-        // BEGIN Android-changed: Use ICU.
         FieldPosition icuFieldPosition = getIcuFieldPosition(fieldPosition);
         icuDecimalFormat.format(number, result, fieldPosition);
         fieldPosition.setBeginIndex(icuFieldPosition.getBeginIndex());
         fieldPosition.setEndIndex(icuFieldPosition.getEndIndex());
         return result;
-        // END Android-changed: Use ICU.
     }
 
-    // Android-removed: private StringBuffer format(BigInteger, StringBuffer, FieldDelegate).
-
     /**
      * Formats an Object producing an <code>AttributedCharacterIterator</code>.
      * You can use the returned <code>AttributedCharacterIterator</code>
@@ -757,7 +703,6 @@
      */
     @Override
     public AttributedCharacterIterator formatToCharacterIterator(Object obj) {
-        // BEGIN Android-changed: Use ICU.
         if (obj == null) {
             throw new NullPointerException("object == null");
         }
@@ -791,13 +736,8 @@
         }
 
         return result.getIterator();
-        // END Android-changed: Use ICU.
     }
 
-    // Android-removed: "fast-path formating logic for double" (sic).
-
-    // Android-removed: subformat(), append().
-
     /**
      * Parses text from a string to produce a <code>Number</code>.
      * <p>
@@ -856,7 +796,6 @@
      */
     @Override
     public Number parse(String text, ParsePosition pos) {
-        // BEGIN Android-changed: Use ICU.
         // Return early if the parse position is bogus.
         if (pos.index < 0 || pos.index >= text.length()) {
             return null;
@@ -890,11 +829,8 @@
             return 0L;
         }
         return number;
-        // END Android-changed: Use ICU.
     }
 
-    // Android-removed: STATUS_* constants, multiplier fields and methods and subparse(String, ...).
-
     /**
      * Returns a copy of the decimal format symbols, which is generally not
      * changed by the programmer or user.
@@ -902,7 +838,6 @@
      * @see java.text.DecimalFormatSymbols
      */
     public DecimalFormatSymbols getDecimalFormatSymbols() {
-        // Android-changed: Use ICU.
         return DecimalFormatSymbols.fromIcuInstance(icuDecimalFormat.getDecimalFormatSymbols());
     }
 
@@ -917,7 +852,6 @@
         try {
             // don't allow multiple references
             symbols = (DecimalFormatSymbols) newSymbols.clone();
-            // Android-changed: Use ICU.
             icuDecimalFormat.setDecimalFormatSymbols(symbols.getIcuDecimalFormatSymbols());
         } catch (Exception foo) {
             // should never happen
@@ -931,7 +865,6 @@
      * @return the positive prefix
      */
     public String getPositivePrefix () {
-        // Android-changed: Use ICU.
         return icuDecimalFormat.getPositivePrefix();
     }
 
@@ -942,12 +875,9 @@
      * @param newValue the new positive prefix
      */
     public void setPositivePrefix (String newValue) {
-        // Android-changed: Use ICU.
         icuDecimalFormat.setPositivePrefix(newValue);
     }
 
-    // Android-removed: private helper getPositivePrefixFieldPositions().
-
     /**
      * Get the  prefix.
      * <P>Examples: -123, ($123) (with negative suffix), sFr-123
@@ -955,7 +885,6 @@
      * @return the negative prefix
      */
     public String getNegativePrefix () {
-        // Android-changed: Use ICU.
         return icuDecimalFormat.getNegativePrefix();
     }
 
@@ -966,12 +895,9 @@
      * @param newValue the new negative prefix
      */
     public void setNegativePrefix (String newValue) {
-        // Android-changed: Use ICU.
         icuDecimalFormat.setNegativePrefix(newValue);
     }
 
-    // Android-removed: private helper getNegativePrefixFieldPositions().
-
     /**
      * Get the positive suffix.
      * <P>Example: 123%
@@ -979,7 +905,6 @@
      * @return the positive suffix
      */
     public String getPositiveSuffix () {
-        // Android-changed: Use ICU.
         return icuDecimalFormat.getPositiveSuffix();
     }
 
@@ -990,12 +915,9 @@
      * @param newValue the new positive suffix
      */
     public void setPositiveSuffix (String newValue) {
-        // Android-changed: Use ICU.
         icuDecimalFormat.setPositiveSuffix(newValue);
     }
 
-    // Android-removed: private helper getPositiveSuffixFieldPositions().
-
     /**
      * Get the negative suffix.
      * <P>Examples: -123%, ($123) (with positive suffixes)
@@ -1003,7 +925,6 @@
      * @return the negative suffix
      */
     public String getNegativeSuffix () {
-        // Android-changed: Use ICU.
         return icuDecimalFormat.getNegativeSuffix();
     }
 
@@ -1014,12 +935,9 @@
      * @param newValue the new negative suffix
      */
     public void setNegativeSuffix (String newValue) {
-        // Android-changed: Use ICU.
         icuDecimalFormat.setNegativeSuffix(newValue);
     }
 
-    // Android-removed: private helper getNegativeSuffixFieldPositions().
-
     /**
      * Gets the multiplier for use in percent, per mille, and similar
      * formats.
@@ -1028,7 +946,6 @@
      * @see #setMultiplier(int)
      */
     public int getMultiplier () {
-        // Android-changed: Use ICU.
         return icuDecimalFormat.getMultiplier();
     }
 
@@ -1051,27 +968,6 @@
     }
 
     /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void setGroupingUsed(boolean newValue) {
-        // Android-changed: Use ICU.
-        icuDecimalFormat.setGroupingUsed(newValue);
-        // Android-removed: fast path related code.
-        // fastPathCheckNeeded = true;
-    }
-
-    // BEGIN Android-added: isGroupingUsed() override delegating to ICU.
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public boolean isGroupingUsed() {
-        return icuDecimalFormat.isGroupingUsed();
-    }
-    // END Android-added: isGroupingUsed() override delegating to ICU.
-
-    /**
      * Return the grouping size. Grouping size is the number of digits between
      * grouping separators in the integer portion of a number.  For example,
      * in the number "123,456.78", the grouping size is 3.
@@ -1082,7 +978,6 @@
      * @see java.text.DecimalFormatSymbols#getGroupingSeparator
      */
     public int getGroupingSize () {
-        // Android-changed: Use ICU.
         return icuDecimalFormat.getGroupingSize();
     }
 
@@ -1099,10 +994,26 @@
      * @see java.text.DecimalFormatSymbols#setGroupingSeparator
      */
     public void setGroupingSize (int newValue) {
-        // Android-changed: Use ICU.
         icuDecimalFormat.setGroupingSize(newValue);
-        // Android-removed: fast path related code.
-        // fastPathCheckNeeded = true;
+    }
+
+    /**
+     * Returns true if grouping is used in this format. For example, in the
+     * English locale, with grouping on, the number 1234567 might be formatted
+     * as "1,234,567". The grouping separator as well as the size of each group
+     * is locale dependant and is determined by sub-classes of NumberFormat.
+     * @see #setGroupingUsed
+     */
+    public boolean isGroupingUsed() {
+        return icuDecimalFormat.isGroupingUsed();
+    }
+
+    /**
+     * Set whether or not grouping will be used in this format.
+     * @see #isGroupingUsed
+     */
+    public void setGroupingUsed(boolean newValue) {
+        icuDecimalFormat.setGroupingUsed(newValue);
     }
 
     /**
@@ -1114,7 +1025,6 @@
      *         {@code false} otherwise
      */
     public boolean isDecimalSeparatorAlwaysShown() {
-        // Android-changed: Use ICU.
         return icuDecimalFormat.isDecimalSeparatorAlwaysShown();
     }
 
@@ -1127,7 +1037,6 @@
      *                 {@code false} otherwise
      */
     public void setDecimalSeparatorAlwaysShown(boolean newValue) {
-        // Android-changed: Use ICU.
         icuDecimalFormat.setDecimalSeparatorAlwaysShown(newValue);
     }
 
@@ -1141,7 +1050,6 @@
      * @since 1.5
      */
     public boolean isParseBigDecimal() {
-        // Android-changed: Use ICU.
         return icuDecimalFormat.isParseBigDecimal();
     }
 
@@ -1155,35 +1063,35 @@
      * @since 1.5
      */
     public void setParseBigDecimal(boolean newValue) {
-        // Android-changed: Use ICU.
         icuDecimalFormat.setParseBigDecimal(newValue);
     }
 
-    // BEGIN Android-added: setParseIntegerOnly()/isParseIntegerOnly() overrides delegating to ICU.
     /**
-     * {@inheritDoc}
+     * Sets whether or not numbers should be parsed as integers only.
+     * @see #isParseIntegerOnly
      */
-    @Override
-    public boolean isParseIntegerOnly() {
-        return icuDecimalFormat.isParseIntegerOnly();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
     public void setParseIntegerOnly(boolean value) {
         super.setParseIntegerOnly(value);
         icuDecimalFormat.setParseIntegerOnly(value);
     }
-    // END Android-added: setParseIntegerOnly()/isParseIntegerOnly() overrides delegating to ICU.
+
+    /**
+     * Returns true if this format will parse numbers as integers only.
+     * For example in the English locale, with ParseIntegerOnly true, the
+     * string "1234." would be parsed as the integer value 1234 and parsing
+     * would stop at the "." character.  Of course, the exact format accepted
+     * by the parse operation is locale dependant and determined by sub-classes
+     * of NumberFormat.
+     */
+    public boolean isParseIntegerOnly() {
+        return icuDecimalFormat.isParseIntegerOnly();
+    }
 
     /**
      * Standard override; no change in semantics.
      */
     @Override
     public Object clone() {
-        // BEGIN Android-changed: Use ICU, remove fast path related code.
         try {
             DecimalFormat other = (DecimalFormat) super.clone();
             other.icuDecimalFormat = (android.icu.text.DecimalFormat) icuDecimalFormat.clone();
@@ -1192,10 +1100,8 @@
         } catch (Exception e) {
             throw new InternalError();
         }
-        // END Android-changed: Use ICU, remove fast path related code.
     }
 
-    // BEGIN Android-changed: re-implement equals() using ICU fields.
     /**
      * Overrides equals
      */
@@ -1224,14 +1130,12 @@
         }
         return other.getRoundingIncrement() == null;
     }
-    // END Android-changed: re-implement equals() using ICU fields.
 
     /**
      * Overrides hashCode
      */
     @Override
     public int hashCode() {
-        // Android-changed: use getPositivePrefix() instead of positivePrefix field.
         return super.hashCode() * 37 + getPositivePrefix().hashCode();
         // just enough fields for a reasonable distribution
     }
@@ -1244,7 +1148,6 @@
      * @see #applyPattern
      */
     public String toPattern() {
-        // Android-changed: use ICU.
         return icuDecimalFormat.toPattern();
     }
 
@@ -1256,12 +1159,9 @@
      * @see #applyPattern
      */
     public String toLocalizedPattern() {
-        // Android-changed: use ICU.
         return icuDecimalFormat.toLocalizedPattern();
     }
 
-    // Android-removed: private helper methods expandAffixes(), expandAffix(), toPattern(boolean).
-
     /**
      * Apply the given pattern to this Format object.  A pattern is a
      * short-hand specification for the various formatting properties.
@@ -1285,11 +1185,11 @@
      * @exception IllegalArgumentException if the given pattern is invalid.
      */
     public void applyPattern(String pattern) {
-        // Android-changed: use ICU.
         icuDecimalFormat.applyPattern(pattern);
         updateFieldsFromIcu();
     }
 
+
     /**
      * Apply the given pattern to this Format object.  The pattern
      * is assumed to be in a localized notation. A pattern is a
@@ -1314,12 +1214,22 @@
      * @exception IllegalArgumentException if the given pattern is invalid.
      */
     public void applyLocalizedPattern(String pattern) {
-        // Android-changed: use ICU.
         icuDecimalFormat.applyLocalizedPattern(pattern);
         updateFieldsFromIcu();
     }
 
-    // Android-removed: applyPattern(String, boolean) as apply[Localized]Pattern calls ICU directly.
+    private void updateFieldsFromIcu() {
+        // Imitate behaviour of ICU4C NumberFormat that Android used up to M.
+        // If the pattern doesn't enforce a different value (some exponential
+        // patterns do), then set the maximum integer digits to 2 billion.
+        if (icuDecimalFormat.getMaximumIntegerDigits() == DOUBLE_INTEGER_DIGITS) {
+            icuDecimalFormat.setMaximumIntegerDigits(2000000000);
+        }
+        maximumIntegerDigits = icuDecimalFormat.getMaximumIntegerDigits();
+        minimumIntegerDigits = icuDecimalFormat.getMinimumIntegerDigits();
+        maximumFractionDigits = icuDecimalFormat.getMaximumFractionDigits();
+        minimumFractionDigits = icuDecimalFormat.getMinimumFractionDigits();
+    }
 
     /**
      * Sets the maximum number of digits allowed in the integer portion of a
@@ -1339,10 +1249,7 @@
             super.setMinimumIntegerDigits((minimumIntegerDigits > DOUBLE_INTEGER_DIGITS) ?
                 DOUBLE_INTEGER_DIGITS : minimumIntegerDigits);
         }
-        // Android-changed: use ICU.
         icuDecimalFormat.setMaximumIntegerDigits(getMaximumIntegerDigits());
-        // Android-removed: fast path related code.
-        // fastPathCheckNeeded = true;
     }
 
     /**
@@ -1363,10 +1270,7 @@
             super.setMaximumIntegerDigits((maximumIntegerDigits > DOUBLE_INTEGER_DIGITS) ?
                 DOUBLE_INTEGER_DIGITS : maximumIntegerDigits);
         }
-        // Android-changed: use ICU.
         icuDecimalFormat.setMinimumIntegerDigits(getMinimumIntegerDigits());
-        // Android-removed: fast path related code.
-        // fastPathCheckNeeded = true;
     }
 
     /**
@@ -1387,10 +1291,7 @@
             super.setMinimumFractionDigits((minimumFractionDigits > DOUBLE_FRACTION_DIGITS) ?
                 DOUBLE_FRACTION_DIGITS : minimumFractionDigits);
         }
-        // Android-changed: use ICU.
         icuDecimalFormat.setMaximumFractionDigits(getMaximumFractionDigits());
-        // Android-removed: fast path related code.
-        // fastPathCheckNeeded = true;
     }
 
     /**
@@ -1411,10 +1312,7 @@
             super.setMaximumFractionDigits((maximumFractionDigits > DOUBLE_FRACTION_DIGITS) ?
                 DOUBLE_FRACTION_DIGITS : maximumFractionDigits);
         }
-        // Android-changed: use ICU.
         icuDecimalFormat.setMinimumFractionDigits(getMinimumFractionDigits());
-        // Android-removed: fast path related code.
-        // fastPathCheckNeeded = true;
     }
 
     /**
@@ -1498,7 +1396,6 @@
      */
     @Override
     public void setCurrency(Currency currency) {
-        // BEGIN Android-changed: use ICU.
         // Set the international currency symbol, and currency symbol on the DecimalFormatSymbols
         // object and tell ICU to use that.
         if (currency != symbols.getCurrency()
@@ -1510,9 +1407,6 @@
             icuDecimalFormat.setMinimumFractionDigits(minimumFractionDigits);
             icuDecimalFormat.setMaximumFractionDigits(maximumFractionDigits);
         }
-        // END Android-changed: use ICU.
-        // Android-removed: fast path related code.
-        // fastPathCheckNeeded = true;
     }
 
     /**
@@ -1527,7 +1421,6 @@
         return roundingMode;
     }
 
-    // Android-added: convertRoundingMode() to convert between Java and ICU RoundingMode enums.
     private static int convertRoundingMode(RoundingMode rm) {
         switch (rm) {
         case UP:
@@ -1565,16 +1458,10 @@
         }
 
         this.roundingMode = roundingMode;
-        // Android-changed: use ICU.
+
         icuDecimalFormat.setRoundingMode(convertRoundingMode(roundingMode));
-        // Android-removed: fast path related code.
-        // fastPathCheckNeeded = true;
     }
 
-    // BEGIN Android-added: 7u40 version of adjustForCurrencyDefaultFractionDigits().
-    // This method was removed in OpenJDK 8 in favor of doing equivalent work in the provider. Since
-    // Android removed support for providers for NumberFormat we keep this method around as an
-    // "Android addition".
     /**
      * Adjusts the minimum and maximum fraction digits to values that
      * are reasonable for the currency's default fraction digits.
@@ -1603,9 +1490,9 @@
             }
         }
     }
-    // END Android-added: Upstream code from earlier OpenJDK release.
 
-    // BEGIN Android-added: Custom serialization code for compatibility with RI serialization.
+    private static final int currentSerialVersion = 4;
+
     // the fields list to be serialized
     private static final ObjectStreamField[] serialPersistentFields = {
             new ObjectStreamField("positivePrefix", String.class),
@@ -1658,7 +1545,6 @@
         fields.put("serialVersionOnStream", currentSerialVersion);
         stream.writeFields();
     }
-    // BEGIN Android-added: Custom serialization code for compatibility with RI serialization.
 
     /**
      * Reads the default serializable fields from the stream and performs
@@ -1703,13 +1589,12 @@
      * literal values.  This is exactly what we want, since that corresponds to
      * the pre-version-2 behavior.
      */
-    // BEGIN Android-added: Custom serialization code for compatibility with RI serialization.
     private void readObject(ObjectInputStream stream)
             throws IOException, ClassNotFoundException {
         ObjectInputStream.GetField fields = stream.readFields();
         this.symbols = (DecimalFormatSymbols) fields.get("symbols", null);
 
-        applyPattern("#");
+        init("#");
 
         // Calling a setter method on an ICU DecimalFormat object will change the object's internal
         // state, even if the value set is the same as the default value (ICU Ticket #13266).
@@ -1798,14 +1683,11 @@
             setMinimumFractionDigits(super.getMinimumFractionDigits());
         }
     }
-    // END Android-added: Custom serialization code for compatibility with RI serialization.
 
     //----------------------------------------------------------------------
     // INSTANCE VARIABLES
     //----------------------------------------------------------------------
 
-    // Android-removed: various fields now stored in icuDecimalFormat.
-
     /**
      * The <code>DecimalFormatSymbols</code> object used by this format.
      * It contains the symbols used to format numbers, e.g. the grouping separator,
@@ -1815,9 +1697,7 @@
      * @see #setDecimalFormatSymbols
      * @see java.text.DecimalFormatSymbols
      */
-    private DecimalFormatSymbols symbols = null; // LIU new DecimalFormatSymbols();
-
-    // Android-removed: useExponentialNotation, *FieldPositions, minExponentDigits.
+    private DecimalFormatSymbols symbols;
 
     /**
      * The maximum number of digits allowed in the integer portion of a
@@ -1829,8 +1709,7 @@
      * @see #getMaximumIntegerDigits
      * @since 1.5
      */
-    // Android-changed: removed initialisation.
-    private int    maximumIntegerDigits /* = super.getMaximumIntegerDigits() */;
+    private int    maximumIntegerDigits;
 
     /**
      * The minimum number of digits allowed in the integer portion of a
@@ -1842,8 +1721,7 @@
      * @see #getMinimumIntegerDigits
      * @since 1.5
      */
-    // Android-changed: removed initialisation.
-    private int    minimumIntegerDigits /* = super.getMinimumIntegerDigits() */;
+    private int    minimumIntegerDigits;
 
     /**
      * The maximum number of digits allowed in the fractional portion of a
@@ -1855,8 +1733,7 @@
      * @see #getMaximumFractionDigits
      * @since 1.5
      */
-    // Android-changed: removed initialisation.
-    private int    maximumFractionDigits /* = super.getMaximumFractionDigits() */;
+    private int    maximumFractionDigits;
 
     /**
      * The minimum number of digits allowed in the fractional portion of a
@@ -1868,8 +1745,7 @@
      * @see #getMinimumFractionDigits
      * @since 1.5
      */
-    // Android-changed: removed initialisation.
-    private int    minimumFractionDigits /* = super.getMinimumFractionDigits() */;
+    private int    minimumFractionDigits;
 
     /**
      * The {@link java.math.RoundingMode} used in this DecimalFormat.
@@ -1879,20 +1755,12 @@
      */
     private RoundingMode roundingMode = RoundingMode.HALF_EVEN;
 
-    // Android-removed: FastPathData, isFastPath, fastPathCheckNeeded and fastPathData.
 
-    //----------------------------------------------------------------------
-
-    static final int currentSerialVersion = 4;
-
-    // Android-removed: serialVersionOnStream.
 
     //----------------------------------------------------------------------
     // CONSTANTS
     //----------------------------------------------------------------------
 
-    // Android-removed: Fast-Path for double Constants, various constants.
-
     // Upper limit on integer and fraction digits for a Java double
     static final int DOUBLE_INTEGER_DIGITS  = 309;
     static final int DOUBLE_FRACTION_DIGITS = 340;
@@ -1904,10 +1772,9 @@
     // Proclaim JDK 1.1 serial compatibility.
     static final long serialVersionUID = 864413376551465018L;
 
-    // Android-added: cachedLocaleData for caching default number format pattern per locale.
     /**
      * Cache to hold the NumberPattern of a Locale.
      */
     private static final ConcurrentMap<Locale, String> cachedLocaleData
-        = new ConcurrentHashMap<>(3);
+        = new ConcurrentHashMap<Locale, String>(3);
 }
diff --git a/ojluni/src/main/java/java/text/NumberFormat.java b/ojluni/src/main/java/java/text/NumberFormat.java
index 70a0aa9..218a668 100644
--- a/ojluni/src/main/java/java/text/NumberFormat.java
+++ b/ojluni/src/main/java/java/text/NumberFormat.java
@@ -286,13 +286,10 @@
      * @see java.text.Format#format
      */
     public final String format(double number) {
-        // Android-removed: fast-path code.
         return format(number, new StringBuffer(),
                       DontCareFieldPosition.INSTANCE).toString();
     }
 
-    // Android-removed: fastFormat method.
-
    /**
      * Specialization of format.
      *
@@ -548,8 +545,6 @@
         return getInstance(inLocale, PERCENTSTYLE);
     }
 
-    // Android-removed: non-API methods getScientificInstance([Locale]).
-
     // Android-changed: Removed reference to NumberFormatProvider.
     /**
      * Returns an array of all locales for which the
@@ -917,7 +912,6 @@
         stream.defaultWriteObject();
     }
 
-    // Android-added: cachedLocaleData.
     /**
      * Cache to hold the NumberPatterns of a Locale.
      */
@@ -927,8 +921,6 @@
     private static final int NUMBERSTYLE = 0;
     private static final int CURRENCYSTYLE = 1;
     private static final int PERCENTSTYLE = 2;
-    // Android-changed: changed: removed SCIENTIFICSTYLE and pull down INTEGERSTYLE value.
-    //private static final int SCIENTIFICSTYLE = 3;
     private static final int INTEGERSTYLE = 3;
 
     /**