-
Enhancement
-
Resolution: Fixed
-
P3
-
9
-
b117
-
Verified
To reproduce run following code
Expected to see record in line number table for "field % 2 == 0 ?"
import com.sun.tools.classfile.*;
import java.io.IOException;
import java.util.Arrays;
public class Test {
public static void main(String[] args) throws IOException, ConstantPoolException {
ClassFile someTestIn = ClassFile.read(Test.class.getResourceAsStream("Test.class"));
for (Method m : someTestIn.methods) {
if ("method".equals(m.getName(someTestIn.constant_pool))) {
Code_attribute code_attribute = (Code_attribute) m.attributes.get(Attribute.Code);
for (Attribute at : code_attribute.attributes) {
if (Attribute.LineNumberTable.equals(at.getName(someTestIn.constant_pool))) {
LineNumberTable_attribute att = (LineNumberTable_attribute) at;
Arrays.asList(att.line_number_table).forEach(e -> System.out.println("Line number = " + e.line_number));
}
}
}
}
method();
}
public static int field;
public static String method() {
String s =
field % 2 == 0 ? //Breakpoint
"true" + field :
"false" + field;
return s;
}
}
Expected to see record in line number table for "field % 2 == 0 ?"
import com.sun.tools.classfile.*;
import java.io.IOException;
import java.util.Arrays;
public class Test {
public static void main(String[] args) throws IOException, ConstantPoolException {
ClassFile someTestIn = ClassFile.read(Test.class.getResourceAsStream("Test.class"));
for (Method m : someTestIn.methods) {
if ("method".equals(m.getName(someTestIn.constant_pool))) {
Code_attribute code_attribute = (Code_attribute) m.attributes.get(Attribute.Code);
for (Attribute at : code_attribute.attributes) {
if (Attribute.LineNumberTable.equals(at.getName(someTestIn.constant_pool))) {
LineNumberTable_attribute att = (LineNumberTable_attribute) at;
Arrays.asList(att.line_number_table).forEach(e -> System.out.println("Line number = " + e.line_number));
}
}
}
}
method();
}
public static int field;
public static String method() {
String s =
field % 2 == 0 ? //Breakpoint
"true" + field :
"false" + field;
return s;
}
}
- relates to
-
JDK-8155816 langtools/tools/javac/classfiles/attributes/LineNumberTable/T8050993.java test broken
-
- Closed
-
-
JDK-8040131 Implement classfile test for LineNumberTable attribute
-
- Closed
-