6

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?

Domenica
  • 123
  • 4

2 Answers2

4

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

Thomas Kläger
  • 17,754
  • 3
  • 23
  • 34
0

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.

user404
  • 1,934
  • 1
  • 16
  • 32
  • 3
    As far as I know, to decompile a .class file is not right copy of original .java file, I mean that you cannot get the right line number ... you can try! – pasquy73 Jan 11 '19 at 08:31
  • 1
    most probably(I did and forgot actually) it excludes the commented codeblocks. – user404 Jan 11 '19 at 08:34