Using Java Annotations - Generating Code

前端 未结 2 990
闹比i
闹比i 2021-01-06 08:27

I\'m using java 6 annotation processing api. I have followed the following excellent tutorial for creating an annotation processor that displays a message at build-time:

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-06 08:53

    If you want runtime modification of you classes, you can use your own classloader and intercept loading of classes, introspect what you want and generate new bytecode using asm library instead of original classes. It is not very tricky, but you must be sure you need exactly that.

提交回复
热议问题