-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use collection interfaces instead of concrete types in generated Java classes #1116
Comments
No particular reason, except that
Just out of curiosity, which other implementation of |
Thanks for taking a look at this @generalmimon .
It's not so much that I'd like to use a different implementation, but I'd like to use values returned from interfaces which return a For example, when calling |
I agree that it generally makes sense, especially in context of serialization (=supplying structures) as opposed to deserialization (=consuming whatever you've been given). With the advent of serialization into the master branch, maybe it's a good idea to correlate that with these changes (at least we're not breaking things twice). It will be likely still quite non-trivial, as you'll end up having to solve problems with construction of all these arrays, e.g. instead of this.aint = new ArrayList<Long>();
for (int i = 0; i < 4; i++) {
this.aint.add(this._io.readU4le());
} it will be more complicated something like: List<Long> aint;
// ...
ArrayList<Long> tmpAint = new ArrayList<Long>();
this.aint = tmpAint;
for (int i = 0; i < 4; i++) {
tmpAint.add(this._io.readU4le());
} |
I don't think so, You might think "what about immutable collections - surely
So I believe the change from I said that it might be a "breaking change", which is technically true (for example, if there is some user application code out there that takes a list from an instance of a KS-generated class and saves it to an Calls to |
@generalmimon Makes sense, thanks for thorough investigation! Then it will be likely simpler. |
We're using 0.11-SNAPSHOT with serialization functionality.
I have the following field in a ksy:
Which generates the following field in its associated Java class:
Is there a reason for using the concrete
java.util.ArrayList
in the generated class instead of thejava.util.List
interface (short of the_read()
method's initialization of said field)?When setting this field, I'd like to be able to pass it any
java.util.List
and not just an explicitjava.util.ArrayList
.The text was updated successfully, but these errors were encountered: