提交 3e00a900 编写于 作者: A alanb

7116404: Miscellaneous warnings (java.rmi.**, serialization, some core classes)

Reviewed-by: lancea, chegar, smarks
上级 3e7e23be
......@@ -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
}
/**
......
......@@ -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
}
......
......@@ -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<Boolean>() {
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 +
......
......@@ -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(
......
......@@ -44,7 +44,7 @@ import java.util.Vector;
*/
public
class SequenceInputStream extends InputStream {
Enumeration e;
Enumeration<? extends InputStream> 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<InputStream> v = new Vector<>(2);
v.addElement(s1);
v.addElement(s2);
......
......@@ -258,7 +258,7 @@ public abstract class ClassLoader {
private final Set<ProtectionDomain> 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,7 +669,7 @@ public abstract class ClassLoader {
return source;
}
private Class defineTransformedClass(String name, byte[] b, int off, int len,
private Class<?> defineTransformedClass(String name, byte[] b, int off, int len,
ProtectionDomain pd,
ClassFormatError cfe, String source)
throws ClassFormatError
......@@ -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,13 +899,13 @@ public abstract class ClassLoader {
return c;
}
private native Class defineClass0(String name, byte[] b, int off, int len,
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,
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,
private native Class<?> defineClass2(String name, java.nio.ByteBuffer b,
int off, int len, ProtectionDomain pd,
String source);
......@@ -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 <a href="#name">binary name</a>,
......@@ -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 <a href="#name">binary name</a> 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<Object>() {
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);
......
......@@ -173,8 +173,8 @@ public abstract class Enum<E extends Enum<E>>
* 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<E> self = this;
if (self.getClass() != other.getClass() && // optimization
self.getDeclaringClass() != other.getDeclaringClass())
throw new ClassCastException();
......@@ -193,10 +193,11 @@ public abstract class Enum<E extends Enum<E>>
* @return the Class object corresponding to this enum constant's
* enum type
*/
@SuppressWarnings("unchecked")
public final Class<E> 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<E>)clazz : (Class<E>)zuper;
}
/**
......
......@@ -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;
}
......@@ -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);
......
......@@ -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
......
......@@ -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 <E extends Enum<E>>
......
......@@ -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<Boolean>() {
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) {
......
......@@ -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;
......
......@@ -156,6 +156,7 @@ public final class MarshalledObject<T> 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<T> 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)
......
......@@ -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));
}
......
......@@ -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<String,LogStream> 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);
}
......
......@@ -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();
......
......@@ -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
......
......@@ -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 +
......
......@@ -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,
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}. */
......
......@@ -48,6 +48,7 @@ public class VM {
return suspended;
}
@SuppressWarnings("deprecation")
public static boolean allowThreadSuspension(ThreadGroup g, boolean b) {
return g.allowThreadSuspension(b);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册