Index: src/net/xp_framework/unittest/ServerTest.java =================================================================== --- src/net/xp_framework/unittest/ServerTest.java (revision 12376) +++ src/net/xp_framework/unittest/ServerTest.java (working copy) @@ -200,7 +200,7 @@ @Test public void lookupPerson() throws Exception { assertAnswer( MessageType.Value, - "O:32:\"net.xp_framework.unittest.Person\":2:{s:2:\"id\";i:1549;s:4:\"name\";s:11:\"Timm Friebe\";}", + "O:32:\"net.xp_framework.unittest.Person\":3:{s:2:\"id\";i:1549;s:4:\"name\";s:11:\"Timm Friebe\";s:16:\"responsibilities\";A:2:{s:6:\"Leader\";s:10:\"Programmer\";}}", new Header( Header.DEFAULT_MAGIC_NUMBER, (byte)1, Index: src/net/xp_framework/unittest/Person.java =================================================================== --- src/net/xp_framework/unittest/Person.java (revision 12376) +++ src/net/xp_framework/unittest/Person.java (working copy) @@ -13,6 +13,7 @@ public class Person implements java.io.Serializable { public int id = 1549; public String name = "Timm Friebe"; + public String[] responsibilities = new String[] { "Leader", "Programmer" }; /** * Returns a string representation if this person object @@ -21,7 +22,24 @@ * @return java.lang.String */ @Override public String toString() { - return (this.getClass().getName() + "(" + id + ") [ name= '" + this.name + "']"); + StringBuilder s= new StringBuilder() + .append(this.getClass().getName()) + .append('(') + .append(id) + .append(") [ name = '") + .append(this.name) + .append(", responsibilities= ") + ; + if (null == this.responsibilities) { + s.append("(null)"); + } else { + s.append("[ "); + for (String responsibility: this.responsibilities) { + s.append("'").append(responsibility).append("' "); + } + s.append(" ]"); + } + return s.append(" ]").toString(); } /** @@ -36,7 +54,11 @@ if (!(o instanceof Person)) return false; // Short-cuircuit Person cmp= (Person)o; - return this.id == cmp.id && this.name.equals(cmp.name); + return ( + this.id == cmp.id && + this.name.equals(cmp.name) && + java.util.Arrays.equals(this.responsibilities, cmp.responsibilities) + ); } /** Index: src/net/xp_framework/unittest/SerializerTest.java =================================================================== --- src/net/xp_framework/unittest/SerializerTest.java (revision 12376) +++ src/net/xp_framework/unittest/SerializerTest.java (working copy) @@ -215,7 +215,7 @@ */ @Test public void representationOfPersonValueObject() throws Exception { assertEquals( - "O:32:\"net.xp_framework.unittest.Person\":2:{s:2:\"id\";i:1549;s:4:\"name\";s:11:\"Timm Friebe\";}", + "O:32:\"net.xp_framework.unittest.Person\":3:{s:2:\"id\";i:1549;s:4:\"name\";s:11:\"Timm Friebe\";s:16:\"responsibilities\";A:2:{s:6:\"Leader\";s:10:\"Programmer\";}}", representationOf(new Person()) ); } @@ -227,7 +227,7 @@ */ @Test public void representationOfEmployeeValueObject() throws Exception { assertEquals( - "O:34:\"net.xp_framework.unittest.Employee\":3:{s:15:\"personellNumber\";i:1375;s:2:\"id\";i:1549;s:4:\"name\";s:11:\"Timm Friebe\";}", + "O:34:\"net.xp_framework.unittest.Employee\":4:{s:15:\"personellNumber\";i:1375;s:2:\"id\";i:1549;s:4:\"name\";s:11:\"Timm Friebe\";s:16:\"responsibilities\";A:2:{s:6:\"Leader\";s:10:\"Programmer\";}}", representationOf(new Employee(1375)) ); } @@ -651,7 +651,7 @@ @Test public void valueOfPersonObject() throws Exception { assertEquals( new Person(), - valueOf("O:32:\"net.xp_framework.unittest.Person\":2:{s:2:\"id\";i:1549;s:4:\"name\";s:11:\"Timm Friebe\";}") + valueOf("O:32:\"net.xp_framework.unittest.Person\":3:{s:2:\"id\";i:1549;s:4:\"name\";s:11:\"Timm Friebe\";s:16:\"responsibilities\";A:2:{s:6:\"Leader\";s:10:\"Programmer\";}}") ); } @@ -663,7 +663,7 @@ @Test public void valueOfEmployeeObject() throws Exception { assertEquals( new Employee(1375), - valueOf("O:34:\"net.xp_framework.unittest.Employee\":3:{s:15:\"personellNumber\";i:1375;s:2:\"id\";i:1549;s:4:\"name\";s:11:\"Timm Friebe\";}") + valueOf("O:34:\"net.xp_framework.unittest.Employee\":4:{s:15:\"personellNumber\";i:1375;s:2:\"id\";i:1549;s:4:\"name\";s:11:\"Timm Friebe\";s:16:\"responsibilities\";A:2:{s:6:\"Leader\";s:10:\"Programmer\";}}") ); } @@ -720,7 +720,7 @@ * */ @Test public void valueOfArray() throws Exception { - Object[] result= (Object[])valueOf("A:2:{O:32:\"net.xp_framework.unittest.Person\":2:{s:2:\"id\";i:1549;s:4:\"name\";s:11:\"Timm Friebe\";}s:5:\"World\";}"); + Object[] result= (Object[])valueOf("A:2:{O:32:\"net.xp_framework.unittest.Person\":3:{s:2:\"id\";i:1549;s:4:\"name\";s:11:\"Timm Friebe\";s:16:\"responsibilities\";A:2:{s:6:\"Leader\";s:10:\"Programmer\";}}s:5:\"World\";}"); assertEquals(new Object[] { new Person(), new String("World") }, result); } Index: src/net/xp_framework/easc/protocol/standard/Serializer.java =================================================================== --- src/net/xp_framework/easc/protocol/standard/Serializer.java (revision 12376) +++ src/net/xp_framework/easc/protocol/standard/Serializer.java (working copy) @@ -216,10 +216,23 @@ String arraylength= serialized.substring(2, serialized.indexOf(':', 2)); int parsed= Integer.parseInt(arraylength); int offset= arraylength.length() + 2 + 2; - Object[] array= new Object[parsed]; + Object[] array; + + if (null == clazz) { + array= new Object[parsed]; + } else if (clazz.isArray()) { + array= (Object[])java.lang.reflect.Array.newInstance(clazz.getComponentType(), parsed); + } else { + throw new SerializationException("Trying to deserialize an array to non-array type " + clazz.getName()); + } for (int i= 0; i < parsed; i++) { - array[i]= Serializer.valueOf(serialized.substring(offset), length, context, null); + Object value= Serializer.valueOf(serialized.substring(offset), length, context, null); + try { + array[i]= value; + } catch (java.lang.ArrayStoreException e) { + throw new SerializationException(array.getClass() + "[" + i + "]= " + value.getClass()); + } offset+= length.value; }