bluelinelabs / bluelinelabs/LoganSquare
Cannot assign a value to final variable
- Dominant language
- Java
- Stars
- 3.2k
- Forks
- 303
- PR merge metrics
- No merged PRs in 30d
Description
`
@JsonObject
public class BaseItem {
@JsonField
public int base = 0;
}
@JsonObject
public class Item 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> {
private static final JsonMapper parentObjectMapper = LoganSquare.mapperFor(BaseItem.class);
private final JsonMapper m84ClassJsonMapper;
public Item$$JsonObjectMapper(ParameterizedType type, ParameterizedType TType, SimpleArrayMap partialMappers) {
partialMappers.put(type, this);
m84ClassJsonMapper = LoganSquare.mapperFor(TType, partialMappers);
parentObjectMapper = LoganSquare.mapperFor(new ParameterizedType() { }); // This line error
}
`
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the compilation failure with the BaseItem and generic Item example, then inspect the generated Item$$JsonObjectMapper shown in the report. Focus on why parentObjectMapper is declared final before being assigned again; done means the example compiles without the final-variable error and retains correct mapping for the inherited and generic fields.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100