It's nice that you can specify Java metadata for sequence classes to turn them into Lists instead of arrays. However, the default mapping doesn't do quite what I'd want ... consider the following Ice file:
If you run slice2java on that file, you get almost identical Java for the two classes. However, the read() method for StringList1Helper looks like this (note the bolded line):Code:module test { ["java:type:java.util.LinkedList"] sequence<string> StringList1; ["java:type:java.util.LinkedList<java.lang.String>"] sequence<string> StringList2; };
While for StringList2Helper, it looks like this:Code:public static java.util.List<java.lang.String> read(IceInternal.BasicStream __is) { java.util.List<java.lang.String> __v; __v = new java.util.LinkedList(); final int __len0 = __is.readAndCheckSeqSize(1); for(int __i0 = 0; __i0 < __len0; __i0++) { String __elem; __elem = __is.readString(); __v.add(__elem); } return __v; }
So in both cases, slice2java clearly knows it's actually using a java.util.List<java.lang.String>, whether you specify the <T> parameter or not in the metadata (look at the return value). However, for StringList1, it's constructing a raw java.util.LinkedList instead of a java.util.LinkedList<java.lang.String> inside the read() method, which causes Eclipse compiler warnings.Code:public static java.util.List<java.lang.String> read(IceInternal.BasicStream __is) { java.util.List<java.lang.String> __v; __v = new java.util.LinkedList<java.lang.String>(); final int __len0 = __is.readAndCheckSeqSize(1); for(int __i0 = 0; __i0 < __len0; __i0++) { String __elem; __elem = __is.readString(); __v.add(__elem); } return __v; }
It seems like this is a bug, unless I'm missing something ...

Reply With Quote
)