Skip to content

Commit 714e126

Browse files
authored
Merge pull request github#6370 from owen-mc/java/model/apache-collections
Java: Model more of Apache Commons Collections
2 parents 1e1ee55 + b23fabe commit 714e126

File tree

80 files changed

+5488
-552
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+5488
-552
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
lgtm,codescanning
2+
* Added models for the base package of Apache Commons Collections. This may lead to more results from any query using data-flow analysis where a relevant path uses one of these container types.

java/ql/src/semmle/code/java/frameworks/apache/Collections.qll

Lines changed: 559 additions & 207 deletions
Large diffs are not rendered by default.

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

Lines changed: 2955 additions & 262 deletions
Large diffs are not rendered by default.

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ class SummaryModelTest extends SummaryModelCsv {
99
row =
1010
[
1111
//"package;type;overrides;name;signature;ext;inputspec;outputspec;kind",
12+
// This is temporarily modelled for the helper function newEnumerationWithElement, until the relevant package is modelled
13+
"org.apache.commons.collections4.iterators;IteratorEnumeration;true;IteratorEnumeration;;;Element of Argument[0];Element of Argument[-1];value",
1214
"generatedtest;Test;false;newRBWithMapValue;;;Argument[0];MapValue of ReturnValue;value",
1315
"generatedtest;Test;false;newRBWithMapKey;;;Argument[0];MapKey of ReturnValue;value"
1416
]
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Generated automatically from org.apache.commons.collections4.ArrayStack for testing purposes
2+
3+
package org.apache.commons.collections4;
4+
5+
import java.util.ArrayList;
6+
7+
public class ArrayStack<E> extends ArrayList<E>
8+
{
9+
public ArrayStack(){}
10+
public ArrayStack(int p0){}
11+
public E peek(){ return null; }
12+
public E peek(int p0){ return null; }
13+
public E pop(){ return null; }
14+
public E push(E p0){ return null; }
15+
public boolean empty(){ return false; }
16+
public int search(Object p0){ return 0; }
17+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Generated automatically from org.apache.commons.collections4.Bag for testing purposes
2+
3+
package org.apache.commons.collections4;
4+
5+
import java.util.Collection;
6+
import java.util.Iterator;
7+
import java.util.Set;
8+
9+
public interface Bag<E> extends Collection<E>
10+
{
11+
Iterator<E> iterator();
12+
Set<E> uniqueSet();
13+
boolean add(E p0);
14+
boolean add(E p0, int p1);
15+
boolean containsAll(Collection<? extends Object> p0);
16+
boolean remove(Object p0);
17+
boolean remove(Object p0, int p1);
18+
boolean removeAll(Collection<? extends Object> p0);
19+
boolean retainAll(Collection<? extends Object> p0);
20+
int getCount(Object p0);
21+
int size();
22+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Generated automatically from org.apache.commons.collections4.BagUtils for testing purposes
2+
3+
package org.apache.commons.collections4;
4+
5+
import org.apache.commons.collections4.Bag;
6+
import org.apache.commons.collections4.Predicate;
7+
import org.apache.commons.collections4.SortedBag;
8+
import org.apache.commons.collections4.Transformer;
9+
10+
public class BagUtils
11+
{
12+
protected BagUtils() {}
13+
public static <E> Bag<E> collectionBag(Bag<E> p0){ return null; }
14+
public static <E> Bag<E> emptyBag(){ return null; }
15+
public static <E> Bag<E> predicatedBag(Bag<E> p0, Predicate<? super E> p1){ return null; }
16+
public static <E> Bag<E> synchronizedBag(Bag<E> p0){ return null; }
17+
public static <E> Bag<E> transformingBag(Bag<E> p0, Transformer<? super E, ? extends E> p1){ return null; }
18+
public static <E> Bag<E> unmodifiableBag(Bag<? extends E> p0){ return null; }
19+
public static <E> SortedBag<E> emptySortedBag(){ return null; }
20+
public static <E> SortedBag<E> predicatedSortedBag(SortedBag<E> p0, Predicate<? super E> p1){ return null; }
21+
public static <E> SortedBag<E> synchronizedSortedBag(SortedBag<E> p0){ return null; }
22+
public static <E> SortedBag<E> transformingSortedBag(SortedBag<E> p0, Transformer<? super E, ? extends E> p1){ return null; }
23+
public static <E> SortedBag<E> unmodifiableSortedBag(SortedBag<E> p0){ return null; }
24+
public static Bag EMPTY_BAG = null;
25+
public static Bag EMPTY_SORTED_BAG = null;
26+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Generated automatically from org.apache.commons.collections4.BidiMap for testing purposes
2+
3+
package org.apache.commons.collections4;
4+
5+
import java.util.Set;
6+
import org.apache.commons.collections4.IterableMap;
7+
8+
public interface BidiMap<K, V> extends IterableMap<K, V>
9+
{
10+
BidiMap<V, K> inverseBidiMap();
11+
K getKey(Object p0);
12+
K removeValue(Object p0);
13+
Set<V> values();
14+
V put(K p0, V p1);
15+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Generated automatically from org.apache.commons.collections4.Closure for testing purposes
2+
3+
package org.apache.commons.collections4;
4+
5+
6+
public interface Closure<T>
7+
{
8+
void execute(T p0);
9+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
// Generated automatically from org.apache.commons.collections4.CollectionUtils for testing purposes
2+
3+
package org.apache.commons.collections4;
4+
5+
import java.util.Collection;
6+
import java.util.Comparator;
7+
import java.util.Enumeration;
8+
import java.util.Iterator;
9+
import java.util.List;
10+
import java.util.Map;
11+
import org.apache.commons.collections4.Closure;
12+
import org.apache.commons.collections4.Equator;
13+
import org.apache.commons.collections4.Predicate;
14+
import org.apache.commons.collections4.Transformer;
15+
16+
public class CollectionUtils
17+
{
18+
protected CollectionUtils() {}
19+
public static <C> Collection<C> predicatedCollection(Collection<C> p0, Predicate<? super C> p1){ return null; }
20+
public static <C> Collection<C> retainAll(Collection<C> p0, Collection<? extends Object> p1){ return null; }
21+
public static <C> Collection<C> synchronizedCollection(Collection<C> p0){ return null; }
22+
public static <C> Collection<C> unmodifiableCollection(Collection<? extends C> p0){ return null; }
23+
public static <C> boolean addAll(Collection<C> p0, C... p1){ return false; }
24+
public static <C> boolean addAll(Collection<C> p0, Enumeration<? extends C> p1){ return false; }
25+
public static <C> boolean addAll(Collection<C> p0, Iterable<? extends C> p1){ return false; }
26+
public static <C> boolean addAll(Collection<C> p0, Iterator<? extends C> p1){ return false; }
27+
public static <C> boolean exists(Iterable<C> p0, Predicate<? super C> p1){ return false; }
28+
public static <C> boolean matchesAll(Iterable<C> p0, Predicate<? super C> p1){ return false; }
29+
public static <C> int countMatches(Iterable<C> p0, Predicate<? super C> p1){ return 0; }
30+
public static <C> void transform(Collection<C> p0, Transformer<? super C, ? extends C> p1){}
31+
public static <E> Collection<E> removeAll(Collection<E> p0, Collection<? extends Object> p1){ return null; }
32+
public static <E> Collection<E> removeAll(Iterable<E> p0, Iterable<? extends E> p1, Equator<? super E> p2){ return null; }
33+
public static <E> Collection<E> retainAll(Iterable<E> p0, Iterable<? extends E> p1, Equator<? super E> p2){ return null; }
34+
public static <E> Collection<E> transformingCollection(Collection<E> p0, Transformer<? super E, ? extends E> p1){ return null; }
35+
public static <E> Collection<List<E>> permutations(Collection<E> p0){ return null; }
36+
public static <E> E extractSingleton(Collection<E> p0){ return null; }
37+
public static <E> boolean isEqualCollection(Collection<? extends E> p0, Collection<? extends E> p1, Equator<? super E> p2){ return false; }
38+
public static <I, O, R extends Collection<? super O>> R collect(Iterable<? extends I> p0, Transformer<? super I, ? extends O> p1, R p2){ return null; }
39+
public static <I, O, R extends Collection<? super O>> R collect(Iterator<? extends I> p0, Transformer<? super I, ? extends O> p1, R p2){ return null; }
40+
public static <I, O> Collection<O> collect(Iterable<I> p0, Transformer<? super I, ? extends O> p1){ return null; }
41+
public static <I, O> Collection<O> collect(Iterator<I> p0, Transformer<? super I, ? extends O> p1){ return null; }
42+
public static <K, V> Map.Entry<K, V> get(Map<K, V> p0, int p1){ return null; }
43+
public static <O extends Comparable<? super O>> List<O> collate(Iterable<? extends O> p0, Iterable<? extends O> p1){ return null; }
44+
public static <O extends Comparable<? super O>> List<O> collate(Iterable<? extends O> p0, Iterable<? extends O> p1, boolean p2){ return null; }
45+
public static <O, R extends Collection<? super O>> R select(Iterable<? extends O> p0, Predicate<? super O> p1, R p2){ return null; }
46+
public static <O, R extends Collection<? super O>> R select(Iterable<? extends O> p0, Predicate<? super O> p1, R p2, R p3){ return null; }
47+
public static <O, R extends Collection<? super O>> R selectRejected(Iterable<? extends O> p0, Predicate<? super O> p1, R p2){ return null; }
48+
public static <O> Collection<O> disjunction(Iterable<? extends O> p0, Iterable<? extends O> p1){ return null; }
49+
public static <O> Collection<O> intersection(Iterable<? extends O> p0, Iterable<? extends O> p1){ return null; }
50+
public static <O> Collection<O> select(Iterable<? extends O> p0, Predicate<? super O> p1){ return null; }
51+
public static <O> Collection<O> selectRejected(Iterable<? extends O> p0, Predicate<? super O> p1){ return null; }
52+
public static <O> Collection<O> subtract(Iterable<? extends O> p0, Iterable<? extends O> p1){ return null; }
53+
public static <O> Collection<O> subtract(Iterable<? extends O> p0, Iterable<? extends O> p1, Predicate<O> p2){ return null; }
54+
public static <O> Collection<O> union(Iterable<? extends O> p0, Iterable<? extends O> p1){ return null; }
55+
public static <O> List<O> collate(Iterable<? extends O> p0, Iterable<? extends O> p1, Comparator<? super O> p2){ return null; }
56+
public static <O> List<O> collate(Iterable<? extends O> p0, Iterable<? extends O> p1, Comparator<? super O> p2, boolean p3){ return null; }
57+
public static <O> Map<O, Integer> getCardinalityMap(Iterable<? extends O> p0){ return null; }
58+
public static <O> int cardinality(O p0, Iterable<? super O> p1){ return 0; }
59+
public static <T, C extends Closure<? super T>> C forAllDo(Iterable<T> p0, C p1){ return null; }
60+
public static <T, C extends Closure<? super T>> C forAllDo(Iterator<T> p0, C p1){ return null; }
61+
public static <T, C extends Closure<? super T>> T forAllButLastDo(Iterable<T> p0, C p1){ return null; }
62+
public static <T, C extends Closure<? super T>> T forAllButLastDo(Iterator<T> p0, C p1){ return null; }
63+
public static <T> Collection<T> emptyCollection(){ return null; }
64+
public static <T> Collection<T> emptyIfNull(Collection<T> p0){ return null; }
65+
public static <T> T find(Iterable<T> p0, Predicate<? super T> p1){ return null; }
66+
public static <T> T get(Iterable<T> p0, int p1){ return null; }
67+
public static <T> T get(Iterator<T> p0, int p1){ return null; }
68+
public static <T> boolean addIgnoreNull(Collection<T> p0, T p1){ return false; }
69+
public static <T> boolean containsAny(Collection<? extends Object> p0, T... p1){ return false; }
70+
public static <T> boolean filter(Iterable<T> p0, Predicate<? super T> p1){ return false; }
71+
public static <T> boolean filterInverse(Iterable<T> p0, Predicate<? super T> p1){ return false; }
72+
public static Collection EMPTY_COLLECTION = null;
73+
public static Object get(Object p0, int p1){ return null; }
74+
public static boolean containsAll(Collection<? extends Object> p0, Collection<? extends Object> p1){ return false; }
75+
public static boolean containsAny(Collection<? extends Object> p0, Collection<? extends Object> p1){ return false; }
76+
public static boolean isEmpty(Collection<? extends Object> p0){ return false; }
77+
public static boolean isEqualCollection(Collection<? extends Object> p0, Collection<? extends Object> p1){ return false; }
78+
public static boolean isFull(Collection<? extends Object> p0){ return false; }
79+
public static boolean isNotEmpty(Collection<? extends Object> p0){ return false; }
80+
public static boolean isProperSubCollection(Collection<? extends Object> p0, Collection<? extends Object> p1){ return false; }
81+
public static boolean isSubCollection(Collection<? extends Object> p0, Collection<? extends Object> p1){ return false; }
82+
public static boolean sizeIsEmpty(Object p0){ return false; }
83+
public static int maxSize(Collection<? extends Object> p0){ return 0; }
84+
public static int size(Object p0){ return 0; }
85+
public static void reverseArray(Object[] p0){}
86+
static void checkIndexBounds(int p0){}
87+
}

0 commit comments

Comments
 (0)