Domenica
Domenica

Reputation: 133

Is it possible to get the line number of annotations from .class file?

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?

Upvotes: 7

Views: 1252

Answers (2)

Thomas Kläger
Thomas Kläger

Reputation: 21435

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

Upvotes: 5

user404
user404

Reputation: 2028

You can use Java Decompiler. Follow this JD GUI, download the jar file and run it, keep the class files you want to decompile in same place with the jd-gui jar's directory and you will find if any annotation is used in source code there.

Upvotes: 0

Related Questions