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

["preserve-slice"] and Ice.Default.SlicedFormat=1


for slice preserving it is stated in the documentation (see link) that each operation needs to have the metadirective format:sliced attached to it.
Is this also the case if the property
Ice.Default.SlicedFormat=1 is used?



  • benoit
    benoit Rennes, France

    As stated in the documentation of the format metadata, the value of Ice.Default.SlicedFormat is used if no format metadata is specified. So you don't need to set format:sliced if you set Ice.Default.SlicedFormat=1.

    You are still required to set the preserve-slice metadata on a base class if you want to be able to preserve the slices. If you don't specify this metadata and you receive an object that needs to be sliced, the slices won't be preserved. This is fine if you don't need to forward the object to another peer but if you want to forward it as-is, you'll want to preserve its slices.

  • Thanks for the quick reply.
    Do I need to specify the preserve-slice in a class that has no classes it inherits from or can it be some class in the middle of the inheritance?

    An example to clarify:
    class A{};
    class B extends A {};
    class C extends B {};

    It don't need the preserving for all classes that inherit from A, only all classes that inherit from B.
    Does this work or does class A need to have the tag ["preserve-slice"]?
  • Also, does the preserving work with nested types (where the outer class possibly is not tagged with ["preserve-slice"])?
    Class B{};
    Class D
    Class B;
    interface MyInterface
          D getData();
  • benoit
    benoit Rennes, France
    Yes, you can set the preserve-slice metadata on any class of the class hierarchy so you're example is fine.

    It also works for objects which are nested within another data type, the object of type B will be sliced and its slice will be preserved when it's forwarded to another peer even if the object B is nested in the class D.

  • OK, thanks. So I need to debug deeper to find why it is not working for me.
  • The problem was that my class with the tag preserve-slice was abstract, so no factory for that type either, which led to my error that the slice-preserving did not work.