Hello,
I'm playing a bit with JGN and it looks nice...
I ran into a NullPointerException using SharedObjects with Lists and Maps. The reason for that is the class information that is passed into the converters is null. I have added the class information into the serialization stream and that fixes the problem.
Index: CollectionConverter.java
===================================================================
--- CollectionConverter.java (revision 1287)
+++ CollectionConverter.java (working copy)
@@ -18,6 +18,7 @@
public class CollectionConverter extends Converter {
public void writeObjectData (MessageClient client, Object object, ByteBuffer buffer) throws ConversionException {
Collection collection = (Collection)object;
+ Converter.writeClass(client, collection.getClass(), buffer);
int length = collection.size();
BufferUtil.writeInt(buffer, length);
if (length == 0) return;
@@ -46,8 +47,9 @@
}
public <T> T readObjectData (ByteBuffer buffer, Class<T> c) throws ConversionException {
+ Collection collection = (Collection)newInstance(Converter.readClass(buffer));
int length = BufferUtil.readInt(buffer);
- Collection collection = (Collection)newInstance(c);
+ //Collection collection = (Collection)newInstance(c);
if (length == 0) return (T)collection;
if (buffer.get() == 1) {
Class elementClass = Converter.readClass(buffer);
@@ -60,5 +62,5 @@
}
return (T)collection;
}
-
+
}
Index: MapConverter.java
===================================================================
--- MapConverter.java (revision 1287)
+++ MapConverter.java (working copy)
@@ -22,6 +22,7 @@
public class MapConverter extends Converter {
public void writeObjectData (MessageClient client, Object object, ByteBuffer buffer) throws ConversionException {
Map<Object, Object> map = (Map)object;
+ Converter.writeClass(client, map.getClass(), buffer);
int length = map.size();
BufferUtil.writeInt(buffer, length);
if (length == 0) return;
@@ -72,7 +73,8 @@
}
public <T> T readObjectData (ByteBuffer buffer, Class<T> c) throws ConversionException {
- Map map = (Map)newInstance(c);
+ Map map = (Map)newInstance(Converter.readClass(buffer));
+ //Map map = (Map)newInstance(c);
int length = BufferUtil.readInt(buffer);
if (length == 0) return (T)map;
// Read element types and get converters.