uglycustard / buildergenerator

A tool to auto generate builders following the Builder pattern for an object graph of JavaBeans.
Apache License 2.0
5 stars 2 forks source link

BG Cannot handle generics wild cards #28

Open uglycustard opened 9 years ago

uglycustard commented 9 years ago

Wild card example:

public List<? extends Root> getChildren() {
    return children;
}

public void setChildren(List<? extends Root> children) {
    this.children = children;
}

Root cause:

Caused by: java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.WildcardTypeImpl cannot be cast to java.lang.Class at uk.co.buildergenerator.BuilderGeneratorUtils.getTargetTypeClass(BuilderGeneratorUtils.java:141) at uk.co.buildergenerator.BuilderGeneratorUtils.getParameterType(BuilderGeneratorUtils.java:176) at uk.co.buildergenerator.WithMethodFactory.createWithMethod(WithMethodFactory.java:20) at uk.co.buildergenerator.WithMethodList.(WithMethodList.java:22) ... 6 more

Wild cards to consider:

? ? extends Number ? super T

See: http://docs.oracle.com/javase/7/docs/api/javax/lang/model/type/WildcardType.html http://docs.oracle.com/javase/7/docs/api/javax/lang/model/type/TypeMirror.html