field.set(this, Enum.valueOf((Class<Enum>) field.getType(), value));
getClass()aftergetType()should not be called – it returns the class of aClassinstance- You can cast
Class<Enum>, to avoid generic problems, because you already know that theClassis anenum