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

Cannot assign a value to final variable #217

Open
shengdoushi opened this issue Oct 21, 2017 · 2 comments
Open

Cannot assign a value to final variable #217

shengdoushi opened this issue Oct 21, 2017 · 2 comments

Comments

@shengdoushi
Copy link

shengdoushi commented Oct 21, 2017

`

@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
Copy link
Author

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

@mkt-tokoi
Copy link

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

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

No branches or pull requests

2 participants