Archived
This forum has been archived. Please start a new discussion on GitHub.
Sequence of classes in Slice?
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:
But changing the declaration of FooSet to...
...causes the Java compilation die with the following 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
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
0
Comments
-
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,
- Mark0 -
Wow, thanks Mark. Somehow I'd totally missed the java.util.List requirement in the FAQ which explains the mapping metadata. Thanks!
chris0