This would have saved me soooo much time. Serializer's

single-arg registerClass() method now throws an exception
if the object is not marked Serializable.  Internally,
the package-load stuff uses the new alternate method that
allows safe non-exception throwing registration since it's
hitting it with every class in a package.
Interestingly enough, messages will still get written out 
because of some questionable code in writeClassAndObject()...
but it won't be read as anything but null despite its
40+ bytes of data.


git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7121 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
PSp..om 2011-03-27 05:31:21 +00:00
parent 0a369b96d8
commit 99a21a8c1d

View File

@ -128,6 +128,10 @@ public abstract class Serializer {
}
public static SerializerRegistration registerClass(Class cls) {
return registerClass(cls, true);
}
public static SerializerRegistration registerClass(Class cls, boolean failOnMiss) {
if (cls.isAnnotationPresent(Serializable.class)) {
Serializable serializable = (Serializable)cls.getAnnotation(Serializable.class);
@ -151,6 +155,9 @@ public abstract class Serializer {
return reg;
}
if (failOnMiss) {
throw new IllegalArgumentException( "Class is not marked @Serializable:" + cls );
}
return null;
}
@ -172,7 +179,7 @@ public abstract class Serializer {
SerializerRegistration[] registeredClasses = new SerializerRegistration[classes.size()];
for (int i = 0; i != classes.size(); ++i) {
Class clz = classes.get(i);
registeredClasses[i] = registerClass(clz);
registeredClasses[i] = registerClass(clz, false);
}
return registeredClasses;
} catch (Exception e) {