jmartinesp / SwissKnife

A multi-purpose library containing view injection and threading for Android using annotations
Apache License 2.0
254 stars 24 forks source link

@Parcelable and generic list in supperclass not generated correctly #31

Closed daberni closed 9 years ago

daberni commented 9 years ago

I have a problem with generic lists in subclasses, where superclass and inherited class both are @Parcelable

I added a testcase https://github.com/daberni/SwissKnife/commit/f6d0023b5030b4c7b8a40efe9de675a0d9e169f0

public class BetterPerson extends Person {

    String someotherProperty
    List<Person> children = []
}

the problem is, that the wrong classloader is used, when reading list from parcel generated code:

  public BetterPerson(Parcel parcel)
  {
    super(parcel);
    List localList = ScriptBytecodeAdapter.createList(new Object[0]);
    this.children = localList;
    String str = parcel.readString();
    this.someotherProperty = str;
    parcel.readList(this.children, List.class.getClassLoader());
    null;
  }

instead of List Person should get used as reference for getClassLoader()

when the List-member is added in the super class Person everything is fine

jmartinesp commented 9 years ago

Could you try this branch? https://github.com/Arasthel/SwissKnife/tree/parcelablelisttest

daberni commented 9 years ago

fixed the issue

jmartinesp commented 9 years ago

Nice!