Archived

This forum has been archived. Please start a new discussion on GitHub.

Slice mapping for java.lang.Object

How can I define a slice interface method with a very generic parameter which gets translated to java.lang.Object in the generated java code?

Thanks,
Sandeep

Comments

  • mes
    mes California
    Hi,

    Ice can only marshal types that are defined in Slice, and there is no marshalable type in Slice that maps to java.lang.Object. The Slice keyword Object represents the base type for Ice objects and maps to Ice.Object in Java. If you are looking for a way to send arbitrary Java types, one possibility is to serialize them and send them as the Slice type sequence<byte>.

    Hope that helps,
    Mark
  • Slice mapping for java.lang.Object

    Hi,

    I was considering using byte[] as a last resort. I think, I will have to use
    the streaming API to convert params to byte[] and back. Is this correct?


    For the other option, using Ice.Object, I guess java types have
    to be converted to corresponding subclasses of Ice.Object on the client
    side. Can you please point me to the relevant references for implementing
    this?
  • mes
    mes California
    sattursa wrote: »
    I was considering using byte[] as a last resort. I think, I will have to use
    the streaming API to convert params to byte[] and back. Is this correct?
    The Ice streaming API only supports Slice types so you cannot use it to serialize a java.lang.Object, at least not directly. It would probably be simpler to use Java's serialization mechanism instead.
    For the other option, using Ice.Object, I guess java types have
    to be converted to corresponding subclasses of Ice.Object on the client
    side. Can you please point me to the relevant references for implementing
    this?
    Essentially you would need to define a Slice class that is equivalent to each Java type you wish to transmit. The Slice-to-Java mapping for classes is described here.

    Take care,
    Mark
  • Slice mapping for java.lang.Object

    Hi Mark,

    Got it

    Thanks.

    Btw, does slice support methods with var args?
  • mes
    mes California
    sattursa wrote: »
    Btw, does slice support methods with var args?
    No, I'm afraid you'll have to use a sequence, dictionary, or some other Slice data structure in place of a variable argument list.

    Regards,
    Mark