Created
December 7, 2011 01:22
-
-
Save rose00/1440966 to your computer and use it in GitHub Desktop.
Re: Review request for java.text.** warning cleanup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Cleanup coding guidelines: | |
http://mail.openjdk.java.net/pipermail/jdk8-dev/2011-December/000380.html | |
Base revision to this patch: | |
http://cr.openjdk.java.net/~dbhole/java.text-warning-cleanup/webrev.02/ | |
diff --git a/src/share/classes/java/text/AttributedString.java b/src/share/classes/java/text/AttributedString.java | |
--- a/src/share/classes/java/text/AttributedString.java | |
+++ b/src/share/classes/java/text/AttributedString.java | |
@@ -160,18 +160,9 @@ | |
Vector<Object> newRunAttributeValues = new Vector<>(attributeCount); | |
runAttributes[0] = newRunAttributes; | |
runAttributeValues[0] = newRunAttributeValues; | |
- | |
- // Suppress warning. Fixing requires naming parameters, which breaks API. See: | |
- // http://mail.openjdk.java.net/pipermail/jdk8-dev/2011-December/000453.html | |
- @SuppressWarnings("rawtypes") | |
- Iterator iterator = attributes.entrySet().iterator(); | |
+ Iterator<? extends Map.Entry<? extends Attribute, ?>> iterator = attributes.entrySet().iterator(); | |
while (iterator.hasNext()) { | |
- | |
- // Suppress warning. Fixing requires naming parameters, which breaks API. See: | |
- // http://mail.openjdk.java.net/pipermail/jdk8-dev/2011-December/000453.html | |
- @SuppressWarnings("unchecked") | |
- Map.Entry<? extends Attribute, ?> entry = (Map.Entry<? extends Attribute, ?>) iterator.next(); | |
- | |
+ Map.Entry<? extends Attribute, ?> entry = iterator.next(); | |
newRunAttributes.addElement(entry.getKey()); | |
newRunAttributeValues.addElement(entry.getValue()); | |
} | |
@@ -424,13 +415,10 @@ | |
private final void createRunAttributeDataVectors() { | |
// use temporary variables so things remain consistent in case of an exception | |
int newRunStarts[] = new int[ARRAY_SIZE_INCREMENT]; | |
- | |
- @SuppressWarnings({"unchecked"}) | |
+ @SuppressWarnings("unchecked") // array creation must have wildcard | |
Vector<Attribute> newRunAttributes[] = (Vector<Attribute>[]) new Vector<?>[ARRAY_SIZE_INCREMENT]; | |
- | |
- @SuppressWarnings({"unchecked"}) | |
+ @SuppressWarnings("unchecked") // array creation must have wildcard | |
Vector<Object> newRunAttributeValues[] = (Vector<Object>[]) new Vector<?>[ARRAY_SIZE_INCREMENT]; | |
- | |
runStarts = newRunStarts; | |
runAttributes = newRunAttributes; | |
runAttributeValues = newRunAttributeValues; | |
@@ -475,13 +463,10 @@ | |
if (runCount == runArraySize) { | |
int newArraySize = runArraySize + ARRAY_SIZE_INCREMENT; | |
int newRunStarts[] = new int[newArraySize]; | |
- | |
- @SuppressWarnings({"unchecked"}) | |
+ @SuppressWarnings("unchecked") // array creation must have wildcard | |
Vector<Attribute> newRunAttributes[] = (Vector<Attribute>[]) new Vector<?>[newArraySize]; | |
- | |
- @SuppressWarnings({"unchecked"}) | |
+ @SuppressWarnings("unchecked") // array creation must have wildcard | |
Vector<Object> newRunAttributeValues[] = (Vector<Object>[]) new Vector<?>[newArraySize]; | |
- | |
for (int i = 0; i < runArraySize; i++) { | |
newRunStarts[i] = runStarts[i]; | |
newRunAttributes[i] = runAttributes[i]; | |
@@ -1085,8 +1070,6 @@ | |
continue; | |
} | |
} | |
- | |
- @SuppressWarnings({"unchecked", "rawtypes"}) | |
Map.Entry<Attribute, Object> entry = new AttributeEntry(key, value); | |
set.add(entry); | |
} | |
@@ -1100,10 +1083,7 @@ | |
} | |
} | |
-// Must suppress the whole class to suppress warning about raw supertype Map.Entry. | |
-// Parameterizing Map.Entry correctly would requires changing return of getKey. | |
-@SuppressWarnings("rawtypes") | |
-class AttributeEntry implements Map.Entry { | |
+class AttributeEntry implements Map.Entry<Attribute,Object> { | |
private Attribute key; | |
private Object value; | |
@@ -1122,7 +1102,7 @@ | |
(value == null ? other.value == null : other.value.equals(value)); | |
} | |
- public Object getKey() { | |
+ public Attribute getKey() { | |
return key; | |
} | |
diff --git a/src/share/classes/java/text/BreakIterator.java b/src/share/classes/java/text/BreakIterator.java | |
--- a/src/share/classes/java/text/BreakIterator.java | |
+++ b/src/share/classes/java/text/BreakIterator.java | |
@@ -440,7 +440,7 @@ | |
private static final int LINE_INDEX = 2; | |
private static final int SENTENCE_INDEX = 3; | |
- @SuppressWarnings({"unchecked"}) | |
+ @SuppressWarnings("unchecked") // array creation must have wildcard | |
private static final SoftReference<BreakIteratorCache>[] iterCache = (SoftReference<BreakIteratorCache>[]) new SoftReference<?>[4]; | |
/** | |
diff --git a/src/share/classes/java/text/DictionaryBasedBreakIterator.java b/src/share/classes/java/text/DictionaryBasedBreakIterator.java | |
--- a/src/share/classes/java/text/DictionaryBasedBreakIterator.java | |
+++ b/src/share/classes/java/text/DictionaryBasedBreakIterator.java | |
@@ -409,10 +409,8 @@ | |
// case there's an error in the text | |
if (text.getIndex() > farthestEndPoint) { | |
farthestEndPoint = text.getIndex(); | |
- | |
@SuppressWarnings("unchecked") | |
- Stack<Integer> currentBreakPositionsCopy = (Stack<Integer>)(currentBreakPositions.clone()); | |
- | |
+ Stack<Integer> currentBreakPositionsCopy = (Stack<Integer>)currentBreakPositions.clone(); | |
bestBreakPositions = currentBreakPositionsCopy; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment