diff --git a/infer/tests/codetoanalyze/java/performance/CollectionTest.java b/infer/tests/codetoanalyze/java/performance/CollectionTest.java index c882503c4..458e2d795 100644 --- a/infer/tests/codetoanalyze/java/performance/CollectionTest.java +++ b/infer/tests/codetoanalyze/java/performance/CollectionTest.java @@ -69,4 +69,27 @@ public class CollectionTest { new_arr.put(1, 1); for (int i = 0; i < new_arr.size(); i++) {} } + + static class Dummy {} + + public enum MyEnumType { + /* The elements of enum is initialized in ``. */ + A(1); + + public final int mValue; + + private MyEnumType(int i) { + mValue = i; + } + + /* This field is also initialized in ``, in which `` is called. */ + private static Dummy s = + new Dummy() { + { + /* This loop is in `` function. It needs the results of `` in order to + get `MyEnumType.values()`. */ + for (MyEnumType type : MyEnumType.values()) {} + } + }; + } } diff --git a/infer/tests/codetoanalyze/java/performance/issues.exp b/infer/tests/codetoanalyze/java/performance/issues.exp index 870aad55c..872f30d18 100644 --- a/infer/tests/codetoanalyze/java/performance/issues.exp +++ b/infer/tests/codetoanalyze/java/performance/issues.exp @@ -60,6 +60,9 @@ codetoanalyze/java/performance/CantHandle.java, CantHandle.square_root_FP(int):v codetoanalyze/java/performance/CantHandle.java, CantHandle.square_root_FP(int):void, 2, INTEGER_OVERFLOW_L5, no_bucket, ERROR, [,Assignment,Binary operation: ([0, +oo] + 1):signed32] codetoanalyze/java/performance/CantHandle.java, CantHandle.square_root_variant_FP(int):void, 0, INFINITE_EXECUTION_TIME, no_bucket, ERROR, [Unbounded loop,Loop at line 25] codetoanalyze/java/performance/CantHandle.java, CantHandle.square_root_variant_FP(int):void, 2, INTEGER_OVERFLOW_L5, no_bucket, ERROR, [,Assignment,Binary operation: ([0, +oo] + 1):signed32] +codetoanalyze/java/performance/CollectionTest.java, CollectionTest$MyEnumType$1.(), 0, INFINITE_EXECUTION_TIME, no_bucket, ERROR, [Unbounded loop,Loop at line 91] +codetoanalyze/java/performance/CollectionTest.java, CollectionTest$MyEnumType$1.(), 4, INTEGER_OVERFLOW_L5, no_bucket, ERROR, [,Assignment,Binary operation: ([0, +oo] + 1):signed32] +codetoanalyze/java/performance/CollectionTest.java, CollectionTest$MyEnumType.():void, 0, INFINITE_EXECUTION_TIME, no_bucket, ERROR, [Call to CollectionTest$MyEnumType$1.(),Unbounded loop,Loop at line 91] codetoanalyze/java/performance/CollectionTest.java, CollectionTest.ensure_call(CollectionTest$MyCollection):void, 0, EXPENSIVE_EXECUTION_TIME, no_bucket, ERROR, [with estimated cost 11 + 5 ⋅ list.length, O(list.length), degree = 1,{list.length},call to void CollectionTest.iterate_over_mycollection(CollectionTest$MyCollection),Loop at line 17] codetoanalyze/java/performance/CollectionTest.java, CollectionTest.iterate_over_call_quad(int,CollectionTest$MyCollection):void, 0, EXPENSIVE_EXECUTION_TIME, no_bucket, ERROR, [with estimated cost 4 + 18 ⋅ list.length + 5 ⋅ list.length × list.length + 3 ⋅ (list.length + 1), O(list.length × list.length), degree = 2,{list.length + 1},Loop at line 48,{list.length},call to void CollectionTest.iterate_over_mycollection(CollectionTest$MyCollection),Loop at line 17,{list.length},Loop at line 48] codetoanalyze/java/performance/CollectionTest.java, CollectionTest.iterate_over_mycollection(CollectionTest$MyCollection):void, 0, EXPENSIVE_EXECUTION_TIME, no_bucket, ERROR, [with estimated cost 5 + 5 ⋅ list.length, O(list.length), degree = 1,{list.length},Loop at line 17]