Skip to content
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

Fix Parcelable Creator logic (deserializer) for List and Parcelable #140

Closed
wants to merge 1 commit into from
Closed

Conversation

eonj
Copy link

@eonj eonj commented May 2, 2019

After some months using this helpful AutoValue Parcel extension, I found that the current implementation is unparcelizing generic-typed fields in an inappropriate way. When a AutoValue declared class type A contains a field typed List<B>, The generated createFromParcel uses readArrayList with ClassLoader of type A -- not B.

I tried to fix this problem in more broad and generous way -- for example, can we fix it with the map? Can we show an informatic message to the user when the type parameter is not a concrete bound but a extends T or a super T? Can we just warn the user instead of blowing javac with an unhandled AutoValueParcelException?

But I failed because I cannot read and change the whole code, so I submit a patch currently used (by my team). Thank you.

@rharter
Copy link
Owner

rharter commented May 20, 2019

This was an intentional change to fix some issues where the generic type can't be used (#108, #109). It was changed in #112.

It looks like this PR is effectively reverting that change and will cause those issues to regress.

@eonj
Copy link
Author

eonj commented May 21, 2019

@rharter Thank you, I read #112 changes and got it: you're right this PR is not sufficiently caring about the type wildcard or extends/super type bounds (as I said above). I'm glad to know that this kindof problem is already known, and also good to know why the UT's were also expecting the wrong type parameters.

My question is: do you have any plans for make right generic support again for the possible cases; or can you give me any instructions for alternative solution for correct generation?

@ZacSweers ZacSweers closed this Jun 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants