Question

The javap command has several options, one of them is -l, which can print line number and local variable tables. Suppose a java program has been compiled successfully and there is the file "Main.class", so running javap -l Main can produce something like:

public static void main(java.lang.String[]);

LineNumberTable:
 line 100: 0
 line 101: 27
 line 275: 54

LocalVariableTable:
 Start Length Slot Name Signature
 0     55     0    args  [Ljava/lang/String;

However, I'm using this javap -l xxx command on the class files of one java program, but the area of line number and local variable table is empty (which shouldn't be). The javap command and other options such as -s, -verbose works fine, but only the line info area corresponding to the -l option is empty.

Has anyone ever encountered such weird case?

Was it helpful?

Solution

Use -g to compile your code, otherwise the line numbers are not kept (akin to the stack trace displaying "compiled code" instead of the line number)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top