7117230: clean up warnings in java.text
authordbhole
Thu, 24 May 2012 19:00:16 -0700
changeset 12848 da701d422d2c
parent 12847 c3999bec8b2c
child 12849 1e155a915581
7117230: clean up warnings in java.text Reviewed-by: jrose, smarks
jdk/src/share/classes/java/text/AttributedCharacterIterator.java
jdk/src/share/classes/java/text/AttributedString.java
jdk/src/share/classes/java/text/BreakDictionary.java
jdk/src/share/classes/java/text/BreakIterator.java
jdk/src/share/classes/java/text/CharacterIteratorFieldDelegate.java
jdk/src/share/classes/java/text/ChoiceFormat.java
jdk/src/share/classes/java/text/CollationElementIterator.java
jdk/src/share/classes/java/text/DateFormat.java
jdk/src/share/classes/java/text/DecimalFormat.java
jdk/src/share/classes/java/text/DictionaryBasedBreakIterator.java
jdk/src/share/classes/java/text/MergeCollation.java
jdk/src/share/classes/java/text/MessageFormat.java
jdk/src/share/classes/java/text/NumberFormat.java
jdk/src/share/classes/java/text/ParseException.java
jdk/src/share/classes/java/text/RBCollationTables.java
jdk/src/share/classes/java/text/RBTableBuilder.java
jdk/src/share/classes/java/text/RuleBasedBreakIterator.java
--- a/jdk/src/share/classes/java/text/AttributedCharacterIterator.java	Thu May 24 10:20:28 2012 -0400
+++ b/jdk/src/share/classes/java/text/AttributedCharacterIterator.java	Thu May 24 19:00:16 2012 -0700
@@ -97,7 +97,7 @@
         private String name;
 
         // table of all instances in this class, used by readResolve
