如何通过Java反射动态创建Java类? [英] How to create Java classes Dynamically by Java Reflection?
问题描述
您可以尝试ASM
ASM
或字节代码工程库
< a href =http://commons.apache.org/bcel/ =nofollow noreferrer>字节代码工程库
用于操纵,在运行时创建课程
在.NET中,我们有Reflection.Emit(C#),它可以做到
Reflection.Emit
不知道是否有直接java等效
您可以在此处看到另一个类似的问题:与...相当的反思。 >
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
这篇关于如何通过Java反射动态创建Java类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!