dsl-json icon indicating copy to clipboard operation
dsl-json copied to clipboard

Argument not withing bounds exception when used with a class with generic type

Open mecoFarid opened this issue 2 years ago • 1 comments

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

mecoFarid avatar Mar 16 '22 07:03 mecoFarid

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.

zapov avatar Mar 16 '22 20:03 zapov

This seems to be working now with latest improvements on master: https://github.com/ngs-doo/dsl-json/commit/2d4067184dd7411a303c733333685ea98f436c27

zapov avatar Jan 03 '23 11:01 zapov

v1.10 released

zapov avatar Jan 07 '23 08:01 zapov