Skip to content

Commit 7004c87

Browse files
committed
Manually edit tests so they pass
1 parent 4388f19 commit 7004c87

File tree

1 file changed

+83
-47
lines changed
  • java/ql/test/library-tests/frameworks/apache-collections

1 file changed

+83
-47
lines changed

java/ql/test/library-tests/frameworks/apache-collections/Test.java

Lines changed: 83 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,54 @@ public class Test {
3232
Object source() { return null; }
3333
void sink(Object o) { }
3434

35+
class MyAbstractKeyValue<K, V> extends AbstractKeyValue<K, V> {
36+
MyAbstractKeyValue(K key, V value) {
37+
super(key, value);
38+
}
39+
40+
K mySetKey(final K key) {
41+
return super.setKey(key);
42+
}
43+
44+
V mySetValue(final V value) {
45+
return super.setValue(value);
46+
}
47+
}
48+
49+
class MyAbstractMapEntry<K, V> extends AbstractMapEntry<K, V> {
50+
MyAbstractMapEntry(final K key, final V value) {
51+
super(key, value);
52+
}
53+
@Override
54+
public K getKey() { return null; }
55+
@Override
56+
public V getValue() { return null; }
57+
}
58+
59+
class MyAbstractMapEntryDecorator<K, V> extends AbstractMapEntryDecorator<K, V> {
60+
MyAbstractMapEntryDecorator(final Map.Entry<K, V> entry) {
61+
super(entry);
62+
}
63+
64+
Map.Entry<K, V> myGetMapEntry() {
65+
return super.getMapEntry();
66+
}
67+
}
68+
3569
public void test() {
3670

3771
{
3872
// "org.apache.commons.collections4.keyvalue;AbstractKeyValue;true;AbstractKeyValue;;;Argument[0];MapKey of Argument[-1];value"
3973
AbstractKeyValue out = null;
4074
Object in = (Object)source();
41-
out = new AbstractKeyValue(in, null);
75+
out = new MyAbstractKeyValue(in, null);
4276
sink(getMapKey(out)); // $hasValueFlow
4377
}
4478
{
4579
// "org.apache.commons.collections4.keyvalue;AbstractKeyValue;true;AbstractKeyValue;;;Argument[1];MapValue of Argument[-1];value"
4680
AbstractKeyValue out = null;
4781
Object in = (Object)source();
48-
out = new AbstractKeyValue(null, in);
82+
out = new MyAbstractKeyValue(null, in);
4983
sink(getMapValue(out)); // $hasValueFlow
5084
}
5185
{
@@ -57,9 +91,9 @@ public void test() {
5791
}
5892
{
5993
// "org.apache.commons.collections4.keyvalue;AbstractKeyValue;true;setKey;;;Argument[0];MapKey of Argument[-1];value"
60-
AbstractKeyValue out = null;
94+
MyAbstractKeyValue out = null;
6195
Object in = (Object)source();
62-
out.setKey(in);
96+
out.mySetKey(in);
6397
sink(getMapKey(out)); // $hasValueFlow
6498
}
6599
{
@@ -72,15 +106,15 @@ public void test() {
72106
{
73107
// "org.apache.commons.collections4.keyvalue;AbstractKeyValue;true;setKey;;;MapValue of Argument[-1];ReturnValue;value"
74108
Object out = null;
75-
AbstractKeyValue in = (AbstractKeyValue)newWithMapValue(source());
76-
out = in.setKey(null);
109+
MyAbstractKeyValue in = (MyAbstractKeyValue)newWithMapValue(source());
110+
out = in.mySetKey(null);
77111
sink(out); // $hasValueFlow
78112
}
79113
{
80114
// "org.apache.commons.collections4.keyvalue;AbstractKeyValue;true;setKey;;;MapValue of Argument[-1];ReturnValue;value"
81115
Object out = null;
82-
AbstractKeyValue in = (AbstractKeyValue)newWithMapValue(source());
83-
out = in.setKey((Object)null);
116+
MyAbstractKeyValue in = (MyAbstractKeyValue)newWithMapValue(source());
117+
out = in.mySetKey((Object)null);
84118
sink(out); // $hasValueFlow
85119
}
86120
{
@@ -106,9 +140,9 @@ public void test() {
106140
}
107141
{
108142
// "org.apache.commons.collections4.keyvalue;AbstractKeyValue;true;setValue;;;Argument[0];MapValue of Argument[-1];value"
109-
AbstractKeyValue out = null;
143+
MyAbstractKeyValue out = null;
110144
Object in = (Object)source();
111-
out.setValue(in);
145+
out.mySetValue(in);
112146
sink(getMapValue(out)); // $hasValueFlow
113147
}
114148
{
@@ -128,112 +162,112 @@ public void test() {
128162
{
129163
// "org.apache.commons.collections4.keyvalue;AbstractKeyValue;true;setValue;;;MapValue of Argument[-1];ReturnValue;value"
130164
Object out = null;
131-
AbstractMapEntry in = (AbstractMapEntry)newWithMapValue(source());
165+
AbstractMapEntry in = (MyAbstractMapEntry)newWithMapValue(source());
132166
out = in.setValue(null);
133167
sink(out); // $hasValueFlow
134168
}
135169
{
136170
// "org.apache.commons.collections4.keyvalue;AbstractKeyValue;true;setValue;;;MapValue of Argument[-1];ReturnValue;value"
137171
Object out = null;
138-
AbstractMapEntry in = (AbstractMapEntry)newWithMapValue(source());
172+
AbstractMapEntry in = (MyAbstractMapEntry)newWithMapValue(source());
139173
out = in.setValue((Object)null);
140174
sink(out); // $hasValueFlow
141175
}
142176
{
143177
// "org.apache.commons.collections4.keyvalue;AbstractKeyValue;true;setValue;;;MapValue of Argument[-1];ReturnValue;value"
144178
Object out = null;
145-
AbstractKeyValue in = (AbstractKeyValue)newWithMapValue(source());
146-
out = in.setValue(null);
179+
MyAbstractKeyValue in = (MyAbstractKeyValue)newWithMapValue(source());
180+
out = in.mySetValue(null);
147181
sink(out); // $hasValueFlow
148182
}
149183
{
150184
// "org.apache.commons.collections4.keyvalue;AbstractKeyValue;true;setValue;;;MapValue of Argument[-1];ReturnValue;value"
151185
Object out = null;
152-
AbstractKeyValue in = (AbstractKeyValue)newWithMapValue(source());
153-
out = in.setValue((Object)null);
186+
MyAbstractKeyValue in = (MyAbstractKeyValue)newWithMapValue(source());
187+
out = in.mySetValue((Object)null);
154188
sink(out); // $hasValueFlow
155189
}
156190
{
157191
// "org.apache.commons.collections4.keyvalue;AbstractKeyValue;true;toString;;;MapKey of Argument[-1];ReturnValue;taint"
158192
String out = null;
159-
AbstractKeyValue in = (AbstractKeyValue)newWithMapKey(source());
193+
AbstractKeyValue in = (MyAbstractKeyValue)newWithMapKey(source());
160194
out = in.toString();
161195
sink(out); // $hasTaintFlow
162196
}
163197
{
164198
// "org.apache.commons.collections4.keyvalue;AbstractKeyValue;true;toString;;;MapValue of Argument[-1];ReturnValue;taint"
165199
String out = null;
166-
AbstractKeyValue in = (AbstractKeyValue)newWithMapValue(source());
200+
AbstractKeyValue in = (MyAbstractKeyValue)newWithMapValue(source());
167201
out = in.toString();
168202
sink(out); // $hasTaintFlow
169203
}
170204
{
171205
// "org.apache.commons.collections4.keyvalue;AbstractMapEntry;true;AbstractMapEntry;;;Argument[0];MapKey of Argument[-1];value"
172206
AbstractMapEntry out = null;
173207
Object in = (Object)source();
174-
out = new AbstractMapEntry(in, null);
208+
out = new MyAbstractMapEntry(in, null);
175209
sink(getMapKey(out)); // $hasValueFlow
176210
}
177211
{
178212
// "org.apache.commons.collections4.keyvalue;AbstractMapEntry;true;AbstractMapEntry;;;Argument[1];MapValue of Argument[-1];value"
179213
AbstractMapEntry out = null;
180214
Object in = (Object)source();
181-
out = new AbstractMapEntry(null, in);
215+
out = new MyAbstractMapEntry(null, in);
182216
sink(getMapValue(out)); // $hasValueFlow
183217
}
184218
{
185219
// "org.apache.commons.collections4.keyvalue;AbstractMapEntryDecorator;true;AbstractMapEntryDecorator;;;MapKey of Argument[0];MapKey of Argument[-1];value"
186220
AbstractMapEntryDecorator out = null;
187-
Map<>.Entry in = (Map<>.Entry)newWithMapKey(source());
188-
out = new AbstractMapEntryDecorator(in);
221+
Map.Entry<String,String> in = (Map.Entry<String,String>)newWithMapKey(source());
222+
out = new MyAbstractMapEntryDecorator(in);
189223
sink(getMapKey(out)); // $hasValueFlow
190224
}
191225
{
192226
// "org.apache.commons.collections4.keyvalue;AbstractMapEntryDecorator;true;AbstractMapEntryDecorator;;;MapValue of Argument[0];MapValue of Argument[-1];value"
193227
AbstractMapEntryDecorator out = null;
194-
Map<>.Entry in = (Map<>.Entry)newWithMapValue(source());
195-
out = new AbstractMapEntryDecorator(in);
228+
Map.Entry<String,String> in = (Map.Entry<String,String>)newWithMapValue(source());
229+
out = new MyAbstractMapEntryDecorator(in);
196230
sink(getMapValue(out)); // $hasValueFlow
197231
}
198232
{
199233
// "org.apache.commons.collections4.keyvalue;AbstractMapEntryDecorator;true;getMapEntry;;;MapKey of Argument[-1];MapKey of ReturnValue;value"
200-
Map<>.Entry out = null;
201-
AbstractMapEntryDecorator in = (AbstractMapEntryDecorator)newWithMapKey(source());
202-
out = in.getMapEntry();
234+
Map.Entry<String,String> out = null;
235+
MyAbstractMapEntryDecorator in = (MyAbstractMapEntryDecorator)newWithMapKey(source());
236+
out = in.myGetMapEntry();
203237
sink(getMapKey(out)); // $hasValueFlow
204238
}
205239
{
206240
// "org.apache.commons.collections4.keyvalue;AbstractMapEntryDecorator;true;getMapEntry;;;MapValue of Argument[-1];MapValue of ReturnValue;value"
207-
Map<>.Entry out = null;
208-
AbstractMapEntryDecorator in = (AbstractMapEntryDecorator)newWithMapValue(source());
209-
out = in.getMapEntry();
241+
Map.Entry<String,String> out = null;
242+
MyAbstractMapEntryDecorator in = (MyAbstractMapEntryDecorator)newWithMapValue(source());
243+
out = in.myGetMapEntry();
210244
sink(getMapValue(out)); // $hasValueFlow
211245
}
212246
{
213247
// "org.apache.commons.collections4.keyvalue;AbstractMapEntryDecorator;true;toString;;;MapKey of Argument[-1];ReturnValue;taint"
214248
String out = null;
215-
AbstractMapEntryDecorator in = (AbstractMapEntryDecorator)newWithMapKey(source());
249+
AbstractMapEntryDecorator in = (MyAbstractMapEntryDecorator)newWithMapKey(source());
216250
out = in.toString();
217251
sink(out); // $hasTaintFlow
218252
}
219253
{
220254
// "org.apache.commons.collections4.keyvalue;AbstractMapEntryDecorator;true;toString;;;MapValue of Argument[-1];ReturnValue;taint"
221255
String out = null;
222-
AbstractMapEntryDecorator in = (AbstractMapEntryDecorator)newWithMapValue(source());
256+
AbstractMapEntryDecorator in = (MyAbstractMapEntryDecorator)newWithMapValue(source());
223257
out = in.toString();
224258
sink(out); // $hasTaintFlow
225259
}
226260
{
227261
// "org.apache.commons.collections4.keyvalue;DefaultKeyValue;true;DefaultKeyValue;(Entry);;MapKey of Argument[0];MapKey of Argument[-1];value"
228262
DefaultKeyValue out = null;
229-
Map<>.Entry in = (Map<>.Entry)newWithMapKey(source());
263+
Map.Entry<String,String> in = (Map.Entry<String,String>)newWithMapKey(source());
230264
out = new DefaultKeyValue(in);
231265
sink(getMapKey(out)); // $hasValueFlow
232266
}
233267
{
234268
// "org.apache.commons.collections4.keyvalue;DefaultKeyValue;true;DefaultKeyValue;(Entry);;MapValue of Argument[0];MapValue of Argument[-1];value"
235269
DefaultKeyValue out = null;
236-
Map<>.Entry in = (Map<>.Entry)newWithMapValue(source());
270+
Map.Entry<String,String> in = (Map.Entry<String,String>)newWithMapValue(source());
237271
out = new DefaultKeyValue(in);
238272
sink(getMapValue(out)); // $hasValueFlow
239273
}
@@ -267,29 +301,29 @@ public void test() {
267301
}
268302
{
269303
// "org.apache.commons.collections4.keyvalue;DefaultKeyValue;true;toMapEntry;;;MapKey of Argument[-1];MapKey of ReturnValue;value"
270-
Map<>.Entry out = null;
304+
Map.Entry<String,String> out = null;
271305
DefaultKeyValue in = (DefaultKeyValue)newWithMapKey(source());
272306
out = in.toMapEntry();
273307
sink(getMapKey(out)); // $hasValueFlow
274308
}
275309
{
276310
// "org.apache.commons.collections4.keyvalue;DefaultKeyValue;true;toMapEntry;;;MapValue of Argument[-1];MapValue of ReturnValue;value"
277-
Map<>.Entry out = null;
311+
Map.Entry<String,String> out = null;
278312
DefaultKeyValue in = (DefaultKeyValue)newWithMapValue(source());
279313
out = in.toMapEntry();
280314
sink(getMapValue(out)); // $hasValueFlow
281315
}
282316
{
283317
// "org.apache.commons.collections4.keyvalue;DefaultMapEntry;true;DefaultMapEntry;(Entry);;MapKey of Argument[0];MapKey of Argument[-1];value"
284318
DefaultMapEntry out = null;
285-
Map<>.Entry in = (Map<>.Entry)newWithMapKey(source());
319+
Map.Entry<String,String> in = (Map.Entry<String,String>)newWithMapKey(source());
286320
out = new DefaultMapEntry(in);
287321
sink(getMapKey(out)); // $hasValueFlow
288322
}
289323
{
290324
// "org.apache.commons.collections4.keyvalue;DefaultMapEntry;true;DefaultMapEntry;(Entry);;MapValue of Argument[0];MapValue of Argument[-1];value"
291325
DefaultMapEntry out = null;
292-
Map<>.Entry in = (Map<>.Entry)newWithMapValue(source());
326+
Map.Entry<String,String> in = (Map.Entry<String,String>)newWithMapValue(source());
293327
out = new DefaultMapEntry(in);
294328
sink(getMapValue(out)); // $hasValueFlow
295329
}
@@ -338,14 +372,14 @@ public void test() {
338372
{
339373
// "org.apache.commons.collections4.keyvalue;UnmodifiableMapEntry;true;UnmodifiableMapEntry;(Entry);;MapKey of Argument[0];MapKey of Argument[-1];value"
340374
UnmodifiableMapEntry out = null;
341-
Map<>.Entry in = (Map<>.Entry)newWithMapKey(source());
375+
Map.Entry<String,String> in = (Map.Entry<String,String>)newWithMapKey(source());
342376
out = new UnmodifiableMapEntry(in);
343377
sink(getMapKey(out)); // $hasValueFlow
344378
}
345379
{
346380
// "org.apache.commons.collections4.keyvalue;UnmodifiableMapEntry;true;UnmodifiableMapEntry;(Entry);;MapValue of Argument[0];MapValue of Argument[-1];value"
347381
UnmodifiableMapEntry out = null;
348-
Map<>.Entry in = (Map<>.Entry)newWithMapValue(source());
382+
Map.Entry<String,String> in = (Map.Entry<String,String>)newWithMapValue(source());
349383
out = new UnmodifiableMapEntry(in);
350384
sink(getMapValue(out)); // $hasValueFlow
351385
}
@@ -394,14 +428,14 @@ public void test() {
394428
{
395429
// "org.apache.commons.collections4;KeyValue;true;getKey;;;MapKey of Argument[-1];ReturnValue;value"
396430
Object out = null;
397-
AbstractMapEntryDecorator in = (AbstractMapEntryDecorator)newWithMapKey(source());
431+
AbstractMapEntryDecorator in = (MyAbstractMapEntryDecorator)newWithMapKey(source());
398432
out = in.getKey();
399433
sink(out); // $hasValueFlow
400434
}
401435
{
402436
// "org.apache.commons.collections4;KeyValue;true;getKey;;;MapKey of Argument[-1];ReturnValue;value"
403437
Object out = null;
404-
AbstractKeyValue in = (AbstractKeyValue)newWithMapKey(source());
438+
AbstractKeyValue in = (MyAbstractKeyValue)newWithMapKey(source());
405439
out = in.getKey();
406440
sink(out); // $hasValueFlow
407441
}
@@ -422,14 +456,14 @@ public void test() {
422456
{
423457
// "org.apache.commons.collections4;KeyValue;true;getValue;;;MapValue of Argument[-1];ReturnValue;value"
424458
Object out = null;
425-
AbstractMapEntryDecorator in = (AbstractMapEntryDecorator)newWithMapValue(source());
459+
AbstractMapEntryDecorator in = (MyAbstractMapEntryDecorator)newWithMapValue(source());
426460
out = in.getValue();
427461
sink(out); // $hasValueFlow
428462
}
429463
{
430464
// "org.apache.commons.collections4;KeyValue;true;getValue;;;MapValue of Argument[-1];ReturnValue;value"
431465
Object out = null;
432-
AbstractKeyValue in = (AbstractKeyValue)newWithMapValue(source());
466+
AbstractKeyValue in = (MyAbstractKeyValue)newWithMapValue(source());
433467
out = in.getValue();
434468
sink(out); // $hasValueFlow
435469
}
@@ -693,10 +727,12 @@ public void test() {
693727
sink(getMapValue(out)); // $hasValueFlow
694728
}
695729
{
730+
// Note it is tricky to get this to compile - the compiler thinks it is ambiguous
731+
// which overload it should choose unless you put the generic types in correctly
696732
// "org.apache.commons.collections4;MapUtils;true;populateMap;(MultiMap,Iterable,Transformer);;Element of Argument[1];MapValue of Argument[0];value"
697-
MultiMap out = null;
698-
Iterable in = (Iterable)newWithElement(source());
699-
MapUtils.populateMap(out, in, (Transformer)null);
733+
MultiMap<Integer, String> out = null;
734+
Iterable<String> in = (Iterable<String>)newWithElement(source());
735+
MapUtils.populateMap(out, in, (Transformer<String, Integer>)null);
700736
sink(getMapValue(out)); // $hasValueFlow
701737
}
702738
{

0 commit comments

Comments
 (0)