I'm trying to get the line number of annotations from .class file, but I can get only the list of annotations, not the lines. Is it possible to do this?
Looking through the Java Class File Specification it seems that for annotations no line number information is recorded.
Since the line number information is not present within the class file you cannot extract it from the class file.
Line numbers are only available for code segments: https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.12
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