From 1e3434e448b7e49327df8608454e30a50dfd7bef Mon Sep 17 00:00:00 2001 From: peytoia Date: Tue, 6 Dec 2011 08:39:02 +0900 Subject: 7116914: Miscellaneous warnings (sun.text) Reviewed-by: smarks, okutsu --- src/share/classes/sun/text/CompactByteArray.java | 6 ++--- src/share/classes/sun/text/IntHashtable.java | 8 +++---- src/share/classes/sun/text/bidi/BidiBase.java | 13 ++++++----- src/share/classes/sun/text/normalizer/ICUData.java | 6 ++--- .../sun/text/normalizer/NormalizerBase.java | 21 +++++++++-------- .../sun/text/normalizer/NormalizerImpl.java | 26 +++++++++++----------- .../classes/sun/text/normalizer/SymbolTable.java | 5 +++++ .../classes/sun/text/normalizer/UnicodeSet.java | 12 ++++++---- .../sun/text/normalizer/UnicodeSetIterator.java | 4 ++-- .../classes/sun/text/normalizer/VersionInfo.java | 2 +- 10 files changed, 58 insertions(+), 45 deletions(-) diff --git a/src/share/classes/sun/text/CompactByteArray.java b/src/share/classes/sun/text/CompactByteArray.java index 042d88ff2..d28b1db03 100644 --- a/src/share/classes/sun/text/CompactByteArray.java +++ b/src/share/classes/sun/text/CompactByteArray.java @@ -264,9 +264,9 @@ public final class CompactByteArray implements Cloneable { { try { CompactByteArray other = (CompactByteArray) super.clone(); - other.values = (byte[])values.clone(); - other.indices = (short[])indices.clone(); - if (hashes != null) other.hashes = (int[])hashes.clone(); + other.values = values.clone(); + other.indices = indices.clone(); + if (hashes != null) other.hashes = hashes.clone(); return other; } catch (CloneNotSupportedException e) { throw new InternalError(e); diff --git a/src/share/classes/sun/text/IntHashtable.java b/src/share/classes/sun/text/IntHashtable.java index a066d0953..679c71060 100644 --- a/src/share/classes/sun/text/IntHashtable.java +++ b/src/share/classes/sun/text/IntHashtable.java @@ -122,11 +122,11 @@ public final class IntHashtable { // this line just scrambles the bits as each value is added into the // has value. This helps to make sure we affect all the bits and that // the same values in a different order will produce a different hash value - result = (int)(result * scrambler + 1); + result = result * scrambler + 1; result += keyList[i]; } for (int i = 0; i < values.length; ++i) { - result = (int)(result * scrambler + 1); + result = result * scrambler + 1; result += values[i]; } return result; @@ -135,8 +135,8 @@ public final class IntHashtable { public Object clone () throws CloneNotSupportedException { IntHashtable result = (IntHashtable) super.clone(); - values = (int[]) values.clone(); - keyList = (int[])keyList.clone(); + values = values.clone(); + keyList = keyList.clone(); return result; } diff --git a/src/share/classes/sun/text/bidi/BidiBase.java b/src/share/classes/sun/text/bidi/BidiBase.java index d6733ceb0..a803f8281 100644 --- a/src/share/classes/sun/text/bidi/BidiBase.java +++ b/src/share/classes/sun/text/bidi/BidiBase.java @@ -1106,7 +1106,7 @@ public class BidiBase { * Assume sizeNeeded>0. * If object != null, then assume size > 0. */ - private Object getMemory(String label, Object array, Class arrayClass, + private Object getMemory(String label, Object array, Class arrayClass, boolean mayAllocate, int sizeNeeded) { int len = Array.getLength(array); @@ -1990,7 +1990,7 @@ public class BidiBase { cell = impTab[oldStateSeq][_prop]; levState.state = GetState(cell); /* isolate the new state */ actionSeq = impAct[GetAction(cell)]; /* isolate the action */ - addLevel = (byte)impTab[levState.state][IMPTABLEVELS_RES]; + addLevel = impTab[levState.state][IMPTABLEVELS_RES]; if (actionSeq != 0) { switch (actionSeq) { @@ -2014,7 +2014,7 @@ public class BidiBase { /* nothing, just clean up */ levState.lastStrongRTL = -1; /* check if we have a pending conditional segment */ - level = (byte)impTab[oldStateSeq][IMPTABLEVELS_RES]; + level = impTab[oldStateSeq][IMPTABLEVELS_RES]; if ((level & 1) != 0 && levState.startON > 0) { /* after ON */ start = levState.startON; /* reset to basic run level */ } @@ -2115,7 +2115,7 @@ public class BidiBase { break; case 11: /* L after L+ON+EN/AN/ON */ - level = (byte)levState.runLevel; + level = levState.runLevel; for (k = start0-1; k >= levState.startON; k--) { if (levels[k] == level+3) { while (levels[k] == level+3) { @@ -2178,7 +2178,7 @@ public class BidiBase { levState.runLevel = levels[start]; levState.impTab = impTabPair.imptab[levState.runLevel & 1]; levState.impAct = impTabPair.impact[levState.runLevel & 1]; - processPropertySeq(levState, (short)sor, start, start); + processPropertySeq(levState, sor, start, start); /* initialize for property state table */ if (dirProps[start] == NSM) { stateImp = (short)(1 + sor); @@ -2230,7 +2230,7 @@ public class BidiBase { } } /* flush possible pending sequence, e.g. ON */ - processPropertySeq(levState, (short)eor, limit, limit); + processPropertySeq(levState, eor, limit, limit); } /* perform (L1) and (X9) ---------------------------------------------------- */ @@ -3484,6 +3484,7 @@ public class BidiBase { } } + @SuppressWarnings("serial") private static AttributedCharacterIterator.Attribute getTextAttribute(String name) { diff --git a/src/share/classes/sun/text/normalizer/ICUData.java b/src/share/classes/sun/text/normalizer/ICUData.java index bf6e60ffb..6163329ed 100644 --- a/src/share/classes/sun/text/normalizer/ICUData.java +++ b/src/share/classes/sun/text/normalizer/ICUData.java @@ -48,12 +48,12 @@ import java.util.MissingResourceException; */ public final class ICUData { - private static InputStream getStream(final Class root, final String resourceName, boolean required) { + private static InputStream getStream(final Class root, final String resourceName, boolean required) { InputStream i = null; if (System.getSecurityManager() != null) { - i = (InputStream)AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + i = AccessController.doPrivileged(new PrivilegedAction() { + public InputStream run() { return root.getResourceAsStream(resourceName); } }); diff --git a/src/share/classes/sun/text/normalizer/NormalizerBase.java b/src/share/classes/sun/text/normalizer/NormalizerBase.java index 576e67bd9..875d059f1 100644 --- a/src/share/classes/sun/text/normalizer/NormalizerBase.java +++ b/src/share/classes/sun/text/normalizer/NormalizerBase.java @@ -886,6 +886,7 @@ public final class NormalizerBase implements Cloneable { * @deprecated ICU 3.2 * @obsolete ICU 3.2 */ + @Deprecated public int setIndex(int index) { setIndexOnly(index); return current(); @@ -899,6 +900,7 @@ public final class NormalizerBase implements Cloneable { * @return The codepoint as an int * @see #startIndex */ + @Deprecated public int getBeginIndex() { return 0; } @@ -911,6 +913,7 @@ public final class NormalizerBase implements Cloneable { * @return The codepoint as an int * @see #endIndex */ + @Deprecated public int getEndIndex() { return endIndex(); } @@ -1235,11 +1238,11 @@ public final class NormalizerBase implements Cloneable { mode, options); if(pNeededToNormalize!=null) { - pNeededToNormalize[0]=(boolean)(destLength!=bufferLength || - Utility.arrayRegionMatches( - buffer,0,dest, - destStart,destLimit - )); + pNeededToNormalize[0]=destLength!=bufferLength || + Utility.arrayRegionMatches( + buffer,0,dest, + destStart,destLimit + ); } } else { /* just copy the source characters */ @@ -1458,10 +1461,10 @@ public final class NormalizerBase implements Cloneable { dest,destStart,destLimit, options); if(pNeededToNormalize!=null) { - pNeededToNormalize[0]=(boolean)(destLength!=bufferLength || - Utility.arrayRegionMatches(buffer,startIndex[0], - dest,destStart, - destLength)); + pNeededToNormalize[0]=destLength!=bufferLength || + Utility.arrayRegionMatches(buffer,startIndex[0], + dest,destStart, + destLength); } } else { /* just copy the source characters */ diff --git a/src/share/classes/sun/text/normalizer/NormalizerImpl.java b/src/share/classes/sun/text/normalizer/NormalizerImpl.java index b0b8e3712..8f0c9662a 100644 --- a/src/share/classes/sun/text/normalizer/NormalizerImpl.java +++ b/src/share/classes/sun/text/normalizer/NormalizerImpl.java @@ -98,11 +98,11 @@ public final class NormalizerImpl { private static final int EXTRA_SHIFT=16; /* norm32 value constants using >16 bits */ - private static final long MIN_SPECIAL = (long)(0xfc000000 & UNSIGNED_INT_MASK); - private static final long SURROGATES_TOP = (long)(0xfff00000 & UNSIGNED_INT_MASK); - private static final long MIN_HANGUL = (long)(0xfff00000 & UNSIGNED_INT_MASK); -// private static final long MIN_JAMO_V = (long)(0xfff20000 & UNSIGNED_INT_MASK); - private static final long JAMO_V_TOP = (long)(0xfff30000 & UNSIGNED_INT_MASK); + private static final long MIN_SPECIAL = 0xfc000000 & UNSIGNED_INT_MASK; + private static final long SURROGATES_TOP = 0xfff00000 & UNSIGNED_INT_MASK; + private static final long MIN_HANGUL = 0xfff00000 & UNSIGNED_INT_MASK; +// private static final long MIN_JAMO_V = 0xfff20000 & UNSIGNED_INT_MASK; + private static final long JAMO_V_TOP = 0xfff30000 & UNSIGNED_INT_MASK; /* indexes[] value names */ @@ -134,7 +134,7 @@ public final class NormalizerImpl { private static final int AUX_COMP_EX_SHIFT = 10; private static final int AUX_NFC_SKIPPABLE_F_SHIFT = 12; - private static final int AUX_MAX_FNC = ((int)1<>CC_SHIFT)&0xFF); + return (int)((norm32>>CC_SHIFT)&0xFF); } public static boolean isFullCompositionExclusion(int c) { if(isFormatVersion_2_1) { int aux =AuxTrieImpl.auxTrie.getCodePointValue(c); - return (boolean)((aux & AUX_COMP_EX_MASK)!=0); + return (aux & AUX_COMP_EX_MASK)!=0; } else { return false; } @@ -2037,7 +2037,7 @@ public final class NormalizerImpl { public static boolean isCanonSafeStart(int c) { if(isFormatVersion_2_1) { int aux = AuxTrieImpl.auxTrie.getCodePointValue(c); - return (boolean)((aux & AUX_UNSAFE_MASK)==0); + return (aux & AUX_UNSAFE_MASK)==0; } else { return false; } @@ -2546,7 +2546,7 @@ public final class NormalizerImpl { // copy these code units all at once if (srcIndex != prevSrc) { - length = (int)(srcIndex - prevSrc); + length = srcIndex - prevSrc; if ((destIndex + length) <= destLimit) { System.arraycopy(src,prevSrc,dest,destIndex,length); } diff --git a/src/share/classes/sun/text/normalizer/SymbolTable.java b/src/share/classes/sun/text/normalizer/SymbolTable.java index a1dfab5bd..95af219f5 100644 --- a/src/share/classes/sun/text/normalizer/SymbolTable.java +++ b/src/share/classes/sun/text/normalizer/SymbolTable.java @@ -65,6 +65,7 @@ import java.text.ParsePosition; * @draft ICU 2.8 * @deprecated This is a draft API and might change in a future release of ICU. */ +@Deprecated public interface SymbolTable { /** @@ -72,6 +73,7 @@ public interface SymbolTable { * @draft ICU 2.8 * @deprecated This is a draft API and might change in a future release of ICU. */ + @Deprecated static final char SYMBOL_REF = '$'; /** @@ -84,6 +86,7 @@ public interface SymbolTable { * @draft ICU 2.8 * @deprecated This is a draft API and might change in a future release of ICU. */ + @Deprecated char[] lookup(String s); /** @@ -95,6 +98,7 @@ public interface SymbolTable { * @draft ICU 2.8 * @deprecated This is a draft API and might change in a future release of ICU. */ + @Deprecated UnicodeMatcher lookupMatcher(int ch); /** @@ -115,5 +119,6 @@ public interface SymbolTable { * @draft ICU 2.8 * @deprecated This is a draft API and might change in a future release of ICU. */ + @Deprecated String parseReference(String text, ParsePosition pos, int limit); } diff --git a/src/share/classes/sun/text/normalizer/UnicodeSet.java b/src/share/classes/sun/text/normalizer/UnicodeSet.java index 569daff4c..42f6fdb54 100644 --- a/src/share/classes/sun/text/normalizer/UnicodeSet.java +++ b/src/share/classes/sun/text/normalizer/UnicodeSet.java @@ -298,7 +298,7 @@ public class UnicodeSet implements UnicodeMatcher { // NOTE: normally the field should be of type SortedSet; but that is missing a public clone!! // is not private so that UnicodeSetIterator can get access - TreeSet strings = new TreeSet(); + TreeSet strings = new TreeSet<>(); /** * The pattern representation of this set. This may not be the @@ -368,7 +368,7 @@ public class UnicodeSet implements UnicodeMatcher { * @stable ICU 2.0 */ public UnicodeSet set(UnicodeSet other) { - list = (int[]) other.list.clone(); + list = other.list.clone(); len = other.len; pat = other.pat; strings = (TreeSet)other.strings.clone(); @@ -524,10 +524,10 @@ public class UnicodeSet implements UnicodeMatcher { } if (includeStrings && strings.size() > 0) { - Iterator it = strings.iterator(); + Iterator it = strings.iterator(); while (it.hasNext()) { result.append('{'); - _appendToPat(result, (String) it.next(), escapeUnprintable); + _appendToPat(result, it.next(), escapeUnprintable); result.append('}'); } } @@ -1180,14 +1180,17 @@ public class UnicodeSet implements UnicodeMatcher { } } syntaxError(chars, "'-' not after char or set"); + break; case '&': if (lastItem == 2 && op == 0) { op = (char) c; continue; } syntaxError(chars, "'&' not after set"); + break; case '^': syntaxError(chars, "'^' not after '['"); + break; case '{': if (op != 0) { syntaxError(chars, "Missing operand after operator"); @@ -1251,6 +1254,7 @@ public class UnicodeSet implements UnicodeMatcher { continue; } syntaxError(chars, "Unquoted '$'"); + break; default: break; } diff --git a/src/share/classes/sun/text/normalizer/UnicodeSetIterator.java b/src/share/classes/sun/text/normalizer/UnicodeSetIterator.java index a27df03de..53a145c20 100644 --- a/src/share/classes/sun/text/normalizer/UnicodeSetIterator.java +++ b/src/share/classes/sun/text/normalizer/UnicodeSetIterator.java @@ -154,7 +154,7 @@ public class UnicodeSetIterator { if (stringIterator == null) return false; codepoint = IS_STRING; // signal that value is actually a string - string = (String)stringIterator.next(); + string = stringIterator.next(); if (!stringIterator.hasNext()) stringIterator = null; return true; } @@ -203,7 +203,7 @@ public class UnicodeSetIterator { * @internal */ protected int nextElement; - private Iterator stringIterator = null; + private Iterator stringIterator = null; /** * Invariant: stringIterator is null when there are no (more) strings remaining diff --git a/src/share/classes/sun/text/normalizer/VersionInfo.java b/src/share/classes/sun/text/normalizer/VersionInfo.java index 44b2e69f3..2f418b007 100644 --- a/src/share/classes/sun/text/normalizer/VersionInfo.java +++ b/src/share/classes/sun/text/normalizer/VersionInfo.java @@ -153,7 +153,7 @@ public final class VersionInfo /** * Map of singletons */ - private static final HashMap MAP_ = new HashMap(); + private static final HashMap MAP_ = new HashMap<>(); /** * Error statement string */ -- cgit v1.2.3