Fixed a bunch of type safety bits pointed out by the latest version of Eclipse.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5274 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -35,7 +35,7 @@ import java.util.RandomAccess;
|
||||
public class BasicStreamers
|
||||
{
|
||||
/** An array of types for all of the basic streamers. */
|
||||
public static Class[] BSTREAMER_TYPES = {
|
||||
public static Class<?>[] BSTREAMER_TYPES = {
|
||||
Boolean.class,
|
||||
Byte.class,
|
||||
Short.class,
|
||||
@@ -419,7 +419,7 @@ public class BasicStreamers
|
||||
public void writeObject (Object object, ObjectOutputStream out, boolean useWriter)
|
||||
throws IOException
|
||||
{
|
||||
writeList(out, (List)object);
|
||||
writeList(out, (List<?>)object);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -538,7 +538,7 @@ public class BasicStreamers
|
||||
return value;
|
||||
}
|
||||
|
||||
public static ArrayList readList (ObjectInputStream ins)
|
||||
public static ArrayList<?> readList (ObjectInputStream ins)
|
||||
throws IOException, ClassNotFoundException
|
||||
{
|
||||
int ecount = ins.readInt();
|
||||
@@ -637,7 +637,7 @@ public class BasicStreamers
|
||||
}
|
||||
}
|
||||
|
||||
public static void writeList (ObjectOutputStream out, List value)
|
||||
public static void writeList (ObjectOutputStream out, List<?> value)
|
||||
throws IOException
|
||||
{
|
||||
int ecount = value.size();
|
||||
|
||||
@@ -28,10 +28,10 @@ package com.threerings.io;
|
||||
class ClassMapping
|
||||
{
|
||||
public short code;
|
||||
public Class sclass;
|
||||
public Class<?> sclass;
|
||||
public Streamer streamer;
|
||||
|
||||
public ClassMapping (short code, Class sclass, Streamer streamer)
|
||||
public ClassMapping (short code, Class<?> sclass, Streamer streamer)
|
||||
{
|
||||
this.code = code;
|
||||
this.sclass = sclass;
|
||||
|
||||
@@ -79,7 +79,7 @@ public abstract class FieldMarshaller
|
||||
}
|
||||
}
|
||||
|
||||
Class ftype = field.getType();
|
||||
Class<?> ftype = field.getType();
|
||||
if (ftype.isInterface()) {
|
||||
// if the class is a pure interface, use Object.
|
||||
ftype = Object.class;
|
||||
@@ -212,7 +212,7 @@ public abstract class FieldMarshaller
|
||||
protected static void createMarshallers ()
|
||||
{
|
||||
// create our table
|
||||
_marshallers = new HashMap<Class, FieldMarshaller>();
|
||||
_marshallers = new HashMap<Class<?>, FieldMarshaller>();
|
||||
|
||||
// create a generic marshaller for streamable instances
|
||||
FieldMarshaller gmarsh = new FieldMarshaller() {
|
||||
@@ -354,11 +354,11 @@ public abstract class FieldMarshaller
|
||||
}
|
||||
|
||||
/** Contains a mapping from field type to field marshaller instance for that type. */
|
||||
protected static HashMap<Class, FieldMarshaller> _marshallers;
|
||||
protected static HashMap<Class<?>, FieldMarshaller> _marshallers;
|
||||
|
||||
/** Defines the signature to a custom field reader method. */
|
||||
protected static final Class[] READER_ARGS = { ObjectInputStream.class };
|
||||
protected static final Class<?>[] READER_ARGS = { ObjectInputStream.class };
|
||||
|
||||
/** Defines the signature to a custom field writer method. */
|
||||
protected static final Class[] WRITER_ARGS = { ObjectOutputStream.class };
|
||||
protected static final Class<?>[] WRITER_ARGS = { ObjectOutputStream.class };
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ public class ObjectInputStream extends DataInputStream
|
||||
throws IOException, ClassNotFoundException
|
||||
{
|
||||
// resolve the class and streamer
|
||||
Class sclass = Class.forName(cname, true, _loader);
|
||||
Class<?> sclass = Class.forName(cname, true, _loader);
|
||||
Streamer streamer = Streamer.getStreamer(sclass);
|
||||
if (STREAM_DEBUG) {
|
||||
log.info(hashCode() + ": New class '" + cname + "' [code=" + code + "].");
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.io.OutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.threerings.NaryaLog.log;
|
||||
|
||||
@@ -71,11 +72,11 @@ public class ObjectOutputStream extends DataOutputStream
|
||||
|
||||
// create our classmap if necessary
|
||||
if (_classmap == null) {
|
||||
_classmap = new HashMap<Class, ClassMapping>();
|
||||
_classmap = new HashMap<Class<?>, ClassMapping>();
|
||||
}
|
||||
|
||||
// otherwise, look up the class mapping record
|
||||
Class sclass = Streamer.getStreamerClass(object);
|
||||
Class<?> sclass = Streamer.getStreamerClass(object);
|
||||
ClassMapping cmap = _classmap.get(sclass);
|
||||
|
||||
// create a class mapping for this class if we've not got one
|
||||
@@ -108,7 +109,7 @@ public class ObjectOutputStream extends DataOutputStream
|
||||
/**
|
||||
* Creates and returns a new class mapping.
|
||||
*/
|
||||
protected ClassMapping createClassMapping (short code, Class sclass, Streamer streamer)
|
||||
protected ClassMapping createClassMapping (short code, Class<?> sclass, Streamer streamer)
|
||||
{
|
||||
return new ClassMapping(code, sclass, streamer);
|
||||
}
|
||||
@@ -135,7 +136,7 @@ public class ObjectOutputStream extends DataOutputStream
|
||||
/**
|
||||
* Writes out the mapping for a class.
|
||||
*/
|
||||
protected void writeClassMapping (int code, Class sclass)
|
||||
protected void writeClassMapping (int code, Class<?> sclass)
|
||||
throws IOException
|
||||
{
|
||||
writeShort(code);
|
||||
@@ -200,7 +201,7 @@ public class ObjectOutputStream extends DataOutputStream
|
||||
|
||||
/** Used to map classes to numeric codes and the {@link Streamer} instance used to write
|
||||
* them. */
|
||||
protected HashMap<Class, ClassMapping> _classmap;
|
||||
protected Map<Class<?>, ClassMapping> _classmap;
|
||||
|
||||
/** A counter used to assign codes to streamed classes. */
|
||||
protected short _nextCode = 1;
|
||||
@@ -212,5 +213,5 @@ public class ObjectOutputStream extends DataOutputStream
|
||||
protected Streamer _streamer;
|
||||
|
||||
/** An optional set of class name translations to use when serializing objects. */
|
||||
protected HashMap<String, String> _translations;
|
||||
protected Map<String, String> _translations;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ import java.security.PrivilegedActionException;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
@@ -54,7 +55,7 @@ public class Streamer
|
||||
/**
|
||||
* Returns true if the supplied target class can be streamed using a streamer.
|
||||
*/
|
||||
public synchronized static boolean isStreamable (Class target)
|
||||
public synchronized static boolean isStreamable (Class<?> target)
|
||||
{
|
||||
while (true) {
|
||||
// if we've got a streamer for it, it's good
|
||||
@@ -82,10 +83,10 @@ public class Streamer
|
||||
* object's natural class, but for enum values, that might be its declaring class as enums use
|
||||
* classes in a way that would otherwise pollute our id to class mapping space.
|
||||
*/
|
||||
public static Class getStreamerClass (Object object)
|
||||
public static Class<?> getStreamerClass (Object object)
|
||||
{
|
||||
return (object instanceof Enum) ?
|
||||
((Enum)object).getDeclaringClass() : object.getClass();
|
||||
((Enum<?>)object).getDeclaringClass() : object.getClass();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,7 +101,7 @@ public class Streamer
|
||||
* {@link Streamable} and is not one of the basic object types (@see {@link
|
||||
* ObjectOutputStream}).
|
||||
*/
|
||||
public synchronized static Streamer getStreamer (final Class target)
|
||||
public synchronized static Streamer getStreamer (final Class<?> target)
|
||||
throws IOException
|
||||
{
|
||||
// if we have not yet initialized ourselves, do so now
|
||||
@@ -211,7 +212,7 @@ public class Streamer
|
||||
// if someone serializes an enum to a file and then adds a value to the enum, changing the
|
||||
// ordinal assignments)
|
||||
if (_target.isEnum()) {
|
||||
out.writeUTF(((Enum)object).name());
|
||||
out.writeUTF(((Enum<?>)object).name());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -262,8 +263,9 @@ public class Streamer
|
||||
if (ObjectInputStream.STREAM_DEBUG) {
|
||||
log.info(in.hashCode() + ": Creating enum '" + _target.getName() + "'.");
|
||||
}
|
||||
@SuppressWarnings("unchecked") Object value = Enum.valueOf(_target, in.readUTF());
|
||||
return value;
|
||||
@SuppressWarnings("unchecked") Class<EnumReader> eclass =
|
||||
(Class<EnumReader>)_target;
|
||||
return Enum.valueOf(eclass, in.readUTF());
|
||||
|
||||
} else {
|
||||
if (ObjectInputStream.STREAM_DEBUG) {
|
||||
@@ -482,7 +484,7 @@ public class Streamer
|
||||
*/
|
||||
protected static void createStreamers ()
|
||||
{
|
||||
_streamers = new HashMap<Class, Streamer>();
|
||||
_streamers = new HashMap<Class<?>, Streamer>();
|
||||
|
||||
// register all of the basic streamers
|
||||
int bscount = BasicStreamers.BSTREAMER_TYPES.length;
|
||||
@@ -491,9 +493,12 @@ public class Streamer
|
||||
BasicStreamers.BSTREAMER_INSTANCES[ii]);
|
||||
}
|
||||
}
|
||||
|
||||
/** Used to coerce the type system into quietude when reading enums from the wire. */
|
||||
protected static enum EnumReader { NOT_USED };
|
||||
|
||||
/** The class for which this streamer instance is configured. */
|
||||
protected Class _target;
|
||||
protected Class<?> _target;
|
||||
|
||||
/** If our target class is an array, this is a reference to a streamer that can stream our
|
||||
* array elements, otherwise it is null. */
|
||||
@@ -513,7 +518,7 @@ public class Streamer
|
||||
protected Method _writer;
|
||||
|
||||
/** Contains the mapping from class names to configured streamer instances. */
|
||||
protected static HashMap<Class, Streamer> _streamers;
|
||||
protected static Map<Class<?>, Streamer> _streamers;
|
||||
|
||||
/** A simple predicate to filter "NotStreamable" members from a Streamable object's fields. */
|
||||
protected static final Predicate<Field> _isStreamableFieldPred = new Predicate<Field>() {
|
||||
@@ -526,11 +531,11 @@ public class Streamer
|
||||
protected static final String READER_METHOD_NAME = "readObject";
|
||||
|
||||
/** The argument list for the custom reader method. */
|
||||
protected static final Class[] READER_ARGS = { ObjectInputStream.class };
|
||||
protected static final Class<?>[] READER_ARGS = { ObjectInputStream.class };
|
||||
|
||||
/** The name of the custom writer method. */
|
||||
protected static final String WRITER_METHOD_NAME = "writeObject";
|
||||
|
||||
/** The argument list for the custom writer method. */
|
||||
protected static final Class[] WRITER_ARGS = { ObjectOutputStream.class };
|
||||
protected static final Class<?>[] WRITER_ARGS = { ObjectOutputStream.class };
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class UnreliableObjectOutputStream extends ObjectOutputStream
|
||||
* Sets the reference to the set that will hold the classes for which mappings have been
|
||||
* written.
|
||||
*/
|
||||
public void setMappedClasses (Set<Class> mappedClasses)
|
||||
public void setMappedClasses (Set<Class<?>> mappedClasses)
|
||||
{
|
||||
_mappedClasses = mappedClasses;
|
||||
}
|
||||
@@ -37,7 +37,7 @@ public class UnreliableObjectOutputStream extends ObjectOutputStream
|
||||
/**
|
||||
* Returns a reference to the set of classes for which mappings have been written.
|
||||
*/
|
||||
public Set<Class> getMappedClasses ()
|
||||
public Set<Class<?>> getMappedClasses ()
|
||||
{
|
||||
return _mappedClasses;
|
||||
}
|
||||
@@ -46,7 +46,7 @@ public class UnreliableObjectOutputStream extends ObjectOutputStream
|
||||
* Notes that the receiver has received the mappings for a group of classes, and thus that from
|
||||
* now on, only the class codes need be sent.
|
||||
*/
|
||||
public void noteMappingsReceived (Collection<Class> sclasses)
|
||||
public void noteMappingsReceived (Collection<Class<?>> sclasses)
|
||||
{
|
||||
// sanity check
|
||||
if (_classmap == null) {
|
||||
@@ -54,7 +54,7 @@ public class UnreliableObjectOutputStream extends ObjectOutputStream
|
||||
}
|
||||
|
||||
// make each class's code positive to signify that we no longer need to send metadata
|
||||
for (Class sclass : sclasses) {
|
||||
for (Class<?> sclass : sclasses) {
|
||||
ClassMapping cmap = _classmap.get(sclass);
|
||||
if (cmap == null) {
|
||||
throw new RuntimeException("No class mapping for " + sclass.getName());
|
||||
@@ -64,7 +64,7 @@ public class UnreliableObjectOutputStream extends ObjectOutputStream
|
||||
}
|
||||
|
||||
@Override // documentation inherited
|
||||
protected ClassMapping createClassMapping (short code, Class sclass, Streamer streamer)
|
||||
protected ClassMapping createClassMapping (short code, Class<?> sclass, Streamer streamer)
|
||||
{
|
||||
// the negative class code indicates that we must rewrite the metadata for the first
|
||||
// instance in each go-round; when we are notified that the other side has cached the
|
||||
@@ -98,7 +98,7 @@ public class UnreliableObjectOutputStream extends ObjectOutputStream
|
||||
}
|
||||
|
||||
@Override // documentation inherited
|
||||
protected void writeClassMapping (int code, Class sclass)
|
||||
protected void writeClassMapping (int code, Class<?> sclass)
|
||||
throws IOException
|
||||
{
|
||||
super.writeClassMapping(code, sclass);
|
||||
@@ -108,5 +108,5 @@ public class UnreliableObjectOutputStream extends ObjectOutputStream
|
||||
}
|
||||
|
||||
/** The set of classes for which we have written mappings. */
|
||||
protected Set<Class> _mappedClasses = new HashSet<Class>();
|
||||
protected Set<Class<?>> _mappedClasses = new HashSet<Class<?>>();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user