Home Help Center

Sequence of classes in Slice?

bartleybartley Member Chris BartleyOrganization: Carnegie Mellon University Robotics InstituteProject: The Telepresence Robot Kit (TeRK) ✭✭
Is it not possible to have a sequence of classes in Slice while using the Java sequence mapping metadata?

For example, the Java generated by the following Slice compiles just fine:
#ifndef TEST_ICE
#define TEST_ICE

module TestModule
   {
   class Foo
      {
      int fooInt;
      };

   sequence<Foo> FooSet;

   interface Baz
      {
      FooSet getFoos();
      };
   };

#endif

But changing the declaration of FooSet to...
["java:type:java.util.HashSet<Foo>"] sequence<Foo> FooSet;

...causes the Java compilation die with the following error:
    [javac] Compiling 21 source files to D:\Test\build\java\src
    [javac] D:\Test\code\java\src-gen\TestModule\FooSetHelper.java:46: cannot find symbol
    [javac] symbol  : constructor ListPatcher(java.util.HashSet<TestModule.Foo>,java.lang.Class<TestModule.Foo>,java.lang.String,int)
    [javac] location: class IceInternal.ListPatcher
    [javac]         __is.readObject(new IceInternal.ListPatcher(__v, Foo.class, __type0, __i0));
    [javac]                             ^
    [javac] 1 error

But, if you then change the Foo class to a struct (but leave the sequence mapping metadata), then the Java compilation works again. Am I doing something wrong?

thanks,

Chris

Comments

  • mesmes CaliforniaAdministrators, ZeroC Staff Mark SpruiellOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    Hi Chris,

    It works when you change from a class to a struct only by accident. The Java mapping requires that any custom sequence type implement java.util.List, which is not true for java.util.HashSet.

    Take care,
    - Mark
  • bartleybartley Member Chris BartleyOrganization: Carnegie Mellon University Robotics InstituteProject: The Telepresence Robot Kit (TeRK) ✭✭
    Wow, thanks Mark. Somehow I'd totally missed the java.util.List requirement in the FAQ which explains the mapping metadata. Thanks!

    chris
Sign In or Register to comment.