Is it possible to generate subclasses at runtime or while an application is running? If so, how is this achieved and what precautions should be taken to prevent a rogue object wreaking havoc inside an application?
Edit: Title modified from "Class generation on the fly".
Take a look at Reflection API.
Create Dynamic class "on the fly"
Read this one too:
Java Reflection: Create an implementing class - Jon Skeet answered it! :)