langtools/test/tools/javac/classfiles/attributes/LocalVariableTable/LocalVariableTestBase.java
equal
deleted
inserted
replaced
127 "code_length = %s" |
127 "code_length = %s" |
128 , e, code_attribute.code_length)); |
128 , e, code_attribute.code_length)); |
129 } |
129 } |
130 } |
130 } |
131 |
131 |
132 private void checkNamesAndTypes(List<LocalVariableTableTest.LocalVariableTable.Entry> entries, |
132 private void checkNamesAndTypes(List<VariableTable.Entry> entries, |
133 Map<String, String> expectedLocals2Types) { |
133 Map<String, String> expectedLocals2Types) { |
134 Map<String, List<String>> actualNames2Types = entries.stream() |
134 Map<String, List<String>> actualNames2Types = entries.stream() |
135 .collect( |
135 .collect( |
136 groupingBy(VariableTable.Entry::name, |
136 groupingBy(VariableTable.Entry::name, |
137 mapping(VariableTable.Entry::type, toList()))); |
137 mapping(VariableTable.Entry::type, toList()))); |
161 "Multiple variables point to the same index in common scope. " + e.getValue())); |
161 "Multiple variables point to the same index in common scope. " + e.getValue())); |
162 } |
162 } |
163 |
163 |
164 } |
164 } |
165 |
165 |
166 private void checkDoubleAndLongIndexes(Collection<LocalVariableTableTest.LocalVariableTable.Entry> entries, |
166 private void checkDoubleAndLongIndexes(Collection<VariableTable.Entry> entries, |
167 Map<String, Integer> scopes, int maxLocals) { |
167 Map<String, Integer> scopes, int maxLocals) { |
168 //check every scope separately |
168 //check every scope separately |
169 Map<Object, List<VariableTable.Entry>> entriesByScope = groupByScope(entries, scopes); |
169 Map<Object, List<VariableTable.Entry>> entriesByScope = groupByScope(entries, scopes); |
170 for (List<VariableTable.Entry> entryList : entriesByScope.values()) { |
170 for (List<VariableTable.Entry> entryList : entriesByScope.values()) { |
171 Map<Integer, VariableTable.Entry> index2Entry = entryList.stream() |
171 Map<Integer, VariableTable.Entry> index2Entry = entryList.stream() |
183 }); |
183 }); |
184 } |
184 } |
185 } |
185 } |
186 |
186 |
187 private Map<Object, List<VariableTable.Entry>> groupByScope( |
187 private Map<Object, List<VariableTable.Entry>> groupByScope( |
188 Collection<LocalVariableTableTest.LocalVariableTable.Entry> entries, Map<String, Integer> scopes) { |
188 Collection<VariableTable.Entry> entries, Map<String, Integer> scopes) { |
189 return entries.stream().collect(groupingBy(e -> scopes.getOrDefault(e.name() + "&" + e.type(), DEFAULT_SCOPE))); |
189 return entries.stream().collect(groupingBy(e -> scopes.getOrDefault(e.name() + "&" + e.type(), DEFAULT_SCOPE))); |
190 } |
190 } |
191 |
191 |
192 protected String getString(int i) { |
192 protected String getString(int i) { |
193 try { |
193 try { |
201 |
201 |
202 interface VariableTable { |
202 interface VariableTable { |
203 |
203 |
204 int localVariableTableLength(); |
204 int localVariableTableLength(); |
205 |
205 |
206 List<LocalVariableTableTest.VariableTable.Entry> entries(); |
206 List<VariableTable.Entry> entries(); |
207 |
207 |
208 int attributeLength(); |
208 int attributeLength(); |
209 |
209 |
210 interface Entry { |
210 interface Entry { |
211 |
211 |