Added a check for no-arg constructor during initialize

to avoid having to wait to find this out until a message
is sent.


git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7694 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
PSp..om 14 years ago
parent 1e9ba3c0b0
commit 98267c3d0f
  1. 13
      engine/src/networking/com/jme3/network/serializing/serializers/FieldSerializer.java

@ -51,7 +51,20 @@ import java.util.logging.Level;
public class FieldSerializer extends Serializer {
private static Map<Class, SavedField[]> savedFields = new HashMap<Class, SavedField[]>();
protected void checkClass(Class clazz) {
// See if the class has a public no-arg constructor
try {
clazz.getConstructor();
} catch( NoSuchMethodException e ) {
throw new RuntimeException( "Registration error: no-argument constructor not found on:" + clazz );
}
}
public void initialize(Class clazz) {
checkClass(clazz);
List<Field> fields = new ArrayList<Field>();
Class processingClass = clazz;

Loading…
Cancel
Save