-
CSR
-
Resolution: Approved
-
P2
-
source
-
minimal
-
Restoring previous raw type usage in a few caues.
-
Java API
-
SE
Summary
Revert to using raw types in some parts of javax.swing.text
to avoid exposing package-private types.
Problem
The generification of swing exposed some package-private types as the bounds of type variables on non-private methods. Such types should not be exposed.
Solution
After due consideration of the alternatives, revert to using raw types for the parameters and return types in question.
Specification
--- old/src/java.desktop/share/classes/javax/swing/text/GapContent.java 2015-01-09 14:48:54.394781325 -0800
+++ new/src/java.desktop/share/classes/javax/swing/text/GapContent.java 2015-01-09 14:48:54.122781325 -0800
@@ -710,8 +710,9 @@
* @param length the length >= 0
* @return the set of instances
*/
- protected Vector<UndoPosRef> getPositionsInRange(Vector<UndoPosRef> v,
- int offset, int length) {
+ @SuppressWarnings({"rawtypes", "unchecked"}) // UndoPosRef type cannot be exposed
+ protected Vector getPositionsInRange(Vector v,
+ int offset, int length) {
int endOffset = offset + length;
int startIndex;
int endIndex;
@@ -758,7 +759,8 @@
*
* @param positions the UndoPosRef instances to reset
*/
- protected void updateUndoPositions(Vector<UndoPosRef> positions, int offset,
+ @SuppressWarnings("rawtypes") // UndoPosRef type cannot be exposed
+ protected void updateUndoPositions(Vector positions, int offset,
int length) {
// Find the indexs of the end points.
int endOffset = offset + length;
@@ -775,7 +777,7 @@
// Reset the location of the refenences.
for(int counter = positions.size() - 1; counter >= 0; counter--) {
- UndoPosRef ref = positions.elementAt(counter);
+ UndoPosRef ref = (UndoPosRef)positions.elementAt(counter);
ref.resetLocation(endOffset, g1);
}
// We have to resort the marks in the range startIndex to endIndex.
@@ -902,7 +904,8 @@
protected String string;
/** An array of instances of UndoPosRef for the Positions in the
* range that was removed, valid after undo. */
- protected Vector<UndoPosRef> posRefs;
+ @SuppressWarnings("rawtypes") // UndoPosRef type cannot be exposed
+ protected Vector posRefs;
} // GapContent.InsertUndo
@@ -911,6 +914,7 @@
*/
@SuppressWarnings("serial") // JDK-implementation class
class RemoveUndo extends AbstractUndoableEdit {
+ @SuppressWarnings("unchecked")
protected RemoveUndo(int offset, String string) {
super();
this.offset = offset;
@@ -934,6 +938,7 @@
}
}
+ @SuppressWarnings("unchecked")
public void redo() throws CannotRedoException {
super.redo();
try {
--- old/src/java.desktop/share/classes/javax/swing/text/StringContent.java 2015-01-09 14:48:55.178781325 -0800
+++ new/src/java.desktop/share/classes/javax/swing/text/StringContent.java 2015-01-09 14:48:54.918781325 -0800
@@ -271,11 +271,12 @@
* @param length the length >= 0
* @return the set of instances
*/
- protected Vector<UndoPosRef> getPositionsInRange(Vector<UndoPosRef> v, int offset,
- int length) {
+ @SuppressWarnings({"rawtypes", "unchecked"}) // UndoPosRef type cannot be exposed
+ protected Vector getPositionsInRange(Vector v, int offset,
+ int length) {
int n = marks.size();
int end = offset + length;
- Vector<UndoPosRef> placeIn = (v == null) ? new Vector<>() : v;
+ Vector placeIn = (v == null) ? new Vector() : v;
for (int i = 0; i < n; i++) {
PosRec mark = marks.elementAt(i);
if (mark.unused) {
@@ -298,9 +299,10 @@
*
* @param positions the positions of the instances
*/
- protected void updateUndoPositions(Vector<UndoPosRef> positions) {
+ @SuppressWarnings("rawtypes") // UndoPosRef type cannot be exposed
+ protected void updateUndoPositions(Vector positions) {
for(int counter = positions.size() - 1; counter >= 0; counter--) {
- UndoPosRef ref = positions.elementAt(counter);
+ UndoPosRef ref = (UndoPosRef)positions.elementAt(counter);
// Check if the Position is still valid.
if(ref.rec.unused) {
positions.removeElementAt(counter);
@@ -437,7 +439,8 @@
protected String string;
// An array of instances of UndoPosRef for the Positions in the
// range that was removed, valid after undo.
- protected Vector<UndoPosRef> posRefs;
+ @SuppressWarnings("rawtypes") // UndoPosRef type cannot be exposed
+ protected Vector posRefs;
}
@@ -445,6 +448,7 @@
* UndoableEdit created for removes.
*/
class RemoveUndo extends AbstractUndoableEdit {
+ @SuppressWarnings("unchecked")
protected RemoveUndo(int offset, String string) {
super();
this.offset = offset;
@@ -471,6 +475,7 @@
}
}
+ @SuppressWarnings("unchecked")
public void redo() throws CannotRedoException {
super.redo();
try {
- csr for
-
JDK-8055059 JDK9b22 public API exposes package private classes
-
- Resolved
-
- relates to
-
CCC-8043549 Fix raw and unchecked lint warnings in javax.swing.text.*
-
- Closed
-