dsl-json
dsl-json copied to clipboard
Argument not withing bounds exception when used with a class with generic type
Library Version: 1.9.4
DslJson Instance: new DslJson<>(Settings.basicSetup().allowArrayFormat(true).skipDefaultValues(false));
I have a class with generic type:
@CompiledJson
public class FilterResponse<T extends Filter> {
private final List<T> list;
public FilterResponse(List<T> list) {
this.list = list;
}
public List<T> getList() {
return list;
}
}
Filter class is a simple POJO class:
public abstract class Filter implements Serializable {}
There is one more class FoodFilter
that extends Filter
class:
@CompiledJson
public class FoodFilter extends Filter{}
I am trying to use FilterResponse
with Retrofit like below:
@GET("Filters")
Call<FilterResponse<FoodFilter>> getFoodFilters();
When building the app, DslJson gives me the following error:
error: type argument T#1 is not within bounds of type-variable T#2 public final static class ObjectFormatConverter<T> implements com.dslplatform.json.runtime.FormatConverter<com.xxxx.FilterResponse<T>> { ^ where T#1,T#2 are type-variables: T#1 extends Object declared in class ObjectFormatConverter T#2 extends Filter declared in class FilterResponse
Please make sure the behavior is same on latest version (1.9.9)
And ideally a reproducible which can become a test would be desired. I tried copy pasting your code into test on latest and it compiles fine.
This seems to be working now with latest improvements on master: https://github.com/ngs-doo/dsl-json/commit/2d4067184dd7411a303c733333685ea98f436c27
v1.10 released