i have these classes
public abstract class Unit
{
public abstract UnitType getType();
...
}
public class Item extends Unit
{
protected ItemType type;
@Override
public ItemType getType()
{
return type;
}
public void setType(ItemType type)
{
this.type = type;
}
...
}
and obvoiusly ItemType
extends UnitType
.
and i get:
javax.el.PropertyNotWritableException: /WEB-INF/facelets/general.xhtml @23,165 value="#{bean.item.type}": The class 'com.example.Item' does not have a writable property 'type'.
i can understand that covariant return type can confuse EL (2.2), so is this a bug?
i can workaround this using
- generics
- change setType signature to
public void setType(UnitType type)
and check instanceof inside - change method name to avoid override
is there a REAL solution instead of workarounds?