From 98267c3d0fa25dea88f1757533f00b993ce7f491 Mon Sep 17 00:00:00 2001 From: "PSp..om" Date: Thu, 23 Jun 2011 08:19:06 +0000 Subject: [PATCH] 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 --- .../serializing/serializers/FieldSerializer.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/engine/src/networking/com/jme3/network/serializing/serializers/FieldSerializer.java b/engine/src/networking/com/jme3/network/serializing/serializers/FieldSerializer.java index 01c24c454..18c38b955 100644 --- a/engine/src/networking/com/jme3/network/serializing/serializers/FieldSerializer.java +++ b/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 savedFields = new HashMap(); + 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 fields = new ArrayList(); Class processingClass = clazz;