author | jlahoda |
Mon, 02 May 2016 06:43:44 +0200 | |
changeset 37754 | 7b4f67ce5cb5 |
child 37755 | b0918e7eb16b |
permissions | -rw-r--r-- |
37754
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
1 |
/* |
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
2 |
* @test /nodynamiccopyright/ |
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
3 |
* @bug 8050993 |
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
4 |
* @summary Verify that the condition in the conditional lexpression gets a LineNumberTable entry |
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
5 |
* @modules jdk.jdeps/com.sun.tools.classfile |
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
6 |
* @compile -g T8050993.java |
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
7 |
* @run main T8050993 |
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
8 |
*/ |
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
9 |
|
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
10 |
import java.io.IOException; |
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
11 |
import java.util.Arrays; |
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
12 |
import java.util.HashSet; |
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
13 |
import java.util.Objects; |
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
14 |
import java.util.Set; |
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
15 |
import java.util.stream.Collectors; |
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
16 |
|
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
17 |
import com.sun.tools.classfile.*; |
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
18 |
|
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
19 |
public class T8050993 { |
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
20 |
public static void main(String[] args) throws IOException, ConstantPoolException { |
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
21 |
ClassFile someTestIn = ClassFile.read(T8050993.class.getResourceAsStream("T8050993.class")); |
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
22 |
Set<Integer> expectedLineNumbers = new HashSet<>(Arrays.asList(48, 49, 46, 47)); |
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
23 |
for (Method m : someTestIn.methods) { |
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
24 |
if ("method".equals(m.getName(someTestIn.constant_pool))) { |
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
25 |
Code_attribute code_attribute = (Code_attribute) m.attributes.get(Attribute.Code); |
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
26 |
for (Attribute at : code_attribute.attributes) { |
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
27 |
if (Attribute.LineNumberTable.equals(at.getName(someTestIn.constant_pool))) { |
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
28 |
LineNumberTable_attribute att = (LineNumberTable_attribute) at; |
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
29 |
Set<Integer> actualLinesNumbers = Arrays.stream(att.line_number_table) |
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
30 |
.map(e -> e.line_number) |
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
31 |
.collect(Collectors.toSet()); |
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
32 |
if (!Objects.equals(expectedLineNumbers, actualLinesNumbers)) { |
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
33 |
throw new AssertionError("Expected LineNumber entries not found;" + |
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
34 |
"actual=" + actualLinesNumbers + ";" + |
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
35 |
"expected=" + expectedLineNumbers); |
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
36 |
} |
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
37 |
} |
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
38 |
} |
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
39 |
} |
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
40 |
} |
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
41 |
} |
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
42 |
|
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
43 |
public static int field; |
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
44 |
|
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
45 |
public static String method() { |
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
46 |
String s = |
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
47 |
field % 2 == 0 ? |
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
48 |
"true" + field : |
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
49 |
"false" + field; |
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
50 |
return s; |
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
51 |
} |
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
52 |
|
7b4f67ce5cb5
8050993: There is no record for condition in ternary operator in LineNumberTable.
jlahoda
parents:
diff
changeset
|
53 |
} |