bluelinelabs / LoganSquare

Screaming fast JSON parsing and serialization library for Android.
Apache License 2.0
3.21k stars 306 forks source link

Cannot assign a value to final variable #217

Open shengdoushi opened 6 years ago

shengdoushi commented 6 years ago

`

@JsonObject
public class BaseItem {
    @JsonField
    public int base = 0;
}

@JsonObject
public class Item<T> extends BaseItem {
    @JsonField
    public T name;
}

`

will compile error:

Cannot assign a value to final variable 'parentObjectMapper'

the error code below:

` public final class Item$$JsonObjectMapper extends JsonMapper<Item> { private static final JsonMapper parentObjectMapper = LoganSquare.mapperFor(BaseItem.class);

        private final JsonMapper<T> m84ClassJsonMapper;

        public Item$$JsonObjectMapper(ParameterizedType type, ParameterizedType TType, SimpleArrayMap<ParameterizedType, JsonMapper> partialMappers) {
             partialMappers.put(type, this);
             m84ClassJsonMapper = LoganSquare.mapperFor(TType, partialMappers);
             parentObjectMapper = LoganSquare.mapperFor(new ParameterizedType<BaseItem>() { }); // This line error
 }

`

shengdoushi commented 6 years ago

parentObjectMapper is a final variable, and has assigned once, so second assign compile error

mkt-tokoi commented 5 years ago

@shengdoushi My project has same error . Could you tell me what did you do for workaround ? Thank you !