diff --git a/src/share/classes/java/lang/Boolean.java b/src/share/classes/java/lang/Boolean.java index 9bf79a320f7f1b317d8a2a510ba827134bcde5ab..feb199465eccda0db481475093cd4c12d558e93c 100644 --- a/src/share/classes/java/lang/Boolean.java +++ b/src/share/classes/java/lang/Boolean.java @@ -60,7 +60,8 @@ public final class Boolean implements java.io.Serializable, * * @since JDK1.1 */ - public static final Class TYPE = Class.getPrimitiveClass("boolean"); + @SuppressWarnings("unchecked") + public static final Class TYPE = (Class) Class.getPrimitiveClass("boolean"); /** * The value of the Boolean. diff --git a/src/share/classes/java/lang/Byte.java b/src/share/classes/java/lang/Byte.java index cb260f803c9d99f714028c4b849a39bad051b041..4c0b1c2233bb97b90b962560f48af5c0c99385d5 100644 --- a/src/share/classes/java/lang/Byte.java +++ b/src/share/classes/java/lang/Byte.java @@ -59,6 +59,7 @@ public final class Byte extends Number implements Comparable { * The {@code Class} instance representing the primitive type * {@code byte}. */ + @SuppressWarnings("unchecked") public static final Class TYPE = (Class) Class.getPrimitiveClass("byte"); /** diff --git a/src/share/classes/java/lang/Character.java b/src/share/classes/java/lang/Character.java index 216098bd5335bc3579d344bbb70b5578f87fdfc0..c03896d987d28e3dc3b4f28245d6405d602f9b38 100644 --- a/src/share/classes/java/lang/Character.java +++ b/src/share/classes/java/lang/Character.java @@ -172,7 +172,7 @@ class Character implements java.io.Serializable, Comparable { * @since 1.1 */ @SuppressWarnings("unchecked") - public static final Class TYPE = Class.getPrimitiveClass("char"); + public static final Class TYPE = (Class) Class.getPrimitiveClass("char"); /* * Normative general types diff --git a/src/share/classes/java/lang/CharacterName.java b/src/share/classes/java/lang/CharacterName.java index a2d84635151c256b42650becf73ce9145f023763..b8e66e39c9f1a356da5296d0741af20ab8e854a1 100644 --- a/src/share/classes/java/lang/CharacterName.java +++ b/src/share/classes/java/lang/CharacterName.java @@ -101,6 +101,8 @@ class CharacterName { if (lookup[cp>>8] == null || (off = lookup[cp>>8][cp&0xff]) == 0) return null; - return new String(strPool, 0, off >>> 8, off & 0xff); // ASCII + @SuppressWarnings("deprecation") + String result = new String(strPool, 0, off >>> 8, off & 0xff); // ASCII + return result; } } diff --git a/src/share/classes/java/lang/Class.java b/src/share/classes/java/lang/Class.java index ca7f1be7927ae4710e38c4bf77240501bfc0cff7..f762d16707ea1c73884ae3122793275ccb43f331 100644 --- a/src/share/classes/java/lang/Class.java +++ b/src/share/classes/java/lang/Class.java @@ -631,6 +631,7 @@ public final * The Java™ Virtual Machine Specification * @since 1.5 */ + @SuppressWarnings("unchecked") public TypeVariable>[] getTypeParameters() { if (getGenericSignature() != null) return (TypeVariable>[])getGenericInfo().getTypeParameters(); @@ -1303,7 +1304,7 @@ public final return java.security.AccessController.doPrivileged( new java.security.PrivilegedAction[]>() { - public Class[] run() { + public Class[] run() { List> list = new ArrayList<>(); Class currentClass = Class.this; while (currentClass != null) { @@ -1315,7 +1316,7 @@ public final } currentClass = currentClass.getSuperclass(); } - return list.toArray(new Class[0]); + return list.toArray(new Class[0]); } }); } @@ -2150,7 +2151,7 @@ public final * Return the Virtual Machine's Class object for the named * primitive type. */ - static native Class getPrimitiveClass(String name); + static native Class getPrimitiveClass(String name); /* @@ -2395,7 +2396,9 @@ public final } // No cached value available; request value from VM if (isInterface()) { - res = new Constructor[0]; + @SuppressWarnings("unchecked") + Constructor[] temporaryRes = (Constructor[]) new Constructor[0]; + res = temporaryRes; } else { res = getDeclaredConstructors0(publicOnly); } @@ -2951,7 +2954,9 @@ public final return null; } }); - enumConstants = (T[])values.invoke(null); + @SuppressWarnings("unchecked") + T[] temporaryConstants = (T[])values.invoke(null); + enumConstants = temporaryConstants; } // These can happen when users concoct enum-like classes // that don't comply with the enum spec. @@ -2996,6 +3001,7 @@ public final * * @since 1.5 */ + @SuppressWarnings("unchecked") public T cast(Object obj) { if (obj != null && !isInstance(obj)) throw new ClassCastException(cannotCastMsg(obj)); @@ -3026,6 +3032,7 @@ public final * the class itself). * @since 1.5 */ + @SuppressWarnings("unchecked") public Class asSubclass(Class clazz) { if (clazz.isAssignableFrom(this)) return (Class) this; @@ -3037,6 +3044,7 @@ public final * @throws NullPointerException {@inheritDoc} * @since 1.5 */ + @SuppressWarnings("unchecked") public A getAnnotation(Class annotationClass) { if (annotationClass == null) throw new NullPointerException(); diff --git a/src/share/classes/java/lang/ClassLoader.java b/src/share/classes/java/lang/ClassLoader.java index d599396e8ad016e3c14c5c1767a5d243572c9e51..3dc1a1076b5884dbb57fbebcbb9a4875909945da 100644 --- a/src/share/classes/java/lang/ClassLoader.java +++ b/src/share/classes/java/lang/ClassLoader.java @@ -1167,7 +1167,8 @@ public abstract class ClassLoader { * @since 1.2 */ public Enumeration getResources(String name) throws IOException { - Enumeration[] tmp = new Enumeration[2]; + @SuppressWarnings("unchecked") + Enumeration[] tmp = (Enumeration[]) new Enumeration[2]; if (parent != null) { tmp[0] = parent.getResources(name); } else { diff --git a/src/share/classes/java/lang/ConditionalSpecialCasing.java b/src/share/classes/java/lang/ConditionalSpecialCasing.java index f45fe3a70298fe2e52cea69f25410d3be08d4e2a..9b2c85004caeb8f195d77f118bf2fc53fa42d55b 100644 --- a/src/share/classes/java/lang/ConditionalSpecialCasing.java +++ b/src/share/classes/java/lang/ConditionalSpecialCasing.java @@ -92,15 +92,15 @@ final class ConditionalSpecialCasing { }; // A hash table that contains the above entries - static Hashtable entryTable = new Hashtable(); + static Hashtable> entryTable = new Hashtable<>(); static { // create hashtable from the entry for (int i = 0; i < entry.length; i ++) { Entry cur = entry[i]; Integer cp = new Integer(cur.getCodePoint()); - HashSet set = (HashSet)entryTable.get(cp); + HashSet set = entryTable.get(cp); if (set == null) { - set = new HashSet(); + set = new HashSet(); } set.add(cur); entryTable.put(cp, set); @@ -151,13 +151,13 @@ final class ConditionalSpecialCasing { } private static char[] lookUpTable(String src, int index, Locale locale, boolean bLowerCasing) { - HashSet set = (HashSet)entryTable.get(new Integer(src.codePointAt(index))); + HashSet set = entryTable.get(new Integer(src.codePointAt(index))); if (set != null) { - Iterator iter = set.iterator(); + Iterator iter = set.iterator(); String currentLang = locale.getLanguage(); while (iter.hasNext()) { - Entry entry = (Entry)iter.next(); + Entry entry = iter.next(); String conditionLang= entry.getLanguage(); if (((conditionLang == null) || (conditionLang.equals(currentLang))) && isConditionMet(src, index, locale, entry.getCondition())) { diff --git a/src/share/classes/java/lang/Double.java b/src/share/classes/java/lang/Double.java index 70e6a7c60f321834e3adedfc572907bd3fbb3d21..8bf9853537d69117a498ddbf1f35720fc7fe72ce 100644 --- a/src/share/classes/java/lang/Double.java +++ b/src/share/classes/java/lang/Double.java @@ -128,6 +128,7 @@ public final class Double extends Number implements Comparable { * * @since JDK1.1 */ + @SuppressWarnings("unchecked") public static final Class TYPE = (Class) Class.getPrimitiveClass("double"); /** @@ -715,7 +716,7 @@ public final class Double extends Number implements Comparable { * @return the {@code double} value represented by this object */ public double doubleValue() { - return (double)value; + return value; } /** diff --git a/src/share/classes/java/lang/EnumConstantNotPresentException.java b/src/share/classes/java/lang/EnumConstantNotPresentException.java index 76bfd2715b5e9e2191c3b94320563e17674e136f..6db7df4a4eabf962c9e5bcf5bd49ccbae0347a94 100644 --- a/src/share/classes/java/lang/EnumConstantNotPresentException.java +++ b/src/share/classes/java/lang/EnumConstantNotPresentException.java @@ -36,6 +36,7 @@ package java.lang; * @see java.lang.reflect.AnnotatedElement * @since 1.5 */ +@SuppressWarnings("rawtypes") /* rawtypes are part of the public api */ public class EnumConstantNotPresentException extends RuntimeException { private static final long serialVersionUID = -6046998521960521108L; diff --git a/src/share/classes/java/lang/Float.java b/src/share/classes/java/lang/Float.java index bd32e366a3d9f1df3c5212d95dc5a1bba615ee5a..65a230a12a59cb3ea5785a3b042f7e06703c182d 100644 --- a/src/share/classes/java/lang/Float.java +++ b/src/share/classes/java/lang/Float.java @@ -126,7 +126,8 @@ public final class Float extends Number implements Comparable { * * @since JDK1.1 */ - public static final Class TYPE = Class.getPrimitiveClass("float"); + @SuppressWarnings("unchecked") + public static final Class TYPE = (Class) Class.getPrimitiveClass("float"); /** * Returns a string representation of the {@code float} diff --git a/src/share/classes/java/lang/Integer.java b/src/share/classes/java/lang/Integer.java index f3bba73b60ddce298c9822b09418c1a20f7ae831..dee52ae1fa852717c2730b7b4120d94f1460b1a1 100644 --- a/src/share/classes/java/lang/Integer.java +++ b/src/share/classes/java/lang/Integer.java @@ -68,6 +68,7 @@ public final class Integer extends Number implements Comparable { * * @since JDK1.1 */ + @SuppressWarnings("unchecked") public static final Class TYPE = (Class) Class.getPrimitiveClass("int"); /** diff --git a/src/share/classes/java/lang/Long.java b/src/share/classes/java/lang/Long.java index 31648edd9e2db4a9964523e47eef47289b0d749f..a87f4096d4df77eaf41d37ce490bb56960547136 100644 --- a/src/share/classes/java/lang/Long.java +++ b/src/share/classes/java/lang/Long.java @@ -66,6 +66,7 @@ public final class Long extends Number implements Comparable { * * @since JDK1.1 */ + @SuppressWarnings("unchecked") public static final Class TYPE = (Class) Class.getPrimitiveClass("long"); /** @@ -734,7 +735,7 @@ public final class Long extends Number implements Comparable { * {@code long} value. */ public long longValue() { - return (long)value; + return value; } /** diff --git a/src/share/classes/java/lang/Short.java b/src/share/classes/java/lang/Short.java index 15a00e17ff65c2ad2af06b725f2b3754182fe62a..6509039fe0ce209b0fdfca7350bcabd9aaf8b7c9 100644 --- a/src/share/classes/java/lang/Short.java +++ b/src/share/classes/java/lang/Short.java @@ -58,6 +58,7 @@ public final class Short extends Number implements Comparable { * The {@code Class} instance representing the primitive type * {@code short}. */ + @SuppressWarnings("unchecked") public static final Class TYPE = (Class) Class.getPrimitiveClass("short"); /** diff --git a/src/share/classes/java/lang/System.java b/src/share/classes/java/lang/System.java index 6e4f7436cf826bdf905c7b72935c501bff658597..e2b010e086bd7e346ffe5dfc0905d20d1f3feee6 100644 --- a/src/share/classes/java/lang/System.java +++ b/src/share/classes/java/lang/System.java @@ -1032,7 +1032,7 @@ public final class System { */ @Deprecated public static void runFinalizersOnExit(boolean value) { - Runtime.getRuntime().runFinalizersOnExit(value); + Runtime.runFinalizersOnExit(value); } /** diff --git a/src/share/classes/java/lang/ThreadLocal.java b/src/share/classes/java/lang/ThreadLocal.java index 50dcf9bfc7d47035aedfd2b944c17b08ff7bc1a5..e5c6e1f78b5b4983eb0e8acf93fa27f6553a0246 100644 --- a/src/share/classes/java/lang/ThreadLocal.java +++ b/src/share/classes/java/lang/ThreadLocal.java @@ -144,8 +144,11 @@ public class ThreadLocal { ThreadLocalMap map = getMap(t); if (map != null) { ThreadLocalMap.Entry e = map.getEntry(this); - if (e != null) - return (T)e.value; + if (e != null) { + @SuppressWarnings("unchecked") + T result = (T)e.value; + return result; + } } return setInitialValue(); } @@ -268,11 +271,11 @@ public class ThreadLocal { * entry can be expunged from table. Such entries are referred to * as "stale entries" in the code that follows. */ - static class Entry extends WeakReference { + static class Entry extends WeakReference> { /** The value associated with this ThreadLocal. */ Object value; - Entry(ThreadLocal k, Object v) { + Entry(ThreadLocal k, Object v) { super(k); value = v; } @@ -325,7 +328,7 @@ public class ThreadLocal { * ThreadLocalMaps are constructed lazily, so we only create * one when we have at least one entry to put in it. */ - ThreadLocalMap(ThreadLocal firstKey, Object firstValue) { + ThreadLocalMap(ThreadLocal firstKey, Object firstValue) { table = new Entry[INITIAL_CAPACITY]; int i = firstKey.threadLocalHashCode & (INITIAL_CAPACITY - 1); table[i] = new Entry(firstKey, firstValue); @@ -348,7 +351,8 @@ public class ThreadLocal { for (int j = 0; j < len; j++) { Entry e = parentTable[j]; if (e != null) { - ThreadLocal key = e.get(); + @SuppressWarnings("unchecked") + ThreadLocal key = (ThreadLocal) e.get(); if (key != null) { Object value = key.childValue(e.value); Entry c = new Entry(key, value); @@ -372,7 +376,7 @@ public class ThreadLocal { * @param key the thread local object * @return the entry associated with key, or null if no such */ - private Entry getEntry(ThreadLocal key) { + private Entry getEntry(ThreadLocal key) { int i = key.threadLocalHashCode & (table.length - 1); Entry e = table[i]; if (e != null && e.get() == key) @@ -390,12 +394,12 @@ public class ThreadLocal { * @param e the entry at table[i] * @return the entry associated with key, or null if no such */ - private Entry getEntryAfterMiss(ThreadLocal key, int i, Entry e) { + private Entry getEntryAfterMiss(ThreadLocal key, int i, Entry e) { Entry[] tab = table; int len = tab.length; while (e != null) { - ThreadLocal k = e.get(); + ThreadLocal k = e.get(); if (k == key) return e; if (k == null) @@ -413,7 +417,7 @@ public class ThreadLocal { * @param key the thread local object * @param value the value to be set */ - private void set(ThreadLocal key, Object value) { + private void set(ThreadLocal key, Object value) { // We don't use a fast path as with get() because it is at // least as common to use set() to create new entries as @@ -427,7 +431,7 @@ public class ThreadLocal { for (Entry e = tab[i]; e != null; e = tab[i = nextIndex(i, len)]) { - ThreadLocal k = e.get(); + ThreadLocal k = e.get(); if (k == key) { e.value = value; @@ -449,7 +453,7 @@ public class ThreadLocal { /** * Remove the entry for key. */ - private void remove(ThreadLocal key) { + private void remove(ThreadLocal key) { Entry[] tab = table; int len = tab.length; int i = key.threadLocalHashCode & (len-1); @@ -479,7 +483,7 @@ public class ThreadLocal { * @param staleSlot index of the first stale entry encountered while * searching for key. */ - private void replaceStaleEntry(ThreadLocal key, Object value, + private void replaceStaleEntry(ThreadLocal key, Object value, int staleSlot) { Entry[] tab = table; int len = tab.length; @@ -501,7 +505,7 @@ public class ThreadLocal { for (int i = nextIndex(staleSlot, len); (e = tab[i]) != null; i = nextIndex(i, len)) { - ThreadLocal k = e.get(); + ThreadLocal k = e.get(); // If we find key, then we need to swap it // with the stale entry to maintain hash table order. @@ -563,7 +567,7 @@ public class ThreadLocal { for (i = nextIndex(staleSlot, len); (e = tab[i]) != null; i = nextIndex(i, len)) { - ThreadLocal k = e.get(); + ThreadLocal k = e.get(); if (k == null) { e.value = null; tab[i] = null; @@ -650,7 +654,7 @@ public class ThreadLocal { for (int j = 0; j < oldLen; ++j) { Entry e = oldTab[j]; if (e != null) { - ThreadLocal k = e.get(); + ThreadLocal k = e.get(); if (k == null) { e.value = null; // Help the GC } else { diff --git a/src/share/classes/java/lang/Void.java b/src/share/classes/java/lang/Void.java index 52a6f2f56c7bf119bcd42f3440e158dc7870fd6e..9231b88a107d0051d8ba5e8695d30366585c174c 100644 --- a/src/share/classes/java/lang/Void.java +++ b/src/share/classes/java/lang/Void.java @@ -40,7 +40,8 @@ class Void { * The {@code Class} object representing the pseudo-type corresponding to * the keyword {@code void}. */ - public static final Class TYPE = Class.getPrimitiveClass("void"); + @SuppressWarnings("unchecked") + public static final Class TYPE = (Class) Class.getPrimitiveClass("void"); /* * The Void class cannot be instantiated. diff --git a/src/solaris/classes/java/lang/ProcessEnvironment.java b/src/solaris/classes/java/lang/ProcessEnvironment.java index bb60c71b604b16dc9b527ccdc03fe45966449b5a..c5cfbaa5da4740ba3dcd479f9eee63d19a8f0b32 100644 --- a/src/solaris/classes/java/lang/ProcessEnvironment.java +++ b/src/solaris/classes/java/lang/ProcessEnvironment.java @@ -91,6 +91,7 @@ final class ProcessEnvironment } /* Only for use by ProcessBuilder.environment() */ + @SuppressWarnings("unchecked") static Map environment() { return new StringEnvironment ((Map)(theEnvironment.clone())); diff --git a/src/windows/classes/java/lang/ProcessEnvironment.java b/src/windows/classes/java/lang/ProcessEnvironment.java index 89e468999998a911ddadd821848ffca9d1fad636..c49f1f327819d993653f9f910c5b2c4129eac81e 100644 --- a/src/windows/classes/java/lang/ProcessEnvironment.java +++ b/src/windows/classes/java/lang/ProcessEnvironment.java @@ -68,6 +68,9 @@ import java.util.*; final class ProcessEnvironment extends HashMap { + + private static final long serialVersionUID = -8017839552603542824L; + private static String validateName(String name) { // An initial `=' indicates a magic Windows variable name -- OK if (name.indexOf('=', 1) != -1 || @@ -144,6 +147,7 @@ final class ProcessEnvironment extends HashMap }; } private static Map.Entry checkedEntry(Object o) { + @SuppressWarnings("unchecked") Map.Entry e = (Map.Entry) o; nonNullString(e.getKey()); nonNullString(e.getValue()); @@ -281,6 +285,7 @@ final class ProcessEnvironment extends HashMap } // Only for use by ProcessBuilder.environment() + @SuppressWarnings("unchecked") static Map environment() { return (Map) theEnvironment.clone(); }