diff --git a/src/share/classes/java/io/File.java b/src/share/classes/java/io/File.java index 4b9d389a2d0bb74c335838354b2bb5f62c31f9b9..fba80c2f4617a80436075319cb7e4af18b5e59d7 100644 --- a/src/share/classes/java/io/File.java +++ b/src/share/classes/java/io/File.java @@ -2006,7 +2006,7 @@ public class File throws IOException { s.defaultWriteObject(); - s.writeChar(this.separatorChar); // Add the separator character + s.writeChar(separatorChar); // Add the separator character } /** diff --git a/src/share/classes/java/io/ObjectInputStream.java b/src/share/classes/java/io/ObjectInputStream.java index 04705e63229555b1a613494d5d76d915c28aa7d3..1963187eaaaa96a1a33e2dd8027846bae4090b4e 100644 --- a/src/share/classes/java/io/ObjectInputStream.java +++ b/src/share/classes/java/io/ObjectInputStream.java @@ -689,9 +689,9 @@ public class ObjectInputStream boolean hasNonPublicInterface = false; // define proxy in class loader of non-public interface(s), if any - Class[] classObjs = new Class[interfaces.length]; + Class[] classObjs = new Class[interfaces.length]; for (int i = 0; i < interfaces.length; i++) { - Class cl = Class.forName(interfaces[i], false, latestLoader); + Class cl = Class.forName(interfaces[i], false, latestLoader); if ((cl.getModifiers() & Modifier.PUBLIC) == 0) { if (hasNonPublicInterface) { if (nonPublicLoader != cl.getClassLoader()) { @@ -1229,7 +1229,7 @@ public class ObjectInputStream * "enableSubclassImplementation" SerializablePermission is checked. */ private void verifySubclass() { - Class cl = getClass(); + Class cl = getClass(); if (cl == ObjectInputStream.class) { return; } @@ -1473,12 +1473,12 @@ public class ObjectInputStream * ClassNotFoundException will be associated with the class' handle in the * handle table). */ - private Class readClass(boolean unshared) throws IOException { + private Class readClass(boolean unshared) throws IOException { if (bin.readByte() != TC_CLASS) { throw new InternalError(); } ObjectStreamClass desc = readClassDesc(false); - Class cl = desc.forClass(); + Class cl = desc.forClass(); passHandle = handles.assign(unshared ? unsharedMarker : cl); ClassNotFoundException resolveEx = desc.getResolveException(); @@ -1542,7 +1542,7 @@ public class ObjectInputStream ifaces[i] = bin.readUTF(); } - Class cl = null; + Class cl = null; ClassNotFoundException resolveEx = null; bin.setBlockDataMode(true); try { @@ -1586,7 +1586,7 @@ public class ObjectInputStream "failed to read class descriptor").initCause(ex); } - Class cl = null; + Class cl = null; ClassNotFoundException resolveEx = null; bin.setBlockDataMode(true); try { @@ -1643,7 +1643,7 @@ public class ObjectInputStream int len = bin.readInt(); Object array = null; - Class cl, ccl = null; + Class cl, ccl = null; if ((cl = desc.forClass()) != null) { ccl = cl.getComponentType(); array = Array.newInstance(ccl, len); @@ -1696,7 +1696,7 @@ public class ObjectInputStream * Reads in and returns enum constant, or null if enum type is * unresolvable. Sets passHandle to enum constant's assigned handle. */ - private Enum readEnum(boolean unshared) throws IOException { + private Enum readEnum(boolean unshared) throws IOException { if (bin.readByte() != TC_ENUM) { throw new InternalError(); } @@ -1713,24 +1713,26 @@ public class ObjectInputStream } String name = readString(false); - Enum en = null; - Class cl = desc.forClass(); + Enum result = null; + Class cl = desc.forClass(); if (cl != null) { try { - en = Enum.valueOf(cl, name); + @SuppressWarnings("unchecked") + Enum en = Enum.valueOf((Class)cl, name); + result = en; } catch (IllegalArgumentException ex) { throw (IOException) new InvalidObjectException( "enum constant " + name + " does not exist in " + cl).initCause(ex); } if (!unshared) { - handles.setObject(enumHandle, en); + handles.setObject(enumHandle, result); } } handles.finish(enumHandle); passHandle = enumHandle; - return en; + return result; } /** @@ -1941,7 +1943,7 @@ public class ObjectInputStream throws IOException { // REMIND: is isInstance check necessary? - Class cl = desc.forClass(); + Class cl = desc.forClass(); if (cl != null && obj != null && !cl.isInstance(obj)) { throw new ClassCastException(); } @@ -2140,7 +2142,7 @@ public class ObjectInputStream * class descriptor, returns -1. Throws IllegalArgumentException if * neither incoming nor local class descriptor contains a match. */ - private int getFieldOffset(String name, Class type) { + private int getFieldOffset(String name, Class type) { ObjectStreamField field = desc.getField(name, type); if (field != null) { return field.getOffset(); @@ -2838,6 +2840,7 @@ public class ObjectInputStream return readUTFBody(readUnsignedShort()); } + @SuppressWarnings("deprecation") public String readLine() throws IOException { return din.readLine(); // deprecated, not worth optimizing } diff --git a/src/share/classes/java/io/ObjectOutputStream.java b/src/share/classes/java/io/ObjectOutputStream.java index 76a08f38d4d360c9bb2927fb015563aabace3058..a93ea5109cf143859884c1e8f271a448d197628c 100644 --- a/src/share/classes/java/io/ObjectOutputStream.java +++ b/src/share/classes/java/io/ObjectOutputStream.java @@ -1034,7 +1034,7 @@ public class ObjectOutputStream * "enableSubclassImplementation" SerializablePermission is checked. */ private void verifySubclass() { - Class cl = getClass(); + Class cl = getClass(); if (cl == ObjectOutputStream.class) { return; } @@ -1060,17 +1060,17 @@ public class ObjectOutputStream * override security-sensitive non-final methods. Returns true if subclass * is "safe", false otherwise. */ - private static boolean auditSubclass(final Class subcl) { + private static boolean auditSubclass(final Class subcl) { Boolean result = AccessController.doPrivileged( new PrivilegedAction() { public Boolean run() { - for (Class cl = subcl; + for (Class cl = subcl; cl != ObjectOutputStream.class; cl = cl.getSuperclass()) { try { cl.getDeclaredMethod( - "writeUnshared", new Class[] { Object.class }); + "writeUnshared", new Class[] { Object.class }); return Boolean.FALSE; } catch (NoSuchMethodException ex) { } @@ -1122,11 +1122,11 @@ public class ObjectOutputStream // check for replacement object Object orig = obj; - Class cl = obj.getClass(); + Class cl = obj.getClass(); ObjectStreamClass desc; for (;;) { // REMIND: skip this check for strings/arrays? - Class repCl; + Class repCl; desc = ObjectStreamClass.lookup(cl, true); if (!desc.hasWriteReplaceMethod() || (obj = desc.invokeWriteReplace(obj)) == null || @@ -1169,7 +1169,7 @@ public class ObjectOutputStream } else if (cl.isArray()) { writeArray(obj, desc, unshared); } else if (obj instanceof Enum) { - writeEnum((Enum) obj, desc, unshared); + writeEnum((Enum) obj, desc, unshared); } else if (obj instanceof Serializable) { writeOrdinaryObject(obj, desc, unshared); } else { @@ -1204,7 +1204,7 @@ public class ObjectOutputStream /** * Writes representation of given class to stream. */ - private void writeClass(Class cl, boolean unshared) throws IOException { + private void writeClass(Class cl, boolean unshared) throws IOException { bout.writeByte(TC_CLASS); writeClassDesc(ObjectStreamClass.lookup(cl, true), false); handles.assign(unshared ? null : cl); @@ -1237,7 +1237,7 @@ public class ObjectOutputStream bout.writeByte(TC_PROXYCLASSDESC); handles.assign(unshared ? null : desc); - Class cl = desc.forClass(); + Class cl = desc.forClass(); Class[] ifaces = cl.getInterfaces(); bout.writeInt(ifaces.length); for (int i = 0; i < ifaces.length; i++) { @@ -1269,7 +1269,7 @@ public class ObjectOutputStream writeClassDescriptor(desc); } - Class cl = desc.forClass(); + Class cl = desc.forClass(); bout.setBlockDataMode(true); annotateClass(cl); bout.setBlockDataMode(false); @@ -1306,7 +1306,7 @@ public class ObjectOutputStream writeClassDesc(desc, false); handles.assign(unshared ? null : array); - Class ccl = desc.forClass().getComponentType(); + Class ccl = desc.forClass().getComponentType(); if (ccl.isPrimitive()) { if (ccl == Integer.TYPE) { int[] ia = (int[]) array; @@ -1377,7 +1377,7 @@ public class ObjectOutputStream /** * Writes given enum constant to stream. */ - private void writeEnum(Enum en, + private void writeEnum(Enum en, ObjectStreamClass desc, boolean unshared) throws IOException @@ -1700,7 +1700,7 @@ public class ObjectOutputStream * types, and any other non-null type matches assignable types only. * Throws IllegalArgumentException if no matching field found. */ - private int getFieldOffset(String name, Class type) { + private int getFieldOffset(String name, Class type) { ObjectStreamField field = desc.getField(name, type); if (field == null) { throw new IllegalArgumentException("no such field " + name + diff --git a/src/share/classes/java/io/ObjectStreamClass.java b/src/share/classes/java/io/ObjectStreamClass.java index f1c0d5b782f0b1c66c3e9df9d426f486c762393d..1a03b6b6a10d67880d1ea9df0a2b7f0047374e8e 100644 --- a/src/share/classes/java/io/ObjectStreamClass.java +++ b/src/share/classes/java/io/ObjectStreamClass.java @@ -144,7 +144,7 @@ public class ObjectStreamClass implements Serializable { private volatile ClassDataSlot[] dataLayout; /** serialization-appropriate constructor, or null if none */ - private Constructor cons; + private Constructor cons; /** class-defined writeObject method, or null if none */ private Method writeObjectMethod; /** class-defined readObject method, or null if none */ @@ -1308,9 +1308,9 @@ public class ObjectStreamClass implements Serializable { * Access checks are disabled on the returned constructor (if any), since * the defining class may still be non-public. */ - private static Constructor getExternalizableConstructor(Class cl) { + private static Constructor getExternalizableConstructor(Class cl) { try { - Constructor cons = cl.getDeclaredConstructor((Class[]) null); + Constructor cons = cl.getDeclaredConstructor((Class[]) null); cons.setAccessible(true); return ((cons.getModifiers() & Modifier.PUBLIC) != 0) ? cons : null; @@ -1324,7 +1324,7 @@ public class ObjectStreamClass implements Serializable { * superclass, or null if none found. Access checks are disabled on the * returned constructor (if any). */ - private static Constructor getSerializableConstructor(Class cl) { + private static Constructor getSerializableConstructor(Class cl) { Class initCl = cl; while (Serializable.class.isAssignableFrom(initCl)) { if ((initCl = initCl.getSuperclass()) == null) { @@ -1332,7 +1332,7 @@ public class ObjectStreamClass implements Serializable { } } try { - Constructor cons = initCl.getDeclaredConstructor((Class[]) null); + Constructor cons = initCl.getDeclaredConstructor((Class[]) null); int mods = cons.getModifiers(); if ((mods & Modifier.PRIVATE) != 0 || ((mods & (Modifier.PUBLIC | Modifier.PROTECTED)) == 0 && @@ -1802,7 +1802,7 @@ public class ObjectStreamClass implements Serializable { signature = getClassSignature(field.getType()); } - public MemberSignature(Constructor cons) { + public MemberSignature(Constructor cons) { member = cons; name = cons.getName(); signature = getMethodSignature( diff --git a/src/share/classes/java/io/SequenceInputStream.java b/src/share/classes/java/io/SequenceInputStream.java index f64ec38c622d763dec700f648c0a838020c7248c..efc3af71a652ac4e5b1a3e15db42e6612fe0d204 100644 --- a/src/share/classes/java/io/SequenceInputStream.java +++ b/src/share/classes/java/io/SequenceInputStream.java @@ -44,7 +44,7 @@ import java.util.Vector; */ public class SequenceInputStream extends InputStream { - Enumeration e; + Enumeration e; InputStream in; /** @@ -85,7 +85,7 @@ class SequenceInputStream extends InputStream { * @param s2 the second input stream to read. */ public SequenceInputStream(InputStream s1, InputStream s2) { - Vector v = new Vector(2); + Vector v = new Vector<>(2); v.addElement(s1); v.addElement(s2); diff --git a/src/share/classes/java/lang/ClassLoader.java b/src/share/classes/java/lang/ClassLoader.java index f8588f527a2c23e9066a6a4d0c615d0614555e20..d599396e8ad016e3c14c5c1767a5d243572c9e51 100644 --- a/src/share/classes/java/lang/ClassLoader.java +++ b/src/share/classes/java/lang/ClassLoader.java @@ -258,7 +258,7 @@ public abstract class ClassLoader { private final Set domains; // Invoked by the VM to record every loaded class with this loader. - void addClass(Class c) { + void addClass(Class c) { classes.addElement(c); } @@ -402,7 +402,7 @@ public abstract class ClassLoader { { synchronized (getClassLoadingLock(name)) { // First, check if the class has already been loaded - Class c = findLoadedClass(name); + Class c = findLoadedClass(name); if (c == null) { long t0 = System.nanoTime(); try { @@ -468,7 +468,7 @@ public abstract class ClassLoader { } // This method is invoked by the virtual machine to load a class. - private Class loadClassInternal(String name) + private Class loadClassInternal(String name) throws ClassNotFoundException { // For backward compatibility, explicitly lock on 'this' when @@ -483,7 +483,7 @@ public abstract class ClassLoader { } // Invoked by the VM after loading class with this loader. - private void checkPackageAccess(Class cls, ProtectionDomain pd) { + private void checkPackageAccess(Class cls, ProtectionDomain pd) { final SecurityManager sm = System.getSecurityManager(); if (sm != null) { final String name = cls.getName(); @@ -669,9 +669,9 @@ public abstract class ClassLoader { return source; } - private Class defineTransformedClass(String name, byte[] b, int off, int len, - ProtectionDomain pd, - ClassFormatError cfe, String source) + private Class defineTransformedClass(String name, byte[] b, int off, int len, + ProtectionDomain pd, + ClassFormatError cfe, String source) throws ClassFormatError { // Class format error - try to transform the bytecode and @@ -679,7 +679,7 @@ public abstract class ClassLoader { // ClassFileTransformer[] transformers = ClassFileTransformer.getTransformers(); - Class c = null; + Class c = null; if (transformers != null) { for (ClassFileTransformer transformer : transformers) { @@ -704,7 +704,7 @@ public abstract class ClassLoader { return c; } - private void postDefineClass(Class c, ProtectionDomain pd) + private void postDefineClass(Class c, ProtectionDomain pd) { if (pd.getCodeSource() != null) { Certificate certs[] = pd.getCodeSource().getCertificates(); @@ -784,7 +784,7 @@ public abstract class ClassLoader { { protectionDomain = preDefineClass(name, protectionDomain); - Class c = null; + Class c = null; String source = defineClassSourceLocation(protectionDomain); try { @@ -882,7 +882,7 @@ public abstract class ClassLoader { protectionDomain = preDefineClass(name, protectionDomain); - Class c = null; + Class c = null; String source = defineClassSourceLocation(protectionDomain); try { @@ -899,15 +899,15 @@ public abstract class ClassLoader { return c; } - private native Class defineClass0(String name, byte[] b, int off, int len, - ProtectionDomain pd); + private native Class defineClass0(String name, byte[] b, int off, int len, + ProtectionDomain pd); - private native Class defineClass1(String name, byte[] b, int off, int len, - ProtectionDomain pd, String source); + private native Class defineClass1(String name, byte[] b, int off, int len, + ProtectionDomain pd, String source); - private native Class defineClass2(String name, java.nio.ByteBuffer b, - int off, int len, ProtectionDomain pd, - String source); + private native Class defineClass2(String name, java.nio.ByteBuffer b, + int off, int len, ProtectionDomain pd, + String source); // true if the name is null or has the potential to be a valid binary name private boolean checkName(String name) { @@ -1010,7 +1010,7 @@ public abstract class ClassLoader { resolveClass0(c); } - private native void resolveClass0(Class c); + private native void resolveClass0(Class c); /** * Finds a class with the specified binary name, @@ -1041,7 +1041,7 @@ public abstract class ClassLoader { if (system == null) { if (!checkName(name)) throw new ClassNotFoundException(name); - Class cls = findBootstrapClass(name); + Class cls = findBootstrapClass(name); if (cls == null) { throw new ClassNotFoundException(name); } @@ -1054,7 +1054,7 @@ public abstract class ClassLoader { * Returns a class loaded by the bootstrap class loader; * or return null if not found. */ - private Class findBootstrapClassOrNull(String name) + private Class findBootstrapClassOrNull(String name) { if (!checkName(name)) return null; @@ -1062,7 +1062,7 @@ public abstract class ClassLoader { } // return null if not found - private native Class findBootstrapClass(String name); + private native Class findBootstrapClass(String name); /** * Returns the class with the given binary name if this @@ -1084,7 +1084,7 @@ public abstract class ClassLoader { return findLoadedClass0(name); } - private native final Class findLoadedClass0(String name); + private native final Class findLoadedClass0(String name); /** * Sets the signers of a class. This should be invoked after defining a @@ -1528,7 +1528,7 @@ public abstract class ClassLoader { // invocation and the desired invoker. static ClassLoader getCallerClassLoader() { // NOTE use of more generic Reflection.getCallerClass() - Class caller = Reflection.getCallerClass(3); + Class caller = Reflection.getCallerClass(3); // This can be null if the VM is requesting it if (caller == null) { return null; @@ -1722,7 +1722,7 @@ public abstract class ClassLoader { private int jniVersion; // the class from which the library is loaded, also indicates // the loader this native library belongs. - private Class fromClass; + private Class fromClass; // the canonicalized name of the native library. String name; @@ -1730,7 +1730,7 @@ public abstract class ClassLoader { native long find(String name); native void unload(); - public NativeLibrary(Class fromClass, String name) { + public NativeLibrary(Class fromClass, String name) { this.name = name; this.fromClass = fromClass; } @@ -1758,7 +1758,7 @@ public abstract class ClassLoader { } // Invoked in the VM to determine the context class in // JNI_Load/JNI_Unload - static Class getFromClass() { + static Class getFromClass() { return ClassLoader.nativeLibraryContext.peek().fromClass; } } @@ -1813,7 +1813,7 @@ public abstract class ClassLoader { } // Invoked in the java.lang.Runtime class to implement load and loadLibrary. - static void loadLibrary(Class fromClass, String name, + static void loadLibrary(Class fromClass, String name, boolean isAbsolute) { ClassLoader loader = (fromClass == null) ? null : fromClass.getClassLoader(); @@ -1860,7 +1860,7 @@ public abstract class ClassLoader { throw new UnsatisfiedLinkError("no " + name + " in java.library.path"); } - private static boolean loadLibrary0(Class fromClass, final File file) { + private static boolean loadLibrary0(Class fromClass, final File file) { boolean exists = AccessController.doPrivileged( new PrivilegedAction() { public Object run() { @@ -2194,8 +2194,8 @@ class SystemClassLoaderAction return parent; } - Constructor ctor = Class.forName(cls, true, parent) - .getDeclaredConstructor(new Class[] { ClassLoader.class }); + Constructor ctor = Class.forName(cls, true, parent) + .getDeclaredConstructor(new Class[] { ClassLoader.class }); ClassLoader sys = (ClassLoader) ctor.newInstance( new Object[] { parent }); Thread.currentThread().setContextClassLoader(sys); diff --git a/src/share/classes/java/lang/Enum.java b/src/share/classes/java/lang/Enum.java index 798ae3fa6f640f43c03db3dce01712626865500e..80fcd9c552643634094d1b114b1642e0fbdbc122 100644 --- a/src/share/classes/java/lang/Enum.java +++ b/src/share/classes/java/lang/Enum.java @@ -173,8 +173,8 @@ public abstract class Enum> * method is the order in which the constants are declared. */ public final int compareTo(E o) { - Enum other = (Enum)o; - Enum self = this; + Enum other = (Enum)o; + Enum self = this; if (self.getClass() != other.getClass() && // optimization self.getDeclaringClass() != other.getDeclaringClass()) throw new ClassCastException(); @@ -193,10 +193,11 @@ public abstract class Enum> * @return the Class object corresponding to this enum constant's * enum type */ + @SuppressWarnings("unchecked") public final Class getDeclaringClass() { - Class clazz = getClass(); - Class zuper = clazz.getSuperclass(); - return (zuper == Enum.class) ? clazz : zuper; + Class clazz = getClass(); + Class zuper = clazz.getSuperclass(); + return (zuper == Enum.class) ? (Class)clazz : (Class)zuper; } /** diff --git a/src/share/classes/java/lang/Package.java b/src/share/classes/java/lang/Package.java index 3ea8013238df12ab8462973fbdac2d888bc38a35..f7af97a65903b332e20b81f1b61d974f33f7c389 100644 --- a/src/share/classes/java/lang/Package.java +++ b/src/share/classes/java/lang/Package.java @@ -608,5 +608,5 @@ public class Package implements java.lang.reflect.AnnotatedElement { private final String implVendor; private final URL sealBase; private transient final ClassLoader loader; - private transient Class packageInfo; + private transient Class packageInfo; } diff --git a/src/share/classes/java/lang/Runtime.java b/src/share/classes/java/lang/Runtime.java index 3fc29d08376b69e3395758bf529fed7e5ded2d94..7f2ef469a20137be52db54b97376e9c6f00f8867 100644 --- a/src/share/classes/java/lang/Runtime.java +++ b/src/share/classes/java/lang/Runtime.java @@ -780,7 +780,7 @@ public class Runtime { load0(System.getCallerClass(), filename); } - synchronized void load0(Class fromClass, String filename) { + synchronized void load0(Class fromClass, String filename) { SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkLink(filename); @@ -833,7 +833,7 @@ public class Runtime { loadLibrary0(System.getCallerClass(), libname); } - synchronized void loadLibrary0(Class fromClass, String libname) { + synchronized void loadLibrary0(Class fromClass, String libname) { SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkLink(libname); diff --git a/src/share/classes/java/lang/SecurityManager.java b/src/share/classes/java/lang/SecurityManager.java index 27f7d90ca1a707b55e69baf704c6bfe51187b07b..f84fe3e16a56a7210b39a15eb957ae5d41108d64 100644 --- a/src/share/classes/java/lang/SecurityManager.java +++ b/src/share/classes/java/lang/SecurityManager.java @@ -400,7 +400,7 @@ class SecurityManager { */ @Deprecated protected Class currentLoadedClass() { - Class c = currentLoadedClass0(); + Class c = currentLoadedClass0(); if ((c != null) && hasAllPermission()) c = null; return c; @@ -1715,7 +1715,7 @@ class SecurityManager { checkPermission(new SecurityPermission(target)); } - private native Class currentLoadedClass0(); + private native Class currentLoadedClass0(); /** * Returns the thread group into which to instantiate any new diff --git a/src/share/classes/java/lang/System.java b/src/share/classes/java/lang/System.java index 5c33dd08fca5b6a259f6618949fd263f257c5aa2..6e4f7436cf826bdf905c7b72935c501bff658597 100644 --- a/src/share/classes/java/lang/System.java +++ b/src/share/classes/java/lang/System.java @@ -1171,13 +1171,13 @@ public final class System { private static void setJavaLangAccess() { // Allow privileged classes outside of java.lang sun.misc.SharedSecrets.setJavaLangAccess(new sun.misc.JavaLangAccess(){ - public sun.reflect.ConstantPool getConstantPool(Class klass) { + public sun.reflect.ConstantPool getConstantPool(Class klass) { return klass.getConstantPool(); } - public void setAnnotationType(Class klass, AnnotationType type) { + public void setAnnotationType(Class klass, AnnotationType type) { klass.setAnnotationType(type); } - public AnnotationType getAnnotationType(Class klass) { + public AnnotationType getAnnotationType(Class klass) { return klass.getAnnotationType(); } public > diff --git a/src/share/classes/java/lang/Thread.java b/src/share/classes/java/lang/Thread.java index 45393eb2373baf5fab60239651d95310231e25a1..b3d2e39d58ffc5759c67b41aee3b1429d187d816 100644 --- a/src/share/classes/java/lang/Thread.java +++ b/src/share/classes/java/lang/Thread.java @@ -1650,7 +1650,7 @@ class Thread implements Runnable { * security-sensitive non-final methods, or else the * "enableContextClassLoaderOverride" RuntimePermission is checked. */ - private static boolean isCCLOverridden(Class cl) { + private static boolean isCCLOverridden(Class cl) { if (cl == Thread.class) return false; @@ -1670,21 +1670,21 @@ class Thread implements Runnable { * override security-sensitive non-final methods. Returns true if the * subclass overrides any of the methods, false otherwise. */ - private static boolean auditSubclass(final Class subcl) { + private static boolean auditSubclass(final Class subcl) { Boolean result = AccessController.doPrivileged( new PrivilegedAction() { public Boolean run() { - for (Class cl = subcl; + for (Class cl = subcl; cl != Thread.class; cl = cl.getSuperclass()) { try { - cl.getDeclaredMethod("getContextClassLoader", new Class[0]); + cl.getDeclaredMethod("getContextClassLoader", new Class[0]); return Boolean.TRUE; } catch (NoSuchMethodException ex) { } try { - Class[] params = {ClassLoader.class}; + Class[] params = {ClassLoader.class}; cl.getDeclaredMethod("setContextClassLoader", params); return Boolean.TRUE; } catch (NoSuchMethodException ex) { diff --git a/src/share/classes/java/lang/ThreadGroup.java b/src/share/classes/java/lang/ThreadGroup.java index a0ec567f494bb3fe47e5ede7851d40bd07a1cb10..8b93210aafae20dea8eb2f5637d7264676a07aed 100644 --- a/src/share/classes/java/lang/ThreadGroup.java +++ b/src/share/classes/java/lang/ThreadGroup.java @@ -670,6 +670,7 @@ class ThreadGroup implements Thread.UncaughtExceptionHandler { * {@link Thread#suspend} for details. */ @Deprecated + @SuppressWarnings("deprecation") public final void suspend() { if (stopOrSuspend(true)) Thread.currentThread().suspend(); @@ -682,6 +683,7 @@ class ThreadGroup implements Thread.UncaughtExceptionHandler { * if (and only if) the current thread is found to be in this thread * group or one of its subgroups. */ + @SuppressWarnings("deprecation") private boolean stopOrSuspend(boolean suspend) { boolean suicide = false; Thread us = Thread.currentThread(); @@ -731,6 +733,7 @@ class ThreadGroup implements Thread.UncaughtExceptionHandler { * deadlock-prone. See {@link Thread#suspend} for details. */ @Deprecated + @SuppressWarnings("deprecation") public final void resume() { int ngroupsSnapshot; ThreadGroup[] groupsSnapshot; diff --git a/src/share/classes/java/rmi/MarshalledObject.java b/src/share/classes/java/rmi/MarshalledObject.java index cd881294995b0950b2b9d8bfebc9b1b93052cff8..4ac4a8bc303991288fed37c07d2ac147be22396e 100644 --- a/src/share/classes/java/rmi/MarshalledObject.java +++ b/src/share/classes/java/rmi/MarshalledObject.java @@ -156,6 +156,7 @@ public final class MarshalledObject implements Serializable { (locBytes == null ? null : new ByteArrayInputStream(locBytes)); MarshalledObjectInputStream in = new MarshalledObjectInputStream(bin, lin); + @SuppressWarnings("unchecked") T obj = (T) in.readObject(); in.close(); return obj; @@ -190,7 +191,7 @@ public final class MarshalledObject implements Serializable { return true; if (obj != null && obj instanceof MarshalledObject) { - MarshalledObject other = (MarshalledObject) obj; + MarshalledObject other = (MarshalledObject) obj; // if either is a ref to null, both must be if (objBytes == null || other.objBytes == null) diff --git a/src/share/classes/java/rmi/dgc/VMID.java b/src/share/classes/java/rmi/dgc/VMID.java index c9f1647e1f169256f9d6756b42f27d7c625ad05c..5e9c0a51b4b99386b1f9d8fae1a9ae6126ca6de2 100644 --- a/src/share/classes/java/rmi/dgc/VMID.java +++ b/src/share/classes/java/rmi/dgc/VMID.java @@ -118,7 +118,7 @@ public final class VMID implements java.io.Serializable { StringBuffer result = new StringBuffer(); if (addr != null) for (int i = 0; i < addr.length; ++ i) { - int x = (int) (addr[i] & 0xFF); + int x = addr[i] & 0xFF; result.append((x < 0x10 ? "0" : "") + Integer.toString(x, 16)); } diff --git a/src/share/classes/java/rmi/server/LogStream.java b/src/share/classes/java/rmi/server/LogStream.java index 4120e32de77ce46c75a6702aab4cae040c3412db..cc35f7a44075eecf60bf45c1c0684fc1d462ab31 100644 --- a/src/share/classes/java/rmi/server/LogStream.java +++ b/src/share/classes/java/rmi/server/LogStream.java @@ -39,7 +39,7 @@ import java.util.*; public class LogStream extends PrintStream { /** table mapping known log names to log stream objects */ - private static Hashtable known = new Hashtable(5); + private static Map known = new HashMap<>(5); /** default output stream for new logs */ private static PrintStream defaultStream = System.err; @@ -90,7 +90,7 @@ public class LogStream extends PrintStream { public static LogStream log(String name) { LogStream stream; synchronized (known) { - stream = (LogStream)known.get(name); + stream = known.get(name); if (stream == null) { stream = new LogStream(name, defaultStream); } diff --git a/src/share/classes/java/rmi/server/RemoteObject.java b/src/share/classes/java/rmi/server/RemoteObject.java index 31aab0c3fbd76794379d93b450f35117a1d70e4f..b3b32c5fb4154ae2c962281b0d7e1b568336de36 100644 --- a/src/share/classes/java/rmi/server/RemoteObject.java +++ b/src/share/classes/java/rmi/server/RemoteObject.java @@ -436,7 +436,7 @@ public abstract class RemoteObject implements Remote, java.io.Serializable { */ String internalRefClassName = RemoteRef.packagePrefix + "." + refClassName; - Class refClass = Class.forName(internalRefClassName); + Class refClass = Class.forName(internalRefClassName); try { ref = (RemoteRef) refClass.newInstance(); diff --git a/src/share/classes/sun/misc/JavaLangAccess.java b/src/share/classes/sun/misc/JavaLangAccess.java index c61f590cddae4f125a8d8cb4bef60dd5d33db3d7..d4805d87d4508b1687501b9da53b18e2e2e3a5c2 100644 --- a/src/share/classes/sun/misc/JavaLangAccess.java +++ b/src/share/classes/sun/misc/JavaLangAccess.java @@ -31,19 +31,19 @@ import sun.nio.ch.Interruptible; public interface JavaLangAccess { /** Return the constant pool for a class. */ - ConstantPool getConstantPool(Class klass); + ConstantPool getConstantPool(Class klass); /** * Set the AnnotationType instance corresponding to this class. * (This method only applies to annotation types.) */ - void setAnnotationType(Class klass, AnnotationType annotationType); + void setAnnotationType(Class klass, AnnotationType annotationType); /** * Get the AnnotationType instance corresponding to this class. * (This method only applies to annotation types.) */ - AnnotationType getAnnotationType(Class klass); + AnnotationType getAnnotationType(Class klass); /** * Returns the elements of an enum class or null if the diff --git a/src/share/classes/sun/misc/Launcher.java b/src/share/classes/sun/misc/Launcher.java index 3d9b336edc26a36d7296d1412115e05ee6965e4c..71b3d3bbce82f6f478e2e106620fd0f0fadcd89d 100644 --- a/src/share/classes/sun/misc/Launcher.java +++ b/src/share/classes/sun/misc/Launcher.java @@ -295,7 +295,7 @@ public class Launcher { /** * Override loadClass so we can checkPackageAccess. */ - public Class loadClass(String name, boolean resolve) + public Class loadClass(String name, boolean resolve) throws ClassNotFoundException { int i = name.lastIndexOf('.'); @@ -473,7 +473,7 @@ public class Launcher { public URLStreamHandler createURLStreamHandler(String protocol) { String name = PREFIX + "." + protocol + ".Handler"; try { - Class c = Class.forName(name); + Class c = Class.forName(name); return (URLStreamHandler)c.newInstance(); } catch (ReflectiveOperationException e) { throw new InternalError("could not load " + protocol + diff --git a/src/share/classes/sun/misc/Unsafe.java b/src/share/classes/sun/misc/Unsafe.java index dba16284b360d190b547c922aabe485fa2898d30..da7ec27986585aafa133e5e8e0088298945ccbab 100644 --- a/src/share/classes/sun/misc/Unsafe.java +++ b/src/share/classes/sun/misc/Unsafe.java @@ -81,7 +81,7 @@ public final class Unsafe { * access to the system properties. */ public static Unsafe getUnsafe() { - Class cc = sun.reflect.Reflection.getCallerClass(2); + Class cc = sun.reflect.Reflection.getCallerClass(2); if (cc.getClassLoader() != null) throw new SecurityException("Unsafe"); return theUnsafe; @@ -616,7 +616,7 @@ public final class Unsafe { * for a given class in one place. */ @Deprecated - public Object staticFieldBase(Class c) { + public Object staticFieldBase(Class c) { Field[] fields = c.getDeclaredFields(); for (int i = 0; i < fields.length; i++) { if (Modifier.isStatic(fields[i].getModifiers())) { @@ -682,7 +682,7 @@ public final class Unsafe { * needed in conjunction with obtaining the static field base of a * class. */ - public native void ensureClassInitialized(Class c); + public native void ensureClassInitialized(Class c); /** * Report the offset of the first element in the storage allocation of a @@ -694,7 +694,7 @@ public final class Unsafe { * @see #getInt(Object, long) * @see #putInt(Object, long, int) */ - public native int arrayBaseOffset(Class arrayClass); + public native int arrayBaseOffset(Class arrayClass); /** The value of {@code arrayBaseOffset(boolean[].class)} */ public static final int ARRAY_BOOLEAN_BASE_OFFSET @@ -743,7 +743,7 @@ public final class Unsafe { * @see #getInt(Object, long) * @see #putInt(Object, long, int) */ - public native int arrayIndexScale(Class arrayClass); + public native int arrayIndexScale(Class arrayClass); /** The value of {@code arrayIndexScale(boolean[].class)} */ public static final int ARRAY_BOOLEAN_INDEX_SCALE @@ -805,11 +805,11 @@ public final class Unsafe { * Tell the VM to define a class, without security checks. By default, the * class loader and protection domain come from the caller's class. */ - public native Class defineClass(String name, byte[] b, int off, int len, - ClassLoader loader, - ProtectionDomain protectionDomain); + public native Class defineClass(String name, byte[] b, int off, int len, + ClassLoader loader, + ProtectionDomain protectionDomain); - public native Class defineClass(String name, byte[] b, int off, int len); + public native Class defineClass(String name, byte[] b, int off, int len); /** * Define a class but do not make it known to the class loader or system dictionary. @@ -827,12 +827,12 @@ public final class Unsafe { * @params data bytes of a class file * @params cpPatches where non-null entries exist, they replace corresponding CP entries in data */ - public native Class defineAnonymousClass(Class hostClass, byte[] data, Object[] cpPatches); + public native Class defineAnonymousClass(Class hostClass, byte[] data, Object[] cpPatches); /** Allocate an instance but do not run any constructor. Initializes the class if it has not yet been. */ - public native Object allocateInstance(Class cls) + public native Object allocateInstance(Class cls) throws InstantiationException; /** Lock the object. It must get unlocked via {@link #monitorExit}. */ diff --git a/src/share/classes/sun/misc/VM.java b/src/share/classes/sun/misc/VM.java index e1fb584bb2cca0d79c819dbd5200e9f9ea4986a8..61b3b0fd97444168d69194ec6902ba0681d91993 100644 --- a/src/share/classes/sun/misc/VM.java +++ b/src/share/classes/sun/misc/VM.java @@ -48,6 +48,7 @@ public class VM { return suspended; } + @SuppressWarnings("deprecation") public static boolean allowThreadSuspension(ThreadGroup g, boolean b) { return g.allowThreadSuspension(b); }