diff --git a/jdk/make/java/sun_nio/Makefile b/jdk/make/java/sun_nio/Makefile index bf316dfb3e2fdccd450b1dc1fbbc9fc19b5a9a26..23f07f13102fafdb8a37af5e11df08c61e9d46ed 100644 --- a/jdk/make/java/sun_nio/Makefile +++ b/jdk/make/java/sun_nio/Makefile @@ -31,7 +31,7 @@ BUILDDIR = ../.. PACKAGE = sun.nio PRODUCT = sun -OTHER_JAVACFLAGS += -Xlint:serial -Werror +OTHER_JAVACFLAGS += -Xlint:serial,-deprecation -Werror include $(BUILDDIR)/common/Defs.gmk # diff --git a/jdk/src/share/classes/sun/io/ByteToCharUTF8.java b/jdk/src/share/classes/sun/io/ByteToCharUTF8.java index 47da36bb4c900f78fa26c1dc1b572bb6895af36d..bff6935a16d05ddba4cd6c813b04068ce9d66352 100644 --- a/jdk/src/share/classes/sun/io/ByteToCharUTF8.java +++ b/jdk/src/share/classes/sun/io/ByteToCharUTF8.java @@ -113,7 +113,7 @@ public class ByteToCharUTF8 extends ByteToCharConverter { savedSize = 1; } else { savedSize = 2; - savedBytes[1] = (byte)input[byteOff++]; + savedBytes[1] = input[byteOff++]; } break; } @@ -135,11 +135,11 @@ public class ByteToCharUTF8 extends ByteToCharConverter { savedSize = 1; } else if (byteOff + 1 >= inEnd) { savedSize = 2; - savedBytes[1] = (byte)input[byteOff++]; + savedBytes[1] = input[byteOff++]; } else { savedSize = 3; - savedBytes[1] = (byte)input[byteOff++]; - savedBytes[2] = (byte)input[byteOff++]; + savedBytes[1] = input[byteOff++]; + savedBytes[2] = input[byteOff++]; } break; } @@ -154,10 +154,10 @@ public class ByteToCharUTF8 extends ByteToCharConverter { throw new MalformedInputException(); } // this byte sequence is UTF16 character - int ucs4 = (int)(0x07 & byte1) << 18 | - (int)(0x3f & byte2) << 12 | - (int)(0x3f & byte3) << 6 | - (int)(0x3f & byte4); + int ucs4 = (0x07 & byte1) << 18 | + (0x3f & byte2) << 12 | + (0x3f & byte3) << 6 | + (0x3f & byte4); outputChar[0] = (char)((ucs4 - 0x10000) / 0x400 + 0xd800); outputChar[1] = (char)((ucs4 - 0x10000) % 0x400 + 0xdc00); outputSize = 2; diff --git a/jdk/src/share/classes/sun/io/CharToByteUnicode.java b/jdk/src/share/classes/sun/io/CharToByteUnicode.java index 6409a7177cbf7d55a42599fb9f5c9557b52d6df7..598cd026930434f9c4a48f993599fe78ec39bb98 100644 --- a/jdk/src/share/classes/sun/io/CharToByteUnicode.java +++ b/jdk/src/share/classes/sun/io/CharToByteUnicode.java @@ -46,7 +46,7 @@ public class CharToByteUnicode extends CharToByteConverter { protected int byteOrder = UNKNOWN; public CharToByteUnicode() { - String enc = (String) java.security.AccessController.doPrivileged( + String enc = java.security.AccessController.doPrivileged( new sun.security.action.GetPropertyAction("sun.io.unicode.encoding", "UnicodeBig")); if (enc.equals("UnicodeBig")) diff --git a/jdk/src/share/classes/sun/io/CharacterEncoding.java b/jdk/src/share/classes/sun/io/CharacterEncoding.java index 73099d9acff75841bc40f4ff840fbc4a48fc7296..2a5ebefd0bd6d6faba45a49f2e83b75f7ecc201b 100644 --- a/jdk/src/share/classes/sun/io/CharacterEncoding.java +++ b/jdk/src/share/classes/sun/io/CharacterEncoding.java @@ -50,11 +50,11 @@ public class CharacterEncoding { private static boolean sjisIsMS932; - private static Map aliasTable; + private static Map aliasTable; private static volatile boolean installedAll; static { - aliasTable = new HashMap(460, 1.0f); /* MDA */ + aliasTable = new HashMap<>(460, 1.0f); /* MDA */ aliasTable.put("us-ascii", "ASCII"); aliasTable.put("ascii", "ASCII"); @@ -119,11 +119,11 @@ public class CharacterEncoding { } // need to use Locale.US so we can load ISO converters in tr_TR locale String lower = name.toLowerCase(Locale.US); - String val = (String) aliasTable.get(lower); + String val = aliasTable.get(lower); if (val == null && !installedAll) { installAll(); - val = (String) aliasTable.get(lower); + val = aliasTable.get(lower); } return val; } @@ -131,7 +131,7 @@ public class CharacterEncoding { private static synchronized void installAll() { if (!installedAll) { GetPropertyAction a = new GetPropertyAction("sun.nio.cs.map"); - String map = ((String)AccessController.doPrivileged(a)); + String map = AccessController.doPrivileged(a); if (map != null) { sjisIsMS932 = map.equalsIgnoreCase("Windows-31J/Shift_JIS"); } else { @@ -857,9 +857,9 @@ public class CharacterEncoding { * Auto Detect converter. */ static String getSJISName() { - String encodeName = (String) AccessController.doPrivileged( - new PrivilegedAction() { - public Object run() { + String encodeName = AccessController.doPrivileged( + new PrivilegedAction() { + public String run() { String osName = System.getProperty("os.name"); if (osName.equals("Solaris") || osName.equals("SunOS")){ return "PCK"; @@ -880,9 +880,9 @@ public class CharacterEncoding { static String getEUCJPName() { - String encodeName = (String) AccessController.doPrivileged( - new PrivilegedAction() { - public Object run() { + String encodeName = AccessController.doPrivileged( + new PrivilegedAction() { + public String run() { String osName = System.getProperty("os.name"); if (osName.equals("Solaris") || osName.equals("SunOS")) return "eucJP-open"; diff --git a/jdk/src/share/classes/sun/io/Converters.java b/jdk/src/share/classes/sun/io/Converters.java index 9b6959b5d61cab930d2e36e4dddda030330a4eed..377ca8f9d3e429a6717798cbb10773e8f772377d 100644 --- a/jdk/src/share/classes/sun/io/Converters.java +++ b/jdk/src/share/classes/sun/io/Converters.java @@ -85,10 +85,11 @@ public class Converters { * this code can be involved in the startup sequence it's important to keep * the footprint down. */ - private static SoftReference[][] classCache - = new SoftReference[][] { - new SoftReference[CACHE_SIZE], - new SoftReference[CACHE_SIZE] + @SuppressWarnings("unchecked") + private static SoftReference[][] classCache + = (SoftReference[][]) new SoftReference[][] { + new SoftReference[CACHE_SIZE], + new SoftReference[CACHE_SIZE] }; private static void moveToFront(Object[] oa, int i) { @@ -98,28 +99,28 @@ public class Converters { oa[0] = ob; } - private static Class cache(int type, Object encoding) { - SoftReference[] srs = classCache[type]; + private static Class cache(int type, Object encoding) { + SoftReference[] srs = classCache[type]; for (int i = 0; i < CACHE_SIZE; i++) { - SoftReference sr = srs[i]; + SoftReference sr = srs[i]; if (sr == null) continue; - Object[] oa = (Object[])sr.get(); + Object[] oa = sr.get(); if (oa == null) { srs[i] = null; continue; } if (oa[1].equals(encoding)) { moveToFront(srs, i); - return (Class)oa[0]; + return (Class)oa[0]; } } return null; } - private static Class cache(int type, Object encoding, Class c) { - SoftReference[] srs = classCache[type]; - srs[CACHE_SIZE - 1] = new SoftReference(new Object[] { c, encoding }); + private static Class cache(int type, Object encoding, Class c) { + SoftReference[] srs = classCache[type]; + srs[CACHE_SIZE - 1] = new SoftReference(new Object[] { c, encoding }); moveToFront(srs, CACHE_SIZE - 1); return c; } @@ -129,12 +130,12 @@ public class Converters { */ public static boolean isCached(int type, String encoding) { synchronized (lock) { - SoftReference[] srs = classCache[type]; + SoftReference[] srs = classCache[type]; for (int i = 0; i < CACHE_SIZE; i++) { - SoftReference sr = srs[i]; + SoftReference sr = srs[i]; if (sr == null) continue; - Object[] oa = (Object[])sr.get(); + Object[] oa = sr.get(); if (oa == null) { srs[i] = null; continue; @@ -152,9 +153,9 @@ public class Converters { private static String getConverterPackageName() { String cp = converterPackageName; if (cp != null) return cp; - java.security.PrivilegedAction pa = + java.security.PrivilegedAction pa = new sun.security.action.GetPropertyAction("file.encoding.pkg"); - cp = (String)java.security.AccessController.doPrivileged(pa); + cp = java.security.AccessController.doPrivileged(pa); if (cp != null) { /* Property is set, so take it as the true converter package */ converterPackageName = cp; @@ -168,9 +169,9 @@ public class Converters { public static String getDefaultEncodingName() { synchronized (lock) { if (defaultEncoding == null) { - java.security.PrivilegedAction pa = + java.security.PrivilegedAction pa = new sun.security.action.GetPropertyAction("file.encoding"); - defaultEncoding = (String)java.security.AccessController.doPrivileged(pa); + defaultEncoding = java.security.AccessController.doPrivileged(pa); } } return defaultEncoding; @@ -194,7 +195,7 @@ public class Converters { * encoding, or throw an UnsupportedEncodingException if no such class can * be found */ - private static Class getConverterClass(int type, String encoding) + private static Class getConverterClass(int type, String encoding) throws UnsupportedEncodingException { String enc = null; @@ -241,7 +242,7 @@ public class Converters { * Instantiate the given converter class, or throw an * UnsupportedEncodingException if it cannot be instantiated */ - private static Object newConverter(String enc, Class c) + private static Object newConverter(String enc, Class c) throws UnsupportedEncodingException { try { @@ -261,7 +262,7 @@ public class Converters { static Object newConverter(int type, String enc) throws UnsupportedEncodingException { - Class c; + Class c; synchronized (lock) { c = cache(type, enc); if (c == null) { @@ -279,9 +280,9 @@ public class Converters { * not yet defined, return a class that implements the fallback default * encoding, which is just ISO 8859-1. */ - private static Class getDefaultConverterClass(int type) { + private static Class getDefaultConverterClass(int type) { boolean fillCache = false; - Class c; + Class c; /* First check the class cache */ c = cache(type, DEFAULT_NAME); @@ -325,7 +326,7 @@ public class Converters { * encoding cannot be determined. */ static Object newDefaultConverter(int type) { - Class c; + Class c; synchronized (lock) { c = getDefaultConverterClass(type); } diff --git a/jdk/src/share/classes/sun/nio/cs/AbstractCharsetProvider.java b/jdk/src/share/classes/sun/nio/cs/AbstractCharsetProvider.java index e3d03e078fc358dcb7abaaf756b3621f99a57ff0..5e86d64cc421793e64829872143b0c1d8aa8c2b6 100644 --- a/jdk/src/share/classes/sun/nio/cs/AbstractCharsetProvider.java +++ b/jdk/src/share/classes/sun/nio/cs/AbstractCharsetProvider.java @@ -48,23 +48,23 @@ public class AbstractCharsetProvider /* Maps canonical names to class names */ - private Map classMap - = new TreeMap(ASCIICaseInsensitiveComparator.CASE_INSENSITIVE_ORDER); + private Map classMap + = new TreeMap<>(ASCIICaseInsensitiveComparator.CASE_INSENSITIVE_ORDER); /* Maps alias names to canonical names */ - private Map aliasMap - = new TreeMap(ASCIICaseInsensitiveComparator.CASE_INSENSITIVE_ORDER); + private Map aliasMap + = new TreeMap<>(ASCIICaseInsensitiveComparator.CASE_INSENSITIVE_ORDER); /* Maps canonical names to alias-name arrays */ - private Map aliasNameMap - = new TreeMap(ASCIICaseInsensitiveComparator.CASE_INSENSITIVE_ORDER); + private Map aliasNameMap + = new TreeMap<>(ASCIICaseInsensitiveComparator.CASE_INSENSITIVE_ORDER); /* Maps canonical names to soft references that hold cached instances */ - private Map cache - = new TreeMap(ASCIICaseInsensitiveComparator.CASE_INSENSITIVE_ORDER); + private Map> cache + = new TreeMap<>(ASCIICaseInsensitiveComparator.CASE_INSENSITIVE_ORDER); private String packagePrefix; @@ -79,13 +79,13 @@ public class AbstractCharsetProvider /* Add an entry to the given map, but only if no mapping yet exists * for the given name. */ - private static void put(Map m, String name, Object value) { + private static void put(Map m, K name, V value) { if (!m.containsKey(name)) m.put(name, value); } - private static void remove(Map m, String name) { - Object x = m.remove(name); + private static void remove(Map m, K name) { + V x = m.remove(name); assert (x != null); } @@ -116,22 +116,22 @@ public class AbstractCharsetProvider protected void init() { } private String canonicalize(String charsetName) { - String acn = (String)aliasMap.get(charsetName); + String acn = aliasMap.get(charsetName); return (acn != null) ? acn : charsetName; } private Charset lookup(String csn) { // Check cache first - SoftReference sr = (SoftReference)cache.get(csn); + SoftReference sr = cache.get(csn); if (sr != null) { - Charset cs = (Charset)sr.get(); + Charset cs = sr.get(); if (cs != null) return cs; } // Do we even support this charset? - String cln = (String)classMap.get(csn); + String cln = classMap.get(csn); if (cln == null) return null; @@ -139,12 +139,12 @@ public class AbstractCharsetProvider // Instantiate the charset and cache it try { - Class c = Class.forName(packagePrefix + "." + cln, - true, - this.getClass().getClassLoader()); + Class c = Class.forName(packagePrefix + "." + cln, + true, + this.getClass().getClassLoader()); Charset cs = (Charset)c.newInstance(); - cache.put(csn, new SoftReference(cs)); + cache.put(csn, new SoftReference(cs)); return cs; } catch (ClassNotFoundException x) { return null; @@ -164,21 +164,21 @@ public class AbstractCharsetProvider public final Iterator charsets() { - final ArrayList ks; + final ArrayList ks; synchronized (this) { init(); - ks = new ArrayList(classMap.keySet()); + ks = new ArrayList<>(classMap.keySet()); } return new Iterator() { - Iterator i = ks.iterator(); + Iterator i = ks.iterator(); public boolean hasNext() { return i.hasNext(); } public Charset next() { - String csn = (String)i.next(); + String csn = i.next(); return lookup(csn); } @@ -191,7 +191,7 @@ public class AbstractCharsetProvider public final String[] aliases(String charsetName) { synchronized (this) { init(); - return (String[])aliasNameMap.get(charsetName); + return aliasNameMap.get(charsetName); } }