Home Help Center

Slice mapping for java.lang.Object

sattursasattursa Member Sandeep SatturOrganization: UBSProject: Trader Desk Top
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

  • mesmes CaliforniaAdministrators, ZeroC Staff Mark SpruiellOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    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
  • sattursasattursa Member Sandeep SatturOrganization: UBSProject: Trader Desk Top
    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?
  • mesmes CaliforniaAdministrators, ZeroC Staff Mark SpruiellOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    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
  • sattursasattursa Member Sandeep SatturOrganization: UBSProject: Trader Desk Top
    Slice mapping for java.lang.Object

    Hi Mark,

    Got it

    Thanks.

    Btw, does slice support methods with var args?
  • mesmes CaliforniaAdministrators, ZeroC Staff Mark SpruiellOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    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
Sign In or Register to comment.