changeset 619:b334982cdefe

6722802: Code improvement and warnings removing from the javax.swing.text package Summary: Removed unnecessary castings and other warnings Reviewed-by: peterz Contributed-by: Florian Brunner <fbrunnerlist@gmx.ch>
author rupashka
date Thu, 24 Jul 2008 16:43:36 +0400
parents ef591cd4c463
children 91722ce41508
files src/share/classes/javax/swing/text/AbstractDocument.java src/share/classes/javax/swing/text/AsyncBoxView.java src/share/classes/javax/swing/text/ComponentView.java src/share/classes/javax/swing/text/DefaultCaret.java src/share/classes/javax/swing/text/DefaultFormatter.java src/share/classes/javax/swing/text/DefaultHighlighter.java src/share/classes/javax/swing/text/DefaultStyledDocument.java src/share/classes/javax/swing/text/ElementIterator.java src/share/classes/javax/swing/text/FlowView.java src/share/classes/javax/swing/text/GapContent.java src/share/classes/javax/swing/text/InternationalFormatter.java src/share/classes/javax/swing/text/JTextComponent.java src/share/classes/javax/swing/text/LayoutQueue.java src/share/classes/javax/swing/text/MaskFormatter.java src/share/classes/javax/swing/text/NumberFormatter.java src/share/classes/javax/swing/text/PlainDocument.java src/share/classes/javax/swing/text/SegmentCache.java src/share/classes/javax/swing/text/SimpleAttributeSet.java src/share/classes/javax/swing/text/StringContent.java src/share/classes/javax/swing/text/StyleContext.java src/share/classes/javax/swing/text/TableView.java src/share/classes/javax/swing/text/TextAction.java src/share/classes/javax/swing/text/TextLayoutStrategy.java src/share/classes/javax/swing/text/ZoneView.java src/share/classes/javax/swing/text/html/AccessibleHTML.java src/share/classes/javax/swing/text/html/CSS.java src/share/classes/javax/swing/text/html/HTML.java src/share/classes/javax/swing/text/html/HTMLDocument.java src/share/classes/javax/swing/text/html/HTMLEditorKit.java src/share/classes/javax/swing/text/html/HTMLWriter.java src/share/classes/javax/swing/text/html/Map.java src/share/classes/javax/swing/text/html/MinimalHTMLWriter.java src/share/classes/javax/swing/text/html/OptionListModel.java src/share/classes/javax/swing/text/html/StyleSheet.java src/share/classes/javax/swing/text/html/TableView.java src/share/classes/javax/swing/text/html/parser/AttributeList.java src/share/classes/javax/swing/text/html/parser/DTD.java src/share/classes/javax/swing/text/html/parser/Element.java src/share/classes/javax/swing/text/html/parser/Entity.java src/share/classes/javax/swing/text/html/parser/Parser.java src/share/classes/javax/swing/text/html/parser/TagStack.java src/share/classes/javax/swing/text/rtf/MockAttributeSet.java src/share/classes/javax/swing/text/rtf/RTFAttributes.java src/share/classes/javax/swing/text/rtf/RTFGenerator.java src/share/classes/javax/swing/text/rtf/RTFParser.java src/share/classes/javax/swing/text/rtf/RTFReader.java
diffstat 46 files changed, 499 insertions(+), 564 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/javax/swing/text/AbstractDocument.java	Thu Jul 24 14:51:13 2008 +0400
+++ b/src/share/classes/javax/swing/text/AbstractDocument.java	Thu Jul 24 16:43:36 2008 +0400
@@ -123,15 +123,15 @@
 
         if (defaultI18NProperty == null) {
             // determine default setting for i18n support
-            Object o = java.security.AccessController.doPrivileged(
-                new java.security.PrivilegedAction() {
-                    public Object run() {
+            String o = java.security.AccessController.doPrivileged(
+                new java.security.PrivilegedAction<String>() {
+                    public String run() {
                         return System.getProperty(I18NProperty);
                     }
                 }
             );
             if (o != null) {
-                defaultI18NProperty = Boolean.valueOf((String)o);
+                defaultI18NProperty = Boolean.valueOf(o);
             } else {
                 defaultI18NProperty = Boolean.FALSE;
             }
@@ -163,7 +163,7 @@
      */
     public Dictionary<Object,Object> getDocumentProperties() {
         if (documentProperties == null) {
-            documentProperties = new Hashtable(2);
+            documentProperties = new Hashtable<Object, Object>(2);
         }
         return documentProperties;
     }
@@ -467,8 +467,7 @@
      * @since 1.4
      */
     public DocumentListener[] getDocumentListeners() {
-        return (DocumentListener[])listenerList.getListeners(
-                DocumentListener.class);
+        return listenerList.getListeners(DocumentListener.class);
     }
 
     /**
@@ -508,8 +507,7 @@
      * @since 1.4
      */
     public UndoableEditListener[] getUndoableEditListeners() {
-        return (UndoableEditListener[])listenerList.getListeners(
-                UndoableEditListener.class);
+        return listenerList.getListeners(UndoableEditListener.class);
     }
 
     /**
@@ -610,7 +608,7 @@
             DefaultDocumentEvent chng =
                     new DefaultDocumentEvent(offs, len, DocumentEvent.EventType.REMOVE);
 
-            boolean isComposedTextElement = false;
+            boolean isComposedTextElement;
             // Check whether the position of interest is the composed text
             isComposedTextElement = Utilities.isComposedTextElement(this, offs);
 
@@ -1051,7 +1049,7 @@
         byte levels[] = calculateBidiLevels( firstPStart, lastPEnd );
 
 
-        Vector newElements = new Vector();
+        Vector<Element> newElements = new Vector<Element>();
 
         // Calculate the first span of characters in the affected range with
         // the same bidi level.  If this level is the same as the level of the
@@ -1831,7 +1829,6 @@
                     }
                     out.println("["+contentStr+"]");
                 } catch (BadLocationException e) {
-                        ;
                 }
 
             } else {
@@ -2460,7 +2457,7 @@
             if(nchildren == 0)
                 return null;
 
-            Vector tempVector = new Vector(nchildren);
+            Vector<AbstractElement> tempVector = new Vector<AbstractElement>(nchildren);
 
             for(int counter = 0; counter < nchildren; counter++)
                 tempVector.addElement(children[counter]);
@@ -2749,7 +2746,7 @@
             // if the number of changes gets too great, start using
             // a hashtable for to locate the change for a given element.
             if ((changeLookup == null) && (edits.size() > 10)) {
-                changeLookup = new Hashtable();
+                changeLookup = new Hashtable<Element, ElementChange>();
                 int n = edits.size();
                 for (int i = 0; i < n; i++) {
                     Object o = edits.elementAt(i);
@@ -2918,7 +2915,7 @@
          */
         public DocumentEvent.ElementChange getChange(Element elem) {
             if (changeLookup != null) {
-                return (DocumentEvent.ElementChange) changeLookup.get(elem);
+                return changeLookup.get(elem);
             }
             int n = edits.size();
             for (int i = 0; i < n; i++) {
@@ -2937,7 +2934,7 @@
 
         private int offset;
         private int length;
-        private Hashtable changeLookup;
+        private Hashtable<Element, ElementChange> changeLookup;
         private DocumentEvent.EventType type;
 
     }
--- a/src/share/classes/javax/swing/text/AsyncBoxView.java	Thu Jul 24 14:51:13 2008 +0400
+++ b/src/share/classes/javax/swing/text/AsyncBoxView.java	Thu Jul 24 16:43:36 2008 +0400
@@ -25,6 +25,7 @@
 package javax.swing.text;
 
 import java.util.*;
+import java.util.List;
 import java.awt.*;
 import javax.swing.SwingUtilities;
 import javax.swing.event.DocumentEvent;
@@ -58,7 +59,7 @@
      */
     public AsyncBoxView(Element elem, int axis) {
         super(elem);
-        stats = new ArrayList();
+        stats = new ArrayList<ChildState>();
         this.axis = axis;
         locator = new ChildLocator();
         flushTask = new FlushTask();
@@ -197,7 +198,7 @@
     protected ChildState getChildState(int index) {
         synchronized(stats) {
             if ((index >= 0) && (index < stats.size())) {
-                return (ChildState) stats.get(index);
+                return stats.get(index);
             }
             return null;
         }
@@ -357,7 +358,7 @@
         synchronized(stats) {
             // remove the replaced state records
             for (int i = 0; i < length; i++) {
-                ChildState cs = (ChildState)stats.remove(offset);
+                ChildState cs = stats.remove(offset);
                 float csSpan = cs.getMajorSpan();
 
                 cs.getChildView().setParent(null);
@@ -863,7 +864,7 @@
     /**
      * The children and their layout statistics.
      */
-    java.util.List stats;
+    List<ChildState> stats;
 
     /**
      * Current span along the major axis.  This
@@ -1110,7 +1111,7 @@
          */
         int updateChildOffsets(float targetOffset) {
             int n = getViewCount();
-            int targetIndex = n - 1;;
+            int targetIndex = n - 1;
             int pos = lastValidOffset.getChildView().getStartOffset();
             int startIndex = getViewIndex(pos, Position.Bias.Forward);
             float start = lastValidOffset.getMajorOffset();
@@ -1394,7 +1395,6 @@
         private float min;
         private float pref;
         private float max;
-        private float align;
         private boolean minorValid;
 
         // major axis
--- a/src/share/classes/javax/swing/text/ComponentView.java	Thu Jul 24 14:51:13 2008 +0400
+++ b/src/share/classes/javax/swing/text/ComponentView.java	Thu Jul 24 16:43:36 2008 +0400
@@ -27,6 +27,7 @@
 import java.awt.*;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
+import java.util.Set;
 import javax.swing.SwingUtilities;
 import javax.swing.event.*;
 
@@ -434,7 +435,7 @@
         /**
          * Shows or hides this component depending on the value of parameter
          * <code>b</code>.
-         * @param <code>b</code>  If <code>true</code>, shows this component;
+         * @param b If <code>true</code>, shows this component;
          * otherwise, hides this component.
          * @see #isVisible
          * @since JDK1.1
@@ -480,7 +481,7 @@
             return yalign;
         }
 
-        public java.util.Set getFocusTraversalKeys(int id) {
+        public Set<AWTKeyStroke> getFocusTraversalKeys(int id) {
             return KeyboardFocusManager.getCurrentKeyboardFocusManager().
                     getDefaultFocusTraversalKeys(id);
         }
--- a/src/share/classes/javax/swing/text/DefaultCaret.java	Thu Jul 24 14:51:13 2008 +0400
+++ b/src/share/classes/javax/swing/text/DefaultCaret.java	Thu Jul 24 16:43:36 2008 +0400
@@ -774,8 +774,7 @@
      * @since 1.4
      */
     public ChangeListener[] getChangeListeners() {
-        return (ChangeListener[])listenerList.getListeners(
-                ChangeListener.class);
+        return listenerList.getListeners(ChangeListener.class);
     }
 
     /**
@@ -1330,7 +1329,7 @@
         if (this.dot != this.mark && component != null) {
             Clipboard clip = getSystemSelection();
             if (clip != null) {
-                String selectedText = null;
+                String selectedText;
                 if (component instanceof JPasswordField
                     && component.getClientProperty("JPasswordField.cutCopyAllowed") !=
                     Boolean.TRUE) {
--- a/src/share/classes/javax/swing/text/DefaultFormatter.java	Thu Jul 24 14:51:13 2008 +0400
+++ b/src/share/classes/javax/swing/text/DefaultFormatter.java	Thu Jul 24 16:43:36 2008 +0400
@@ -68,7 +68,7 @@
     private boolean commitOnEdit;
 
     /** Class used to create new instances. */
-    private Class valueClass;
+    private Class<?> valueClass;
 
     /** NavigationFilter that forwards calls back to DefaultFormatter. */
     private NavigationFilter navigationFilter;
@@ -231,7 +231,7 @@
      * @return Object representation of text
      */
     public Object stringToValue(String string) throws ParseException {
-        Class vc = getValueClass();
+        Class<?> vc = getValueClass();
         JFormattedTextField ftf = getFormattedTextField();
 
         if (vc == null && ftf != null) {
--- a/src/share/classes/javax/swing/text/DefaultHighlighter.java	Thu Jul 24 14:51:13 2008 +0400
+++ b/src/share/classes/javax/swing/text/DefaultHighlighter.java	Thu Jul 24 16:43:36 2008 +0400
@@ -56,7 +56,7 @@
         // PENDING(prinz) - should cull ranges not visible
         int len = highlights.size();
         for (int i = 0; i < len; i++) {
-            HighlightInfo info = (HighlightInfo) highlights.elementAt(i);
+            HighlightInfo info = highlights.elementAt(i);
             if (!(info instanceof LayeredHighlightInfo)) {
                 // Avoid allocing unless we need it.
                 Rectangle a = component.getBounds();
@@ -66,7 +66,7 @@
                 a.width -= insets.left + insets.right;
                 a.height -= insets.top + insets.bottom;
                 for (; i < len; i++) {
-                    info = (HighlightInfo)highlights.elementAt(i);
+                    info = highlights.elementAt(i);
                     if (!(info instanceof LayeredHighlightInfo)) {
                         Highlighter.HighlightPainter p = info.getPainter();
                         p.paint(g, info.getStartOffset(), info.getEndOffset(),
@@ -159,7 +159,7 @@
                 int p0 = -1;
                 int p1 = -1;
                 for (int i = 0; i < len; i++) {
-                    HighlightInfo hi = (HighlightInfo)highlights.elementAt(i);
+                    HighlightInfo hi = highlights.elementAt(i);
                     if (hi instanceof LayeredHighlightInfo) {
                         LayeredHighlightInfo info = (LayeredHighlightInfo)hi;
                         minX = Math.min(minX, info.x);
@@ -195,7 +195,7 @@
                 int p0 = Integer.MAX_VALUE;
                 int p1 = 0;
                 for (int i = 0; i < len; i++) {
-                    HighlightInfo info = (HighlightInfo) highlights.elementAt(i);
+                    HighlightInfo info = highlights.elementAt(i);
                     p0 = Math.min(p0, info.p0.getOffset());
                     p1 = Math.max(p1, info.p1.getOffset());
                 }
@@ -282,7 +282,7 @@
                                        Shape viewBounds,
                                        JTextComponent editor, View view) {
         for (int counter = highlights.size() - 1; counter >= 0; counter--) {
-            Object tag = highlights.elementAt(counter);
+            HighlightInfo tag = highlights.elementAt(counter);
             if (tag instanceof LayeredHighlightInfo) {
                 LayeredHighlightInfo lhi = (LayeredHighlightInfo)tag;
                 int start = lhi.getStartOffset();
@@ -333,7 +333,7 @@
 
     private final static Highlighter.Highlight[] noHighlights =
             new Highlighter.Highlight[0];
-    private Vector highlights = new Vector();  // Vector<HighlightInfo>
+    private Vector<HighlightInfo> highlights = new Vector<HighlightInfo>();
     private JTextComponent component;
     private boolean drawsLayeredHighlights;
     private SafeDamager safeDamager = new SafeDamager();
@@ -573,8 +573,8 @@
      * call.
      */
     class SafeDamager implements Runnable {
-        private Vector p0 = new Vector(10);
-        private Vector p1 = new Vector(10);
+        private Vector<Position> p0 = new Vector<Position>(10);
+        private Vector<Position> p1 = new Vector<Position>(10);
         private Document lastDoc = null;
 
         /**
@@ -589,8 +589,8 @@
                     int len = p0.size();
                     for (int i = 0; i < len; i++){
                         mapper.damageRange(component,
-                                ((Position)p0.get(i)).getOffset(),
-                                ((Position)p1.get(i)).getOffset());
+                                p0.get(i).getOffset(),
+                                p1.get(i).getOffset());
                     }
                 }
             }
--- a/src/share/classes/javax/swing/text/DefaultStyledDocument.java	Thu Jul 24 14:51:13 2008 +0400
+++ b/src/share/classes/javax/swing/text/DefaultStyledDocument.java	Thu Jul 24 16:43:36 2008 +0400
@@ -84,7 +84,7 @@
      */
     public DefaultStyledDocument(Content c, StyleContext styles) {
         super(c, styles);
-        listeningStyles = new Vector();
+        listeningStyles = new Vector<Style>();
         buffer = new ElementBuffer(createDefaultRoot());
         Style defaultStyle = styles.getStyle(StyleContext.DEFAULT_STYLE);
         setLogicalStyle(0, defaultStyle);
@@ -349,7 +349,7 @@
             int prevStartOffset = prevLeaf.getStartOffset();
             BranchElement prevParent = (BranchElement) prevLeaf.getParentElement();
             int prevIndex = prevParent.getElementIndex(prevStartOffset);
-            Element newElem = null;
+            Element newElem;
             newElem = createLeafElement(prevParent, prevLeaf.getAttributes(),
                                             prevStartOffset, lastEndOffset);
             Element[] prevRemoved = { prevLeaf };
@@ -511,7 +511,7 @@
             AttributeSet sCopy = s.copyAttributes();
 
             // PENDING(prinz) - this isn't a very efficient way to iterate
-            int lastEnd = Integer.MAX_VALUE;
+            int lastEnd;
             for (int pos = offset; pos < (offset + length); pos = lastEnd) {
                 Element run = getCharacterElement(pos);
                 lastEnd = run.getEndOffset();
@@ -597,7 +597,7 @@
      * @return the element
      */
     public Element getParagraphElement(int pos) {
-        Element e = null;
+        Element e;
         for (e = getDefaultRootElement(); ! e.isLeaf(); ) {
             int index = e.getElementIndex(pos);
             e = e.getElement(index);
@@ -614,7 +614,7 @@
      * @return the element
      */
     public Element getCharacterElement(int pos) {
-        Element e = null;
+        Element e;
         for (e = getDefaultRootElement(); ! e.isLeaf(); ) {
             int index = e.getElementIndex(pos);
             e = e.getElement(index);
@@ -655,7 +655,7 @@
 
         try {
             Segment s = new Segment();
-            Vector parseBuffer = new Vector();
+            Vector<ElementSpec> parseBuffer = new Vector<ElementSpec>();
             ElementSpec lastStartSpec = null;
             boolean insertingAfterNewline = false;
             short lastStartDirection = ElementSpec.OriginateDirection;
@@ -670,8 +670,7 @@
                                    offset, endOffset);
                     for(int counter = parseBuffer.size() - 1; counter >= 0;
                         counter--) {
-                        ElementSpec spec = (ElementSpec)parseBuffer.
-                                            elementAt(counter);
+                        ElementSpec spec = parseBuffer.elementAt(counter);
                         if(spec.getType() == ElementSpec.StartTagType) {
                             lastStartSpec = spec;
                             break;
@@ -709,7 +708,7 @@
                                            n - lastOffset));
             }
 
-            ElementSpec first = (ElementSpec) parseBuffer.firstElement();
+            ElementSpec first = parseBuffer.firstElement();
 
             int docLength = getLength();
 
@@ -750,7 +749,7 @@
             // direction isn't originate, and the element at endOffset
             // is a leaf.
             if(insertingAtBoundry && endOffset < docLength) {
-                ElementSpec last = (ElementSpec) parseBuffer.lastElement();
+                ElementSpec last = parseBuffer.lastElement();
                 if(last.getType() == ElementSpec.ContentType &&
                    last.getDirection() != ElementSpec.JoinPreviousDirection &&
                    ((lastStartSpec == null && (paragraph == pParagraph ||
@@ -772,7 +771,7 @@
             else if(!insertingAtBoundry && lastStartSpec != null &&
                     lastStartSpec.getDirection() ==
                     ElementSpec.JoinFractureDirection) {
-                ElementSpec last = (ElementSpec) parseBuffer.lastElement();
+                ElementSpec last = parseBuffer.lastElement();
                 if(last.getType() == ElementSpec.ContentType &&
                    last.getDirection() != ElementSpec.JoinPreviousDirection &&
                    attr.isEqual(cattr)) {
@@ -805,7 +804,7 @@
      * necessarily create the last start spec).
      */
     short createSpecsForInsertAfterNewline(Element paragraph,
-                    Element pParagraph, AttributeSet pattr, Vector parseBuffer,
+            Element pParagraph, AttributeSet pattr, Vector<ElementSpec> parseBuffer,
                                                  int offset, int endOffset) {
         // Need to find the common parent of pParagraph and paragraph.
         if(paragraph.getParentElement() == pParagraph.getParentElement()) {
@@ -825,8 +824,8 @@
         else {
             // Will only happen for text with more than 2 levels.
             // Find the common parent of a paragraph and pParagraph
-            Vector leftParents = new Vector();
-            Vector rightParents = new Vector();
+            Vector<Element> leftParents = new Vector<Element>();
+            Vector<Element> rightParents = new Vector<Element>();
             Element e = pParagraph;
             while(e != null) {
                 leftParents.addElement(e);
@@ -847,11 +846,10 @@
                                               (null, ElementSpec.EndTagType));
                 }
                 // And the starts.
-                ElementSpec spec = null;
+                ElementSpec spec;
                 for(int counter = rightParents.size() - 1;
                     counter >= 0; counter--) {
-                    spec = new ElementSpec(((Element)rightParents.
-                                   elementAt(counter)).getAttributes(),
+                    spec = new ElementSpec(rightParents.elementAt(counter).getAttributes(),
                                    ElementSpec.StartTagType);
                     if(counter > 0)
                         spec.setDirection(ElementSpec.JoinNextDirection);
@@ -1007,7 +1005,7 @@
             if (listenerList.getListenerCount(DocumentListener.class) == 0) {
                 for (int counter = listeningStyles.size() - 1; counter >= 0;
                      counter--) {
-                    ((Style)listeningStyles.elementAt(counter)).
+                    listeningStyles.elementAt(counter).
                                     removeChangeListener(styleChangeListener);
                 }
                 listeningStyles.removeAllElements();
@@ -1077,7 +1075,7 @@
 
     private void readObject(ObjectInputStream s)
             throws ClassNotFoundException, IOException {
-        listeningStyles = new Vector();
+        listeningStyles = new Vector<Style>();
         s.defaultReadObject();
         // Reinstall style listeners.
         if (styleContextChangeListener == null &&
@@ -1101,7 +1099,7 @@
     protected ElementBuffer buffer;
 
     /** Styles listening to. */
-    private transient Vector listeningStyles;
+    private transient Vector<Style> listeningStyles;
 
     /** Listens to Styles. */
     private transient ChangeListener styleChangeListener;
@@ -1401,8 +1399,8 @@
          */
         public ElementBuffer(Element root) {
             this.root = root;
-            changes = new Vector();
-            path = new Stack();
+            changes = new Vector<ElemChanges>();
+            path = new Stack<ElemChanges>();
         }
 
         /**
@@ -1454,7 +1452,7 @@
                 elem = child;
                 index = elem.getElementIndex(0);
             }
-            ElemChanges ec = (ElemChanges) path.peek();
+            ElemChanges ec = path.peek();
             Element child = ec.parent.getElement(ec.index);
             ec.added.addElement(createLeafElement(ec.parent,
                                 child.getAttributes(), getLength(),
@@ -1646,7 +1644,7 @@
                 index = e.getElementIndex(offs);
             }
 
-            ElemChanges ec = (ElemChanges) path.peek();
+            ElemChanges ec = path.peek();
             Element child = ec.parent.getElement(ec.index);
             // make sure there is something to do... if the
             // offset is already at a boundary then there is
@@ -1722,15 +1720,14 @@
         void endEdits(DefaultDocumentEvent de) {
             int n = changes.size();
             for (int i = 0; i < n; i++) {
-                ElemChanges ec = (ElemChanges) changes.elementAt(i);
+                ElemChanges ec = changes.elementAt(i);
                 Element[] removed = new Element[ec.removed.size()];
                 ec.removed.copyInto(removed);
                 Element[] added = new Element[ec.added.size()];
                 ec.added.copyInto(added);
                 int index = ec.index;
                 ((BranchElement) ec.parent).replace(index, removed.length, added);
-                ElementEdit ee = new ElementEdit((BranchElement) ec.parent,
-                                                 index, removed, added);
+                ElementEdit ee = new ElementEdit(ec.parent, index, removed, added);
                 de.addEdit(ee);
             }
 
@@ -1767,12 +1764,12 @@
             this.endOffset = offset + length;
             pos = offset;
             if (changes == null) {
-                changes = new Vector();
+                changes = new Vector<ElemChanges>();
             } else {
                 changes.removeAllElements();
             }
             if (path == null) {
-                path = new Stack();
+                path = new Stack<ElemChanges>();
             } else {
                 path.removeAllElements();
             }
@@ -1799,7 +1796,7 @@
         }
 
         void pop() {
-            ElemChanges ec = (ElemChanges) path.peek();
+            ElemChanges ec = path.peek();
             path.pop();
             if ((ec.added.size() > 0) || (ec.removed.size() > 0)) {
                 changes.addElement(ec);
@@ -1808,7 +1805,7 @@
                 if(e.getElementCount() == 0) {
                     // if we pushed a branch element that didn't get
                     // used, make sure its not marked as having been added.
-                    ec = (ElemChanges) path.peek();
+                    ec = path.peek();
                     ec.added.removeElement(e);
                 }
             }
@@ -1822,7 +1819,7 @@
         }
 
         void insertElement(ElementSpec es) {
-            ElemChanges ec = (ElemChanges) path.peek();
+            ElemChanges ec = path.peek();
             switch(es.getType()) {
             case ElementSpec.StartTagType:
                 switch(es.getDirection()) {
@@ -1930,7 +1927,7 @@
                 int index0 = elem.getElementIndex(rmOffs0);
                 int index1 = elem.getElementIndex(rmOffs1);
                 push(elem, index0);
-                ElemChanges ec = (ElemChanges)path.peek();
+                ElemChanges ec = path.peek();
 
                 // if the range is contained by one element,
                 // we just forward the request
@@ -2068,7 +2065,7 @@
                 if (rj.getStartOffset() == rmOffs1) {
                     rj = null;
                 }
-                Vector children = new Vector();
+                Vector<Element> children = new Vector<Element>();
 
                 // transfer the left
                 for (int i = 0; i < ljIndex; i++) {
@@ -2142,7 +2139,7 @@
             }
             Element e = createBranchElement(parent, clonee.getAttributes());
             int n = clonee.getElementCount();
-            ArrayList childrenList = new ArrayList(n);
+            ArrayList<Element> childrenList = new ArrayList<Element>(n);
             for (int i = 0; i < n; i++) {
                 Element elem = clonee.getElement(i);
                 if (elem.getStartOffset() < rmOffs0 || elem.getEndOffset() > rmOffs1) {
@@ -2150,7 +2147,7 @@
                 }
             }
             Element[] children = new Element[childrenList.size()];
-            children = (Element[])childrenList.toArray(children);
+            children = childrenList.toArray(children);
             ((BranchElement)e).replace(0, 0, children);
             return e;
         }
@@ -2355,7 +2352,7 @@
          */
         void fractureDeepestLeaf(ElementSpec[] specs) {
             // Split the bottommost leaf. It will be recreated elsewhere.
-            ElemChanges ec = (ElemChanges) path.peek();
+            ElemChanges ec = path.peek();
             Element child = ec.parent.getElement(ec.index);
             // Inserts at offset 0 do not need to recreate child (it would
             // have a length of 0!).
@@ -2380,7 +2377,7 @@
          */
         void insertFirstContent(ElementSpec[] specs) {
             ElementSpec firstSpec = specs[0];
-            ElemChanges ec = (ElemChanges) path.peek();
+            ElemChanges ec = path.peek();
             Element child = ec.parent.getElement(ec.index);
             int firstEndOffset = offset + firstSpec.getLength();
             boolean isOnlyContent = (specs.length == 1);
@@ -2463,8 +2460,8 @@
         transient int offset;
         transient int length;
         transient int endOffset;
-        transient Vector changes;  // Vector<ElemChanges>
-        transient Stack path;      // Stack<ElemChanges>
+        transient Vector<ElemChanges> changes;
+        transient Stack<ElemChanges> path;
         transient boolean insertOp;
 
         transient boolean recreateLeafs; // For insert.
@@ -2494,8 +2491,8 @@
                 this.parent = parent;
                 this.index = index;
                 this.isFracture = isFracture;
-                added = new Vector();
-                removed = new Vector();
+                added = new Vector<Element>();
+                removed = new Vector<Element>();
             }
 
             public String toString() {
@@ -2504,8 +2501,8 @@
 
             Element parent;
             int index;
-            Vector added;
-            Vector removed;
+            Vector<Element> added;
+            Vector<Element> removed;
             boolean isFracture;
         }
 
@@ -2611,7 +2608,7 @@
         /* This has an implicit reference to the handler object.  */
         private class DocReference extends WeakReference<DefaultStyledDocument> {
 
-            DocReference(DefaultStyledDocument d, ReferenceQueue q) {
+            DocReference(DefaultStyledDocument d, ReferenceQueue<DefaultStyledDocument> q) {
                 super(d, q);
             }
 
@@ -2624,19 +2621,19 @@
         }
 
         /** Class-specific reference queues.  */
-        private final static Map<Class, ReferenceQueue> queueMap
-                = new HashMap<Class, ReferenceQueue>();
+        private final static Map<Class, ReferenceQueue<DefaultStyledDocument>> queueMap
+                = new HashMap<Class, ReferenceQueue<DefaultStyledDocument>>();
 
         /** A weak reference to the document object.  */
         private DocReference doc;
 
         AbstractChangeHandler(DefaultStyledDocument d) {
             Class c = getClass();
-            ReferenceQueue q;
+            ReferenceQueue<DefaultStyledDocument> q;
             synchronized (queueMap) {
                 q = queueMap.get(c);
                 if (q == null) {
-                    q = new ReferenceQueue();
+                    q = new ReferenceQueue<DefaultStyledDocument>();
                     queueMap.put(c, q);
                 }
             }
@@ -2650,7 +2647,7 @@
          */
         static List<ChangeListener> getStaleListeners(ChangeListener l) {
             List<ChangeListener> staleListeners = new ArrayList<ChangeListener>();
-            ReferenceQueue q = queueMap.get(l.getClass());
+            ReferenceQueue<DefaultStyledDocument> q = queueMap.get(l.getClass());
 
             if (q != null) {
                 DocReference r;
--- a/src/share/classes/javax/swing/text/ElementIterator.java	Thu Jul 24 14:51:13 2008 +0400
+++ b/src/share/classes/javax/swing/text/ElementIterator.java	Thu Jul 24 16:43:36 2008 +0400
@@ -72,7 +72,7 @@
 
 
     private Element root;
-    private Stack elementStack = null;
+    private Stack<StackItem> elementStack = null;
 
     /**
      * The StackItem class stores the element
@@ -148,9 +148,9 @@
         try {
             ElementIterator it = new ElementIterator(root);
             if (elementStack != null) {
-                it.elementStack = new Stack();
+                it.elementStack = new Stack<StackItem>();
                 for (int i = 0; i < elementStack.size(); i++) {
-                    StackItem item = (StackItem)elementStack.elementAt(i);
+                    StackItem item = elementStack.elementAt(i);
                     StackItem clonee = (StackItem)item.clone();
                     it.elementStack.push(clonee);
                 }
@@ -173,7 +173,7 @@
             return null;
         }
 
-        elementStack = new Stack();
+        elementStack = new Stack<StackItem>();
         if (root.getElementCount() != 0) {
             elementStack.push(new StackItem(root));
         }
@@ -209,7 +209,7 @@
           get a handle to the element on top of the stack.
         */
         if (! elementStack.empty()) {
-            StackItem item = (StackItem)elementStack.peek();
+            StackItem item = elementStack.peek();
             Element elem = item.getElement();
             int index = item.getIndex();
             // self reference
@@ -247,7 +247,7 @@
 
         // get a handle to the element on top of the stack
 
-        StackItem item = (StackItem)elementStack.peek();
+        StackItem item = elementStack.peek();
         Element elem = item.getElement();
         int index = item.getIndex();
 
@@ -272,7 +272,7 @@
             if (!elementStack.isEmpty()) {
                 /* Increment the child index for the item that
                    is now on top of the stack. */
-                StackItem top = (StackItem)elementStack.peek();
+                StackItem top = elementStack.peek();
                 top.incrementIndex();
                 /* We now want to return its next child, therefore
                    call next() recursively. */
@@ -300,7 +300,7 @@
 
         // get a handle to the element on top of the stack
         //
-        StackItem item = (StackItem)elementStack.peek();
+        StackItem item = elementStack.peek();
         Element elem = item.getElement();
         int index = item.getIndex();
 
@@ -320,8 +320,8 @@
             /* We need to return either the item
                below the top item or one of the
                former's children. */
-            Object top = elementStack.pop();
-            item = (StackItem)elementStack.peek();
+            StackItem top = elementStack.pop();
+            item = elementStack.peek();
 
             // restore the top item.
             elementStack.push(top);
--- a/src/share/classes/javax/swing/text/FlowView.java	Thu Jul 24 14:51:13 2008 +0400
+++ b/src/share/classes/javax/swing/text/FlowView.java	Thu Jul 24 16:43:36 2008 +0400
@@ -184,9 +184,9 @@
         final int faxis = getFlowAxis();
         int newSpan;
         if (faxis == X_AXIS) {
-            newSpan = (int)width;
+            newSpan = width;
         } else {
-            newSpan = (int)height;
+            newSpan = height;
         }
         if (layoutSpan != newSpan) {
             layoutChanged(faxis);
@@ -197,7 +197,7 @@
         // repair the flow if necessary
         if (! isLayoutValid(faxis)) {
             final int heightAxis = getAxis();
-            int oldFlowHeight = (int)((heightAxis == X_AXIS)? getWidth() : getHeight());
+            int oldFlowHeight = (heightAxis == X_AXIS)? getWidth() : getHeight();
             strategy.layout(this);
             int newFlowHeight = (int) getPreferredSpan(heightAxis);
             if (oldFlowHeight != newFlowHeight) {
--- a/src/share/classes/javax/swing/text/GapContent.java	Thu Jul 24 14:51:13 2008 +0400
+++ b/src/share/classes/javax/swing/text/GapContent.java	Thu Jul 24 16:43:36 2008 +0400
@@ -83,7 +83,7 @@
 
         marks = new MarkVector();
         search = new MarkData(0);
-        queue = new ReferenceQueue();
+        queue = new ReferenceQueue<StickyPosition>();
     }
 
     /**
@@ -262,13 +262,13 @@
      * it.  The update table holds only a reference
      * to this data.
      */
-    final class MarkData extends WeakReference {
+    final class MarkData extends WeakReference<StickyPosition> {
 
         MarkData(int index) {
             super(null);
             this.index = index;
         }
-        MarkData(int index, StickyPosition position, ReferenceQueue queue) {
+        MarkData(int index, StickyPosition position, ReferenceQueue<? super StickyPosition> queue) {
             super(position, queue);
             this.index = index;
         }
@@ -287,7 +287,7 @@
         }
 
         StickyPosition getPosition() {
-            return (StickyPosition)get();
+            return get();
         }
         int index;
     }
@@ -329,7 +329,7 @@
      */
     private transient int unusedMarks = 0;
 
-    private transient ReferenceQueue queue;
+    private transient ReferenceQueue<StickyPosition> queue;
 
     final static int GROWTH_SIZE = 1024 * 512;
 
@@ -535,7 +535,7 @@
             return 0;
         }
 
-        int cmp = 0;
+        int cmp;
         MarkData last = marks.elementAt(upper);
         cmp = compare(o, last);
         if (cmp > 0)
@@ -691,7 +691,7 @@
         s.defaultReadObject();
         marks = new MarkVector();
         search = new MarkData(0);
-        queue = new ReferenceQueue();
+        queue = new ReferenceQueue<StickyPosition>();
     }
 
 
--- a/src/share/classes/javax/swing/text/InternationalFormatter.java	Thu Jul 24 14:51:13 2008 +0400
+++ b/src/share/classes/javax/swing/text/InternationalFormatter.java	Thu Jul 24 16:43:36 2008 +0400
@@ -27,6 +27,7 @@
 import java.awt.event.ActionEvent;
 import java.io.*;
 import java.text.*;
+import java.text.AttributedCharacterIterator.Attribute;
 import java.util.*;
 import javax.swing.*;
 import javax.swing.text.*;
@@ -352,13 +353,13 @@
             updateMask();
         }
 
-        Map attrs = getAttributes(offset);
+        Map<Attribute, Object> attrs = getAttributes(offset);
 
         if (attrs != null && attrs.size() > 0) {
-            ArrayList al = new ArrayList();
+            ArrayList<Attribute> al = new ArrayList<Attribute>();
 
             al.addAll(attrs.keySet());
-            return (Format.Field[])al.toArray(EMPTY_FIELD_ARRAY);
+            return al.toArray(EMPTY_FIELD_ARRAY);
         }
         return EMPTY_FIELD_ARRAY;
     }
@@ -440,7 +441,7 @@
     /**
      * Returns a Set of the attribute identifiers at <code>index</code>.
      */
-    Map getAttributes(int index) {
+    Map<Attribute, Object> getAttributes(int index) {
         if (isValidMask()) {
             AttributedCharacterIterator iterator = getIterator();
 
--- a/src/share/classes/javax/swing/text/JTextComponent.java	Thu Jul 24 14:51:13 2008 +0400
+++ b/src/share/classes/javax/swing/text/JTextComponent.java	Thu Jul 24 16:43:36 2008 +0400
@@ -386,7 +386,7 @@
      * @since 1.4
      */
     public CaretListener[] getCaretListeners() {
-        return (CaretListener[])listenerList.getListeners(CaretListener.class);
+        return listenerList.getListeners(CaretListener.class);
     }
 
     /**
@@ -1171,16 +1171,15 @@
      * @param actions the set of actions
      */
     public static void loadKeymap(Keymap map, KeyBinding[] bindings, Action[] actions) {
-        Hashtable h = new Hashtable();
-        for (int i = 0; i < actions.length; i++) {
-            Action a = actions[i];
+        Hashtable<String, Action> h = new Hashtable<String, Action>();
+        for (Action a : actions) {
             String value = (String)a.getValue(Action.NAME);
             h.put((value!=null ? value:""), a);
         }
-        for (int i = 0; i < bindings.length; i++) {
-            Action a = (Action) h.get(bindings[i].actionName);
+        for (KeyBinding binding : bindings) {
+            Action a = h.get(binding.actionName);
             if (a != null) {
-                map.addActionForKeyStroke(bindings[i].key, a);
+                map.addActionForKeyStroke(binding.key, a);
             }
         }
     }
@@ -1192,11 +1191,11 @@
      * invoked from within a <code>doPrivileged</code>, and it is also
      * assumed <code>klass</code> extends <code>JTextComponent</code>.
      */
-    private static Boolean isProcessInputMethodEventOverridden(Class klass) {
+    private static Boolean isProcessInputMethodEventOverridden(Class<?> klass) {
         if (klass == JTextComponent.class) {
             return Boolean.FALSE;
         }
-        Boolean retValue = (Boolean)overrideMap.get(klass.getName());
+        Boolean retValue = overrideMap.get(klass.getName());
 
         if (retValue != null) {
             return retValue;
@@ -2053,7 +2052,7 @@
      */
     public boolean getScrollableTracksViewportWidth() {
         if (getParent() instanceof JViewport) {
-            return (((JViewport)getParent()).getWidth() > getPreferredSize().width);
+            return (getParent().getWidth() > getPreferredSize().width);
         }
         return false;
     }
@@ -2073,7 +2072,7 @@
      */
     public boolean getScrollableTracksViewportHeight() {
         if (getParent() instanceof JViewport) {
-            return (((JViewport)getParent()).getHeight() > getPreferredSize().height);
+            return (getParent().getHeight() > getPreferredSize().height);
         }
         return false;
     }
@@ -3033,7 +3032,7 @@
                 StyledDocument sdoc = (StyledDocument)model;
                 return sdoc.getParagraphElement(index);
             } else {
-                Element para = null;
+                Element para;
                 for (para = model.getDefaultRootElement(); ! para.isLeaf(); ) {
                     int pos = para.getElementIndex(index);
                     para = para.getElement(pos);
@@ -3535,7 +3534,7 @@
                 throw new BadLocationException("Location out of bounds", index);
             }
             // locate the Element at index
-            Element indexElement = null;
+            Element indexElement;
             // locate the Element at our index/offset
             int elementIndex = -1;        // test for initialization
             for (indexElement = model.getDefaultRootElement();
@@ -3553,7 +3552,7 @@
             // find the first Element before/after ours w/the same AttributeSet
             // if we are already at edge of the first element in our parent
             // then return that edge
-            Element edgeElement = indexElement;
+            Element edgeElement;
             switch (direction) {
             case -1:
             case 1:
@@ -3903,7 +3902,7 @@
      * Maps from class name to Boolean indicating if
      * <code>processInputMethodEvent</code> has been overriden.
      */
-    private static Map overrideMap;
+    private static Map<String, Boolean> overrideMap;
 
     /**
      * Returns a string representation of this <code>JTextComponent</code>.
@@ -4007,9 +4006,9 @@
         }
         private DataFlavor getFlavor(DataFlavor[] flavors) {
             if (flavors != null) {
-                for (int counter = 0; counter < flavors.length; counter++) {
-                    if (flavors[counter].equals(DataFlavor.stringFlavor)) {
-                        return flavors[counter];
+                for (DataFlavor flavor : flavors) {
+                    if (flavor.equals(DataFlavor.stringFlavor)) {
+                        return flavor;
                     }
                 }
             }
@@ -4065,7 +4064,7 @@
         DefaultKeymap(String nm, Keymap parent) {
             this.nm = nm;
             this.parent = parent;
-            bindings = new Hashtable();
+            bindings = new Hashtable<KeyStroke, Action>();
         }
 
         /**
@@ -4095,7 +4094,7 @@
         }
 
         public Action getAction(KeyStroke key) {
-            Action a = (Action) bindings.get(key);
+            Action a = bindings.get(key);
             if ((a == null) && (parent != null)) {
                 a = parent.getAction(key);
             }
@@ -4105,8 +4104,8 @@
         public KeyStroke[] getBoundKeyStrokes() {
             KeyStroke[] keys = new KeyStroke[bindings.size()];
             int i = 0;
-            for (Enumeration e = bindings.keys() ; e.hasMoreElements() ;) {
-                keys[i++] = (KeyStroke) e.nextElement();
+            for (Enumeration<KeyStroke> e = bindings.keys() ; e.hasMoreElements() ;) {
+                keys[i++] = e.nextElement();
             }
             return keys;
         }
@@ -4114,8 +4113,8 @@
         public Action[] getBoundActions() {
             Action[] actions = new Action[bindings.size()];
             int i = 0;
-            for (Enumeration e = bindings.elements() ; e.hasMoreElements() ;) {
-                actions[i++] = (Action) e.nextElement();
+            for (Enumeration<Action> e = bindings.elements() ; e.hasMoreElements() ;) {
+                actions[i++] = e.nextElement();
             }
             return actions;
         }
@@ -4126,13 +4125,12 @@
             }
             KeyStroke[] retValue = null;
             // Determine local bindings first.
-            Vector keyStrokes = null;
-            for (Enumeration enum_ = bindings.keys();
-                 enum_.hasMoreElements();) {
-                Object key = enum_.nextElement();
+            Vector<KeyStroke> keyStrokes = null;
+            for (Enumeration<KeyStroke> keys = bindings.keys(); keys.hasMoreElements();) {
+                KeyStroke key = keys.nextElement();
                 if (bindings.get(key) == a) {
                     if (keyStrokes == null) {
-                        keyStrokes = new Vector();
+                        keyStrokes = new Vector<KeyStroke>();
                     }
                     keyStrokes.addElement(key);
                 }
@@ -4153,7 +4151,7 @@
                     }
                     if (rCount > 0 && rCount < pStrokes.length) {
                         if (keyStrokes == null) {
-                            keyStrokes = new Vector();
+                            keyStrokes = new Vector<KeyStroke>();
                         }
                         for (int counter = pStrokes.length - 1; counter >= 0;
                              counter--) {
@@ -4218,7 +4216,7 @@
 
         String nm;
         Keymap parent;
-        Hashtable bindings;
+        Hashtable<KeyStroke, Action> bindings;
         Action defaultAction;
     }
 
@@ -4507,8 +4505,7 @@
     //
     public InputMethodRequests getInputMethodRequests() {
         if (inputMethodRequestsHandler == null) {
-            inputMethodRequestsHandler =
-                (InputMethodRequests)new InputMethodRequestsHandler();
+            inputMethodRequestsHandler = new InputMethodRequestsHandler();
             Document doc = getDocument();
             if (doc != null) {
                 doc.addDocumentListener((DocumentListener)inputMethodRequestsHandler);
@@ -4923,16 +4920,16 @@
     //
     private boolean isProcessInputMethodEventOverridden() {
         if (overrideMap == null) {
-            overrideMap = Collections.synchronizedMap(new HashMap());
+            overrideMap = Collections.synchronizedMap(new HashMap<String, Boolean>());
         }
-        Boolean retValue = (Boolean)overrideMap.get(getClass().getName());
+        Boolean retValue = overrideMap.get(getClass().getName());
 
         if (retValue != null) {
             return retValue.booleanValue();
         }
-        Boolean ret = (Boolean)AccessController.doPrivileged(new
-                       PrivilegedAction() {
-            public Object run() {
+        Boolean ret = AccessController.doPrivileged(new
+                       PrivilegedAction<Boolean>() {
+            public Boolean run() {
                 return isProcessInputMethodEventOverridden(
                                 JTextComponent.this.getClass());
             }
--- a/src/share/classes/javax/swing/text/LayoutQueue.java	Thu Jul 24 14:51:13 2008 +0400
+++ b/src/share/classes/javax/swing/text/LayoutQueue.java	Thu Jul 24 16:43:36 2008 +0400
@@ -35,7 +35,7 @@
  */
 public class LayoutQueue {
 
-    Vector tasks;
+    Vector<Runnable> tasks;
     Thread worker;
 
     static LayoutQueue defaultQueue;
@@ -44,7 +44,7 @@
      * Construct a layout queue.
      */
     public LayoutQueue() {
-        tasks = new Vector();
+        tasks = new Vector<Runnable>();
     }
 
     /**
@@ -90,7 +90,7 @@
                 return null;
             }
         }
-        Runnable work = (Runnable) tasks.firstElement();
+        Runnable work = tasks.firstElement();
         tasks.removeElementAt(0);
         return work;
     }
--- a/src/share/classes/javax/swing/text/MaskFormatter.java	Thu Jul 24 14:51:13 2008 +0400
+++ b/src/share/classes/javax/swing/text/MaskFormatter.java	Thu Jul 24 16:43:36 2008 +0400
@@ -446,7 +446,7 @@
      */
     private Object stringToValue(String value, boolean completeMatch) throws
                          ParseException {
-        int errorOffset = -1;
+        int errorOffset;
 
         if ((errorOffset = getInvalidOffset(value, completeMatch)) == -1) {
             if (!getValueContainsLiteralCharacters()) {
@@ -498,8 +498,8 @@
      */
     private void updateInternalMask() throws ParseException {
         String mask = getMask();
-        ArrayList fixed = new ArrayList();
-        ArrayList temp = fixed;
+        ArrayList<MaskCharacter> fixed = new ArrayList<MaskCharacter>();
+        ArrayList<MaskCharacter> temp = fixed;
 
         if (mask != null) {
             for (int counter = 0, maxCounter = mask.length();
--- a/src/share/classes/javax/swing/text/NumberFormatter.java	Thu Jul 24 14:51:13 2008 +0400
+++ b/src/share/classes/javax/swing/text/NumberFormatter.java	Thu Jul 24 16:43:36 2008 +0400
@@ -299,10 +299,7 @@
             if (attrs.get(NumberFormat.Field.SIGN) != null) {
                 size--;
             }
-            if (size == 0) {
-                return true;
-            }
-            return false;
+            return size == 0;
         }
         return true;
     }
@@ -315,10 +312,7 @@
     boolean isNavigatable(int index) {
         if (!super.isNavigatable(index)) {
             // Don't skip the decimal, it causes wierd behavior
-            if (getBufferedChar(index) == getDecimalSeparator()) {
-                return true;
-            }
-            return false;
+            return getBufferedChar(index) == getDecimalSeparator();
         }
         return true;
     }
@@ -341,11 +335,7 @@
                 Map attrs = iterator.getAttributes();
 
                 if (attrs != null && attrs.size() > 0) {
-                    Iterator keys = attrs.keySet().iterator();
-
-                    while (keys.hasNext()) {
-                        Object key = keys.next();
-
+                    for (Object key : attrs.keySet()) {
                         if (key instanceof NumberFormat.Field) {
                             return (NumberFormat.Field)key;
                         }
@@ -461,7 +451,7 @@
                     }
                 }
                 if (string != null) {
-                    Class valueClass = getValueClass();
+                    Class<?> valueClass = getValueClass();
 
                     if (valueClass == null) {
                         valueClass = value.getClass();
--- a/src/share/classes/javax/swing/text/PlainDocument.java	Thu Jul 24 14:51:13 2008 +0400
+++ b/src/share/classes/javax/swing/text/PlainDocument.java	Thu Jul 24 16:43:36 2008 +0400
@@ -318,7 +318,7 @@
     }
 
     private AbstractElement defaultRoot;
-    private Vector added = new Vector();     // Vector<Element>
-    private Vector removed = new Vector();   // Vector<Element>
+    private Vector<Element> added = new Vector<Element>();
+    private Vector<Element> removed = new Vector<Element>();
     private transient Segment s;
 }
--- a/src/share/classes/javax/swing/text/SegmentCache.java	Thu Jul 24 14:51:13 2008 +0400
+++ b/src/share/classes/javax/swing/text/SegmentCache.java	Thu Jul 24 16:43:36 2008 +0400
@@ -48,7 +48,7 @@
     /**
      * A list of the currently unused Segments.
      */
-    private List segments;
+    private List<Segment> segments;
 
 
     /**
@@ -80,7 +80,7 @@
      * Creates and returns a SegmentCache.
      */
     public SegmentCache() {
-        segments = new ArrayList(11);
+        segments = new ArrayList<Segment>(11);
     }
 
     /**
@@ -92,7 +92,7 @@
             int size = segments.size();
 
             if (size > 0) {
-                return (Segment)segments.remove(size - 1);
+                return segments.remove(size - 1);
             }
         }
         return new CachedSegment();
--- a/src/share/classes/javax/swing/text/SimpleAttributeSet.java	Thu Jul 24 14:51:13 2008 +0400
+++ b/src/share/classes/javax/swing/text/SimpleAttributeSet.java	Thu Jul 24 16:43:36 2008 +0400
@@ -56,7 +56,7 @@
      */
     public static final AttributeSet EMPTY = new EmptyAttributeSet();
 
-    private transient Hashtable table = new Hashtable(3);
+    private transient Hashtable<Object, Object> table = new Hashtable<Object, Object>(3);
 
     /**
      * Creates a new attribute set.
@@ -73,7 +73,7 @@
         addAttributes(source);
     }
 
-    private SimpleAttributeSet(Hashtable table) {
+    private SimpleAttributeSet(Hashtable<Object, Object> table) {
         this.table = table;
     }
 
@@ -341,7 +341,7 @@
     private void readObject(ObjectInputStream s)
       throws ClassNotFoundException, IOException {
         s.defaultReadObject();
-        table = new Hashtable(3);
+        table = new Hashtable<Object, Object>(3);
         StyleContext.readAttributeSet(s, this);
     }
 
--- a/src/share/classes/javax/swing/text/StringContent.java	Thu Jul 24 14:51:13 2008 +0400
+++ b/src/share/classes/javax/swing/text/StringContent.java	Thu Jul 24 16:43:36 2008 +0400
@@ -174,7 +174,7 @@
         // some small documents won't have any sticky positions
         // at all, so the buffer is created lazily.
         if (marks == null) {
-            marks = new Vector();
+            marks = new Vector<PosRec>();
         }
         return new StickyPosition(offset);
     }
@@ -226,7 +226,7 @@
         }
         int n = marks.size();
         for (int i = 0; i < n; i++) {
-            PosRec mark = (PosRec) marks.elementAt(i);
+            PosRec mark = marks.elementAt(i);
             if (mark.unused) {
                 // this record is no longer used, get rid of it
                 marks.removeElementAt(i);
@@ -241,7 +241,7 @@
     synchronized void updateMarksForRemove(int offset, int length) {
         int n = marks.size();
         for (int i = 0; i < n; i++) {
-            PosRec mark = (PosRec) marks.elementAt(i);
+            PosRec mark = marks.elementAt(i);
             if (mark.unused) {
                 // this record is no longer used, get rid of it
                 marks.removeElementAt(i);
@@ -276,7 +276,7 @@
         int end = offset + length;
         Vector placeIn = (v == null) ? new Vector() : v;
         for (int i = 0; i < n; i++) {
-            PosRec mark = (PosRec) marks.elementAt(i);
+            PosRec mark = marks.elementAt(i);
             if (mark.unused) {
                 // this record is no longer used, get rid of it
                 marks.removeElementAt(i);
@@ -312,7 +312,7 @@
     private static final char[] empty = new char[0];
     private char[] data;
     private int count;
-    transient Vector marks;
+    transient Vector<PosRec> marks;
 
     /**
      * holds the data for a mark... separately from
--- a/src/share/classes/javax/swing/text/StyleContext.java	Thu Jul 24 14:51:13 2008 +0400
+++ b/src/share/classes/javax/swing/text/StyleContext.java	Thu Jul 24 16:43:36 2008 +0400
@@ -246,7 +246,7 @@
      */
     public Font getFont(String family, int style, int size) {
         fontSearch.setValue(family, style, size);
-        Font f = (Font) fontTable.get(fontSearch);
+        Font f = fontTable.get(fontSearch);
         if (f == null) {
             // haven't seen this one yet.
             Style defaultStyle =
@@ -517,12 +517,11 @@
         // PENDING(prinz) should consider finding a alternative to
         // generating extra garbage on search key.
         SmallAttributeSet key = createSmallAttributeSet(search);
-        WeakReference reference = (WeakReference)attributesPool.get(key);
+        WeakReference<SmallAttributeSet> reference = attributesPool.get(key);
         SmallAttributeSet a;
-        if (reference == null
-            || (a = (SmallAttributeSet)reference.get()) == null) {
+        if (reference == null || (a = reference.get()) == null) {
             a = key;
-            attributesPool.put(a, new WeakReference(a));
+            attributesPool.put(a, new WeakReference<SmallAttributeSet>(a));
         }
         return a;
     }
@@ -547,9 +546,7 @@
     public String toString() {
         removeUnusedSets();
         String s = "";
-        Iterator iterator = attributesPool.keySet().iterator();
-        while (iterator.hasNext()) {
-            SmallAttributeSet set = (SmallAttributeSet)iterator.next();
+        for (SmallAttributeSet set : attributesPool.keySet()) {
             s = s + set + "\n";
         }
         return s;
@@ -676,8 +673,8 @@
     public static void registerStaticAttributeKey(Object key) {
         String ioFmt = key.getClass().getName() + "." + key.toString();
         if (freezeKeyMap == null) {
-            freezeKeyMap = new Hashtable();
-            thawKeyMap = new Hashtable();
+            freezeKeyMap = new Hashtable<Object, String>();
+            thawKeyMap = new Hashtable<String, Object>();
         }
         freezeKeyMap.put(key, ioFmt);
         thawKeyMap.put(ioFmt, key);
@@ -716,10 +713,10 @@
       throws ClassNotFoundException, IOException
     {
         fontSearch = new FontKey(null, 0, 0);
-        fontTable = new Hashtable();
+        fontTable = new Hashtable<FontKey, Font>();
         search = new SimpleAttributeSet();
         attributesPool = Collections.
-            synchronizedMap(new WeakHashMap());
+                synchronizedMap(new WeakHashMap<SmallAttributeSet, WeakReference<SmallAttributeSet>>());
         s.defaultReadObject();
     }
 
@@ -731,15 +728,15 @@
      */
     public static final String DEFAULT_STYLE = "default";
 
-    private static Hashtable freezeKeyMap;
-    private static Hashtable thawKeyMap;
+    private static Hashtable<Object, String> freezeKeyMap;
+    private static Hashtable<String, Object> thawKeyMap;
 
     private Style styles;
     private transient FontKey fontSearch = new FontKey(null, 0, 0);
-    private transient Hashtable fontTable = new Hashtable();
+    private transient Hashtable<FontKey, Font> fontTable = new Hashtable<FontKey, Font>();
 
-    private transient Map attributesPool = Collections.
-        synchronizedMap(new WeakHashMap());
+    private transient Map<SmallAttributeSet, WeakReference<SmallAttributeSet>> attributesPool = Collections.
+            synchronizedMap(new WeakHashMap<SmallAttributeSet, WeakReference<SmallAttributeSet>>());
     private transient MutableAttributeSet search = new SimpleAttributeSet();
 
     /**
@@ -1176,8 +1173,8 @@
             }
         }
 
-        private Vector keys = new Vector();
-        private Vector data = new Vector();
+        private Vector<Object> keys = new Vector<Object>();
+        private Vector<Object> data = new Vector<Object>();
     }
 
     /**
@@ -1344,8 +1341,7 @@
          * @since 1.4
          */
         public ChangeListener[] getChangeListeners() {
-            return (ChangeListener[])listenerList.getListeners(
-                    ChangeListener.class);
+            return listenerList.getListeners(ChangeListener.class);
         }
 
 
--- a/src/share/classes/javax/swing/text/TableView.java	Thu Jul 24 14:51:13 2008 +0400
+++ b/src/share/classes/javax/swing/text/TableView.java	Thu Jul 24 16:43:36 2008 +0400
@@ -76,7 +76,7 @@
      */
     public TableView(Element elem) {
         super(elem, View.Y_AXIS);
-        rows = new Vector();
+        rows = new Vector<TableRow>();
         gridValid = false;
     }
 
@@ -139,7 +139,7 @@
 
     TableRow getRow(int row) {
         if (row < rows.size()) {
-            return (TableRow) rows.elementAt(row);
+            return rows.elementAt(row);
         }
         return null;
     }
@@ -227,7 +227,7 @@
             for (int i = 0; i < n; i++) {
                 View v = getView(i);
                 if (v instanceof TableRow) {
-                    rows.addElement(v);
+                    rows.addElement((TableRow) v);
                     TableRow rv = (TableRow) v;
                     rv.clearFilledColumns();
                     rv.setRow(i);
@@ -368,8 +368,7 @@
         long min = 0;
         long pref = 0;
         long max = 0;
-        for (int i = 0; i < columnRequirements.length; i++) {
-            SizeRequirements req = columnRequirements[i];
+        for (SizeRequirements req : columnRequirements) {
             min += req.minimum;
             pref += req.preferred;
             max += req.maximum;
@@ -578,7 +577,7 @@
     int[] columnSpans;
     int[] columnOffsets;
     SizeRequirements[] columnRequirements;
-    Vector rows;
+    Vector<TableRow> rows;
     boolean gridValid;
     static final private BitSet EMPTY = new BitSet();
 
--- a/src/share/classes/javax/swing/text/TextAction.java	Thu Jul 24 14:51:13 2008 +0400
+++ b/src/share/classes/javax/swing/text/TextAction.java	Thu Jul 24 16:43:36 2008 +0400
@@ -103,14 +103,12 @@
      * @return the augmented list
      */
     public static final Action[] augmentList(Action[] list1, Action[] list2) {
-        Hashtable h = new Hashtable();
-        for (int i = 0; i < list1.length; i++) {
-            Action a = list1[i];
+        Hashtable<String, Action> h = new Hashtable<String, Action>();
+        for (Action a : list1) {
             String value = (String)a.getValue(Action.NAME);
             h.put((value!=null ? value:""), a);
         }
-        for (int i = 0; i < list2.length; i++) {
-            Action a = list2[i];
+        for (Action a : list2) {
             String value = (String)a.getValue(Action.NAME);
             h.put((value!=null ? value:""), a);
         }
--- a/src/share/classes/javax/swing/text/TextLayoutStrategy.java	Thu Jul 24 14:51:13 2008 +0400
+++ b/src/share/classes/javax/swing/text/TextLayoutStrategy.java	Thu Jul 24 16:43:36 2008 +0400
@@ -103,7 +103,7 @@
      * constraints for each row.  This is called by a FlowView.layout
      * to update the child views in the flow.
      *
-     * @param v the view to reflow
+     * @param fv the view to reflow
      */
     public void layout(FlowView fv) {
         super.layout(fv);
@@ -485,9 +485,9 @@
          * Returns a map with the attributes defined on the current
          * character.
          */
-        public Map getAttributes() {
+        public Map<Attribute, Object> getAttributes() {
             Object[] ka = keys.toArray();
-            Hashtable h = new Hashtable();
+            Hashtable<Attribute, Object> h = new Hashtable<Attribute, Object>();
             for (int i = 0; i < ka.length; i++) {
                 TextAttribute a = (TextAttribute) ka[i];
                 Object value = getAttribute(a);
@@ -520,16 +520,16 @@
          * iterator's text range. The set is empty if no
          * attributes are defined.
          */
-        public Set getAllAttributeKeys() {
+        public Set<Attribute> getAllAttributeKeys() {
             return keys;
         }
 
         View v;
 
-        static Set keys;
+        static Set<Attribute> keys;
 
         static {
-            keys = new HashSet();
+            keys = new HashSet<Attribute>();
             keys.add(TextAttribute.FONT);
             keys.add(TextAttribute.RUN_DIRECTION);
         }
--- a/src/share/classes/javax/swing/text/ZoneView.java	Thu Jul 24 14:51:13 2008 +0400
+++ b/src/share/classes/javax/swing/text/ZoneView.java	Thu Jul 24 16:43:36 2008 +0400
@@ -79,7 +79,7 @@
 
     int maxZoneSize = 8 * 1024;
     int maxZonesLoaded = 3;
-    Vector loadedZones;
+    Vector<View> loadedZones;
 
     /**
      * Constructs a ZoneView.
@@ -89,7 +89,7 @@
      */
     public ZoneView(Element elem, int axis) {
         super(elem, axis);
-        loadedZones = new Vector();
+        loadedZones = new Vector<View>();
     }
 
     /**
@@ -157,7 +157,7 @@
 
     void unloadOldZones() {
         while (loadedZones.size() > getMaxZonesLoaded()) {
-            View zone = (View) loadedZones.elementAt(0);
+            View zone = loadedZones.elementAt(0);
             loadedZones.removeElementAt(0);
             unloadZone(zone);
         }
@@ -206,7 +206,7 @@
      */
     protected View createZone(int p0, int p1) {
         Document doc = getDocument();
-        View zone = null;
+        View zone;
         try {
             zone = new Zone(getElement(),
                             doc.createPosition(p0),
@@ -285,7 +285,7 @@
         // divide the old zone into a new set of bins
         Element elem = getElement();
         Document doc = elem.getDocument();
-        Vector zones = new Vector();
+        Vector<View> zones = new Vector<View>();
         int offs = offs0;
         do {
             offs0 = offs;
--- a/src/share/classes/javax/swing/text/html/AccessibleHTML.java	Thu Jul 24 14:51:13 2008 +0400
+++ b/src/share/classes/javax/swing/text/html/AccessibleHTML.java	Thu Jul 24 16:43:36 2008 +0400
@@ -456,7 +456,7 @@
         /**
          * Sets the Cursor of this object.
          *
-         * @param c the new Cursor for the object
+         * @param cursor the new Cursor for the object
          * @see #getCursor
          */
         public void setCursor(Cursor cursor) {
@@ -1076,7 +1076,7 @@
                     StyledDocument sdoc = (StyledDocument)model;
                     return sdoc.getParagraphElement(index);
                 } else {
-                    Element para = null;
+                    Element para;
                     for (para = model.getDefaultRootElement(); ! para.isLeaf(); ) {
                         int pos = para.getElementIndex(index);
                         para = para.getElement(pos);
@@ -1465,7 +1465,7 @@
             // Determine the max row/col count.
             int delta = 0;
             int maxCols = 0;
-            int rows = 0;
+            int rows;
             for (int counter = 0; counter < getChildCount(); counter++) {
                 TableRowElementInfo row = getRow(counter);
                 int prev = 0;
@@ -1929,7 +1929,7 @@
              * Returns a boolean value indicating whether the specified column
              * is selected.
              *
-             * @param r zero-based column of the table
+             * @param c zero-based column of the table
              * @return the boolean value true if the specified column is selected.
              * Otherwise, false.
              */
@@ -1966,7 +1966,7 @@
             public int [] getSelectedAccessibleRows() {
                 if (validateIfNecessary()) {
                     int nRows = getAccessibleRowCount();
-                    Vector vec = new Vector();
+                    Vector<Integer> vec = new Vector<Integer>();
 
                     for (int i = 0; i < nRows; i++) {
                         if (isAccessibleRowSelected(i)) {
@@ -1975,7 +1975,7 @@
                     }
                     int retval[] = new int[vec.size()];
                     for (int i = 0; i < retval.length; i++) {
-                        retval[i] = ((Integer)vec.elementAt(i)).intValue();
+                        retval[i] = vec.elementAt(i).intValue();
                     }
                     return retval;
                 }
@@ -1991,7 +1991,7 @@
             public int [] getSelectedAccessibleColumns() {
                 if (validateIfNecessary()) {
                     int nColumns = getAccessibleRowCount();
-                    Vector vec = new Vector();
+                    Vector<Integer> vec = new Vector<Integer>();
 
                     for (int i = 0; i < nColumns; i++) {
                         if (isAccessibleColumnSelected(i)) {
@@ -2000,7 +2000,7 @@
                     }
                     int retval[] = new int[vec.size()];
                     for (int i = 0; i < retval.length; i++) {
-                        retval[i] = ((Integer)vec.elementAt(i)).intValue();
+                        retval[i] = vec.elementAt(i).intValue();
                     }
                     return retval;
                 }
@@ -2134,15 +2134,16 @@
                 // Header information is modeled as a Hashtable of
                 // ArrayLists where each Hashtable entry represents
                 // a row containing one or more headers.
-                private Hashtable headers = new Hashtable();
+                private Hashtable<Integer, ArrayList<TableCellElementInfo>> headers =
+                        new Hashtable<Integer, ArrayList<TableCellElementInfo>>();
                 private int rowCount = 0;
                 private int columnCount = 0;
 
                 public void addHeader(TableCellElementInfo cellInfo, int rowNumber) {
                     Integer rowInteger = Integer.valueOf(rowNumber);
-                    ArrayList list = (ArrayList)headers.get(rowInteger);
+                    ArrayList<TableCellElementInfo> list = headers.get(rowInteger);
                     if (list == null) {
-                        list = new ArrayList();
+                        list = new ArrayList<TableCellElementInfo>();
                         headers.put(rowInteger, list);
                     }
                     list.add(cellInfo);
@@ -2201,9 +2202,9 @@
                 }
 
                 private TableCellElementInfo getElementInfoAt(int r, int c) {
-                    ArrayList list = (ArrayList)headers.get(Integer.valueOf(r));
+                    ArrayList<TableCellElementInfo> list = headers.get(Integer.valueOf(r));
                     if (list != null) {
-                        return (TableCellElementInfo)list.get(c);
+                        return list.get(c);
                     } else {
                         return null;
                     }
@@ -2364,7 +2365,7 @@
                  * Returns a boolean value indicating whether the specified column
                  * is selected.
                  *
-                 * @param r zero-based column of the table
+                 * @param c zero-based column of the table
                  * @return the boolean value true if the specified column is selected.
                  * Otherwise, false.
                  */
@@ -2585,7 +2586,6 @@
             private void getAccessible(ElementInfo elementInfo) {
                 if (elementInfo instanceof Accessible) {
                     accessible = (Accessible)elementInfo;
-                    return;
                 } else {
                     for (int i = 0; i < elementInfo.getChildCount(); i++) {
                         getAccessible(elementInfo.getChild(i));
@@ -2643,7 +2643,7 @@
         /**
          * The children of this ElementInfo.
          */
-        private ArrayList children;
+        private ArrayList<ElementInfo> children;
         /**
          * The Element this ElementInfo is providing information for.
          */
@@ -2754,11 +2754,11 @@
          */
         public ElementInfo getChild(int index) {
             if (validateIfNecessary()) {
-                ArrayList children = this.children;
+                ArrayList<ElementInfo> children = this.children;
 
                 if (children != null && index >= 0 &&
                                         index < children.size()) {
-                    return (ElementInfo)children.get(index);
+                    return children.get(index);
                 }
             }
             return null;
@@ -2777,7 +2777,7 @@
          */
         protected void addChild(ElementInfo child) {
             if (children == null) {
-                children = new ArrayList();
+                children = new ArrayList<ElementInfo>();
             }
             children.add(child);
         }
@@ -2927,8 +2927,8 @@
             isValid = false;
             canBeValid = first;
             if (children != null) {
-                for (int counter = 0; counter < children.size(); counter++) {
-                    ((ElementInfo)children.get(counter)).invalidate(false);
+                for (ElementInfo child : children) {
+                    child.invalidate(false);
                 }
                 children = null;
             }
--- a/src/share/classes/javax/swing/text/html/CSS.java	Thu Jul 24 14:51:13 2008 +0400
+++ b/src/share/classes/javax/swing/text/html/CSS.java	Thu Jul 24 16:43:36 2008 +0400
@@ -468,7 +468,7 @@
     public CSS() {
         baseFontSize = baseFontSizeIndex + 1;
         // setup the css conversion table
-        valueConvertor = new Hashtable();
+        valueConvertor = new Hashtable<Object, Object>();
         valueConvertor.put(CSS.Attribute.FONT_SIZE, new FontSize());
         valueConvertor.put(CSS.Attribute.FONT_FAMILY, new FontFamily());
         valueConvertor.put(CSS.Attribute.FONT_WEIGHT, new FontWeight());
@@ -637,7 +637,7 @@
      * Maps from a StyleConstants to a CSS Attribute.
      */
     Attribute styleConstantsKeyToCSSKey(StyleConstants sc) {
-        return (Attribute)styleConstantToCssMap.get(sc);
+        return styleConstantToCssMap.get(sc);
     }
 
     /**
@@ -645,7 +645,7 @@
      */
     Object styleConstantsValueToCSSValue(StyleConstants sc,
                                          Object styleValue) {
-        Object cssKey = styleConstantsKeyToCSSKey(sc);
+        Attribute cssKey = styleConstantsKeyToCSSKey(sc);
         if (cssKey != null) {
             CssValue conv = (CssValue)valueConvertor.get(cssKey);
             return conv.fromStyleConstants(sc, styleValue);
@@ -659,8 +659,7 @@
      */
     Object cssValueToStyleConstantsValue(StyleConstants key, Object value) {
         if (value instanceof CssValue) {
-            return ((CssValue)value).toStyleConstants((StyleConstants)key,
-                                                      null);
+            return ((CssValue)value).toStyleConstants(key, null);
         }
         return null;
     }
@@ -784,7 +783,7 @@
      * Convert a set of HTML attributes to an equivalent
      * set of CSS attributes.
      *
-     * @param AttributeSet containing the HTML attributes.
+     * @param htmlAttrSet AttributeSet containing the HTML attributes.
      * @return AttributeSet containing the corresponding CSS attributes.
      *        The AttributeSet will be empty if there are no mapping
      *        CSS attributes.
@@ -841,8 +840,8 @@
         return cssAttrSet;
     }
 
-    private static final Hashtable attributeMap = new Hashtable();
-    private static final Hashtable valueMap = new Hashtable();
+    private static final Hashtable<String, Attribute> attributeMap = new Hashtable<String, Attribute>();
+    private static final Hashtable<String, Value> valueMap = new Hashtable<String, Value>();
 
     /**
      * The hashtable and the static initalization block below,
@@ -854,18 +853,18 @@
      * Therefore, the value associated with each HTML.Attribute.
      * key ends up being an array of CSS.Attribute.* objects.
      */
-    private static final Hashtable htmlAttrToCssAttrMap = new Hashtable(20);
+    private static final Hashtable<HTML.Attribute, CSS.Attribute[]> htmlAttrToCssAttrMap = new Hashtable<HTML.Attribute, CSS.Attribute[]>(20);
 
     /**
      * The hashtable and static initialization that follows sets
      * up a translation from StyleConstants (i.e. the <em>well known</em>
      * attributes) to the associated CSS attributes.
      */
-    private static final Hashtable styleConstantToCssMap = new Hashtable(17);
+    private static final Hashtable<Object, Attribute> styleConstantToCssMap = new Hashtable<Object, Attribute>(17);
     /** Maps from HTML value to a CSS value. Used in internal mapping. */
-    private static final Hashtable htmlValueToCssValueMap = new Hashtable(8);
+    private static final Hashtable<String, CSS.Value> htmlValueToCssValueMap = new Hashtable<String, CSS.Value>(8);
     /** Maps from CSS value (string) to internal value. */
-    private static final Hashtable cssValueToInternalValueMap = new Hashtable(13);
+    private static final Hashtable<String, CSS.Value> cssValueToInternalValueMap = new Hashtable<String, CSS.Value>(13);
 
     static {
         // load the attribute map
@@ -995,8 +994,8 @@
         // Register all the CSS attribute keys for archival/unarchival
         Object[] keys = CSS.Attribute.allAttributes;
         try {
-            for (int i = 0; i < keys.length; i++) {
-                StyleContext.registerStaticAttributeKey(keys[i]);
+            for (Object key : keys) {
+                StyleContext.registerStaticAttributeKey(key);
             }
         } catch (Throwable e) {
             e.printStackTrace();
@@ -1005,8 +1004,8 @@
         // Register all the CSS Values for archival/unarchival
         keys = CSS.Value.allValues;
         try {
-            for (int i = 0; i < keys.length; i++) {
-                StyleContext.registerStaticAttributeKey(keys[i]);
+            for (Object key : keys) {
+                StyleContext.registerStaticAttributeKey(key);
             }
         } catch (Throwable e) {
             e.printStackTrace();
@@ -1034,7 +1033,7 @@
      *  doesn't represent a valid attribute key
      */
     public static final Attribute getAttribute(String name) {
-        return (Attribute) attributeMap.get(name);
+        return attributeMap.get(name);
     }
 
     /**
@@ -1050,7 +1049,7 @@
      *  not mean that it doesn't represent a valid CSS value
      */
     static final Value getValue(String name) {
-        return (Value) valueMap.get(name);
+        return valueMap.get(name);
     }
 
 
@@ -1159,7 +1158,7 @@
      * to a Color.
      */
     static Color stringToColor(String str) {
-      Color color = null;
+      Color color;
 
       if (str == null) {
           return null;
@@ -1299,7 +1298,7 @@
     static String[] parseStrings(String value) {
         int         current, last;
         int         length = (value == null) ? 0 : value.length();
-        Vector      temp = new Vector(4);
+        Vector<String> temp = new Vector<String>(4);
 
         current = 0;
         while (current < length) {
@@ -1423,10 +1422,10 @@
         if (cssAttrList == null || htmlAttrValue == null) {
             return;
         }
-        for (int i = 0; i < cssAttrList.length; i++) {
-            Object o = getCssValue(cssAttrList[i], htmlAttrValue);
+        for (Attribute cssAttr : cssAttrList) {
+            Object o = getCssValue(cssAttr, htmlAttrValue);
             if (o != null) {
-                cssAttrSet.addAttribute(cssAttrList[i], o);
+                cssAttrSet.addAttribute(cssAttr , o);
             }
         }
     }
@@ -1452,7 +1451,7 @@
      * @return CSS.Attribute[]
      */
     private CSS.Attribute[] getCssAttribute(HTML.Attribute hAttr) {
-        return (CSS.Attribute[])htmlAttrToCssAttrMap.get(hAttr);
+        return htmlAttrToCssAttrMap.get(hAttr);
     }
 
     /**
@@ -2599,8 +2598,8 @@
      * to an AttributeSet or returned to the developer.
      */
     static class LengthUnit implements Serializable {
-        static Hashtable lengthMapping = new Hashtable(6);
-        static Hashtable w3cLengthMapping = new Hashtable(6);
+        static Hashtable<String, Float> lengthMapping = new Hashtable<String, Float>(6);
+        static Hashtable<String, Float> w3cLengthMapping = new Hashtable<String, Float>(6);
         static {
             lengthMapping.put("pt", new Float(1f));
             // Not sure about 1.3, determined by experiementation.
@@ -2642,7 +2641,7 @@
             }
             if (length >= 2) {
                 units = value.substring(length - 2, length);
-                Float scale = (Float)lengthMapping.get(units);
+                Float scale = lengthMapping.get(units);
                 if (scale != null) {
                     try {
                         this.value = Float.valueOf(value.substring(0,
@@ -2686,10 +2685,10 @@
         }
 
         float getValue(boolean w3cLengthUnits) {
-            Hashtable mapping = (w3cLengthUnits) ? w3cLengthMapping : lengthMapping;
+            Hashtable<String, Float> mapping = (w3cLengthUnits) ? w3cLengthMapping : lengthMapping;
             float scale = 1;
             if (units != null) {
-                Float scaleFloat = (Float)mapping.get(units);
+                Float scaleFloat = mapping.get(units);
                 if (scaleFloat != null) {
                     scale = scaleFloat.floatValue();
                 }
@@ -2699,10 +2698,10 @@
         }
 
         static float getValue(float value, String units, Boolean w3cLengthUnits) {
-            Hashtable mapping = (w3cLengthUnits) ? w3cLengthMapping : lengthMapping;
+            Hashtable<String, Float> mapping = (w3cLengthUnits) ? w3cLengthMapping : lengthMapping;
             float scale = 1;
             if (units != null) {
-                Float scaleFloat = (Float)mapping.get(units);
+                Float scaleFloat = mapping.get(units);
                 if (scaleFloat != null) {
                     scale = scaleFloat.floatValue();
                 }
@@ -3089,7 +3088,7 @@
             iter.setIndex(i);
             int margin0 = lastMargin;
             int margin1 = (int) iter.getLeadingCollapseSpan();
-            totalSpacing += Math.max(margin0, margin1);;
+            totalSpacing += Math.max(margin0, margin1);
             preferred += (int) iter.getPreferredSpan(0);
             minimum += iter.getMinimumSpan(0);
             maximum += iter.getMaximumSpan(0);
@@ -3127,7 +3126,7 @@
          * of margin collapsing, and the flexibility to adjust the sizes.
          */
         long preferred = 0;
-        long currentPreferred = 0;
+        long currentPreferred;
         int lastMargin = 0;
         int totalSpacing = 0;
         int n = iter.getCount();
@@ -3199,7 +3198,7 @@
             }
         }
         // make the adjustments
-        int totalOffset = (int)iter.getBorderWidth();;
+        int totalOffset = (int)iter.getBorderWidth();
         for (int i = 0; i < n; i++) {
             iter.setIndex(i);
             iter.setOffset( iter.getOffset() + totalOffset);
@@ -3331,7 +3330,7 @@
         s.defaultReadObject();
         // Reconstruct the hashtable.
         int numValues = s.readInt();
-        valueConvertor = new Hashtable(Math.max(1, numValues));
+        valueConvertor = new Hashtable<Object, Object>(Math.max(1, numValues));
         while (numValues-- > 0) {
             Object key = s.readObject();
             Object value = s.readObject();
@@ -3372,7 +3371,7 @@
     //
 
     /** Maps from CSS key to CssValue. */
-    private transient Hashtable valueConvertor;
+    private transient Hashtable<Object, Object> valueConvertor;
 
     /** Size used for relative units. */
     private int baseFontSize;
--- a/src/share/classes/javax/swing/text/html/HTML.java	Thu Jul 24 14:51:13 2008 +0400
+++ b/src/share/classes/javax/swing/text/html/HTML.java	Thu Jul 24 16:43:36 2008 +0400
@@ -133,7 +133,7 @@
          *
          * @return <code>true</code> if this tag is considered to be a paragraph
          *         in the internal HTML model. <code>false</code> - otherwise.
-         * @see javax.swing.text.html.HTMLDocument#HTMLReader#ParagraphAction
+         * @see HTMLDocument.HTMLReader.ParagraphAction
          */
         boolean isParagraph() {
             return (
@@ -536,10 +536,10 @@
     // that the hashtable grew to was determined, and then that very size
     // is used.
     //
-    private static final Hashtable tagHashtable = new Hashtable(73);
+    private static final Hashtable<String, Tag> tagHashtable = new Hashtable<String, Tag>(73);
 
     /** Maps from StyleConstant key to HTML.Tag. */
-    private static final Hashtable scMapping = new Hashtable(8);
+    private static final Hashtable<Object, Tag> scMapping = new Hashtable<Object, Tag>(8);
 
     static {
 
@@ -598,8 +598,8 @@
      */
     public static Tag getTag(String tagName) {
 
-        Object t =  tagHashtable.get(tagName);
-        return (t == null ? null : (Tag)t);
+        Tag t =  tagHashtable.get(tagName);
+        return (t == null ? null : t);
     }
 
     /**
@@ -613,7 +613,7 @@
      *   <code>null</code> if not found
      */
     static Tag getTagForStyleConstantsKey(StyleConstants sc) {
-        return (Tag)scMapping.get(sc);
+        return scMapping.get(sc);
     }
 
     /**
@@ -646,7 +646,7 @@
     public static final String NULL_ATTRIBUTE_VALUE = "#DEFAULT";
 
     // size determined similar to size of tagHashtable
-    private static final Hashtable attHashtable = new Hashtable(77);
+    private static final Hashtable<String, Attribute> attHashtable = new Hashtable<String, Attribute>(77);
 
     static {
 
@@ -687,11 +687,11 @@
      * @return the <code>Attribute</code> corresponding to <code>attName</code>
      */
     public static Attribute getAttributeKey(String attName) {
-        Object a = attHashtable.get(attName);
+        Attribute a = attHashtable.get(attName);
         if (a == null) {
           return null;
         }
-        return (Attribute)a;
+        return a;
     }
 
 }
--- a/src/share/classes/javax/swing/text/html/HTMLDocument.java	Thu Jul 24 14:51:13 2008 +0400
+++ b/src/share/classes/javax/swing/text/html/HTMLDocument.java	Thu Jul 24 16:43:36 2008 +0400
@@ -745,7 +745,7 @@
      */
     private Element findFrame(String frameName) {
         ElementIterator it = new ElementIterator(this);
-        Element next = null;
+        Element next;
 
         while ((next = it.next()) != null) {
             AttributeSet attr = next.getAttributes();
@@ -891,7 +891,7 @@
 
     /**
      * Returns the Map associated with the given name.
-     * @param the name of the desired <code>Map</code>
+     * @param name the name of the desired <code>Map</code>
      * @return the <code>Map</code> or <code>null</code> if it can't
      *          be found, or if <code>name</code> is <code>null</code>
      */
@@ -1759,7 +1759,7 @@
      * Used to store button groups for radio buttons in
      * a form.
      */
-    private HashMap radioButtonGroupsMap;
+    private HashMap<String, ButtonGroup> radioButtonGroupsMap;
 
     /**
      * Document property for the number of tokens to buffer
@@ -1824,7 +1824,7 @@
     /**
      * I18N property key.
      *
-     * @see AbstractDocument.I18NProperty
+     * @see AbstractDocument#I18NProperty
      */
     private static final String I18NProperty = "i18n";
 
@@ -1915,7 +1915,7 @@
                 AttributeSet a = (AttributeSet)
                     elem.getAttributes().getAttribute(tag);
                 if (a == null) {
-                    a = (AttributeSet)elem.getAttributes();
+                    a = elem.getAttributes();
                 }
                 return a;
             }
@@ -2193,7 +2193,7 @@
             isStyleCSS = "text/css".equals(getDefaultStyleSheetType());
             this.offset = offset;
             threshold = HTMLDocument.this.getTokenThreshold();
-            tagMap = new Hashtable(57);
+            tagMap = new Hashtable<HTML.Tag, TagAction>(57);
             TagAction na = new TagAction();
             TagAction ba = new BlockAction();
             TagAction pa = new ParagraphAction();
@@ -2435,7 +2435,7 @@
                          (StyleConstants.NameAttribute) == HTML.Tag.BODY &&
                          pPath[1].getEndOffset() == length) {
                     String lastText = getText(length - 1, 1);
-                    DefaultDocumentEvent event = null;
+                    DefaultDocumentEvent event;
                     Element[] added;
                     Element[] removed;
                     int index;
@@ -2496,7 +2496,7 @@
         }
 
         private Element[] getPathTo(int offset) {
-            Stack elements = new Stack();
+            Stack<Element> elements = new Stack<Element>();
             Element e = getDefaultRootElement();
             int index;
             while (!e.isLeaf()) {
@@ -2610,7 +2610,7 @@
             else {
                 styleAttributes = null;
             }
-            TagAction action = (TagAction) tagMap.get(t);
+            TagAction action = tagMap.get(t);
 
             if (action != null) {
                 action.start(t, a);
@@ -2640,7 +2640,7 @@
                 addSpecialElement(HTML.Tag.COMMENT, sas);
             }
 
-            TagAction action = (TagAction)tagMap.get(HTML.Tag.COMMENT);
+            TagAction action = tagMap.get(HTML.Tag.COMMENT);
             if (action != null) {
                 action.start(HTML.Tag.COMMENT, new SimpleAttributeSet());
                 action.end(HTML.Tag.COMMENT);
@@ -2681,7 +2681,7 @@
                     inBlock--;
                 }
             }
-            TagAction action = (TagAction) tagMap.get(t);
+            TagAction action = tagMap.get(t);
             if (action != null) {
                 action.end(t);
             }
@@ -2707,7 +2707,7 @@
                 styleAttributes = null;
             }
 
-            TagAction action = (TagAction) tagMap.get(t);
+            TagAction action = tagMap.get(t);
             if (action != null) {
                 action.start(t, a);
                 action.end(t);
@@ -2802,7 +2802,7 @@
                 // might be defined in the FORM.
                 // for new group new ButtonGroup will be created (fix for 4529702)
                 // group name is a key in radioButtonGroupsMap
-                radioButtonGroupsMap = new HashMap();
+                radioButtonGroupsMap = new HashMap<String, ButtonGroup>();
             }
 
             public void end(HTML.Tag t) {
@@ -3015,7 +3015,7 @@
                     if (rel.equals("stylesheet") ||
                         rel.equals("alternate stylesheet")) {
                         if (styles == null) {
-                            styles = new Vector(3);
+                            styles = new Vector<Object>(3);
                         }
                         styles.addElement(t);
                         styles.addElement(a.copyAttributes());
@@ -3055,7 +3055,7 @@
             public void start(HTML.Tag t, MutableAttributeSet a) {
                 if (inHead) {
                     if (styles == null) {
-                        styles = new Vector(3);
+                        styles = new Vector<Object>(3);
                     }
                     styles.addElement(t);
                     styles.addElement(a.getAttribute(HTML.Attribute.TYPE));
@@ -3280,7 +3280,7 @@
                 String name = (String) a.getAttribute(HTML.Attribute.NAME);
                 String value = (String) a.getAttribute(HTML.Attribute.VALUE);
                 if ((name != null) && (value != null)) {
-                    ElementSpec objSpec = (ElementSpec) parseBuffer.lastElement();
+                    ElementSpec objSpec = parseBuffer.lastElement();
                     MutableAttributeSet objAttr = (MutableAttributeSet) objSpec.getAttributes();
                     objAttr.addAttribute(name, value);
                 }
@@ -3360,7 +3360,7 @@
                     int size = HTML.getIntegerAttributeValue(attr,
                                                              HTML.Attribute.SIZE,
                                                              1);
-                    boolean multiple = ((String)attr.getAttribute(HTML.Attribute.MULTIPLE) != null);
+                    boolean multiple = attr.getAttribute(HTML.Attribute.MULTIPLE) != null;
                     if ((size > 1) || multiple) {
                         OptionListModel m = new OptionListModel();
                         if (multiple) {
@@ -3460,9 +3460,9 @@
                     if (type.equals("radio")) {
                         String name = (String) attr.getAttribute(HTML.Attribute.NAME);
                         if ( radioButtonGroupsMap == null ) { //fix for 4772743
-                           radioButtonGroupsMap = new HashMap();
+                           radioButtonGroupsMap = new HashMap<String, ButtonGroup>();
                         }
-                        ButtonGroup radioButtonGroup = (ButtonGroup)radioButtonGroupsMap.get(name);
+                        ButtonGroup radioButtonGroup = radioButtonGroupsMap.get(name);
                         if (radioButtonGroup == null) {
                             radioButtonGroup = new ButtonGroup();
                             radioButtonGroupsMap.put(name,radioButtonGroup);
@@ -3604,7 +3604,7 @@
             // an open/close with no content will be removed, so we
             // add a space of content to keep the element being formed.
             ElementSpec prev = (parseBuffer.size() > 0) ?
-                (ElementSpec) parseBuffer.lastElement() : null;
+                parseBuffer.lastElement() : null;
             if (prev != null && prev.getType() == ElementSpec.StartTagType) {
                 char[] one = new char[1];
                 one[0] = ' ';
@@ -3737,7 +3737,7 @@
                 // This attemps to clean it up.
                 int removeCounter = insertTagDepthDelta;
                 while (removeCounter < 0 && size >= 0 &&
-                       ((ElementSpec)parseBuffer.elementAt(size - 1)).
+                        parseBuffer.elementAt(size - 1).
                        getType() == ElementSpec.EndTagType) {
                     parseBuffer.removeElementAt(--size);
                     removeCounter++;
@@ -3751,7 +3751,7 @@
                 // an extra \n in the middle of content.
                 int index = 0;
                 if (pushDepth > 0) {
-                    if (((ElementSpec)parseBuffer.elementAt(0)).getType() ==
+                    if (parseBuffer.elementAt(0).getType() ==
                         ElementSpec.ContentType) {
                         index++;
                     }
@@ -3759,19 +3759,19 @@
                 index += (popDepth + pushDepth);
                 int cCount = 0;
                 int cStart = index;
-                while (index < size && ((ElementSpec)parseBuffer.elementAt
-                            (index)).getType() == ElementSpec.ContentType) {
+                while (index < size && parseBuffer.elementAt
+                        (index).getType() == ElementSpec.ContentType) {
                     index++;
                     cCount++;
                 }
                 if (cCount > 1) {
-                    while (index < size && ((ElementSpec)parseBuffer.elementAt
-                               (index)).getType() == ElementSpec.EndTagType) {
+                    while (index < size && parseBuffer.elementAt
+                            (index).getType() == ElementSpec.EndTagType) {
                         index++;
                     }
                     if (index == size) {
-                        char[] lastText = ((ElementSpec)parseBuffer.elementAt
-                                           (cStart + cCount - 1)).getArray();
+                        char[] lastText = parseBuffer.elementAt
+                                (cStart + cCount - 1).getArray();
                         if (lastText.length == 1 && lastText[0] == NEWLINE[0]){
                             index = cStart + cCount - 1;
                             while (size > index) {
@@ -3785,8 +3785,7 @@
                 // Make sure there is in fact a newline
                 for (int counter = parseBuffer.size() - 1; counter >= 0;
                                    counter--) {
-                    ElementSpec spec = (ElementSpec)parseBuffer.
-                                                    elementAt(counter);
+                    ElementSpec spec = parseBuffer.elementAt(counter);
                     if (spec.getType() == ElementSpec.ContentType) {
                         if (spec.getArray()[spec.getLength() - 1] != '\n') {
                             SimpleAttributeSet attrs =new SimpleAttributeSet();
@@ -3817,7 +3816,7 @@
          * of stylesheets.
          */
         void linkCSSStyleSheet(String href) {
-            URL url = null;
+            URL url;
             try {
                 url = new URL(base, href);
             } catch (MalformedURLException mfe) {
@@ -4031,7 +4030,7 @@
          * indicating the type (may be null), and the elements following
          * it until the next HTML.Tag are the rules as Strings.
          */
-        Vector styles;
+        Vector<Object> styles;
         /** True if inside the head tag. */
         boolean inHead = false;
         /** Set to true if the style language is text/css. Since this is
@@ -4048,10 +4047,10 @@
          */
         Option option;
 
-        protected Vector<ElementSpec> parseBuffer = new Vector();    // Vector<ElementSpec>
+        protected Vector<ElementSpec> parseBuffer = new Vector<ElementSpec>();
         protected MutableAttributeSet charAttr = new TaggedAttributeSet();
-        Stack charAttrStack = new Stack();
-        Hashtable tagMap;
+        Stack<AttributeSet> charAttrStack = new Stack<AttributeSet>();
+        Hashtable<HTML.Tag, TagAction> tagMap;
         int inBlock = 0;
 
         /**
--- a/src/share/classes/javax/swing/text/html/HTMLEditorKit.java	Thu Jul 24 14:51:13 2008 +0400
+++ b/src/share/classes/javax/swing/text/html/HTMLEditorKit.java	Thu Jul 24 16:43:36 2008 +0400
@@ -898,7 +898,7 @@
             } catch (MalformedURLException m) {
                 u = null;
             }
-            HyperlinkEvent linkEvent = null;
+            HyperlinkEvent linkEvent;
 
             if (!hdoc.isFrameDocument()) {
                 linkEvent = new HyperlinkEvent(
@@ -1271,11 +1271,11 @@
                     && (parentContainer = container.getParent()) != null
                     && (parentContainer instanceof javax.swing.JViewport)) {
                     JViewport viewPort = (JViewport)parentContainer;
-                    Object cachedObject;
                     if (cachedViewPort != null) {
-                        if ((cachedObject = cachedViewPort.get()) != null) {
+                        JViewport cachedObject = cachedViewPort.get();
+                        if (cachedObject != null) {
                             if (cachedObject != viewPort) {
-                                ((JComponent)cachedObject).removeComponentListener(this);
+                                cachedObject.removeComponentListener(this);
                             }
                         } else {
                             cachedViewPort = null;
@@ -1283,7 +1283,7 @@
                     }
                     if (cachedViewPort == null) {
                         viewPort.addComponentListener(this);
-                        cachedViewPort = new WeakReference(viewPort);
+                        cachedViewPort = new WeakReference<JViewport>(viewPort);
                     }
 
                     componentVisibleWidth = viewPort.getExtentSize().width;
@@ -1295,9 +1295,9 @@
                     }
                 } else {
                     if (cachedViewPort != null) {
-                        Object cachedObject;
-                        if ((cachedObject = cachedViewPort.get()) != null) {
-                            ((JComponent)cachedObject).removeComponentListener(this);
+                        JViewport cachedObject = cachedViewPort.get();
+                        if (cachedObject != null) {
+                            cachedObject.removeComponentListener(this);
                         }
                         cachedViewPort = null;
                     }
@@ -1351,7 +1351,7 @@
              * we need to keep this reference in order to remove BodyBoxView from viewPort listeners.
              *
              */
-            private Reference cachedViewPort = null;
+            private Reference<JViewport> cachedViewPort = null;
             private boolean isListening = false;
             private int viewVisibleWidth = Integer.MAX_VALUE;
             private int componentVisibleWidth = Integer.MAX_VALUE;
@@ -1928,7 +1928,7 @@
             int prevEndOffset = -1;
 
             // highlight the next link or object after the current caret position
-            Element nextElement = null;
+            Element nextElement;
             while ((nextElement = ei.next()) != null) {
                 String name = nextElement.getName();
                 AttributeSet attr = nextElement.getAttributes();
@@ -1969,7 +1969,6 @@
                 comp.setCaretPosition(prevStartOffset);
                 moveCaretPosition(comp, kit, prevStartOffset, prevEndOffset);
                 kit.prevHypertextOffset = prevStartOffset;
-                return;
             }
         }
 
@@ -2113,7 +2112,7 @@
             if (view != null && view instanceof ObjectView) {
                 Component comp = ((ObjectView)view).getComponent();
                 if (comp != null && comp instanceof Accessible) {
-                    AccessibleContext ac = ((Accessible)comp).getAccessibleContext();
+                    AccessibleContext ac = comp.getAccessibleContext();
                     if (ac != null) {
                         AccessibleAction aa = ac.getAccessibleAction();
                         if (aa != null) {
@@ -2207,7 +2206,7 @@
             // invoke the next link or object action
             String urlString = null;
             String objString = null;
-            Element currentElement = null;
+            Element currentElement;
             while ((currentElement = ei.next()) != null) {
                 String name = currentElement.getName();
                 AttributeSet attr = currentElement.getAttributes();
--- a/src/share/classes/javax/swing/text/html/HTMLWriter.java	Thu Jul 24 14:51:13 2008 +0400
+++ b/src/share/classes/javax/swing/text/html/HTMLWriter.java	Thu Jul 24 16:43:36 2008 +0400
@@ -46,7 +46,7 @@
      * Stores all elements for which end tags have to
      * be emitted.
      */
-    private Stack blockElementStack = new Stack();
+    private Stack<Element> blockElementStack = new Stack<Element>();
     private boolean inContent = false;
     private boolean inPre = false;
     /** When inPre is true, this will indicate the end offset of the pre
@@ -62,12 +62,12 @@
      * character level attributes.  Examples include
      * &lt;b&gt;, &lt;i&gt;, &lt;font&gt;, and &lt;a&gt;.
      */
-    private Vector tags = new Vector(10);
+    private Vector<HTML.Tag> tags = new Vector<HTML.Tag>(10);
 
     /**
      * Values for the tags.
      */
-    private Vector tagValues = new Vector(10);
+    private Vector<Object> tagValues = new Vector<Object>(10);
 
     /**
      * Used when writing out content.
@@ -77,7 +77,7 @@
     /*
      * This is used in closeOutUnwantedEmbeddedTags.
      */
-    private Vector tagsToRemove = new Vector(10);
+    private Vector<HTML.Tag> tagsToRemove = new Vector<HTML.Tag>(10);
 
     /**
      * Set to true after the head has been output.
@@ -133,7 +133,7 @@
     public void write() throws IOException, BadLocationException {
         ElementIterator it = getElementIterator();
         Element current = null;
-        Element next = null;
+        Element next;
 
         wroteHead = false;
         setCurrentLineLength(0);
@@ -169,7 +169,7 @@
                        item on top of the stack, is the parent of the
                        next.
                     */
-                    Element top = (Element)blockElementStack.peek();
+                    Element top = blockElementStack.peek();
                     while (top != next.getParentElement()) {
                         /*
                            pop() will return top.
@@ -183,7 +183,7 @@
                             }
                             endTag(top);
                         }
-                        top = (Element)blockElementStack.peek();
+                        top = blockElementStack.peek();
                     }
                 } else if (current.getParentElement() == next.getParentElement()) {
                     /*
@@ -191,7 +191,7 @@
                        is correct.  But, we need to make sure that if current is
                        on the stack, we pop it off, and put out its end tag.
                     */
-                    Element top = (Element)blockElementStack.peek();
+                    Element top = blockElementStack.peek();
                     if (top == current) {
                         blockElementStack.pop();
                         endTag(top);
@@ -219,7 +219,7 @@
             endTag(current);
         }
         while (!blockElementStack.empty()) {
-            current = (Element)blockElementStack.pop();
+            current = blockElementStack.pop();
             if (!synthesizedElement(current)) {
                 AttributeSet attrs = current.getAttributes();
                 if (!matchNameAttribute(attrs, HTML.Tag.PRE) &&
@@ -308,7 +308,7 @@
             //
             if (nameTag != null && endTag != null &&
                 (endTag instanceof String) &&
-                ((String)endTag).equals("true")) {
+                endTag.equals("true")) {
                 outputEndTag = true;
             }
 
@@ -769,7 +769,7 @@
         int size = tags.size();
         // First, find all the tags that need to be removed.
         for (int i = size - 1; i >= 0; i--) {
-            t = (HTML.Tag)tags.elementAt(i);
+            t = tags.elementAt(i);
             tValue = tagValues.elementAt(i);
             if ((attr == null) || noMatchForTagInAttributes(attr, t, tValue)) {
                 firstIndex = i;
@@ -780,7 +780,7 @@
             // Then close them out.
             boolean removeAll = ((size - firstIndex) == tagsToRemove.size());
             for (int i = size - 1; i >= firstIndex; i--) {
-                t = (HTML.Tag)tags.elementAt(i);
+                t = tags.elementAt(i);
                 if (removeAll || tagsToRemove.contains(t)) {
                     tags.removeElementAt(i);
                     tagValues.removeElementAt(i);
@@ -794,7 +794,7 @@
             // as we closed them out, but they should remain open.
             size = tags.size();
             for (int i = firstIndex; i < size; i++) {
-                t = (HTML.Tag)tags.elementAt(i);
+                t = tags.elementAt(i);
                 write('<');
                 write(t.toString());
                 Object o = tagValues.elementAt(i);
@@ -813,11 +813,8 @@
      * false
      */
     private boolean isFormElementWithContent(AttributeSet attr) {
-        if (matchNameAttribute(attr, HTML.Tag.TEXTAREA) ||
-            matchNameAttribute(attr, HTML.Tag.SELECT)) {
-            return true;
-        }
-        return false;
+        return matchNameAttribute(attr, HTML.Tag.TEXTAREA) ||
+                matchNameAttribute(attr, HTML.Tag.SELECT);
     }
 
 
--- a/src/share/classes/javax/swing/text/html/Map.java	Thu Jul 24 14:51:13 2008 +0400
+++ b/src/share/classes/javax/swing/text/html/Map.java	Thu Jul 24 16:43:36 2008 +0400
@@ -41,10 +41,10 @@
     /** Name of the Map. */
     private String           name;
     /** An array of AttributeSets. */
-    private Vector           areaAttributes;
+    private Vector<AttributeSet>           areaAttributes;
     /** An array of RegionContainments, will slowly grow to match the
      * length of areaAttributes as needed. */
-    private Vector           areas;
+    private Vector<RegionContainment>           areas;
 
     public Map() {
     }
@@ -68,7 +68,7 @@
             return;
         }
         if (areaAttributes == null) {
-            areaAttributes = new Vector(2);
+            areaAttributes = new Vector<AttributeSet>(2);
         }
         areaAttributes.addElement(as.copyAttributes());
     }
@@ -81,8 +81,7 @@
             int numAreas = (areas != null) ? areas.size() : 0;
             for (int counter = areaAttributes.size() - 1; counter >= 0;
                  counter--) {
-                if (((AttributeSet)areaAttributes.elementAt(counter)).
-                    isEqual(as)){
+                if (areaAttributes.elementAt(counter).isEqual(as)){
                     areaAttributes.removeElementAt(counter);
                     if (counter < numAreas) {
                         areas.removeElementAt(counter);
@@ -121,17 +120,16 @@
             int      numAreas = (areas != null) ? areas.size() : 0;
 
             if (areas == null) {
-                areas = new Vector(numAttributes);
+                areas = new Vector<RegionContainment>(numAttributes);
             }
             for (int counter = 0; counter < numAttributes; counter++) {
                 if (counter >= numAreas) {
                     areas.addElement(createRegionContainment
-                            ((AttributeSet)areaAttributes.elementAt(counter)));
+                            (areaAttributes.elementAt(counter)));
                 }
-                RegionContainment       rc = (RegionContainment)areas.
-                                             elementAt(counter);
+                RegionContainment rc = areas.elementAt(counter);
                 if (rc != null && rc.contains(x, y, width, height)) {
-                    return (AttributeSet)areaAttributes.elementAt(counter);
+                    return areaAttributes.elementAt(counter);
                 }
             }
         }
--- a/src/share/classes/javax/swing/text/html/MinimalHTMLWriter.java	Thu Jul 24 14:51:13 2008 +0400
+++ b/src/share/classes/javax/swing/text/html/MinimalHTMLWriter.java	Thu Jul 24 16:43:36 2008 +0400
@@ -97,7 +97,7 @@
      * Maps from style name as held by the Document, to the archived
      * style name (style name written out). These may differ.
      */
-    private Hashtable styleNameMapping;
+    private Hashtable<String, String> styleNameMapping;
 
     /**
      * Creates a new MinimalHTMLWriter.
@@ -134,7 +134,7 @@
      *
      */
     public void write() throws IOException, BadLocationException {
-        styleNameMapping = new Hashtable();
+        styleNameMapping = new Hashtable<String, String>();
         writeStartTag("<html>");
         writeHeader();
         writeBody();
@@ -296,7 +296,7 @@
          */
         it.current();
 
-        Element next = null;
+        Element next;
 
         writeStartTag("<body>");
 
@@ -715,7 +715,7 @@
         if (styleNameMapping == null) {
             return style;
         }
-        String retValue = (String)styleNameMapping.get(style);
+        String retValue = styleNameMapping.get(style);
         return (retValue == null) ? style : retValue;
     }
 
--- a/src/share/classes/javax/swing/text/html/OptionListModel.java	Thu Jul 24 14:51:13 2008 +0400
+++ b/src/share/classes/javax/swing/text/html/OptionListModel.java	Thu Jul 24 16:43:36 2008 +0400
@@ -108,8 +108,7 @@
      * @since 1.4
      */
     public ListSelectionListener[] getListSelectionListeners() {
-        return (ListSelectionListener[])listenerList.getListeners(
-                ListSelectionListener.class);
+        return listenerList.getListeners(ListSelectionListener.class);
     }
 
     /**
@@ -131,7 +130,7 @@
 
     /**
      * @param firstIndex The first index in the interval.
-     * @param index1 The last index in the interval.
+     * @param lastIndex The last index in the interval.
      * @param isAdjusting True if this is the final change in a series of them.
      * @see EventListenerList
      */
@@ -528,8 +527,8 @@
             anchorIndex = leadIndex;
         }
 
-        int oldMin = Math.min(this.anchorIndex, this.leadIndex);;
-        int oldMax = Math.max(this.anchorIndex, this.leadIndex);;
+        int oldMin = Math.min(this.anchorIndex, this.leadIndex);
+        int oldMax = Math.max(this.anchorIndex, this.leadIndex);
         int newMin = Math.min(anchorIndex, leadIndex);
         int newMax = Math.max(anchorIndex, leadIndex);
         if (value.get(this.anchorIndex)) {
--- a/src/share/classes/javax/swing/text/html/StyleSheet.java	Thu Jul 24 14:51:13 2008 +0400
+++ b/src/share/classes/javax/swing/text/html/StyleSheet.java	Thu Jul 24 16:43:36 2008 +0400
@@ -164,7 +164,7 @@
     public StyleSheet() {
         super();
         selectorMapping = new SelectorMapping(0);
-        resolvedStyles = new Hashtable();
+        resolvedStyles = new Hashtable<String, ResolvedStyle>();
         if (css == null) {
             css = new CSS();
         }
@@ -190,7 +190,7 @@
 
         try {
             // Build an array of all the parent elements.
-            Vector searchContext = sb.getVector();
+            Vector<Element> searchContext = sb.getVector();
 
             for (Element p = e; p != null; p = p.getParentElement()) {
                 searchContext.addElement(p);
@@ -205,7 +205,7 @@
 
             // >= 1 as the HTML.Tag for the 0th element is passed in.
             for (int counter = n - 1; counter >= 1; counter--) {
-                e = (Element)searchContext.elementAt(counter);
+                e = searchContext.elementAt(counter);
                 attr = e.getAttributes();
                 name = attr.getAttribute(StyleConstants.NameAttribute);
                 eName = name.toString();
@@ -225,7 +225,7 @@
                 cacheLookup.append(' ');
             }
             cacheLookup.append(t.toString());
-            e = (Element)searchContext.elementAt(0);
+            e = searchContext.elementAt(0);
             attr = e.getAttributes();
             if (e.isLeaf()) {
                 // For leafs, we use the second tier attributes.
@@ -368,10 +368,9 @@
                 if (rule != null) {
                     mapping.setStyle(null);
                     if (resolvedStyles.size() > 0) {
-                        Enumeration values = resolvedStyles.elements();
+                        Enumeration<ResolvedStyle> values = resolvedStyles.elements();
                         while (values.hasMoreElements()) {
-                            ResolvedStyle style = (ResolvedStyle)values.
-                                                    nextElement();
+                            ResolvedStyle style = values.nextElement();
                             style.removeStyle(rule);
                         }
                     }
@@ -392,7 +391,7 @@
     public void addStyleSheet(StyleSheet ss) {
         synchronized(this) {
             if (linkedStyleSheets == null) {
-                linkedStyleSheets = new Vector();
+                linkedStyleSheets = new Vector<StyleSheet>();
             }
             if (!linkedStyleSheets.contains(ss)) {
                 int index = 0;
@@ -828,7 +827,7 @@
         /**
          * Creates a new attribute set based on a supplied set of attributes.
          *
-         * @param source the set of attributes
+         * @param attrs the set of attributes
          */
         public SmallConversionSet(AttributeSet attrs) {
             super(attrs);
@@ -1045,9 +1044,9 @@
      */
     private synchronized void linkStyleSheetAt(StyleSheet ss, int index) {
         if (resolvedStyles.size() > 0) {
-            Enumeration values = resolvedStyles.elements();
+            Enumeration<ResolvedStyle> values = resolvedStyles.elements();
             while (values.hasMoreElements()) {
-                ResolvedStyle rule = (ResolvedStyle)values.nextElement();
+                ResolvedStyle rule = values.nextElement();
                 rule.insertExtendedStyleAt(ss.getRule(rule.getName()),
                                            index);
             }
@@ -1061,9 +1060,9 @@
      */
     private synchronized void unlinkStyleSheet(StyleSheet ss, int index) {
         if (resolvedStyles.size() > 0) {
-            Enumeration values = resolvedStyles.elements();
+            Enumeration<ResolvedStyle> values = resolvedStyles.elements();
             while (values.hasMoreElements()) {
-                ResolvedStyle rule = (ResolvedStyle)values.nextElement();
+                ResolvedStyle rule = values.nextElement();
                 rule.removeExtendedStyleAt(index);
             }
         }
@@ -1076,7 +1075,7 @@
     String[] getSimpleSelectors(String selector) {
         selector = cleanSelectorString(selector);
         SearchBuffer sb = SearchBuffer.obtainSearchBuffer();
-        Vector selectors = sb.getVector();
+        Vector<String> selectors = sb.getVector();
         int lastIndex = 0;
         int length = selector.length();
         while (lastIndex != -1) {
@@ -1256,7 +1255,7 @@
     private synchronized Style getResolvedStyle(String selector,
                                                 Vector elements,
                                                 HTML.Tag t) {
-        Style retStyle = (Style)resolvedStyles.get(selector);
+        Style retStyle = resolvedStyles.get(selector);
         if (retStyle == null) {
             retStyle = createResolvedStyle(selector, elements, t);
         }
@@ -1268,7 +1267,7 @@
      * create the resolved style, if necessary.
      */
     private synchronized Style getResolvedStyle(String selector) {
-        Style retStyle = (Style)resolvedStyles.get(selector);
+        Style retStyle = resolvedStyles.get(selector);
         if (retStyle == null) {
             retStyle = createResolvedStyle(selector);
         }
@@ -1280,15 +1279,14 @@
      * such that <code>elements</code> will remain ordered by
      * specificity.
      */
-    private void addSortedStyle(SelectorMapping mapping, Vector elements) {
+    private void addSortedStyle(SelectorMapping mapping, Vector<SelectorMapping> elements) {
         int       size = elements.size();
 
         if (size > 0) {
             int     specificity = mapping.getSpecificity();
 
             for (int counter = 0; counter < size; counter++) {
-                if (specificity >= ((SelectorMapping)elements.elementAt
-                                    (counter)).getSpecificity()) {
+                if (specificity >= elements.elementAt(counter).getSpecificity()) {
                     elements.insertElementAt(mapping, counter);
                     return;
                 }
@@ -1303,10 +1301,10 @@
      * any child mappings for any of the Elements in <code>elements</code>.
      */
     private synchronized void getStyles(SelectorMapping parentMapping,
-                           Vector styles,
+                           Vector<SelectorMapping> styles,
                            String[] tags, String[] ids, String[] classes,
                            int index, int numElements,
-                           Hashtable alreadyChecked) {
+                           Hashtable<SelectorMapping, SelectorMapping> alreadyChecked) {
         // Avoid desending the same mapping twice.
         if (alreadyChecked.contains(parentMapping)) {
             return;
@@ -1367,8 +1365,8 @@
                                       String[] tags,
                                       String[] ids, String[] classes) {
         SearchBuffer sb = SearchBuffer.obtainSearchBuffer();
-        Vector tempVector = sb.getVector();
-        Hashtable tempHashtable = sb.getHashtable();
+        Vector<SelectorMapping> tempVector = sb.getVector();
+        Hashtable<SelectorMapping, SelectorMapping> tempHashtable = sb.getHashtable();
         // Determine all the Styles that are appropriate, placing them
         // in tempVector
         try {
@@ -1418,13 +1416,11 @@
             int numStyles = tempVector.size();
             AttributeSet[] attrs = new AttributeSet[numStyles + numLinkedSS];
             for (int counter = 0; counter < numStyles; counter++) {
-                attrs[counter] = ((SelectorMapping)tempVector.
-                                  elementAt(counter)).getStyle();
+                attrs[counter] = tempVector.elementAt(counter).getStyle();
             }
             // Get the AttributeSet from linked style sheets.
             for (int counter = 0; counter < numLinkedSS; counter++) {
-                AttributeSet attr = ((StyleSheet)linkedStyleSheets.
-                                 elementAt(counter)).getRule(selector);
+                AttributeSet attr = linkedStyleSheets.elementAt(counter).getRule(selector);
                 if (attr == null) {
                     attrs[counter + numStyles] = SimpleAttributeSet.EMPTY;
                 }
@@ -1514,11 +1510,11 @@
     private Style createResolvedStyle(String selector) {
         SearchBuffer sb = SearchBuffer.obtainSearchBuffer();
         // Will contain the tags, ids, and classes, in that order.
-        Vector elements = sb.getVector();
+        Vector<String> elements = sb.getVector();
         try {
             boolean done;
             int dotIndex = 0;
-            int spaceIndex = 0;
+            int spaceIndex;
             int poundIndex = 0;
             int lastIndex = 0;
             int length = selector.length();
@@ -1640,9 +1636,9 @@
             String[] classes = new String[numTags];
             for (int index = 0, eIndex = total - 3; index < numTags;
                  index++, eIndex -= 3) {
-                tags[index] = (String)elements.elementAt(eIndex);
-                classes[index] = (String)elements.elementAt(eIndex + 1);
-                ids[index] = (String)elements.elementAt(eIndex + 2);
+                tags[index] = elements.elementAt(eIndex);
+                classes[index] = elements.elementAt(eIndex + 1);
+                ids[index] = elements.elementAt(eIndex + 2);
             }
             return createResolvedStyle(selector, tags, ids, classes);
         }
@@ -1661,9 +1657,9 @@
                                                    Style newStyle,
                                                    int specificity) {
         if (resolvedStyles.size() > 0) {
-            Enumeration values = resolvedStyles.elements();
+            Enumeration<ResolvedStyle> values = resolvedStyles.elements();
             while (values.hasMoreElements()) {
-                ResolvedStyle style = (ResolvedStyle)values.nextElement();
+                ResolvedStyle style = values.nextElement();
                 if (style.matches(selectorName)) {
                     style.insertStyle(newStyle, specificity);
                 }
@@ -1682,7 +1678,7 @@
     private static class SearchBuffer {
         /** A stack containing instances of SearchBuffer. Used in getting
          * rules. */
-        static Stack searchBuffers = new Stack();
+        static Stack<SearchBuffer> searchBuffers = new Stack<SearchBuffer>();
         // A set of temporary variables that can be used in whatever way.
         Vector vector = null;
         StringBuffer stringBuffer = null;
@@ -1696,7 +1692,7 @@
             SearchBuffer sb;
             try {
                 if(!searchBuffers.empty()) {
-                   sb = (SearchBuffer)searchBuffers.pop();
+                   sb = searchBuffers.pop();
                 } else {
                    sb = new SearchBuffer();
                 }
@@ -1922,7 +1918,7 @@
         static boolean isLeftToRight(View v) {
             boolean ret = true;
             if (isOrientationAware(v)) {
-                Container container = null;
+                Container container;
                 if (v != null && (container = v.getContainer()) != null) {
                     ret = container.getComponentOrientation().isLeftToRight();
                 }
@@ -1938,8 +1934,8 @@
          */
         static boolean isOrientationAware(View v) {
             boolean ret = false;
-            AttributeSet attr = null;
-            Object obj = null;
+            AttributeSet attr;
+            Object obj;
             if (v != null
                 && (attr = v.getElement().getAttributes()) != null
                 && (obj = attr.getAttribute(StyleConstants.NameAttribute)) instanceof HTML.Tag
@@ -1953,7 +1949,7 @@
             return ret;
         }
 
-        static enum HorizontalMargin { LEFT, RIGHT };
+        static enum HorizontalMargin { LEFT, RIGHT }
 
         /**
          * for <dir>, <menu>, <ul> etc.
@@ -2362,7 +2358,7 @@
          * @param itemNum number to format
          */
         String formatAlphaNumerals(int itemNum) {
-            String result = "";
+            String result;
 
             if (itemNum > 26) {
                 result = formatAlphaNumerals(itemNum / 26) +
@@ -2411,7 +2407,7 @@
          * Converts the item number into a roman numeral
          *
          * @param level position
-         * @param num   digit to format
+         * @param digit digit to format
          */
         String formatRomanDigit(int level, int digit) {
             String result = "";
@@ -2625,7 +2621,7 @@
             // implementation.
             Document doc = v.getDocument();
             SearchBuffer sb = SearchBuffer.obtainSearchBuffer();
-            Vector muxList = sb.getVector();
+            Vector<AttributeSet> muxList = sb.getVector();
             try {
                 if (doc instanceof HTMLDocument) {
                     StyleSheet styles = StyleSheet.this;
@@ -2641,8 +2637,8 @@
                         while (keys.hasMoreElements()) {
                             Object key = keys.nextElement();
                             if (key instanceof HTML.Tag) {
-                                if ((HTML.Tag)key  == HTML.Tag.A) {
-                                    Object o = a.getAttribute((HTML.Tag)key);
+                                if (key == HTML.Tag.A) {
+                                    Object o = a.getAttribute(key);
                                 /**
                                    In the case of an A tag, the css rules
                                    apply only for tags that have their
@@ -3059,10 +3055,10 @@
             SelectorMapping retValue = null;
 
             if (children != null) {
-                retValue = (SelectorMapping)children.get(selector);
+                retValue = children.get(selector);
             }
             else if (create) {
-                children = new HashMap(7);
+                children = new HashMap<String, SelectorMapping>(7);
             }
             if (retValue == null && create) {
                 int specificity = getChildSpecificity(selector);
@@ -3121,7 +3117,7 @@
          * Any sub selectors. Key will be String, and value will be
          * another SelectorMapping.
          */
-        private HashMap children;
+        private HashMap<String, SelectorMapping> children;
     }
 
 
@@ -3138,11 +3134,11 @@
 
     /** Maps from selector (as a string) to Style that includes all
      * relevant styles. */
-    private Hashtable resolvedStyles;
+    private Hashtable<String, ResolvedStyle> resolvedStyles;
 
     /** Vector of StyleSheets that the rules are to reference.
      */
-    private Vector linkedStyleSheets;
+    private Vector<StyleSheet> linkedStyleSheets;
 
     /** Where the style sheet was found. Used for relative imports. */
     private URL base;
@@ -3279,7 +3275,7 @@
         public void endRule() {
             int n = selectors.size();
             for (int i = 0; i < n; i++) {
-                String[] selector = (String[]) selectors.elementAt(i);
+                String[] selector = selectors.elementAt(i);
                 if (selector.length > 0) {
                     StyleSheet.this.addRule(selector, declaration, isLink);
                 }
@@ -3296,8 +3292,8 @@
         }
 
 
-        Vector selectors = new Vector();
-        Vector selectorTokens = new Vector();
+        Vector<String[]> selectors = new Vector<String[]>();
+        Vector<String> selectorTokens = new Vector<String>();
         /** Name of the current property. */
         String propertyName;
         MutableAttributeSet declaration = new SimpleAttributeSet();
--- a/src/share/classes/javax/swing/text/html/TableView.java	Thu Jul 24 14:51:13 2008 +0400
+++ b/src/share/classes/javax/swing/text/html/TableView.java	Thu Jul 24 16:43:36 2008 +0400
@@ -48,7 +48,7 @@
      */
     public TableView(Element elem) {
         super(elem, View.Y_AXIS);
-        rows = new Vector();
+        rows = new Vector<RowView>();
         gridValid = false;
         captionIndex = -1;
         totalColumnRequirements = new SizeRequirements();
@@ -127,14 +127,14 @@
 
     RowView getRow(int row) {
         if (row < rows.size()) {
-            return (RowView) rows.elementAt(row);
+            return rows.elementAt(row);
         }
         return null;
     }
 
     protected View getViewAtPoint(int x, int y, Rectangle alloc) {
         int n = getViewCount();
-        View v = null;
+        View v;
         Rectangle allocation = new Rectangle();
         for (int i = 0; i < n; i++) {
             allocation.setBounds(alloc);
@@ -273,7 +273,7 @@
             for (int i = 0; i < n; i++) {
                 View v = getView(i);
                 if (v instanceof RowView) {
-                    rows.addElement(v);
+                    rows.addElement((RowView) v);
                     RowView rv = (RowView) v;
                     rv.clearFilledColumns();
                     rv.rowIndex = rows.size() - 1;
@@ -990,7 +990,7 @@
     RowIterator rowIterator = new RowIterator();
     ColumnIterator colIterator = new ColumnIterator();
 
-    Vector rows;
+    Vector<RowView> rows;
 
     // whether to display comments inside table or not.
     boolean skipComments = false;
--- a/src/share/classes/javax/swing/text/html/parser/AttributeList.java	Thu Jul 24 14:51:13 2008 +0400
+++ b/src/share/classes/javax/swing/text/html/parser/AttributeList.java	Thu Jul 24 16:43:36 2008 +0400
@@ -129,7 +129,7 @@
     /**
      * Create a hashtable of attribute types.
      */
-    static Hashtable attributeTypes = new Hashtable();
+    static Hashtable<Object, Object> attributeTypes = new Hashtable<Object, Object>();
 
     static void defineAttributeType(String nm, int val) {
         Integer num = Integer.valueOf(val);
--- a/src/share/classes/javax/swing/text/html/parser/DTD.java	Thu Jul 24 14:51:13 2008 +0400
+++ b/src/share/classes/javax/swing/text/html/parser/DTD.java	Thu Jul 24 16:43:36 2008 +0400
@@ -104,7 +104,7 @@
      *   <code>name</code> <code>String</code>
      */
     public Entity getEntity(String name) {
-        return (Entity)entityHash.get(name);
+        return entityHash.get(name);
     }
 
     /**
@@ -113,7 +113,7 @@
      *    <code>ch</code> character
      */
     public Entity getEntity(int ch) {
-        return (Entity)entityHash.get(Integer.valueOf(ch));
+        return entityHash.get(Integer.valueOf(ch));
     }
 
     /**
@@ -137,7 +137,7 @@
      *   <code>name</code>, which may be newly created
      */
     public Element getElement(String name) {
-        Element e = (Element)elementHash.get(name);
+        Element e = elementHash.get(name);
         if (e == null) {
             e = new Element(name, elements.size());
             elements.addElement(e);
@@ -154,7 +154,7 @@
      *   <code>index</code>
      */
     public Element getElement(int index) {
-        return (Element)elements.elementAt(index);
+        return elements.elementAt(index);
     }
 
     /**
@@ -170,7 +170,7 @@
      *   if not found
      */
     public Entity defineEntity(String name, int type, char data[]) {
-        Entity ent = (Entity)entityHash.get(name);
+        Entity ent = entityHash.get(name);
         if (ent == null) {
             ent = new Entity(name, type, data);
             entityHash.put(name, ent);
@@ -259,8 +259,7 @@
         BitSet excl = null;
         if (exclusions != null && exclusions.length > 0) {
             excl = new BitSet();
-            for (int i = 0; i < exclusions.length; i++) {
-                String str = exclusions[i];
+            for (String str : exclusions) {
                 if (str.length() > 0) {
                     excl.set(getElement(str).getIndex());
                 }
@@ -269,8 +268,7 @@
         BitSet incl = null;
         if (inclusions != null && inclusions.length > 0) {
             incl = new BitSet();
-            for (int i = 0; i < inclusions.length; i++) {
-                String str = inclusions[i];
+            for (String str : inclusions) {
                 if (str.length() > 0) {
                     incl.set(getElement(str).getIndex());
                 }
@@ -285,9 +283,9 @@
      * @return the new <code>AttributeList</code>
      */
     protected AttributeList defAttributeList(String name, int type, int modifier, String value, String values, AttributeList atts) {
-        Vector vals = null;
+        Vector<String> vals = null;
         if (values != null) {
-            vals = new Vector();
+            vals = new Vector<String>();
             for (StringTokenizer s = new StringTokenizer(values, "|") ; s.hasMoreTokens() ;) {
                 String str = s.nextToken();
                 if (str.length() > 0) {
@@ -318,7 +316,7 @@
     /**
      * The hashtable of DTDs.
      */
-    static Hashtable dtdHash = new Hashtable();
+    static Hashtable<String, DTD> dtdHash = new Hashtable<String, DTD>();
 
   public static void putDTDHash(String name, DTD dtd) {
     dtdHash.put(name, dtd);
@@ -334,7 +332,7 @@
      */
     public static DTD getDTD(String name) throws IOException {
         name = name.toLowerCase();
-        DTD dtd = (DTD)dtdHash.get(name);
+        DTD dtd = dtdHash.get(name);
         if (dtd == null)
           dtd = new DTD(name);
 
@@ -432,10 +430,10 @@
             int modifier = in.readByte();
             short valueId = in.readShort();
             String value = (valueId == -1) ? null : names[valueId];
-            Vector values = null;
+            Vector<String> values = null;
             short numValues = in.readShort();
             if (numValues > 0) {
-                values = new Vector(numValues);
+                values = new Vector<String>(numValues);
                 for (int i = 0; i < numValues; i++) {
                     values.addElement(names[in.readShort()]);
                 }
--- a/src/share/classes/javax/swing/text/html/parser/Element.java	Thu Jul 24 14:51:13 2008 +0400
+++ b/src/share/classes/javax/swing/text/html/parser/Element.java	Thu Jul 24 16:43:36 2008 +0400
@@ -159,7 +159,7 @@
     }
 
 
-    static Hashtable contentTypes = new Hashtable();
+    static Hashtable<String, Integer> contentTypes = new Hashtable<String, Integer>();
 
     static {
         contentTypes.put("CDATA", Integer.valueOf(CDATA));
@@ -169,7 +169,7 @@
     }
 
     public static int name2type(String nm) {
-        Integer val = (Integer)contentTypes.get(nm);
+        Integer val = contentTypes.get(nm);
         return (val != null) ? val.intValue() : 0;
     }
 }
--- a/src/share/classes/javax/swing/text/html/parser/Entity.java	Thu Jul 24 14:51:13 2008 +0400
+++ b/src/share/classes/javax/swing/text/html/parser/Entity.java	Thu Jul 24 16:43:36 2008 +0400
@@ -107,7 +107,7 @@
     }
 
 
-    static Hashtable entityTypes = new Hashtable();
+    static Hashtable<String, Integer> entityTypes = new Hashtable<String, Integer>();
 
     static {
         entityTypes.put("PUBLIC", Integer.valueOf(PUBLIC));
@@ -133,7 +133,7 @@
      *   to "CDATA", if none exists
      */
     public static int name2type(String nm) {
-        Integer i = (Integer)entityTypes.get(nm);
+        Integer i = entityTypes.get(nm);
         return (i == null) ? CDATA : i.intValue();
     }
 }
--- a/src/share/classes/javax/swing/text/html/parser/Parser.java	Thu Jul 24 14:51:13 2008 +0400
+++ b/src/share/classes/javax/swing/text/html/parser/Parser.java	Thu Jul 24 16:43:36 2008 +0400
@@ -649,12 +649,10 @@
 
         if (!strict) {
             ContentModel content = stack.contentModel();
-            Vector elemVec = new Vector();
+            Vector<Element> elemVec = new Vector<Element>();
             if (content != null) {
                 content.getElements(elemVec);
-                for (Enumeration v = elemVec.elements(); v.hasMoreElements();) {
-                    Element e = (Element)v.nextElement();
-
+                for (Element e : elemVec) {
                     // Ensure that this element has not been included as
                     // part of the exclusions in the DTD.
                     //
@@ -1349,9 +1347,9 @@
                 continue;
             }
 
-            AttributeList att = null;
-            String attname = null;
-            String attvalue = null;
+            AttributeList att;
+            String attname;
+            String attvalue;
 
             if (parseIdentifier(true)) {
                 attname = getString(0);
@@ -1549,7 +1547,7 @@
      * Parse a start or end tag.
      */
     void parseTag() throws IOException {
-        Element elem = null;
+        Element elem;
         boolean net = false;
         boolean warned = false;
         boolean unknown = false;
--- a/src/share/classes/javax/swing/text/html/parser/TagStack.java	Thu Jul 24 14:51:13 2008 +0400
+++ b/src/share/classes/javax/swing/text/html/parser/TagStack.java	Thu Jul 24 16:43:36 2008 +0400
@@ -124,22 +124,6 @@
         return (exclusions != null) && exclusions.get(elem.getIndex());
     }
 
-    /**
-     * Update the Vector elemVec with all the elements that
-     * are part of the inclusions listed in DTD for the element
-     * currently on the TagStack.
-     */
-    boolean included(Vector elemVec, DTD dtd) {
-
-        for (int i = 0 ; i < inclusions.size(); i++) {
-            if (inclusions.get(i)) {
-                elemVec.addElement(dtd.getElement(i));
-                System.out.println("Element add thru' inclusions: " + dtd.getElement(i).getName());
-            }
-        }
-        return (!elemVec.isEmpty());
-    }
-
 
     /**
      * Advance the state by reducing the given element.
--- a/src/share/classes/javax/swing/text/rtf/MockAttributeSet.java	Thu Jul 24 14:51:13 2008 +0400
+++ b/src/share/classes/javax/swing/text/rtf/MockAttributeSet.java	Thu Jul 24 16:43:36 2008 +0400
@@ -35,7 +35,7 @@
 class MockAttributeSet
     implements AttributeSet, MutableAttributeSet
 {
-    public Dictionary backing;
+    public Dictionary<Object, Object> backing;
 
     public boolean isEmpty()
     {
--- a/src/share/classes/javax/swing/text/rtf/RTFAttributes.java	Thu Jul 24 14:51:13 2008 +0400
+++ b/src/share/classes/javax/swing/text/rtf/RTFAttributes.java	Thu Jul 24 16:43:36 2008 +0400
@@ -36,7 +36,7 @@
     static RTFAttribute attributes[];
 
     static {
-        Vector a = new Vector();
+        Vector<RTFAttribute> a = new Vector<RTFAttribute>();
         int CHR = RTFAttribute.D_CHARACTER;
         int PGF = RTFAttribute.D_PARAGRAPH;
         int SEC = RTFAttribute.D_SECTION;
@@ -131,14 +131,13 @@
         attributes = attrs;
     }
 
-    static Dictionary attributesByKeyword()
+    static Dictionary<String, RTFAttribute> attributesByKeyword()
     {
-        Dictionary d = new Hashtable(attributes.length);
-        int i, m;
+        Dictionary<String, RTFAttribute> d = new Hashtable<String, RTFAttribute>(attributes.length);
 
-        m = attributes.length;
-        for(i = 0; i < m; i++)
-            d.put(attributes[i].rtfName(), attributes[i]);
+        for (RTFAttribute attribute : attributes) {
+            d.put(attribute.rtfName(), attribute);
+        }
 
         return d;
     }
--- a/src/share/classes/javax/swing/text/rtf/RTFGenerator.java	Thu Jul 24 14:51:13 2008 +0400
+++ b/src/share/classes/javax/swing/text/rtf/RTFGenerator.java	Thu Jul 24 16:43:36 2008 +0400
@@ -52,11 +52,11 @@
 {
     /* These dictionaries map Colors, font names, or Style objects
        to Integers */
-    Dictionary colorTable;
+    Dictionary<Object, Integer> colorTable;
     int colorCount;
-    Dictionary fontTable;
+    Dictionary<String, Integer> fontTable;
     int fontCount;
-    Dictionary styleTable;
+    Dictionary<AttributeSet, Integer> styleTable;
     int styleCount;
 
     /* where all the text is going */
@@ -90,7 +90,7 @@
        would require allocating an object for every character
        written (slow!). */
     static class CharacterKeywordPair
-      { public char character; public String keyword; };
+      { public char character; public String keyword; }
     static protected CharacterKeywordPair[] textKeywords;
 
     static {
@@ -98,7 +98,7 @@
 
         Dictionary textKeywordDictionary = RTFReader.textKeywords;
         Enumeration keys = textKeywordDictionary.keys();
-        Vector tempPairs = new Vector();
+        Vector<CharacterKeywordPair> tempPairs = new Vector<CharacterKeywordPair>();
         while(keys.hasMoreElements()) {
             CharacterKeywordPair pair = new CharacterKeywordPair();
             pair.keyword = (String)keys.nextElement();
@@ -133,14 +133,14 @@
 
 public RTFGenerator(OutputStream to)
 {
-    colorTable = new Hashtable();
+    colorTable = new Hashtable<Object, Integer>();
     colorTable.put(defaultRTFColor, Integer.valueOf(0));
     colorCount = 1;
 
-    fontTable = new Hashtable();
+    fontTable = new Hashtable<String, Integer>();
     fontCount = 0;
 
-    styleTable = new Hashtable();
+    styleTable = new Hashtable<AttributeSet, Integer>();
     /* TODO: put default style in style table */
     styleCount = 0;
 
@@ -197,7 +197,7 @@
 private void tallyStyles(AttributeSet a) {
     while (a != null) {
         if (a instanceof Style) {
-            Integer aNum = (Integer)styleTable.get(a);
+            Integer aNum = styleTable.get(a);
             if (aNum == null) {
                 styleCount = styleCount + 1;
                 aNum = new Integer(styleCount);
@@ -225,7 +225,7 @@
 {
     while(a != null) {
         if (a instanceof Style) {
-            Integer aNum = (Integer)styleTable.get(a);
+            Integer aNum = styleTable.get(a);
             if (aNum != null) {
                 if (domain == null ||
                     domain.equals(a.getAttribute(Constants.StyleType)))
@@ -319,11 +319,11 @@
 
     /* write font table */
     String[] sortedFontTable = new String[fontCount];
-    Enumeration fonts = fontTable.keys();
+    Enumeration<String> fonts = fontTable.keys();
     String font;
     while(fonts.hasMoreElements()) {
-        font = (String)fonts.nextElement();
-        Integer num = (Integer)(fontTable.get(font));
+        font = fonts.nextElement();
+        Integer num = fontTable.get(font);
         sortedFontTable[num.intValue()] = font;
     }
     writeBegingroup();
@@ -344,7 +344,7 @@
         Color color;
         while(colors.hasMoreElements()) {
             color = (Color)colors.nextElement();
-            Integer num = (Integer)(colorTable.get(color));
+            Integer num = colorTable.get(color);
             sortedColorTable[num.intValue()] = color;
         }
         writeBegingroup();
@@ -366,10 +366,10 @@
     if (styleCount > 1) {
         writeBegingroup();
         writeControlWord("stylesheet");
-        Enumeration styles = styleTable.keys();
+        Enumeration<AttributeSet> styles = styleTable.keys();
         while(styles.hasMoreElements()) {
             Style style = (Style)styles.nextElement();
-            int styleNumber = ((Integer)styleTable.get(style)).intValue();
+            int styleNumber = styleTable.get(style).intValue();
             writeBegingroup();
             String styleType = (String)style.getAttribute(Constants.StyleType);
             if (styleType == null)
@@ -398,7 +398,7 @@
 
             basis = style.getResolveParent();
             if (basis != null && basis instanceof Style) {
-                Integer basedOn = (Integer)styleTable.get(basis);
+                Integer basedOn = styleTable.get(basis);
                 if (basedOn != null) {
                     writeControlWord("sbasedon", basedOn.intValue());
                 }
@@ -406,7 +406,7 @@
 
             Style nextStyle = (Style)style.getAttribute(Constants.StyleNext);
             if (nextStyle != null) {
-                Integer nextNum = (Integer)styleTable.get(nextStyle);
+                Integer nextNum = styleTable.get(nextStyle);
                 if (nextNum != null) {
                     writeControlWord("snext", nextNum.intValue());
                 }
@@ -725,7 +725,7 @@
 
     if ((parm = attrDiff(current, newAttributes,
                          StyleConstants.FontFamily, null)) != null) {
-        Number fontNum = (Number)fontTable.get(parm);
+        Integer fontNum = fontTable.get(parm);
         writeControlWord("f", fontNum.intValue());
     }
 
@@ -746,7 +746,7 @@
         if (parm == MagicToken)
             colorNum = 0;
         else
-            colorNum = ((Number)colorTable.get(parm)).intValue();
+            colorNum = colorTable.get(parm).intValue();
         writeControlWord("cb", colorNum);
     }
 
@@ -756,7 +756,7 @@
         if (parm == MagicToken)
             colorNum = 0;
         else
-            colorNum = ((Number)colorTable.get(parm)).intValue();
+            colorNum = colorTable.get(parm).intValue();
         writeControlWord("cf", colorNum);
     }
 }
--- a/src/share/classes/javax/swing/text/rtf/RTFParser.java	Thu Jul 24 14:51:13 2008 +0400
+++ b/src/share/classes/javax/swing/text/rtf/RTFParser.java	Thu Jul 24 16:43:36 2008 +0400
@@ -92,7 +92,7 @@
   // table of non-text characters in rtf
   static final boolean rtfSpecialsTable[];
   static {
-    rtfSpecialsTable = (boolean[])noSpecialsTable.clone();
+    rtfSpecialsTable = noSpecialsTable.clone();
     rtfSpecialsTable['\n'] = true;
     rtfSpecialsTable['\r'] = true;
     rtfSpecialsTable['{'] = true;
--- a/src/share/classes/javax/swing/text/rtf/RTFReader.java	Thu Jul 24 14:51:13 2008 +0400
+++ b/src/share/classes/javax/swing/text/rtf/RTFReader.java	Thu Jul 24 16:43:36 2008 +0400
@@ -54,7 +54,7 @@
   /** Miscellaneous information about the parser's state. This
    *  dictionary is saved and restored when an RTF group begins
    *  or ends. */
-  Dictionary parserState;   /* Current parser state */
+  Dictionary<Object, Object> parserState;   /* Current parser state */
   /** This is the "dst" item from parserState. rtfDestination
    *  is the current rtf destination. It is cached in an instance
    *  variable for speed. */
@@ -63,7 +63,7 @@
   MutableAttributeSet documentAttributes;
 
   /** This Dictionary maps Integer font numbers to String font names. */
-  Dictionary fontTable;
+  Dictionary<Integer, String> fontTable;
   /** This array maps color indices to Color objects. */
   Color[] colorTable;
   /** This array maps character style numbers to Style objects. */
@@ -86,7 +86,7 @@
    *  Unicode character. */
   int skippingCharacters;
 
-  static private Dictionary straightforwardAttributes;
+  static private Dictionary<String, RTFAttribute> straightforwardAttributes;
   static {
       straightforwardAttributes = RTFAttributes.attributesByKeyword();
   }
@@ -96,9 +96,9 @@
   /* this should be final, but there's a bug in javac... */
   /** textKeywords maps RTF keywords to single-character strings,
    *  for those keywords which simply insert some text. */
-  static Dictionary textKeywords = null;
+  static Dictionary<String, String> textKeywords = null;
   static {
-      textKeywords = new Hashtable();
+      textKeywords = new Hashtable<String, String>();
       textKeywords.put("\\",         "\\");
       textKeywords.put("{",          "{");
       textKeywords.put("}",          "}");
@@ -129,10 +129,10 @@
   static final String TabAlignmentKey = "tab_alignment";
   static final String TabLeaderKey = "tab_leader";
 
-  static Dictionary characterSets;
+  static Dictionary<String, char[]> characterSets;
   static boolean useNeXTForAnsi = false;
   static {
-      characterSets = new Hashtable();
+      characterSets = new Hashtable<String, char[]>();
   }
 
 /* TODO: per-font font encodings ( \fcharset control word ) ? */
@@ -148,8 +148,8 @@
     int i;
 
     target = destination;
-    parserState = new Hashtable();
-    fontTable = new Hashtable();
+    parserState = new Hashtable<Object, Object>();
+    fontTable = new Hashtable<Integer, String>();
 
     rtfversion = -1;
 
@@ -220,7 +220,7 @@
     Object oldSaveState = parserState.get("_savedState");
     if (oldSaveState != null)
         parserState.remove("_savedState");
-    Dictionary saveState = (Dictionary)((Hashtable)parserState).clone();
+    Dictionary<String, Object> saveState = (Dictionary<String, Object>)((Hashtable)parserState).clone();
     if (oldSaveState != null)
         saveState.put("_savedState", oldSaveState);
     parserState.put("_savedState", saveState);
@@ -242,7 +242,7 @@
         skippingCharacters = 0;
     }
 
-    Dictionary restoredState = (Dictionary)parserState.get("_savedState");
+    Dictionary<Object, Object> restoredState = (Dictionary<Object, Object>)parserState.get("_savedState");
     Destination restoredDestination = (Destination)restoredState.get("dst");
     if (restoredDestination != rtfDestination) {
         rtfDestination.close(); /* allow the destination to clean up */
@@ -281,7 +281,7 @@
     while(docProps.hasMoreElements()) {
         Object propName = docProps.nextElement();
         target.putProperty(propName,
-                           documentAttributes.getAttribute((String)propName));
+                           documentAttributes.getAttribute(propName));
     }
 
     /* RTFParser should have ensured that all our groups are closed */
@@ -301,7 +301,7 @@
  */
 public boolean handleKeyword(String keyword)
 {
-    Object item;
+    String item;
     boolean ignoreGroupIfUnknownKeywordSave = ignoreGroupIfUnknownKeyword;
 
     if (skippingCharacters > 0) {
@@ -312,7 +312,7 @@
     ignoreGroupIfUnknownKeyword = false;
 
     if ((item = textKeywords.get(keyword)) != null) {
-        handleText((String)item);
+        handleText(item);
         return true;
     }
 
@@ -556,14 +556,12 @@
 getCharacterSet(final String name)
     throws IOException
 {
-    char[] set;
-
-    set = (char [])characterSets.get(name);
+    char[] set = characterSets.get(name);
     if (set == null) {
       InputStream charsetStream;
-      charsetStream = (InputStream)java.security.AccessController.
-                      doPrivileged(new java.security.PrivilegedAction() {
-          public Object run() {
+      charsetStream = java.security.AccessController.
+              doPrivileged(new java.security.PrivilegedAction<InputStream>() {
+          public InputStream run() {
               return RTFReader.class.getResourceAsStream
                                      ("charsets/" + name + ".txt");
           }
@@ -686,7 +684,7 @@
 class FonttblDestination implements Destination
 {
     int nextFontNumber;
-    Object fontNumberKey = null;
+    Integer fontNumberKey = null;
     String nextFontFamily;
 
     public void handleBinaryBlob(byte[] data)
@@ -716,7 +714,6 @@
 
         nextFontNumber = -1;
         nextFontFamily = null;
-        return;
     }
 
     public boolean handleKeyword(String keyword)
@@ -747,10 +744,10 @@
        dump its contents to the debugging log. */
     public void close()
     {
-        Enumeration nums = fontTable.keys();
+        Enumeration<Integer> nums = fontTable.keys();
         warning("Done reading font table.");
         while(nums.hasMoreElements()) {
-            Integer num = (Integer)nums.nextElement();
+            Integer num = nums.nextElement();
             warning("Number " + num + ": " + fontTable.get(num));
         }
     }
@@ -761,19 +758,19 @@
 class ColortblDestination implements Destination
 {
     int red, green, blue;
-    Vector proTemTable;
+    Vector<Color> proTemTable;
 
     public ColortblDestination()
     {
         red = 0;
         green = 0;
         blue = 0;
-        proTemTable = new Vector();
+        proTemTable = new Vector<Color>();
     }
 
     public void handleText(String text)
     {
-        int index = 0;
+        int index;
 
         for (index = 0; index < text.length(); index ++) {
             if (text.charAt(index) == ';') {
@@ -823,11 +820,11 @@
     extends DiscardingDestination
     implements Destination
 {
-    Dictionary definedStyles;
+    Dictionary<Integer, StyleDefiningDestination> definedStyles;
 
     public StylesheetDestination()
     {
-        definedStyles = new Hashtable();
+        definedStyles = new Hashtable<Integer, StyleDefiningDestination>();
     }
 
     public void begingroup()
@@ -837,19 +834,18 @@
 
     public void close()
     {
-        Vector chrStyles, pgfStyles, secStyles;
-        chrStyles = new Vector();
-        pgfStyles = new Vector();
-        secStyles = new Vector();
-        Enumeration styles = definedStyles.elements();
+        Vector<Style> chrStyles = new Vector<Style>();
+        Vector<Style> pgfStyles = new Vector<Style>();
+        Vector<Style> secStyles = new Vector<Style>();
+        Enumeration<StyleDefiningDestination> styles = definedStyles.elements();
         while(styles.hasMoreElements()) {
             StyleDefiningDestination style;
             Style defined;
-            style = (StyleDefiningDestination)styles.nextElement();
+            style = styles.nextElement();
             defined = style.realize();
             warning("Style "+style.number+" ("+style.styleName+"): "+defined);
             String stype = (String)defined.getAttribute(Constants.StyleType);
-            Vector toSet;
+            Vector<Style> toSet;
             if (stype.equals(Constants.STSection)) {
                 toSet = secStyles;
             } else if (stype.equals(Constants.STCharacter)) {
@@ -989,7 +985,7 @@
 
             if (basedOn != STYLENUMBER_NONE) {
                 StyleDefiningDestination styleDest;
-                styleDest = (StyleDefiningDestination)definedStyles.get(Integer.valueOf(basedOn));
+                styleDest = definedStyles.get(Integer.valueOf(basedOn));
                 if (styleDest != null && styleDest != this) {
                     basis = styleDest.realize();
                 }
@@ -1016,7 +1012,7 @@
 
             if (nextStyle != STYLENUMBER_NONE) {
                 StyleDefiningDestination styleDest;
-                styleDest = (StyleDefiningDestination)definedStyles.get(Integer.valueOf(nextStyle));
+                styleDest = definedStyles.get(Integer.valueOf(nextStyle));
                 if (styleDest != null) {
                     next = styleDest.realize();
                 }
@@ -1122,9 +1118,8 @@
         }
 
         {
-            Object item = straightforwardAttributes.get(keyword);
-            if (item != null) {
-                RTFAttribute attr = (RTFAttribute)item;
+            RTFAttribute attr = straightforwardAttributes.get(keyword);
+            if (attr != null) {
                 boolean ok;
 
                 switch(attr.domain()) {
@@ -1191,9 +1186,8 @@
         }
 
         {
-            Object item = straightforwardAttributes.get(keyword);
-            if (item != null) {
-                RTFAttribute attr = (RTFAttribute)item;
+            RTFAttribute attr = straightforwardAttributes.get(keyword);
+            if (attr != null) {
                 boolean ok;
 
                 switch(attr.domain()) {
@@ -1267,12 +1261,12 @@
             parserState.remove("tab_leader");
 
             TabStop newStop = new TabStop(tabPosition, tabAlignment, tabLeader);
-            Dictionary tabs;
+            Dictionary<Object, Object> tabs;
             Integer stopCount;
 
-            tabs = (Dictionary)parserState.get("_tabs");
+            tabs = (Dictionary<Object, Object>)parserState.get("_tabs");
             if (tabs == null) {
-                tabs = new Hashtable();
+                tabs = new Hashtable<Object, Object>();
                 parserState.put("_tabs", tabs);
                 stopCount = Integer.valueOf(1);
             } else {
@@ -1369,7 +1363,7 @@
         /* note setFontFamily() can not handle a null font */
         String fontFamily;
         if (fontnum != null)
-            fontFamily = (String)fontTable.get(fontnum);
+            fontFamily = fontTable.get(fontnum);
         else
             fontFamily = null;
         if (fontFamily != null)
@@ -1474,9 +1468,9 @@
 
         handleKeyword("fs", 24);  /* 12 pt. */
 
-        Enumeration attributes = straightforwardAttributes.elements();
+        Enumeration<RTFAttribute> attributes = straightforwardAttributes.elements();
         while(attributes.hasMoreElements()) {
-            RTFAttribute attr = (RTFAttribute)attributes.nextElement();
+            RTFAttribute attr = attributes.nextElement();
             if (attr.domain() == RTFAttribute.D_CHARACTER)
                 attr.setDefault(characterAttributes);
         }
@@ -1498,9 +1492,9 @@
         StyleConstants.setAlignment(paragraphAttributes,
                                     StyleConstants.ALIGN_LEFT);
 
-        Enumeration attributes = straightforwardAttributes.elements();
+        Enumeration<RTFAttribute> attributes = straightforwardAttributes.elements();
         while(attributes.hasMoreElements()) {
-            RTFAttribute attr = (RTFAttribute)attributes.nextElement();
+            RTFAttribute attr = attributes.nextElement();
             if (attr.domain() == RTFAttribute.D_PARAGRAPH)
                 attr.setDefault(characterAttributes);
         }
@@ -1511,9 +1505,9 @@
      *  \sectd keyword. */
     protected void resetSectionAttributes()
     {
-        Enumeration attributes = straightforwardAttributes.elements();
+        Enumeration<RTFAttribute> attributes = straightforwardAttributes.elements();
         while(attributes.hasMoreElements()) {
-            RTFAttribute attr = (RTFAttribute)attributes.nextElement();
+            RTFAttribute attr = attributes.nextElement();
             if (attr.domain() == RTFAttribute.D_SECTION)
                 attr.setDefault(characterAttributes);
         }