views:

68

answers:

2

How can I create Java Pojo at runtime? ASM or BCEL is required for this?

I am reading a XML file and I want to generate Pojo according to this xml.

+2  A: 

There are lot of libraries available to generate classes in runtime. If you want to create a class and write it back to disk, BCEL and CGLIB is good. If you want most of them for runtime only, CGLIB is probably the best

Teja Kantamneni
A: 

You might find that generating the code in memory is much easier to work with. (ASM is very good otherwise) With generated code you just have to create the java you would need.

You can use tools like BeanShell or the Compiler API

Peter Lawrey