提交 59f1bc28 编写于 作者: A andrew

6959197: When building with JAVAC_MAX_WARNINGS=true, the build fails in...

6959197: When building with JAVAC_MAX_WARNINGS=true, the build fails in sun/nio/cs due to the use of -Werror
Summary: Remove unneeded casts, add generic types and make better use of static data
Reviewed-by: sherman
上级 696bbff9
......@@ -37,7 +37,7 @@ PRODUCT = sun
# This re-directs all the class files to a separate location
CLASSDESTDIR = $(TEMPDIR)/classes
OTHER_JAVACFLAGS += -Xlint:serial -Werror
OTHER_JAVACFLAGS += -Xlint:serial,-deprecation -Werror
include $(BUILDDIR)/common/Defs.gmk
#
......
......@@ -124,15 +124,15 @@ public abstract class ByteToCharISO2022 extends ByteToCharConverter
switch(shiftFlag) {
case SOFlag:
tmpIndex = curSODes;
tmpConverter = (ByteToCharConverter [])SOConverter;
tmpConverter = SOConverter;
break;
case SS2Flag:
tmpIndex = curSS2Des;
tmpConverter = (ByteToCharConverter [])SS2Converter;
tmpConverter = SS2Converter;
break;
case SS3Flag:
tmpIndex = curSS3Des;
tmpConverter = (ByteToCharConverter [])SS3Converter;
tmpConverter = SS3Converter;
break;
}
......
......@@ -141,7 +141,7 @@ public class ByteToCharISO2022JP extends ByteToCharJIS0208 {
} else {
savedSize = 2;
savedBytes[0] = (byte)byte1;
savedBytes[1] = (byte)input[readOff + inputSize];
savedBytes[1] = input[readOff + inputSize];
inputSize++;
}
break;
......
......@@ -34,14 +34,12 @@ public class ByteToCharJISAutoDetect extends ByteToCharConverter {
private final static int SJIS1B_MASK = 0x04;
private final static int EUCJP_KANA1_MASK = 0x08;
private final static int EUCJP_KANA2_MASK = 0x10;
private static byte[] maskTable1;
private static byte[] maskTable2;
private final static byte[] maskTable1 = JISAutoDetect.getByteMask1();
private final static byte[] maskTable2 = JISAutoDetect.getByteMask2();
private final static int SS2 = 0x8e;
private final static int SS3 = 0x8f;
private final static JISAutoDetect nioCoder = new JISAutoDetect();
// SJISName is set to either "SJIS" or "MS932"
private String SJISName;
private String EUCJPName;
......@@ -57,8 +55,6 @@ public class ByteToCharJISAutoDetect extends ByteToCharConverter {
defaultConv = new ByteToCharISO8859_1();
defaultConv.subChars = subChars;
defaultConv.subMode = subMode;
maskTable1 = nioCoder.getByteMask1();
maskTable2 = nioCoder.getByteMask2();
}
public int flush(char [] output, int outStart, int outEnd)
......@@ -133,7 +129,7 @@ public class ByteToCharJISAutoDetect extends ByteToCharConverter {
break;
}
if ((mask == SJIS2B_MASK) || (mask == SJIS1B_MASK)
|| (nioCoder.canBeSJIS1B(firstmask) && secondmask == 0)) {
|| (JISAutoDetect.canBeSJIS1B(firstmask) && secondmask == 0)) {
convName = SJISName;
break;
}
......@@ -145,15 +141,15 @@ public class ByteToCharJISAutoDetect extends ByteToCharConverter {
// character boundary. If we tried both
// possibilities here, it might be able to be
// determined correctly.
if ((byte1 == SS3) && nioCoder.canBeEUCJP(secondmask)) {
if ((byte1 == SS3) && JISAutoDetect.canBeEUCJP(secondmask)) {
if (cnt+1 < inEnd) {
int nextbyte = input[cnt+1] & 0xff;
if (! nioCoder.canBeEUCJP(maskTable2[nextbyte]))
if (! JISAutoDetect.canBeEUCJP(maskTable2[nextbyte]))
convName = SJISName;
} else
convName = SJISName;
}
if (nioCoder.canBeEUCKana(firstmask, secondmask))
if (JISAutoDetect.canBeEUCKana(firstmask, secondmask))
euckana++;
} else {
if ((firstmask & SJIS1B_MASK) != 0) {
......
......@@ -66,7 +66,7 @@ public class CharToBytePCK extends CharToByteSJIS {
switch (ch) {
case '\u2015':
return (int)0x815C;
return 0x815C;
case '\u2014':
return 0;
default:
......
......@@ -103,7 +103,7 @@ public class DoubleByte {
public final static char[] B2C_UNMAPPABLE;
static {
B2C_UNMAPPABLE = new char[0x100];
Arrays.fill(B2C_UNMAPPABLE, (char)UNMAPPABLE_DECODING);
Arrays.fill(B2C_UNMAPPABLE, UNMAPPABLE_DECODING);
}
public static class Decoder extends CharsetDecoder
......@@ -374,7 +374,7 @@ public class DoubleByte {
static final char[] b2cSB;
static {
b2cSB = new char[0x100];
Arrays.fill(b2cSB, (char)UNMAPPABLE_DECODING);
Arrays.fill(b2cSB, UNMAPPABLE_DECODING);
}
Decoder_EBCDIC_DBCSONLY(Charset cs, char[][] b2c, int b2Min, int b2Max) {
super(cs, 0.5f, 1.0f, b2c, b2cSB, b2Min, b2Max);
......
......@@ -79,8 +79,10 @@ public class EUC_JP
JIS_X_0201.Decoder decoderJ0201;
JIS_X_0212_Decoder decoderJ0212;
short[] j0208Index1;
String[] j0208Index2;
private static final short[] j0208Index1 =
JIS_X_0208_Decoder.getIndex1();
private static final String[] j0208Index2 =
JIS_X_0208_Decoder.getIndex2();
protected Decoder(Charset cs) {
super(cs);
......@@ -88,8 +90,6 @@ public class EUC_JP
decoderJ0212 = new JIS_X_0212_Decoder(cs);
start = 0xa1;
end = 0xfe;
j0208Index1 = super.getIndex1();
j0208Index2 = super.getIndex2();
}
protected char decode0212(int byte1, int byte2) {
return decoderJ0212.decodeDouble(byte1, byte2);
......@@ -238,8 +238,10 @@ public class EUC_JP
JIS_X_0201.Encoder encoderJ0201;
JIS_X_0212_Encoder encoderJ0212;
short[] j0208Index1;
String[] j0208Index2;
private static final short[] j0208Index1 =
JIS_X_0208_Encoder.getIndex1();
private static final String[] j0208Index2 =
JIS_X_0208_Encoder.getIndex2();
private final Surrogate.Parser sgp = new Surrogate.Parser();
......@@ -247,8 +249,6 @@ public class EUC_JP
super(cs, 3.0f, 3.0f);
encoderJ0201 = new JIS_X_0201.Encoder(cs);
encoderJ0212 = new JIS_X_0212_Encoder(cs);
j0208Index1 = super.getIndex1();
j0208Index2 = super.getIndex2();
}
public boolean canEncode(char c) {
......
......@@ -65,20 +65,18 @@ public class EUC_JP_LINUX
private static class Decoder extends CharsetDecoder {
JIS_X_0201.Decoder decoderJ0201;
JIS_X_0208_Decoder decodeMappingJ0208;
protected final char REPLACE_CHAR='\uFFFD';
short[] jis0208Index1;
String[] jis0208Index2;
private static final int start = 0xa1;
private static final int end = 0xfe;
private static final short[] jis0208Index1 =
JIS_X_0208_Decoder.getIndex1();
private static final String[] jis0208Index2 =
JIS_X_0208_Decoder.getIndex2();
private Decoder(Charset cs) {
super(cs, 1.0f, 1.0f);
decoderJ0201 = new JIS_X_0201.Decoder(cs);
decodeMappingJ0208 = new JIS_X_0208_Decoder(cs);
decodeMappingJ0208.start = 0xa1;
decodeMappingJ0208.end = 0xfe;
jis0208Index1 = decodeMappingJ0208.getIndex1();
jis0208Index2 = decodeMappingJ0208.getIndex2();
}
protected char convSingleByte(int b) {
......@@ -93,11 +91,11 @@ public class EUC_JP_LINUX
}
if (((byte1 < 0) || (byte1 > jis0208Index1.length))
|| ((byte2 < decodeMappingJ0208.start) || (byte2 > decodeMappingJ0208.end)))
|| ((byte2 < start) || (byte2 > end)))
return REPLACE_CHAR;
int n = (jis0208Index1[byte1 - 0x80] & 0xf) * (decodeMappingJ0208.end - decodeMappingJ0208.start + 1)
+ (byte2 - decodeMappingJ0208.start);
int n = (jis0208Index1[byte1 - 0x80] & 0xf) * (end - start + 1)
+ (byte2 - start);
return jis0208Index2[jis0208Index1[byte1 - 0x80] >> 4].charAt(n);
}
......@@ -213,18 +211,16 @@ public class EUC_JP_LINUX
private static class Encoder extends CharsetEncoder {
JIS_X_0201.Encoder encoderJ0201;
JIS_X_0208_Encoder encoderJ0208;
private final Surrogate.Parser sgp = new Surrogate.Parser();
short[] jis0208Index1;
String[] jis0208Index2;
private static final short[] jis0208Index1 =
JIS_X_0208_Encoder.getIndex1();
private static final String[] jis0208Index2 =
JIS_X_0208_Encoder.getIndex2();
private Encoder(Charset cs) {
super(cs, 2.0f, 2.0f);
encoderJ0201 = new JIS_X_0201.Encoder(cs);
encoderJ0208 = new JIS_X_0208_Encoder(cs);
jis0208Index1 = encoderJ0208.getIndex1();
jis0208Index2 = encoderJ0208.getIndex2();
}
public boolean canEncode(char c) {
......
......@@ -75,8 +75,12 @@ public class EUC_JP_Open
JIS_X_0212_Solaris_Decoder decodeMappingJ0212;
JIS_X_0208_Solaris_Decoder decodeMappingJ0208;
short[] j0208Index1;
String[] j0208Index2;
private static final short[] j0208Index1 =
JIS_X_0208_Solaris_Decoder.getIndex1();
private static final String[] j0208Index2 =
JIS_X_0208_Solaris_Decoder.getIndex2();
private static final int start = 0xa1;
private static final int end = 0xfe;
protected final char REPLACE_CHAR='\uFFFD';
......@@ -84,11 +88,6 @@ public class EUC_JP_Open
super(cs);
decoderJ0201 = new JIS_X_0201.Decoder(cs);
decodeMappingJ0212 = new JIS_X_0212_Solaris_Decoder(cs);
decodeMappingJ0208 = new JIS_X_0208_Solaris_Decoder(cs);
decodeMappingJ0208.start = 0xa1;
decodeMappingJ0208.end = 0xfe;
j0208Index1 = decodeMappingJ0208.getIndex1();
j0208Index2 = decodeMappingJ0208.getIndex2();
}
......@@ -103,9 +102,9 @@ public class EUC_JP_Open
}
if (((byte1 < 0)
|| (byte1 > decodeMappingJ0208.getIndex1().length))
|| ((byte2 < decodeMappingJ0208.start)
|| (byte2 > decodeMappingJ0208.end)))
|| (byte1 > j0208Index1.length))
|| ((byte2 < start)
|| (byte2 > end)))
return REPLACE_CHAR;
char result = super.decodeDouble(byte1, byte2);
......@@ -113,8 +112,8 @@ public class EUC_JP_Open
return result;
} else {
int n = (j0208Index1[byte1 - 0x80] & 0xf) *
(decodeMappingJ0208.end - decodeMappingJ0208.start + 1)
+ (byte2 - decodeMappingJ0208.start);
(end - start + 1)
+ (byte2 - start);
return j0208Index2[j0208Index1[byte1 - 0x80] >> 4].charAt(n);
}
}
......@@ -125,10 +124,11 @@ public class EUC_JP_Open
JIS_X_0201.Encoder encoderJ0201;
JIS_X_0212_Solaris_Encoder encoderJ0212;
JIS_X_0208_Solaris_Encoder encoderJ0208;
short[] j0208Index1;
String[] j0208Index2;
private static final short[] j0208Index1 =
JIS_X_0208_Solaris_Encoder.getIndex1();
private static final String[] j0208Index2 =
JIS_X_0208_Solaris_Encoder.getIndex2();
private final Surrogate.Parser sgp = new Surrogate.Parser();
......@@ -136,9 +136,6 @@ public class EUC_JP_Open
super(cs);
encoderJ0201 = new JIS_X_0201.Encoder(cs);
encoderJ0212 = new JIS_X_0212_Solaris_Encoder(cs);
encoderJ0208 = new JIS_X_0208_Solaris_Encoder(cs);
j0208Index1 = encoderJ0208.getIndex1();
j0208Index2 = encoderJ0208.getIndex2();
}
protected int encodeSingle(char inputChar, byte[] outputByte) {
......
......@@ -423,7 +423,7 @@ public class EUC_TW extends Charset implements HistoricallyNamedCharset
if (dst.remaining() < outSize)
return CoderResult.OVERFLOW;
for (int i = 0; i < outSize; i++)
dst.put((byte)bb[i]);
dst.put(bb[i]);
mark += inSize;
}
return CoderResult.UNDERFLOW;
......
......@@ -12339,7 +12339,7 @@ public class GB18030
int start = 0x40, end = 0xFE;
if (((byte1 < 0) || (byte1 > index1.length))
|| ((byte2 < start) || (byte2 > end)))
return (char)'\uFFFD';
return '\uFFFD';
int n = (index1[byte1] & 0xf) * (end - start + 1) + (byte2 - start);
return index2[index1[byte1] >> 4].charAt(n);
......
......@@ -43,7 +43,7 @@ public class HKSCS {
private char[][] b2cBmp;
private char[][] b2cSupp;
private static DoubleByte.Decoder big5Dec;
private DoubleByte.Decoder big5Dec;
protected Decoder(Charset cs,
DoubleByte.Decoder big5Dec,
......@@ -355,7 +355,7 @@ public class HKSCS {
c2b[hi] = new char[0x100];
Arrays.fill(c2b[hi], (char)UNMAPPABLE_ENCODING);
}
c2b[hi][c & 0xff] = (char)bb;
c2b[hi][c & 0xff] = bb;
}
c++;
}
......
......@@ -104,15 +104,15 @@ abstract class ISO2022
switch(shiftFlag) {
case SOFlag:
tmpIndex = curSODes;
tmpDecoder = (CharsetDecoder [])SODecoder;
tmpDecoder = SODecoder;
break;
case SS2Flag:
tmpIndex = curSS2Des;
tmpDecoder = (CharsetDecoder [])SS2Decoder;
tmpDecoder = SS2Decoder;
break;
case SS3Flag:
tmpIndex = curSS3Des;
tmpDecoder = (CharsetDecoder [])SS3Decoder;
tmpDecoder = SS3Decoder;
break;
}
......
......@@ -82,11 +82,11 @@ public class JISAutoDetect
* with the sun.io JISAutoDetect implementation
*/
public byte[] getByteMask1() {
public static byte[] getByteMask1() {
return Decoder.maskTable1;
}
public byte[] getByteMask2() {
public static byte[] getByteMask2() {
return Decoder.maskTable2;
}
......
......@@ -101,17 +101,15 @@ public class PCK
private static class Encoder extends SJIS.Encoder {
private JIS_X_0201.Encoder jis0201;
private JIS_X_0208_Solaris_Encoder jis0208;
short[] j0208Index1;
String[] j0208Index2;
private static final short[] j0208Index1 =
JIS_X_0208_Solaris_Encoder.getIndex1();
private static final String[] j0208Index2 =
JIS_X_0208_Solaris_Encoder.getIndex2();
private Encoder(Charset cs) {
super(cs);
jis0201 = new JIS_X_0201.Encoder(cs);
jis0208 = new JIS_X_0208_Solaris_Encoder(cs);
j0208Index1 = jis0208.getIndex1();
j0208Index2 = jis0208.getIndex2();
}
protected int encodeDouble(char ch) {
......@@ -121,7 +119,7 @@ public class PCK
switch (ch) {
case '\u2015':
return (int)0x815C;
return 0x815C;
case '\u2014':
return 0;
default:
......
......@@ -114,14 +114,14 @@ public class SJIS
private JIS_X_0201.Encoder jis0201;
short[] j0208Index1;
String[] j0208Index2;
private static final short[] j0208Index1 =
JIS_X_0208_Encoder.getIndex1();
private static final String[] j0208Index2 =
JIS_X_0208_Encoder.getIndex2();
protected Encoder(Charset cs) {
super(cs);
jis0201 = new JIS_X_0201.Encoder(cs);
j0208Index1 = super.getIndex1();
j0208Index2 = super.getIndex2();
}
protected int encodeSingle(char inputChar) {
......
......@@ -43,8 +43,8 @@ public class COMPOUND_TEXT_Encoder extends CharsetEncoder {
* cannot be used for actual encoding because they are shared across all
* COMPOUND_TEXT encoders and may be stateful.
*/
private static final Map encodingToEncoderMap =
Collections.synchronizedMap(new HashMap(21, 1.0f));
private static final Map<String,CharsetEncoder> encodingToEncoderMap =
Collections.synchronizedMap(new HashMap<String,CharsetEncoder>(21, 1.0f));
private static final CharsetEncoder latin1Encoder;
private static final CharsetEncoder defaultEncoder;
private static final boolean defaultEncodingSupported;
......@@ -221,7 +221,7 @@ public class COMPOUND_TEXT_Encoder extends CharsetEncoder {
out.put((byte)0x1B);
out.put((byte)0x25);
out.put((byte)0x2F);
out.put((byte)nonStandardBytes[3]);
out.put(nonStandardBytes[3]);
int toWrite = Math.min(numBytes - nonStandardBytesOff,
(1 << 14) - 1 - nonStandardEncodingLen);
......@@ -313,12 +313,9 @@ public class COMPOUND_TEXT_Encoder extends CharsetEncoder {
}
// 4. Brute force search of all supported encodings.
for (Iterator iter = CompoundTextSupport.getEncodings().iterator();
iter.hasNext();)
for (String encoding : CompoundTextSupport.getEncodings())
{
String encoding = (String)iter.next();
CharsetEncoder enc =
(CharsetEncoder)encodingToEncoderMap.get(encoding);
CharsetEncoder enc = encodingToEncoderMap.get(encoding);
if (enc == null) {
enc = CompoundTextSupport.getEncoder(encoding);
if (enc == null) {
......
......@@ -130,13 +130,13 @@ final class CompoundTextSupport {
/**
* Maps a GL or GR escape sequence to an encoding.
*/
private static final Map sequenceToEncodingMap;
private static final Map<ControlSequence, String> sequenceToEncodingMap;
/**
* Indicates whether a particular encoding wants the high bit turned on
* or off.
*/
private static final Map highBitsMap;
private static final Map<ControlSequence, Boolean> highBitsMap;
/**
* Maps an encoding to an escape sequence. Rather than manage two
......@@ -144,18 +144,21 @@ final class CompoundTextSupport {
* modify both GL and GR if necessary. This makes the output slightly less
* efficient, but our code much simpler.
*/
private static final Map encodingToSequenceMap;
private static final Map<String, ControlSequence> encodingToSequenceMap;
/**
* The keys of 'encodingToSequenceMap', sorted in preferential order.
*/
private static final List encodings;
private static final List<String> encodings;
static {
HashMap tSequenceToEncodingMap = new HashMap(33, 1.0f);
HashMap tHighBitsMap = new HashMap(31, 1.0f);
HashMap tEncodingToSequenceMap = new HashMap(21, 1.0f);
ArrayList tEncodings = new ArrayList(21);
HashMap<ControlSequence, String> tSequenceToEncodingMap =
new HashMap<>(33, 1.0f);
HashMap<ControlSequence, Boolean> tHighBitsMap =
new HashMap<>(31, 1.0f);
HashMap<String, ControlSequence> tEncodingToSequenceMap =
new HashMap<>(21, 1.0f);
ArrayList<String> tEncodings = new ArrayList<>(21);
if (!(isEncodingSupported("US-ASCII") &&
isEncodingSupported("ISO-8859-1")))
......@@ -457,13 +460,12 @@ final class CompoundTextSupport {
return getNonStandardDecoder(escSequence, null);
}
static boolean getHighBit(byte[] escSequence) {
Boolean bool = (Boolean)highBitsMap.get
(new ControlSequence(escSequence));
Boolean bool = highBitsMap.get(new ControlSequence(escSequence));
return (bool == Boolean.TRUE);
}
static CharsetDecoder getNonStandardDecoder(byte[] escSequence,
byte[] encoding) {
return getDecoder((String)sequenceToEncodingMap.get
return getDecoder(sequenceToEncodingMap.get
(new ControlSequence(escSequence, encoding)));
}
static CharsetDecoder getDecoder(String enc) {
......@@ -474,7 +476,7 @@ final class CompoundTextSupport {
try {
cs = Charset.forName(enc);
} catch (IllegalArgumentException e) {
Class cls;
Class<?> cls;
try {
cls = Class.forName("sun.awt.motif." + enc);
} catch (ClassNotFoundException ee) {
......@@ -497,22 +499,20 @@ final class CompoundTextSupport {
// For Encoder
static byte[] getEscapeSequence(String encoding) {
ControlSequence seq = (ControlSequence)
encodingToSequenceMap.get(encoding);
ControlSequence seq = encodingToSequenceMap.get(encoding);
if (seq != null) {
return seq.escSequence;
}
return null;
}
static byte[] getEncoding(String encoding) {
ControlSequence seq = (ControlSequence)
encodingToSequenceMap.get(encoding);
ControlSequence seq = encodingToSequenceMap.get(encoding);
if (seq != null) {
return seq.encoding;
}
return null;
}
static List getEncodings() {
static List<String> getEncodings() {
return encodings;
}
static CharsetEncoder getEncoder(String enc) {
......@@ -523,7 +523,7 @@ final class CompoundTextSupport {
try {
cs = Charset.forName(enc);
} catch (IllegalArgumentException e) {
Class cls;
Class<?> cls;
try {
cls = Class.forName("sun.awt.motif." + enc);
} catch (ClassNotFoundException ee) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册