-        private static final Map instanceMap = new HashMap(7);
+        private static final Map<String, Attribute> instanceMap = new HashMap<>(7);
 
         /**
          * Constructs an {@code Attribute} with the given name.
@@ -150,7 +150,7 @@
                 throw new InvalidObjectException("subclass didn't correctly implement readResolve");
             }
 
-            Attribute instance = (Attribute) instanceMap.get(getName());
+            Attribute instance = instanceMap.get(getName());
             if (instance != null) {
                 return instance;
             } else {
--- a/jdk/src/share/classes/java/text/AttributedString.java	Thu May 24 10:20:28 2012 -0400
+++ b/jdk/src/share/classes/java/text/AttributedString.java	Thu May 24 19:00:16 2012 -0700
@@ -61,8 +61,8 @@
     int runArraySize;               // current size of the arrays
     int runCount;                   // actual number of runs, <= runArraySize
     int runStarts[];                // start index for each run
-    Vector runAttributes[];         // vector of attribute keys for each run
-    Vector runAttributeValues[];    // parallel vector of attribute values for each run
+    Vector<Attribute> runAttributes[];         // vector of attribute keys for each run
+    Vector<Object> runAttributeValues[];    // parallel vector of attribute values for each run
 
     /**
      * Constructs an AttributedString instance with the given
@@ -92,7 +92,7 @@
                 // Determine the runs, creating a new run when the attributes
                 // differ.
                 int offset = 0;
-                Map last = null;
+                Map<Attribute,Object> last = null;
 
                 for (int counter = 0; counter < iterators.length; counter++) {
                     AttributedCharacterIterator iterator = iterators[counter];
@@ -103,7 +103,7 @@
                     while (index < end) {
                         iterator.setIndex(index);
 
-                        Map attrs = iterator.getAttributes();
+                        Map<Attribute,Object> attrs = iterator.getAttributes();
 
                         if (mapsDiffer(last, attrs)) {
                             setAttributes(attrs, index - start + offset);
@@ -156,13 +156,14 @@
         int attributeCount = attributes.size();
         if (attributeCount > 0) {
             createRunAttributeDataVectors();
-            Vector newRunAttributes = new Vector(attributeCount);
-            Vector newRunAttributeValues = new Vector(attributeCount);
+            Vector<Attribute> newRunAttributes = new Vector<>(attributeCount);
+            Vector<Object> newRunAttributeValues = new Vector<>(attributeCount);
             runAttributes[0] = newRunAttributes;
             runAttributeValues[0] = newRunAttributeValues;
-            Iterator iterator = attributes.entrySet().iterator();
+
+            Iterator<? extends Map.Entry<? extends Attribute, ?>> iterator = attributes.entrySet().iterator();
             while (iterator.hasNext()) {
-                Map.Entry entry = (Map.Entry) iterator.next();
+                Map.Entry<? extends Attribute, ?> entry = iterator.next();
                 newRunAttributes.addElement(entry.getKey());
                 newRunAttributeValues.addElement(entry.getValue());
             }
@@ -252,7 +253,7 @@
             return;
 
         // Select attribute keys to be taken care of
-        HashSet keys = new HashSet();
+        HashSet<Attribute> keys = new HashSet<>();
         if (attributes == null) {
             keys.addAll(text.getAllAttributeKeys());
         } else {
@@ -266,9 +267,9 @@
         // Get and set attribute runs for each attribute name. Need to
         // scan from the top of the text so that we can discard any
         // Annotation that is no longer applied to a subset text segment.
-        Iterator itr = keys.iterator();
+        Iterator<Attribute> itr = keys.iterator();
         while (itr.hasNext()) {
-            Attribute attributeKey = (Attribute)itr.next();
+            Attribute attributeKey = itr.next();
             text.setIndex(textBeginIndex);
             while (text.getIndex() < endIndex) {
                 int start = text.getRunStart(attributeKey);
@@ -390,10 +391,11 @@
         int beginRunIndex = ensureRunBreak(beginIndex);
         int endRunIndex = ensureRunBreak(endIndex);
 
-        Iterator iterator = attributes.entrySet().iterator();
+        Iterator<? extends Map.Entry<? extends Attribute, ?>> iterator =
+            attributes.entrySet().iterator();
         while (iterator.hasNext()) {
-            Map.Entry entry = (Map.Entry) iterator.next();
-            addAttributeRunData((Attribute) entry.getKey(), entry.getValue(), beginRunIndex, endRunIndex);
+            Map.Entry<? extends Attribute, ?> entry = iterator.next();
+            addAttributeRunData(entry.getKey(), entry.getValue(), beginRunIndex, endRunIndex);
         }
     }
 
@@ -415,8 +417,13 @@
     private final void createRunAttributeDataVectors() {
         // use temporary variables so things remain consistent in case of an exception
         int newRunStarts[] = new int[ARRAY_SIZE_INCREMENT];
-        Vector newRunAttributes[] = new Vector[ARRAY_SIZE_INCREMENT];
-        Vector newRunAttributeValues[] = new Vector[ARRAY_SIZE_INCREMENT];
+
+        @SuppressWarnings("unchecked")
+        Vector<Attribute> newRunAttributes[] = (Vector<Attribute>[]) new Vector<?>[ARRAY_SIZE_INCREMENT];
+
+        @SuppressWarnings("unchecked")
+        Vector<Object> newRunAttributeValues[] = (Vector<Object>[]) new Vector<?>[ARRAY_SIZE_INCREMENT];
+
         runStarts = newRunStarts;
         runAttributes = newRunAttributes;
         runAttributeValues = newRunAttributeValues;
@@ -461,8 +468,13 @@
         if (runCount == runArraySize) {
             int newArraySize = runArraySize + ARRAY_SIZE_INCREMENT;
             int newRunStarts[] = new int[newArraySize];
-            Vector newRunAttributes[] = new Vector[newArraySize];
-            Vector newRunAttributeValues[] = new Vector[newArraySize];
+
+            @SuppressWarnings("unchecked")
+            Vector<Attribute> newRunAttributes[] = (Vector<Attribute>[]) new Vector<?>[newArraySize];
+
+            @SuppressWarnings("unchecked")
+            Vector<Object> newRunAttributeValues[] = (Vector<Object>[]) new Vector<?>[newArraySize];
+
             for (int i = 0; i < runArraySize; i++) {
                 newRunStarts[i] = runStarts[i];
                 newRunAttributes[i] = runAttributes[i];
@@ -476,17 +488,17 @@
 
         // make copies of the attribute information of the old run that the new one used to be part of
         // use temporary variables so things remain consistent in case of an exception
-        Vector newRunAttributes = null;
-        Vector newRunAttributeValues = null;
+        Vector<Attribute> newRunAttributes = null;
+        Vector<Object> newRunAttributeValues = null;
 
         if (copyAttrs) {
-            Vector oldRunAttributes = runAttributes[runIndex - 1];
-            Vector oldRunAttributeValues = runAttributeValues[runIndex - 1];
+            Vector<Attribute> oldRunAttributes = runAttributes[runIndex - 1];
+            Vector<Object> oldRunAttributeValues = runAttributeValues[runIndex - 1];
             if (oldRunAttributes != null) {
-                newRunAttributes = (Vector) oldRunAttributes.clone();
+                newRunAttributes = new Vector<>(oldRunAttributes);
             }
             if (oldRunAttributeValues != null) {
-                newRunAttributeValues = (Vector) oldRunAttributeValues.clone();
+                newRunAttributeValues =  new Vector<>(oldRunAttributeValues);
             }
         }
 
@@ -511,8 +523,8 @@
         for (int i = beginRunIndex; i < endRunIndex; i++) {
             int keyValueIndex = -1; // index of key and value in our vectors; assume we don't have an entry yet
             if (runAttributes[i] == null) {
-                Vector newRunAttributes = new Vector();
-                Vector newRunAttributeValues = new Vector();
+                Vector<Attribute> newRunAttributes = new Vector<>();
+                Vector<Object> newRunAttributeValues = new Vector<>();
                 runAttributes[i] = newRunAttributes;
                 runAttributeValues[i] = newRunAttributeValues;
             } else {
@@ -597,8 +609,8 @@
     }
 
     private synchronized Object getAttribute(Attribute attribute, int runIndex) {
-        Vector currentRunAttributes = runAttributes[runIndex];
-        Vector currentRunAttributeValues = runAttributeValues[runIndex];
+        Vector<Attribute> currentRunAttributes = runAttributes[runIndex];
+        Vector<Object> currentRunAttributeValues = runAttributeValues[runIndex];
         if (currentRunAttributes == null) {
             return null;
         }
@@ -650,10 +662,10 @@
     }
 
     // returns whether all specified attributes have equal values in the runs with the given indices
-    private boolean attributeValuesMatch(Set attributes, int runIndex1, int runIndex2) {
-        Iterator iterator = attributes.iterator();
+    private boolean attributeValuesMatch(Set<? extends Attribute> attributes, int runIndex1, int runIndex2) {
+        Iterator<? extends Attribute> iterator = attributes.iterator();
         while (iterator.hasNext()) {
-            Attribute key = (Attribute) iterator.next();
+            Attribute key = iterator.next();
            if (!valuesMatch(getAttribute(key, runIndex1), getAttribute(key, runIndex2))) {
                 return false;
             }
@@ -690,7 +702,7 @@
      * (typically the end of the text) to the ones specified in attrs.
      * This is only meant to be called from the constructor!
      */
