Looking for a java code generation library [closed]

偶尔善良 提交于 2019-12-01 06:06:24

There are several libraries with various capabilities and ease of use:

You will probably have to take a look at the API of each one to determine which one is more suitable for your purposes.

Maybe you should be interested in cglib?

I like ASM the best. It uses a visitor pattern that can be a little confusing at first when you are generating code; but once you grasp it, it's really clean and easy.

I've had a look into this a little while back as well and had a pretty hard time finding anything useful. The most promising candidate I found was actually built right into the compiler:

Java annotation processing (APT)

They recently included APT with javac, so it's always available.

I haven't really had too much time yet to look into it, but at first glance, it seems infinitely powerful (generate/modify source code or byte code, throw errors, warnings, ...) but it could be a bit complex to wrap your head around. There might be some good tutorials out there, but I don't have a specific link for you at the moment.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!