I want to write a tool which generates some code using a compiled .class
file as input. Specifically, I want to read from this class file:
The input class file will likely refer to several types that are not in the tool's classpath. This is ok, I don't need to do anything with them, just need to read fully qualified type names as strings. I do need to get some information from the annotations, but they will be in the tool's classpath.
Is there a library which I can use for this purpose? It would be nice if the API was a bit like the reflection API, but it doesn't have to be.
ASM http://asm.ow2.org/ allows you to read a class from a file/input stream without class loading it. It allows you to see annotations which are not loaded at runtime. It can also be used to modify the class byte code/annotations/method etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With