Loading ...
Sorry, an error occurred while loading the content.

Java implementors question - java.lang.Object

Expand Messages
  • Pete Hendry
    We are looking closely at behaviour around the use of java.lang.Object. In particular, the use in collections and Maps. There has been discussion about how a
    Message 1 of 1 , Nov 14, 2001
    • 0 Attachment
      We are looking closely at behaviour around the use of java.lang.Object. In particular, the use in collections and Maps.
      There has been discussion about how a Map should be represented and Lists, Sets and Vectors can be represented as
      anyType[]. However, how do you ensure that what is received is the same as what was sent. For example, in Java, would
      the other toolkits serialize

      Integer[]

      and

      int[]

      the same on the wire? If so, then if I have the code

      Map map = new HashMap();
      map.put( "intArray", new int[] {1,2} );
      map.put( "integerArray", new Integer[] {new Integer(1),new Integer(2)} );

      and send this Map serialized something like

      <map SOAP-ENC:arrayType="..." >
      <item>
      <key xsi:type="xsd:string">intArray</key>
      <value xsi:type="tns:ArrayOfint" SOAP-ENC:arrayType="xsd:int[2]" >
      <item xsi:type="xsd:int">1</item>
      <item xsi:type="xsd:int">2</item>
      </value>
      </item>
      <item>
      <key xsi:type="xsd:string">integerArray</key>
      <value xsi:type="tns:ArrayOfint" SOAP-ENC:arrayType="xsd:int[2]" >
      <item xsi:type="xsd:int">1</item>
      <item xsi:type="xsd:int">2</item>
      </value>
      </item
      </map>

      In this case both int and Integer are mapped to xsd:int (you could say map Integer to xsd:integer which would fix this,
      but the same is also true for other arrays of primitives like short, boolean, etc.).

      On receiving this argument how do you tell which array was int[] and which was Integer[] when reconstructing the Map? I
      would suggest we need extra type information for this (perhaps in the form of an attribute).

      The problem is the same if you consider an interface such as

      void sendMessage( Object param )

      and the client sends either int[] or Integer[] (or short[], etc). There is no indication of the original type of the
      argument out of the 2 choices so it is not possible to accurately deserialize and call this method.

      Any ideas on how this could be addressed in a consistent manner or is it considered a non-issue? Does Apache deal with
      this as I seem to recall Apache Soap 2.2 had both primitive and primitive Object wrapper deserializers.

      Pete
    Your message has been successfully submitted and would be delivered to recipients shortly.