Reflection is used to load java class classes and manipulate them on the fly. But I have across a weird question that is asking me how to create Java classes on the fly by Reflection.I mean the classes is not compiled or have source code till we want them created. Is it really possible? Any examples?
解决方案
You can try ASM
ASM
or Byte code engineering library
for manipulating, creating classes at run time
In .NET we have Reflection.Emit(C#) which can do that
Reflection.Emit
Not sure whether there is a direct java equivalent.
You can see another similar question on SO here Java equivalent of reflection.emit