-    private void setAttributes(Map attrs, int offset) {
+    private void setAttributes(Map<Attribute, Object> attrs, int offset) {
         if (runCount == 0) {
             createRunAttributeDataVectors();
         }
@@ -699,12 +711,12 @@
         int size;
 
         if (attrs != null && (size = attrs.size()) > 0) {
-            Vector runAttrs = new Vector(size);
-            Vector runValues = new Vector(size);
-            Iterator iterator = attrs.entrySet().iterator();
+            Vector<Attribute> runAttrs = new Vector<>(size);
+            Vector<Object> runValues = new Vector<>(size);
+            Iterator<Map.Entry<Attribute, Object>> iterator = attrs.entrySet().iterator();
 
             while (iterator.hasNext()) {
-                Map.Entry entry = (Map.Entry)iterator.next();
+                Map.Entry<Attribute, Object> entry = iterator.next();
 
                 runAttrs.add(entry.getKey());
                 runValues.add(entry.getValue());
@@ -717,7 +729,7 @@
     /**
      * Returns true if the attributes specified in last and attrs differ.
      */
-    private static boolean mapsDiffer(Map last, Map attrs) {
+    private static <K,V> boolean mapsDiffer(Map<K, V> last, Map<K, V> attrs) {
         if (last == null) {
             return (attrs != null && attrs.size() > 0);
         }
@@ -761,7 +773,7 @@
             this.currentIndex = beginIndex;
             updateRunInfo();
             if (attributes != null) {
-                relevantAttributes = (Attribute[]) attributes.clone();
+                relevantAttributes = attributes.clone();
             }
         }
 
@@ -944,7 +956,7 @@
             if (runAttributes == null || currentRunIndex == -1 || runAttributes[currentRunIndex] == null) {
                 // ??? would be nice to return null, but current spec doesn't allow it
                 // returning Hashtable saves AttributeMap from dealing with emptiness
-                return new Hashtable();
+                return new Hashtable<>();
             }
             return new AttributeMap(currentRunIndex, beginIndex, endIndex);
         }
@@ -954,16 +966,16 @@
             if (runAttributes == null) {
                 // ??? would be nice to return null, but current spec doesn't allow it
                 // returning HashSet saves us from dealing with emptiness
-                return new HashSet();
+                return new HashSet<>();
             }
             synchronized (AttributedString.this) {
                 // ??? should try to create this only once, then update if necessary,
                 // and give callers read-only view
-                Set keys = new HashSet();
+                Set<Attribute> keys = new HashSet<>();
                 int i = 0;
                 while (i < runCount) {
                     if (runStarts[i] < endIndex && (i == runCount - 1 || runStarts[i + 1] > beginIndex)) {
-                        Vector currentRunAttributes = runAttributes[i];
+                        Vector<Attribute> currentRunAttributes = runAttributes[i];
                         if (currentRunAttributes != null) {
                             int j = currentRunAttributes.size();
                             while (j-- > 0) {
@@ -1052,12 +1064,12 @@
             this.endIndex = endIndex;
         }
 
-        public Set entrySet() {
-            HashSet set = new HashSet();
+        public Set<Map.Entry<Attribute, Object>> entrySet() {
+            HashSet<Map.Entry<Attribute, Object>> set = new HashSet<>();
             synchronized (AttributedString.this) {
                 int size = runAttributes[runIndex].size();
                 for (int i = 0; i < size; i++) {
-                    Attribute key = (Attribute) runAttributes[runIndex].get(i);
+                    Attribute key = runAttributes[runIndex].get(i);
                     Object value = runAttributeValues[runIndex].get(i);
                     if (value instanceof Annotation) {
                         value = AttributedString.this.getAttributeCheckRange(key,
@@ -1066,7 +1078,8 @@
                             continue;
                         }
                     }
-                    Map.Entry entry = new AttributeEntry(key, value);
+
+                    Map.Entry<Attribute, Object> entry = new AttributeEntry(key, value);
                     set.add(entry);
                 }
             }
@@ -1079,7 +1092,7 @@
     }
 }
 
-class AttributeEntry implements Map.Entry {
+class AttributeEntry implements Map.Entry<Attribute,Object> {
 
     private Attribute key;
     private Object value;
@@ -1098,7 +1111,7 @@
             (value == null ? other.value == null : other.value.equals(value));
     }
 
-    public Object getKey() {
+    public Attribute getKey() {
         return key;
     }
 
--- a/jdk/src/share/classes/java/text/BreakDictionary.java	Thu May 24 10:20:28 2012 -0400
+++ b/jdk/src/share/classes/java/text/BreakDictionary.java	Thu May 24 19:00:16 2012 -0700
@@ -145,9 +145,9 @@
 
         BufferedInputStream in;
         try {
-            in = (BufferedInputStream)AccessController.doPrivileged(
-                new PrivilegedExceptionAction() {
-                    public Object run() throws Exception {
+            in = AccessController.doPrivileged(
+                new PrivilegedExceptionAction<BufferedInputStream>() {
+                    public BufferedInputStream run() throws Exception {
                         return new BufferedInputStream(getClass().getResourceAsStream("/sun/text/resources/" + dictionaryName));
                     }
                 }
--- a/jdk/src/share/classes/java/text/BreakIterator.java	Thu May 24 10:20:28 2012 -0400
+++ b/jdk/src/share/classes/java/text/BreakIterator.java	Thu May 24 19:00:16 2012 -0700
@@ -439,7 +439,9 @@
     private static final int WORD_INDEX = 1;
     private static final int LINE_INDEX = 2;
     private static final int SENTENCE_INDEX = 3;
-    private static final SoftReference[] iterCache = new SoftReference[4];
+
+    @SuppressWarnings("unchecked")
+    private static final SoftReference<BreakIteratorCache>[] iterCache = (SoftReference<BreakIteratorCache>[]) new SoftReference<?>[4];
 
     /**
      * Returns a new <code>BreakIterator</code> instance
@@ -554,7 +556,7 @@
                                                   String dataName,
                                                   String dictionaryName) {
         if (iterCache[type] != null) {
-            BreakIteratorCache cache = (BreakIteratorCache) iterCache[type].get();
+            BreakIteratorCache cache = iterCache[type].get();
             if (cache != null) {
                 if (cache.getLocale().equals(locale)) {
                     return cache.createBreakInstance();
@@ -567,13 +569,13 @@
                                                    dataName,
                                                    dictionaryName);
         BreakIteratorCache cache = new BreakIteratorCache(locale, result);
-        iterCache[type] = new SoftReference(cache);
+        iterCache[type] = new SoftReference<>(cache);
         return result;
     }
 
     private static ResourceBundle getBundle(final String baseName, final Locale locale) {
-         return (ResourceBundle) AccessController.doPrivileged(new PrivilegedAction() {
-            public Object run() {
+         return AccessController.doPrivileged(new PrivilegedAction<ResourceBundle>() {
+            public ResourceBundle run() {
                 return ResourceBundle.getBundle(baseName, locale);
             }
         });
--- a/jdk/src/share/classes/java/text/CharacterIteratorFieldDelegate.java	Thu May 24 10:20:28 2012 -0400
+++ b/jdk/src/share/classes/java/text/CharacterIteratorFieldDelegate.java	Thu May 24 19:00:16 2012 -0700
@@ -41,7 +41,7 @@
      * for existing regions result in invoking addAttribute on the existing
      * AttributedStrings.
      */
-    private ArrayList attributedStrings;
+    private ArrayList<AttributedString> attributedStrings;
     /**
      * Running count of the number of characters that have
      * been encountered.
@@ -50,7 +50,7 @@
 
 
     CharacterIteratorFieldDelegate() {
-        attributedStrings = new ArrayList();
+        attributedStrings = new ArrayList<>();
     }
 
     public void formatted(Format.Field attr, Object value, int start, int end,
@@ -62,7 +62,7 @@
                 int asIndex = attributedStrings.size() - 1;
 
                 while (start < index) {
-                    AttributedString as = (AttributedString)attributedStrings.
+                    AttributedString as = attributedStrings.
                                            get(asIndex--);
                     int newIndex = index - as.length();
                     int aStart = Math.max(0, start - newIndex);
@@ -116,8 +116,8 @@
                                     AttributedCharacterIterator[iCount];
 
         for (int counter = 0; counter < iCount; counter++) {
-            iterators[counter] = ((AttributedString)attributedStrings.
-                                  get(counter)).getIterator();
+            iterators[counter] = attributedStrings.
+                                  get(counter).getIterator();
         }
         return new AttributedString(iterators).getIterator();
     }
--- a/jdk/src/share/classes/java/text/ChoiceFormat.java	Thu May 24 10:20:28 2012 -0400
+++ b/jdk/src/share/classes/java/text/ChoiceFormat.java	Thu May 24 19:00:16 2012 -0700
@@ -457,8 +457,8 @@
     {
         ChoiceFormat other = (ChoiceFormat) super.clone();
         // for primitives or immutables, shallow clone is enough
-        other.choiceLimits = (double[]) choiceLimits.clone();
-        other.choiceFormats = (String[]) choiceFormats.clone();
+        other.choiceLimits = choiceLimits.clone();
+        other.choiceFormats = choiceFormats.clone();
         return other;
     }
 
--- a/jdk/src/share/classes/java/text/CollationElementIterator.java	Thu May 24 10:20:28 2012 -0400
+++ b/jdk/src/share/classes/java/text/CollationElementIterator.java	Thu May 24 19:00:16 2012 -0700
@@ -412,6 +412,7 @@
      * @param newOffset The new character offset into the original text.
      * @since 1.2
      */
+    @SuppressWarnings("deprecation") // getBeginIndex, getEndIndex and setIndex are deprecated
     public void setOffset(int newOffset)
     {
         if (text != null) {
@@ -645,14 +646,14 @@
     {
         // First get the ordering of this single character,
         // which is always the first element in the list
-        Vector list = ordering.getContractValues(ch);
-        EntryPair pair = (EntryPair)list.firstElement();
+        Vector<EntryPair> list = ordering.getContractValues(ch);
+        EntryPair pair = list.firstElement();
         int order = pair.value;
 
         // find out the length of the longest contracting character sequence in the list.
         // There's logic in the builder code to make sure the longest sequence is always
         // the last.
-        pair = (EntryPair)list.lastElement();
+        pair = list.lastElement();
         int maxLength = pair.entryName.length();
 
         // (the Normalizer is cloned here so that the seeking we do in the next loop
@@ -684,7 +685,7 @@
         // to this sequence
         maxLength = 1;
         for (int i = list.size() - 1; i > 0; i--) {
-            pair = (EntryPair)list.elementAt(i);
+            pair = list.elementAt(i);
             if (!pair.fwd)
                 continue;
 
@@ -721,11 +722,11 @@
         // rather than off.  Notice that we still use append() and startsWith() when
         // working on the fragment.  This is because the entry pairs that are used
         // in reverse iteration have their names reversed already.
-        Vector list = ordering.getContractValues(ch);
-        EntryPair pair = (EntryPair)list.firstElement();
+        Vector<EntryPair> list = ordering.getContractValues(ch);
+        EntryPair pair = list.firstElement();
         int order = pair.value;
 
-        pair = (EntryPair)list.lastElement();
+        pair = list.lastElement();
         int maxLength = pair.entryName.length();
 
         NormalizerBase tempText = (NormalizerBase)text.clone();
@@ -747,7 +748,7 @@
 
         maxLength = 1;
         for (int i = list.size() - 1; i > 0; i--) {
-            pair = (EntryPair)list.elementAt(i);
+            pair = list.elementAt(i);
             if (pair.fwd)
                 continue;
 
--- a/jdk/src/share/classes/java/text/DateFormat.java	Thu May 24 10:20:28 2012 -0400
+++ b/jdk/src/share/classes/java/text/DateFormat.java	Thu May 24 19:00:16 2012 -0700
@@ -798,7 +798,7 @@
         private static final long serialVersionUID = 7441350119349544720L;
 
         // table of all instances in this class, used by readResolve
-        private static final Map instanceMap = new HashMap(18);
+        private static final Map<String, Field> instanceMap = new HashMap<>(18);
         // Maps from Calendar constant (such as Calendar.ERA) to Field
         // constant (such as Field.ERA).
         private static final Field[] calendarToFieldMapping =
--- a/jdk/src/share/classes/java/text/DecimalFormat.java	Thu May 24 10:20:28 2012 -0400
+++ b/jdk/src/share/classes/java/text/DecimalFormat.java	Thu May 24 19:00:16 2012 -0700
@@ -2051,7 +2051,7 @@
      * @return FieldPosition array of the resulting fields.
      */
     private FieldPosition[] expandAffix(String pattern) {
-        ArrayList positions = null;
+        ArrayList<FieldPosition> positions = null;
         int stringIndex = 0;
         for (int i=0; i<pattern.length(); ) {
             char c = pattern.charAt(i++);
@@ -2071,7 +2071,7 @@
                     }
                     if (string.length() > 0) {
                         if (positions == null) {
-                            positions = new ArrayList(2);
+                            positions = new ArrayList<>(2);
                         }
                         FieldPosition fp = new FieldPosition(Field.CURRENCY);
                         fp.setBeginIndex(stringIndex);
@@ -2098,7 +2098,7 @@
                 }
                 if (fieldID != null) {
                     if (positions == null) {
-                        positions = new ArrayList(2);
+                        positions = new ArrayList<>(2);
                     }
                     FieldPosition fp = new FieldPosition(fieldID, field);
                     fp.setBeginIndex(stringIndex);
@@ -2109,7 +2109,7 @@
             stringIndex++;
         }
         if (positions != null) {
-            return (FieldPosition[])positions.toArray(EmptyFieldPositionArray);
+            return positions.toArray(EmptyFieldPositionArray);
         }
         return EmptyFieldPositionArray;
     }
--- a/jdk/src/share/classes/java/text/DictionaryBasedBreakIterator.java	Thu May 24 10:20:28 2012 -0400
+++ b/jdk/src/share/classes/java/text/DictionaryBasedBreakIterator.java	Thu May 24 19:00:16 2012 -0700
@@ -356,9 +356,9 @@
         // continues in this way until we either successfully make it all the way
         // across the range, or exhaust all of our combinations of break
         // positions.)
-        Stack currentBreakPositions = new Stack();
-        Stack possibleBreakPositions = new Stack();
-        Vector wrongBreakPositions = new Vector();
+        Stack<Integer> currentBreakPositions = new Stack<>();
+        Stack<Integer> possibleBreakPositions = new Stack<>();
+        Vector<Integer> wrongBreakPositions = new Vector<>();
 
         // the dictionary is implemented as a trie, which is treated as a state
         // machine.  -1 represents the end of a legal word.  Every word in the
@@ -374,7 +374,7 @@
         // farthest as real break positions, and then start over from scratch with
         // the character where the error occurred.
         int farthestEndPoint = text.getIndex();
-        Stack bestBreakPositions = null;
+        Stack<Integer> bestBreakPositions = null;
 
         // initialize (we always exit the loop with a break statement)
         c = getCurrent();
@@ -409,7 +409,11 @@
                 // case there's an error in the text
                 if (text.getIndex() > farthestEndPoint) {
                     farthestEndPoint = text.getIndex();
-                    bestBreakPositions = (Stack)(currentBreakPositions.clone());
+
+                    @SuppressWarnings("unchecked")
+                    Stack<Integer> currentBreakPositionsCopy = (Stack<Integer>) currentBreakPositions.clone();
+
+                    bestBreakPositions = currentBreakPositionsCopy;
                 }
 
                 // wrongBreakPositions is a list of all break positions
@@ -448,7 +452,7 @@
                     }
                     else {
                         if ((currentBreakPositions.size() == 0 ||
-                             ((Integer)(currentBreakPositions.peek())).intValue() != text.getIndex())
+                             currentBreakPositions.peek().intValue() != text.getIndex())
                             && text.getIndex() != startPos) {
                             currentBreakPositions.push(new Integer(text.getIndex()));
                         }
@@ -463,15 +467,15 @@
                 // it.  Then back up to that position and start over from there (i.e.,
                 // treat that position as the beginning of a new word)
                 else {
-                    Integer temp = (Integer)possibleBreakPositions.pop();
-                    Object temp2 = null;
+                    Integer temp = possibleBreakPositions.pop();
+                    Integer temp2 = null;
                     while (!currentBreakPositions.isEmpty() && temp.intValue() <
-                           ((Integer)currentBreakPositions.peek()).intValue()) {
+                           currentBreakPositions.peek().intValue()) {
                         temp2 = currentBreakPositions.pop();
                         wrongBreakPositions.addElement(temp2);
                     }
                     currentBreakPositions.push(temp);
-                    text.setIndex(((Integer)currentBreakPositions.peek()).intValue());
+                    text.setIndex(currentBreakPositions.peek().intValue());
                 }
 
                 // re-sync "c" for the next go-round, and drop out of the loop if
@@ -507,7 +511,7 @@
         cachedBreakPositions[0] = startPos;
 
         for (int i = 0; i < currentBreakPositions.size(); i++) {
-            cachedBreakPositions[i + 1] = ((Integer)currentBreakPositions.elementAt(i)).intValue();
+            cachedBreakPositions[i + 1] = currentBreakPositions.elementAt(i).intValue();
         }
         positionInCache = 0;
     }
--- a/jdk/src/share/classes/java/text/MergeCollation.java	Thu May 24 10:20:28 2012 -0400
+++ b/jdk/src/share/classes/java/text/MergeCollation.java	Thu May 24 19:00:16 2012 -0700
@@ -88,19 +88,19 @@
     public String getPattern(boolean withWhiteSpace) {
         StringBuffer result = new StringBuffer();
         PatternEntry tmp = null;
-        ArrayList extList = null;
+        ArrayList<PatternEntry> extList = null;
         int i;
         for (i = 0; i < patterns.size(); ++i) {
-            PatternEntry entry = (PatternEntry) patterns.get(i);
+            PatternEntry entry = patterns.get(i);
             if (entry.extension.length() != 0) {
                 if (extList == null)
-                    extList = new ArrayList();
+                    extList = new ArrayList<>();
                 extList.add(entry);
             } else {
                 if (extList != null) {
                     PatternEntry last = findLastWithNoExtension(i-1);
                     for (int j = extList.size() - 1; j >= 0 ; j--) {
-                        tmp = (PatternEntry)(extList.get(j));
+                        tmp = extList.get(j);
                         tmp.addToBuffer(result, false, withWhiteSpace, last);
                     }
                     extList = null;
@@ -111,7 +111,7 @@
         if (extList != null) {
             PatternEntry last = findLastWithNoExtension(i-1);
             for (int j = extList.size() - 1; j >= 0 ; j--) {
-                tmp = (PatternEntry)(extList.get(j));
+                tmp = extList.get(j);
                 tmp.addToBuffer(result, false, withWhiteSpace, last);
             }
             extList = null;
@@ -121,7 +121,7 @@
 
     private final PatternEntry findLastWithNoExtension(int i) {
         for (--i;i >= 0; --i) {
-            PatternEntry entry = (PatternEntry) patterns.get(i);
+            PatternEntry entry = patterns.get(i);
             if (entry.extension.length() == 0) {
                 return entry;
             }
@@ -149,7 +149,7 @@
         StringBuffer result = new StringBuffer();
         for (int i = 0; i < patterns.size(); ++i)
         {
-            PatternEntry entry = (PatternEntry) patterns.get(i);
+            PatternEntry entry = patterns.get(i);
             if (entry != null) {
                 entry.addToBuffer(result, true, withWhiteSpace, null);
             }
@@ -198,13 +198,13 @@
      * @return the requested pattern entry
      */
     public PatternEntry getItemAt(int index) {
-        return (PatternEntry) patterns.get(index);
+        return patterns.get(index);
     }
 
     //============================================================
     // privates
     //============================================================
-    ArrayList patterns = new ArrayList(); // a list of PatternEntries
+    ArrayList<PatternEntry> patterns = new ArrayList<>(); // a list of PatternEntries
 
     private transient PatternEntry saveEntry = null;
     private transient PatternEntry lastEntry = null;
@@ -326,7 +326,7 @@
         } else {
             int i;
             for (i = patterns.size() - 1; i >= 0; --i) {
-                PatternEntry e = (PatternEntry) patterns.get(i);
+                PatternEntry e = patterns.get(i);
                 if (e.chars.regionMatches(0,entry.chars,0,
                                               e.chars.length())) {
                     excessChars.append(entry.chars.substring(e.chars.length(),
--- a/jdk/src/share/classes/java/text/MessageFormat.java	Thu May 24 10:20:28 2012 -0400
+++ b/jdk/src/share/classes/java/text/MessageFormat.java	Thu May 24 19:00:16 2012 -0700
@@ -422,6 +422,7 @@
      * @param pattern the pattern for this message format
      * @exception IllegalArgumentException if the pattern is invalid
      */
+    @SuppressWarnings("fallthrough") // fallthrough in switch is expected, suppress it
     public void applyPattern(String pattern) {
             StringBuilder[] segments = new StringBuilder[4];
             // Allocate only segments[SEG_RAW] here. The rest are
@@ -897,7 +898,7 @@
      */
     public AttributedCharacterIterator formatToCharacterIterator(Object arguments) {
         StringBuffer result = new StringBuffer();
-        ArrayList iterators = new ArrayList();
+        ArrayList<AttributedCharacterIterator> iterators = new ArrayList<>();
 
         if (arguments == null) {
             throw new NullPointerException(
@@ -908,7 +909,7 @@
             return createAttributedCharacterIterator("");
         }
         return createAttributedCharacterIterator(
-                     (AttributedCharacterIterator[])iterators.toArray(
+                     iterators.toArray(
                      new AttributedCharacterIterator[iterators.size()]));
     }
 
@@ -1074,14 +1075,14 @@
         MessageFormat other = (MessageFormat) super.clone();
 
         // clone arrays. Can't do with utility because of bug in Cloneable
-        other.formats = (Format[]) formats.clone(); // shallow clone
+        other.formats = formats.clone(); // shallow clone
         for (int i = 0; i < formats.length; ++i) {
             if (formats[i] != null)
                 other.formats[i] = (Format)formats[i].clone();
         }
         // for primitives or immutables, shallow clone is enough
-        other.offsets = (int[]) offsets.clone();
-        other.argumentNumbers = (int[]) argumentNumbers.clone();
+        other.offsets = offsets.clone();
+        other.argumentNumbers = argumentNumbers.clone();
 
         return other;
     }
@@ -1224,7 +1225,7 @@
      *            expected by the format element(s) that use it.
      */
     private StringBuffer subformat(Object[] arguments, StringBuffer result,
-                                   FieldPosition fp, List characterIterators) {
+                                   FieldPosition fp, List<AttributedCharacterIterator> characterIterators) {
         // note: this implementation assumes a fast substring & index.
         // if this is not true, would be better to append chars one by one.
         int lastOffset = 0;
--- a/jdk/src/share/classes/java/text/NumberFormat.java	Thu May 24 10:20:28 2012 -0400
+++ b/jdk/src/share/classes/java/text/NumberFormat.java	Thu May 24 19:00:16 2012 -0700
@@ -756,7 +756,7 @@
         }
 
         /* try the cache first */
-        String[] numberPatterns = (String[])cachedLocaleData.get(desiredLocale);
+        String[] numberPatterns = cachedLocaleData.get(desiredLocale);
         if (numberPatterns == null) { /* cache miss */
             ResourceBundle resource = LocaleData.getNumberFormatData(desiredLocale);
             numberPatterns = resource.getStringArray("NumberPatterns");
@@ -844,7 +844,7 @@
     /**
      * Cache to hold the NumberPatterns of a Locale.
      */
-    private static final Hashtable cachedLocaleData = new Hashtable(3);
+    private static final Hashtable<Locale, String[]> cachedLocaleData = new Hashtable<>(3);
 
     // Constants used by factory methods to specify a style of format.
     private static final int NUMBERSTYLE = 0;
@@ -1035,7 +1035,7 @@
         private static final long serialVersionUID = 7494728892700160890L;
 
         // table of all instances in this class, used by readResolve
-        private static final Map instanceMap = new HashMap(11);
+        private static final Map<String, Field> instanceMap = new HashMap<>(11);
 
         /**
          * Creates a Field instance with the specified
--- a/jdk/src/share/classes/java/text/ParseException.java	Thu May 24 10:20:28 2012 -0400
+++ b/jdk/src/share/classes/java/text/ParseException.java	Thu May 24 19:00:16 2012 -0700
@@ -49,6 +49,8 @@
 public
 class ParseException extends Exception {
 
+    private static final long serialVersionUID = 2703218443322787634L;
+
     /**
      * Constructs a ParseException with the specified detail message and
      * offset.
--- a/jdk/src/share/classes/java/text/RBCollationTables.java	Thu May 24 10:20:28 2012 -0400
+++ b/jdk/src/share/classes/java/text/RBCollationTables.java	Thu May 24 19:00:16 2012 -0700
@@ -112,8 +112,8 @@
         void fillInTables(boolean f2ary,
                           boolean swap,
                           UCompactIntArray map,
-                          Vector cTbl,
-                          Vector eTbl,
+                          Vector<Vector<EntryPair>> cTbl,
+                          Vector<int[]> eTbl,
                           IntHashtable cFlgs,
                           short mso,
                           short mto) {
@@ -155,18 +155,18 @@
      *  table.
      *  @param ch the starting character of the contracting string
      */
-    Vector getContractValues(int ch)
+    Vector<EntryPair> getContractValues(int ch)
     {
         int index = mapping.elementAt(ch);
         return getContractValuesImpl(index - CONTRACTCHARINDEX);
     }
 
     //get contract values from contractTable by index
-    private Vector getContractValuesImpl(int index)
+    private Vector<EntryPair> getContractValuesImpl(int index)
     {
         if (index >= 0)
         {
-            return (Vector)contractTable.elementAt(index);
+            return contractTable.elementAt(index);
         }
         else // not found
         {
@@ -202,7 +202,7 @@
             // this could cause a performance problem, but in practise that
             // rarely happens
             for (int i = 0; i < expandTable.size(); i++) {
-                int[] valueList = (int [])expandTable.elementAt(i);
+                int[] valueList = expandTable.elementAt(i);
                 int length = valueList.length;
 
                 if (length > result && valueList[length-1] == order) {
@@ -220,7 +220,7 @@
      *  @param idx the index of the expanding string value list
      */
     final int[] getExpandValueList(int order) {
-        return (int[])expandTable.elementAt(order - EXPANDCHARINDEX);
+        return expandTable.elementAt(order - EXPANDCHARINDEX);
     }
 
     /**
@@ -260,9 +260,9 @@
         }
     }
 
-    final static int getEntry(Vector list, String name, boolean fwd) {
+    final static int getEntry(Vector<EntryPair> list, String name, boolean fwd) {
         for (int i = 0; i < list.size(); i++) {
-            EntryPair pair = (EntryPair)list.elementAt(i);
+            EntryPair pair = list.elementAt(i);
             if (pair.fwd == fwd && pair.entryName.equals(name)) {
                 return i;
             }
@@ -294,8 +294,8 @@
     private boolean seAsianSwapping = false;
 
     private UCompactIntArray mapping = null;
-    private Vector contractTable = null;
-    private Vector expandTable = null;
+    private Vector<Vector<EntryPair>> contractTable = null;
+    private Vector<int[]> expandTable = null;
     private IntHashtable contractFlags = null;
 
     private short maxSecOrder = 0;
--- a/jdk/src/share/classes/java/text/RBTableBuilder.java	Thu May 24 10:20:28 2012 -0400
+++ b/jdk/src/share/classes/java/text/RBTableBuilder.java	Thu May 24 19:00:16 2012 -0700
@@ -85,7 +85,7 @@
             throw new ParseException("Build rules empty.", 0);
 
         // This array maps Unicode characters to their collation ordering
-        mapping = new UCompactIntArray((int)RBCollationTables.UNMAPPED);
+        mapping = new UCompactIntArray(RBCollationTables.UNMAPPED);
         // Normalize the build rules.  Find occurances of all decomposed characters
         // and normalize the rules before feeding into the builder.  By "normalize",
         // we mean that all precomposed Unicode characters must be converted into
@@ -263,7 +263,7 @@
     {
         if (expandTable != null) {
             for (int i = 0; i < expandTable.size(); i++) {
-                int[] valueList = (int [])expandTable.elementAt(i);
+                int[] valueList = expandTable.elementAt(i);
                 for (int j = 0; j < valueList.length; j++) {
                     int order = valueList[j];
                     if (order < RBCollationTables.EXPANDCHARINDEX && order > CHARINDEX) {
@@ -354,7 +354,7 @@
                                           boolean fwd)
     {
         if (contractTable == null) {
-            contractTable = new Vector(INITIALTABLESIZE);
+            contractTable = new Vector<>(INITIALTABLESIZE);
         }
 
         //initial character
@@ -366,12 +366,12 @@
           */
         // See if the initial character of the string already has a contract table.
         int entry = mapping.elementAt(ch);
-        Vector entryTable = getContractValuesImpl(entry - RBCollationTables.CONTRACTCHARINDEX);
+        Vector<EntryPair> entryTable = getContractValuesImpl(entry - RBCollationTables.CONTRACTCHARINDEX);
 
         if (entryTable == null) {
             // We need to create a new table of contract entries for this base char
             int tableIndex = RBCollationTables.CONTRACTCHARINDEX + contractTable.size();
-            entryTable = new Vector(INITIALTABLESIZE);
+            entryTable = new Vector<>(INITIALTABLESIZE);
             contractTable.addElement(entryTable);
 
             // Add the initial character's current ordering first. then
@@ -383,10 +383,10 @@
         // Now add (or replace) this string in the table
         int index = RBCollationTables.getEntry(entryTable, groupChars, fwd);
         if (index != RBCollationTables.UNMAPPED) {
-            EntryPair pair = (EntryPair) entryTable.elementAt(index);
+            EntryPair pair = entryTable.elementAt(index);
             pair.value = anOrder;
         } else {
-            EntryPair pair = (EntryPair)entryTable.lastElement();
+            EntryPair pair = entryTable.lastElement();
 
             // NOTE:  This little bit of logic is here to speed CollationElementIterator
             // .nextContractChar().  This code ensures that the longest sequence in
@@ -426,11 +426,11 @@
             int ch = Character.isHighSurrogate(ch0)?
               Character.toCodePoint(ch0, groupChars.charAt(1)):ch0;
               */
-            Vector entryTable = getContractValues(ch);
+            Vector<EntryPair> entryTable = getContractValues(ch);
             if (entryTable != null) {
                 int index = RBCollationTables.getEntry(entryTable, groupChars, true);
                 if (index != RBCollationTables.UNMAPPED) {
-                    EntryPair pair = (EntryPair) entryTable.elementAt(index);
+                    EntryPair pair = entryTable.elementAt(index);
                     result = pair.value;
                 }
             }
@@ -442,8 +442,8 @@
         int order = mapping.elementAt(ch);
 
         if (order >= RBCollationTables.CONTRACTCHARINDEX) {
-            Vector groupList = getContractValuesImpl(order - RBCollationTables.CONTRACTCHARINDEX);
-            EntryPair pair = (EntryPair)groupList.firstElement();
+            Vector<EntryPair> groupList = getContractValuesImpl(order - RBCollationTables.CONTRACTCHARINDEX);
+            EntryPair pair = groupList.firstElement();
             order = pair.value;
         }
         return order;
@@ -454,17 +454,17 @@
      *  table.
      *  @param ch the starting character of the contracting string
      */
-    private Vector getContractValues(int ch)
+    private Vector<EntryPair> getContractValues(int ch)
     {
         int index = mapping.elementAt(ch);
         return getContractValuesImpl(index - RBCollationTables.CONTRACTCHARINDEX);
     }
 
-    private Vector getContractValuesImpl(int index)
+    private Vector<EntryPair> getContractValuesImpl(int index)
     {
         if (index >= 0)
         {
-            return (Vector)contractTable.elementAt(index);
+            return contractTable.elementAt(index);
         }
         else // not found
         {
@@ -513,7 +513,7 @@
      */
     private int addExpansion(int anOrder, String expandChars) {
         if (expandTable == null) {
-            expandTable = new Vector(INITIALTABLESIZE);
+            expandTable = new Vector<>(INITIALTABLESIZE);
         }
 
         // If anOrder is valid, we want to add it at the beginning of the list
@@ -610,8 +610,8 @@
     private boolean seAsianSwapping = false;
 
     private UCompactIntArray mapping = null;
-    private Vector   contractTable = null;
-    private Vector   expandTable = null;
+    private Vector<Vector<EntryPair>>   contractTable = null;
+    private Vector<int[]>   expandTable = null;
 
     private short maxSecOrder = 0;
     private short maxTerOrder = 0;
--- a/jdk/src/share/classes/java/text/RuleBasedBreakIterator.java	Thu May 24 10:20:28 2012 -0400
+++ b/jdk/src/share/classes/java/text/RuleBasedBreakIterator.java	Thu May 24 19:00:16 2012 -0700
@@ -444,9 +444,9 @@
 
         BufferedInputStream is;
         try {
-            is = (BufferedInputStream)AccessController.doPrivileged(
-                new PrivilegedExceptionAction() {
-                    public Object run() throws Exception {
+            is = AccessController.doPrivileged(
+                new PrivilegedExceptionAction<BufferedInputStream>() {
+                    public BufferedInputStream run() throws Exception {
                         return new BufferedInputStream(getClass().getResourceAsStream("/sun/text/resources/" + datafile));
                     }
                 }