[Ikvm-developers] java.lang.class.getFields() ikvmc compatability problem
Brought to you by:
jfrijters
|
From: Brian S. <bri...@gm...> - 2007-04-26 05:35:36
|
We created a test case where java.lang.class.getFields() produces a different order when compiled statically using ikvmc. When using the native java code or using ikvm the output is public java.lang.String TestFields$TestFieldClass.receiverCode public short TestFields$TestFieldClass.receiverId When compiling using ikvmc 0.34 rc2 and running the created executable the output is public short TestFields$TestFieldClass.receiverId public java.lang.String TestFields$TestFieldClass.receiverCode This causes a compatibility problem when we send data over the network from a server using the native java library to a c# client that was compiled with ikvmc. When we send data a serializer is dynamically created for the class that needs to be sent over the network. The serializer depends on the order of getFields. The client depends on the fact that the server serializer runs same. When getFields produces a different order on the server or client the data is out of order. The problem is mentioned below in this blog http://blogs.msdn.com/haibo_luo/archive/2006/07/09/661091.aspx Test Case: IKVMGetFieldsTest.java import java.lang.reflect.Field; public class IKVMGetFieldsTest { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Field[] myFields = TestFields.TestFieldClass.class.getFields(); for (Field myField : myFields) { System.out.println(myField.toString()); } } } TestFields.java public interface TestFields { public static class TestFieldClass { public String receiverCode; /** * The unique id assigned to this invocation receiver class at * registration time. */ public short receiverId; } } |