-
CSR
-
Resolution: Approved
-
P4
-
source
-
minimal
-
Java API
-
SE
Summary
Generify portions of the javax.swing.text
package.
Problem
Various methods in javax.swing.text.* use raw types; they should be updated to use generics.
Solution
Generify the types, subject to the usual JDK evolution policies.
Specification
--- old/src/share/classes/javax/swing/text/AbstractDocument.java 2014-06-10 11:51:28.000000000 -0700
+++ new/src/share/classes/javax/swing/text/AbstractDocument.java 2014-06-10 11:51:28.000000000 -0700
@@ -2193,7 +2193,7 @@
* <code>Enumeration</code>.
* @return the children of the receiver as an <code>Enumeration</code>
*/
- public abstract Enumeration children();
+ public abstract Enumeration<?> children();
// --- serialization ---------------------------------------------
@@ -2456,7 +2456,7 @@
* <code>Enumeration</code>.
* @return the children of the receiver
*/
- public Enumeration children() {
+ public Enumeration<AbstractElement> children() {
if(nchildren == 0)
return null;
@@ -2610,7 +2610,7 @@
* <code>Enumeration</code>.
* @return the children of the receiver
*/
- public Enumeration children() {
+ public Enumeration<?> children() {
return null;
}
--- old/src/share/classes/javax/swing/text/DateFormatter.java 2014-06-10 11:51:29.000000000 -0700
+++ new/src/share/classes/javax/swing/text/DateFormatter.java 2014-06-10 11:51:29.000000000 -0700
@@ -108,8 +108,8 @@
/**
* Returns the field that will be adjusted by adjustValue.
*/
- Object getAdjustField(int start, Map attributes) {
- Iterator attrs = attributes.keySet().iterator();
+ Object getAdjustField(int start, Map<?, ?> attributes) {
+ Iterator<?> attrs = attributes.keySet().iterator();
while (attrs.hasNext()) {
Object key = attrs.next();
@@ -127,7 +127,7 @@
* Adjusts the Date if FieldPosition identifies a known calendar
* field.
*/
- Object adjustValue(Object value, Map attributes, Object key,
+ Object adjustValue(Object value, Map<?, ?> attributes, Object key,
int direction) throws
BadLocationException, ParseException {
if (key != null) {
--- old/src/share/classes/javax/swing/text/GapContent.java 2014-06-10 11:51:31.000000000 -0700
+++ new/src/share/classes/javax/swing/text/GapContent.java 2014-06-10 11:51:31.000000000 -0700
@@ -710,7 +710,8 @@
* @param length the length >= 0
* @return the set of instances
*/
- protected Vector getPositionsInRange(Vector v, int offset, int length) {
+ protected Vector<UndoPosRef> getPositionsInRange(Vector<UndoPosRef> v,
+ int offset, int length) {
int endOffset = offset + length;
int startIndex;
int endIndex;
@@ -738,8 +739,9 @@
endIndex = findMarkAdjustIndex(endOffset + (g1 - g0) + 1);
}
- Vector placeIn = (v == null) ? new Vector(Math.max(1, endIndex -
- startIndex)) : v;
+ Vector<UndoPosRef> placeIn = (v == null) ?
+ new Vector<>(Math.max(1, endIndex - startIndex)) :
+ v;
for (int counter = startIndex; counter < endIndex; counter++) {
placeIn.addElement(new UndoPosRef(marks.elementAt(counter)));
@@ -756,7 +758,7 @@
*
* @param positions the UndoPosRef instances to reset
*/
- protected void updateUndoPositions(Vector positions, int offset,
+ protected void updateUndoPositions(Vector<UndoPosRef> positions, int offset,
int length) {
// Find the indexs of the end points.
int endOffset = offset + length;
@@ -900,7 +902,7 @@
protected String string;
/** An array of instances of UndoPosRef for the Positions in the
* range that was removed, valid after undo. */
- protected Vector posRefs;
+ protected Vector<UndoPosRef> posRefs;
} // GapContent.InsertUndo
@@ -952,6 +954,6 @@
protected String string;
/** An array of instances of UndoPosRef for the Positions in the
* range that was removed, valid before undo. */
- protected Vector posRefs;
+ protected Vector<UndoPosRef> posRefs;
} // GapContent.RemoveUndo
}
--- old/src/share/classes/javax/swing/text/InternationalFormatter.java 2014-06-10 11:51:32.000000000 -0700
+++ new/src/share/classes/javax/swing/text/InternationalFormatter.java 2014-06-10 11:51:32.000000000 -0700
@@ -211,7 +211,7 @@
* @param minimum Minimum legal value that can be input
* @see #setValueClass
*/
- public void setMinimum(Comparable minimum) {
+ public void setMinimum(Comparable<?> minimum) {
if (getValueClass() == null && minimum != null) {
setValueClass(minimum.getClass());
}
@@ -223,7 +223,7 @@
*
* @return Minimum legal value that can be input
*/
- public Comparable getMinimum() {
+ public Comparable<?> getMinimum() {
return min;
}
@@ -236,7 +236,7 @@
* @param max Maximum legal value that can be input
* @see #setValueClass
*/
- public void setMaximum(Comparable max) {
+ public void setMaximum(Comparable<?> max) {
if (getValueClass() == null && max != null) {
setValueClass(max.getClass());
}
@@ -248,7 +248,7 @@
*
* @return Maximum legal value that can be input
*/
- public Comparable getMaximum() {
+ public Comparable<?> getMaximum() {
return max;
}
@@ -411,7 +411,8 @@
* false is returned.
*/
@@ -858,7 +860,7 @@
/**
* Returns the field that will be adjusted by adjustValue.
*/
- Object getAdjustField(int start, Map attributes) {
+ Object getAdjustField(int start, Map<?, ?> attributes) {
return null;
}
@@ -900,7 +902,7 @@
* null depending upon <code>canIncrement</code>) and
* <code>direction</code> is the amount to increment by.
*/
- Object adjustValue(Object value, Map attributes, Object field,
+ Object adjustValue(Object value, Map<?, ?> attributes, Object field,
int direction) throws
BadLocationException, ParseException {
return null;
--- old/src/share/classes/javax/swing/text/SimpleAttributeSet.java 2014-06-10 11:51:34.000000000 -0700
+++ new/src/share/classes/javax/swing/text/SimpleAttributeSet.java 2014-06-10 11:51:34.000000000 -0700
@@ -364,7 +365,7 @@
public Object getAttribute(Object key) {
return null;
}
- public Enumeration getAttributeNames() {
+ public Enumeration<?> getAttributeNames() {
return Collections.emptyEnumeration();
}
public boolean containsAttribute(Object name, Object value) {
--- old/src/share/classes/javax/swing/text/StringContent.java 2014-06-10 11:51:34.000000000 -0700
+++ new/src/share/classes/javax/swing/text/StringContent.java 2014-06-10 11:51:34.000000000 -0700
@@ -271,11 +271,11 @@
* @param length the length >= 0
* @return the set of instances
*/
- protected Vector getPositionsInRange(Vector v, int offset,
+ protected Vector<UndoPosRef> getPositionsInRange(Vector<UndoPosRef> v, int offset,
int length) {
int n = marks.size();
int end = offset + length;
@@ -298,9 +298,9 @@
*
* @param positions the positions of the instances
*/
- protected void updateUndoPositions(Vector positions) {
+ protected void updateUndoPositions(Vector<UndoPosRef> positions) {
for(int counter = positions.size() - 1; counter >= 0; counter--) {
@@ -437,7 +437,7 @@
protected String string;
// An array of instances of UndoPosRef for the Positions in the
// range that was removed, valid after undo.
- protected Vector posRefs;
+ protected Vector<UndoPosRef> posRefs;
}
@@ -494,6 +494,6 @@
protected String string;
// An array of instances of UndoPosRef for the Positions in the
// range that was removed, valid before undo.
- protected Vector posRefs;
+ protected Vector<UndoPosRef> posRefs;
}
}
--- old/src/share/classes/javax/swing/text/StyleContext.java 2014-06-10 11:51:35.000000000 -0700
+++ new/src/share/classes/javax/swing/text/StyleContext.java 2014-06-10 11:51:35.000000000 -0700
@@ -1142,7 +1142,7 @@
/**
* Removes the set of keys from the set.
*/
- public void removeAttributes(Enumeration names) {
+ public void removeAttributes(Enumeration<?> names) {
while (names.hasMoreElements()) {
Object name = names.nextElement();
removeAttribute(name);
@@ -1153,7 +1153,7 @@
* Removes the set of matching attributes from the set.
*/
public void removeAttributes(AttributeSet attr) {
- Enumeration names = attr.getAttributeNames();
+ Enumeration<?> names = attr.getAttributeNames();
while (names.hasMoreElements()) {
Object name = names.nextElement();
Object value = attr.getAttribute(name);
--- old/src/share/classes/javax/swing/text/html/MuxingAttributeSet.java 2014-06-10 11:51:40.000000000 -0700
+++ new/src/share/classes/javax/swing/text/html/MuxingAttributeSet.java 2014-06-10 11:51:40.000000000 -0700
@@ -213,7 +213,7 @@
* @return the attribute names
* @see AttributeSet#getAttributeNames
*/
- public Enumeration getAttributeNames() {
+ public Enumeration<?> getAttributeNames() {
return new MuxingAttributeNameEnumeration();
}
--- old/src/share/classes/javax/swing/text/rtf/RTFReader.java 2014-06-10 11:51:43.000000000 -0700
+++ new/src/share/classes/javax/swing/text/rtf/RTFReader.java 2014-06-10 11:51:43.000000000 -0700
@@ -628,7 +631,7 @@
boolean handleKeyword(String keyword, int parameter);
void begingroup();
- void endgroup(Dictionary oldState);
+ void endgroup(Dictionary<Object, Object> oldState);
void close();
}
@@ -666,7 +669,7 @@
current group level as necessary */
}
- public void endgroup(Dictionary oldState)
+ public void endgroup(Dictionary<Object, Object> oldState)
{
/* Ignore groups */
}
@@ -736,7 +739,7 @@
/* Groups are irrelevant. */
public void begingroup() {}
- public void endgroup(Dictionary oldState) {}
+ public void endgroup(Dictionary<Object, Object> oldState) {}
/* currently, the only thing we do when the font table ends is
dump its contents to the debugging log. */
@@ -806,7 +809,7 @@
/* Groups are irrelevant. */
public void begingroup() {}
- public void endgroup(Dictionary oldState) {}
+ public void endgroup(Dictionary<Object, Object> oldState) {}
/* Shouldn't see any binary blobs ... */
public void handleBinaryBlob(byte[] data) {}
@@ -1098,7 +1101,7 @@
parserState.put("sec", sectionAttributes);
}
- public void endgroup(Dictionary oldState)
+ public void endgroup(Dictionary<Object, Object> oldState)
{
characterAttributes = (MutableAttributeSet)parserState.get("chr");
paragraphAttributes = (MutableAttributeSet)parserState.get("pgf
- csr for
-
JDK-8043549 Fix raw and unchecked lint warnings in javax.swing.text.*
- Resolved
- relates to
-
CCC-8055059 JDK9b22 public API exposes package private classes
- Closed