I have an abstract class Entity and a derived class, let's call it Fred. I'm using newInstance() but I want to store the new instance in a HashMap<String, Entity>. When I do (Entity) klass.newInstance(); I'm getting an exception that I can't cast to Entity but I don't understand why.
To further complicate matters, the class definition for Fred is created dynamically at runtime using a Javassist class loader.
Any suggestions appreciated.