From da8ce0dcc228579d4795973bdfb4f1695a9db996 Mon Sep 17 00:00:00 2001 From: Mikhail Onischuck <43421682+dog-m@users.noreply.github.com> Date: Thu, 25 Apr 2024 16:42:43 +0300 Subject: [PATCH 01/10] Up-to-date approximations sample --- .../src/main/java/generated/java/lang/Double.java | 6 +++--- approximations/src/main/java/generated/java/lang/Float.java | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/approximations/src/main/java/generated/java/lang/Double.java b/approximations/src/main/java/generated/java/lang/Double.java index 54d9ec03..754164f4 100644 --- a/approximations/src/main/java/generated/java/lang/Double.java +++ b/approximations/src/main/java/generated/java/lang/Double.java @@ -32,11 +32,11 @@ public final class Double implements LibSLRuntime.Automaton, Comparable public static final int MIN_EXPONENT = -1022; - public static final double MAX_VALUE = 1.7976931348623157E308; + public static final double MAX_VALUE = 1.7976931348623157E308d; - public static final double MIN_VALUE = 4.9E-324; + public static final double MIN_VALUE = 4.9E-324d; - public static final double MIN_NORMAL = 2.2250738585072014E-308; + public static final double MIN_NORMAL = 2.2250738585072014E-308d; public static final double POSITIVE_INFINITY = 1.0d / 0.0d; diff --git a/approximations/src/main/java/generated/java/lang/Float.java b/approximations/src/main/java/generated/java/lang/Float.java index 1deac7a5..a91df9f6 100644 --- a/approximations/src/main/java/generated/java/lang/Float.java +++ b/approximations/src/main/java/generated/java/lang/Float.java @@ -32,11 +32,11 @@ public final class Float implements LibSLRuntime.Automaton, Comparable { public static final int MIN_EXPONENT = -126; - public static final float MAX_VALUE = 3.4028235e+38f; + public static final float MAX_VALUE = 3.4028235E38f; - public static final float MIN_VALUE = 1.4e-45f; + public static final float MIN_VALUE = 1.4E-45f; - public static final float MIN_NORMAL = 1.17549435e-38f; + public static final float MIN_NORMAL = 1.17549435E-38f; public static final float NEGATIVE_INFINITY = -1.0f / 0.0f; From 0f081f101e0c20f11c19cd112b526b60e1c0ca42 Mon Sep 17 00:00:00 2001 From: Valentyn Sobol Date: Fri, 26 Apr 2024 14:17:17 +0300 Subject: [PATCH 02/10] Upgrade jacodb to "neo" version --- approximations/build.gradle.kts | 8 ++++++-- .../src/main/java/decoders/BaseDecoder.java | 2 +- .../java/io/InputStream$Void_Decoder.java | 8 ++++---- .../decoders/java/lang/Double_Decoder.java | 8 ++++---- .../decoders/java/lang/Float_Decoder.java | 8 ++++---- .../decoders/java/lang/Integer_Decoder.java | 2 +- .../decoders/java/lang/Object_Decoder.java | 4 ++-- .../java/lang/SecurityManager_Decoder.java | 4 ++-- .../java/lang/StringBuffer_Decoder.java | 8 ++++---- .../java/lang/StringBuilder_Decoder.java | 8 ++++---- .../decoders/java/util/ArrayList_Decoder.java | 8 ++++---- .../decoders/java/util/HashSet_Decoder.java | 2 +- .../java/util/LinkedHashSet_Decoder.java | 2 +- .../java/util/LinkedList_Decoder.java | 8 ++++---- .../java/util/OptionalDouble_Decoder.java | 6 +++--- .../java/util/OptionalInt_Decoder.java | 6 +++--- .../java/util/OptionalLong_Decoder.java | 6 +++--- .../decoders/java/util/Optional_Decoder.java | 6 +++--- .../decoders/java/util/Random_Decoder.java | 4 ++-- .../atomic/AtomicBoolean_Decoder.java | 8 ++++---- .../atomic/AtomicInteger_Decoder.java | 8 ++++---- .../concurrent/atomic/AtomicLong_Decoder.java | 8 ++++---- .../atomic/AtomicReference_Decoder.java | 8 ++++---- usvm-api/usvm-api.jar | Bin 8897 -> 8926 bytes 24 files changed, 72 insertions(+), 68 deletions(-) diff --git a/approximations/build.gradle.kts b/approximations/build.gradle.kts index ed543c07..23559ac0 100644 --- a/approximations/build.gradle.kts +++ b/approximations/build.gradle.kts @@ -5,11 +5,15 @@ plugins { repositories { mavenCentral() + maven("https://jitpack.io") } +private val jacodbPackage = "com.github.UnitTestBot.jacodb" +private val jacodbVersion = "890624770b" // jacodb neo branch + dependencies { - compileOnly("org.jacodb:jacodb-api:1.4.0") - compileOnly("org.jacodb:jacodb-approximations:1.4.0") + compileOnly("$jacodbPackage:jacodb-api-jvm:$jacodbVersion") + compileOnly("$jacodbPackage:jacodb-approximations:$jacodbVersion") compileOnly(files(rootDir.resolve("usvm-api/usvm-api.jar"))) } diff --git a/approximations/src/main/java/decoders/BaseDecoder.java b/approximations/src/main/java/decoders/BaseDecoder.java index fe1672a0..942e037b 100644 --- a/approximations/src/main/java/decoders/BaseDecoder.java +++ b/approximations/src/main/java/decoders/BaseDecoder.java @@ -1,6 +1,6 @@ package decoders; -import org.jacodb.api.*; +import org.jacodb.api.jvm.*; import org.usvm.api.decoder.DecoderApi; import java.util.ArrayList; diff --git a/approximations/src/main/java/decoders/java/io/InputStream$Void_Decoder.java b/approximations/src/main/java/decoders/java/io/InputStream$Void_Decoder.java index ce3ee17a..c49312f8 100644 --- a/approximations/src/main/java/decoders/java/io/InputStream$Void_Decoder.java +++ b/approximations/src/main/java/decoders/java/io/InputStream$Void_Decoder.java @@ -1,9 +1,9 @@ package decoders.java.io; -import org.jacodb.api.JcClassOrInterface; -import org.jacodb.api.JcMethod; -import org.jacodb.api.JcParameter; -import org.jacodb.api.JcType; +import org.jacodb.api.jvm.JcClassOrInterface; +import org.jacodb.api.jvm.JcMethod; +import org.jacodb.api.jvm.JcParameter; +import org.jacodb.api.jvm.JcType; import org.usvm.api.decoder.DecoderApi; import org.usvm.api.decoder.DecoderFor; import org.usvm.api.decoder.ObjectData; diff --git a/approximations/src/main/java/decoders/java/lang/Double_Decoder.java b/approximations/src/main/java/decoders/java/lang/Double_Decoder.java index de7b283b..269147fe 100644 --- a/approximations/src/main/java/decoders/java/lang/Double_Decoder.java +++ b/approximations/src/main/java/decoders/java/lang/Double_Decoder.java @@ -1,9 +1,9 @@ package decoders.java.lang; -import org.jacodb.api.JcClassOrInterface; -import org.jacodb.api.JcField; -import org.jacodb.api.JcMethod; -import org.jacodb.api.JcParameter; +import org.jacodb.api.jvm.JcClassOrInterface; +import org.jacodb.api.jvm.JcField; +import org.jacodb.api.jvm.JcMethod; +import org.jacodb.api.jvm.JcParameter; import org.usvm.api.decoder.DecoderApi; import org.usvm.api.decoder.DecoderFor; import org.usvm.api.decoder.ObjectData; diff --git a/approximations/src/main/java/decoders/java/lang/Float_Decoder.java b/approximations/src/main/java/decoders/java/lang/Float_Decoder.java index d9a43dbe..640f9b4c 100644 --- a/approximations/src/main/java/decoders/java/lang/Float_Decoder.java +++ b/approximations/src/main/java/decoders/java/lang/Float_Decoder.java @@ -1,9 +1,9 @@ package decoders.java.lang; -import org.jacodb.api.JcClassOrInterface; -import org.jacodb.api.JcField; -import org.jacodb.api.JcMethod; -import org.jacodb.api.JcParameter; +import org.jacodb.api.jvm.JcClassOrInterface; +import org.jacodb.api.jvm.JcField; +import org.jacodb.api.jvm.JcMethod; +import org.jacodb.api.jvm.JcParameter; import org.usvm.api.decoder.DecoderApi; import org.usvm.api.decoder.DecoderFor; import org.usvm.api.decoder.ObjectData; diff --git a/approximations/src/main/java/decoders/java/lang/Integer_Decoder.java b/approximations/src/main/java/decoders/java/lang/Integer_Decoder.java index 41e7d40b..0c5f4a83 100644 --- a/approximations/src/main/java/decoders/java/lang/Integer_Decoder.java +++ b/approximations/src/main/java/decoders/java/lang/Integer_Decoder.java @@ -1,6 +1,6 @@ package decoders.java.lang; -import org.jacodb.api.*; +import org.jacodb.api.jvm.*; import org.usvm.api.decoder.DecoderApi; import org.usvm.api.decoder.DecoderFor; import org.usvm.api.decoder.ObjectData; diff --git a/approximations/src/main/java/decoders/java/lang/Object_Decoder.java b/approximations/src/main/java/decoders/java/lang/Object_Decoder.java index f975e86f..e9277bb5 100644 --- a/approximations/src/main/java/decoders/java/lang/Object_Decoder.java +++ b/approximations/src/main/java/decoders/java/lang/Object_Decoder.java @@ -1,7 +1,7 @@ package decoders.java.lang; -import org.jacodb.api.JcClassOrInterface; -import org.jacodb.api.JcMethod; +import org.jacodb.api.jvm.JcClassOrInterface; +import org.jacodb.api.jvm.JcMethod; import org.usvm.api.decoder.DecoderApi; import org.usvm.api.decoder.DecoderFor; import org.usvm.api.decoder.ObjectData; diff --git a/approximations/src/main/java/decoders/java/lang/SecurityManager_Decoder.java b/approximations/src/main/java/decoders/java/lang/SecurityManager_Decoder.java index 0a0423fc..7fa402fc 100644 --- a/approximations/src/main/java/decoders/java/lang/SecurityManager_Decoder.java +++ b/approximations/src/main/java/decoders/java/lang/SecurityManager_Decoder.java @@ -1,7 +1,7 @@ package decoders.java.lang; -import org.jacodb.api.JcClassOrInterface; -import org.jacodb.api.JcMethod; +import org.jacodb.api.jvm.JcClassOrInterface; +import org.jacodb.api.jvm.JcMethod; import org.usvm.api.decoder.DecoderApi; import org.usvm.api.decoder.DecoderFor; import org.usvm.api.decoder.ObjectData; diff --git a/approximations/src/main/java/decoders/java/lang/StringBuffer_Decoder.java b/approximations/src/main/java/decoders/java/lang/StringBuffer_Decoder.java index c73ce954..a79d1220 100644 --- a/approximations/src/main/java/decoders/java/lang/StringBuffer_Decoder.java +++ b/approximations/src/main/java/decoders/java/lang/StringBuffer_Decoder.java @@ -1,9 +1,9 @@ package decoders.java.lang; -import org.jacodb.api.JcClassOrInterface; -import org.jacodb.api.JcField; -import org.jacodb.api.JcMethod; -import org.jacodb.api.JcParameter; +import org.jacodb.api.jvm.JcClassOrInterface; +import org.jacodb.api.jvm.JcField; +import org.jacodb.api.jvm.JcMethod; +import org.jacodb.api.jvm.JcParameter; import org.usvm.api.decoder.DecoderApi; import org.usvm.api.decoder.DecoderFor; import org.usvm.api.decoder.ObjectData; diff --git a/approximations/src/main/java/decoders/java/lang/StringBuilder_Decoder.java b/approximations/src/main/java/decoders/java/lang/StringBuilder_Decoder.java index b26b0c77..a4abacdc 100644 --- a/approximations/src/main/java/decoders/java/lang/StringBuilder_Decoder.java +++ b/approximations/src/main/java/decoders/java/lang/StringBuilder_Decoder.java @@ -1,9 +1,9 @@ package decoders.java.lang; -import org.jacodb.api.JcClassOrInterface; -import org.jacodb.api.JcField; -import org.jacodb.api.JcMethod; -import org.jacodb.api.JcParameter; +import org.jacodb.api.jvm.JcClassOrInterface; +import org.jacodb.api.jvm.JcField; +import org.jacodb.api.jvm.JcMethod; +import org.jacodb.api.jvm.JcParameter; import org.usvm.api.decoder.DecoderApi; import org.usvm.api.decoder.DecoderFor; import org.usvm.api.decoder.ObjectData; diff --git a/approximations/src/main/java/decoders/java/util/ArrayList_Decoder.java b/approximations/src/main/java/decoders/java/util/ArrayList_Decoder.java index 3e7fc6a8..162bde35 100644 --- a/approximations/src/main/java/decoders/java/util/ArrayList_Decoder.java +++ b/approximations/src/main/java/decoders/java/util/ArrayList_Decoder.java @@ -1,9 +1,9 @@ package decoders.java.util; -import org.jacodb.api.JcClassOrInterface; -import org.jacodb.api.JcField; -import org.jacodb.api.JcMethod; -import org.jacodb.api.JcParameter; +import org.jacodb.api.jvm.JcClassOrInterface; +import org.jacodb.api.jvm.JcField; +import org.jacodb.api.jvm.JcMethod; +import org.jacodb.api.jvm.JcParameter; import org.usvm.api.SymbolicList; import org.usvm.api.decoder.DecoderApi; import org.usvm.api.decoder.DecoderFor; diff --git a/approximations/src/main/java/decoders/java/util/HashSet_Decoder.java b/approximations/src/main/java/decoders/java/util/HashSet_Decoder.java index d58a6983..0f787250 100644 --- a/approximations/src/main/java/decoders/java/util/HashSet_Decoder.java +++ b/approximations/src/main/java/decoders/java/util/HashSet_Decoder.java @@ -1,6 +1,6 @@ package decoders.java.util; -import org.jacodb.api.*; +import org.jacodb.api.jvm.*; import org.usvm.api.SymbolicMap; import org.usvm.api.decoder.DecoderApi; import org.usvm.api.decoder.DecoderFor; diff --git a/approximations/src/main/java/decoders/java/util/LinkedHashSet_Decoder.java b/approximations/src/main/java/decoders/java/util/LinkedHashSet_Decoder.java index 700f42d3..2ba5090a 100644 --- a/approximations/src/main/java/decoders/java/util/LinkedHashSet_Decoder.java +++ b/approximations/src/main/java/decoders/java/util/LinkedHashSet_Decoder.java @@ -1,6 +1,6 @@ package decoders.java.util; -import org.jacodb.api.*; +import org.jacodb.api.jvm.*; import org.usvm.api.SymbolicMap; import org.usvm.api.decoder.DecoderApi; import org.usvm.api.decoder.DecoderFor; diff --git a/approximations/src/main/java/decoders/java/util/LinkedList_Decoder.java b/approximations/src/main/java/decoders/java/util/LinkedList_Decoder.java index 47383b85..b2c3896f 100644 --- a/approximations/src/main/java/decoders/java/util/LinkedList_Decoder.java +++ b/approximations/src/main/java/decoders/java/util/LinkedList_Decoder.java @@ -1,9 +1,9 @@ package decoders.java.util; -import org.jacodb.api.JcClassOrInterface; -import org.jacodb.api.JcField; -import org.jacodb.api.JcMethod; -import org.jacodb.api.JcParameter; +import org.jacodb.api.jvm.JcClassOrInterface; +import org.jacodb.api.jvm.JcField; +import org.jacodb.api.jvm.JcMethod; +import org.jacodb.api.jvm.JcParameter; import org.usvm.api.SymbolicList; import org.usvm.api.decoder.DecoderApi; import org.usvm.api.decoder.DecoderFor; diff --git a/approximations/src/main/java/decoders/java/util/OptionalDouble_Decoder.java b/approximations/src/main/java/decoders/java/util/OptionalDouble_Decoder.java index 905a3d38..bc23ed21 100644 --- a/approximations/src/main/java/decoders/java/util/OptionalDouble_Decoder.java +++ b/approximations/src/main/java/decoders/java/util/OptionalDouble_Decoder.java @@ -4,9 +4,9 @@ import java.util.List; import java.util.OptionalDouble; -import org.jacodb.api.JcClassOrInterface; -import org.jacodb.api.JcField; -import org.jacodb.api.JcMethod; +import org.jacodb.api.jvm.JcClassOrInterface; +import org.jacodb.api.jvm.JcField; +import org.jacodb.api.jvm.JcMethod; import org.usvm.api.decoder.DecoderApi; import org.usvm.api.decoder.DecoderFor; import org.usvm.api.decoder.ObjectData; diff --git a/approximations/src/main/java/decoders/java/util/OptionalInt_Decoder.java b/approximations/src/main/java/decoders/java/util/OptionalInt_Decoder.java index ac1df0ce..0524167c 100644 --- a/approximations/src/main/java/decoders/java/util/OptionalInt_Decoder.java +++ b/approximations/src/main/java/decoders/java/util/OptionalInt_Decoder.java @@ -1,8 +1,8 @@ package decoders.java.util; -import org.jacodb.api.JcClassOrInterface; -import org.jacodb.api.JcField; -import org.jacodb.api.JcMethod; +import org.jacodb.api.jvm.JcClassOrInterface; +import org.jacodb.api.jvm.JcField; +import org.jacodb.api.jvm.JcMethod; import org.usvm.api.decoder.DecoderApi; import org.usvm.api.decoder.DecoderFor; import org.usvm.api.decoder.ObjectData; diff --git a/approximations/src/main/java/decoders/java/util/OptionalLong_Decoder.java b/approximations/src/main/java/decoders/java/util/OptionalLong_Decoder.java index c11f29ee..5863f529 100644 --- a/approximations/src/main/java/decoders/java/util/OptionalLong_Decoder.java +++ b/approximations/src/main/java/decoders/java/util/OptionalLong_Decoder.java @@ -1,8 +1,8 @@ package decoders.java.util; -import org.jacodb.api.JcClassOrInterface; -import org.jacodb.api.JcField; -import org.jacodb.api.JcMethod; +import org.jacodb.api.jvm.JcClassOrInterface; +import org.jacodb.api.jvm.JcField; +import org.jacodb.api.jvm.JcMethod; import org.usvm.api.decoder.DecoderApi; import org.usvm.api.decoder.DecoderFor; import org.usvm.api.decoder.ObjectData; diff --git a/approximations/src/main/java/decoders/java/util/Optional_Decoder.java b/approximations/src/main/java/decoders/java/util/Optional_Decoder.java index 1903b22b..433de15c 100644 --- a/approximations/src/main/java/decoders/java/util/Optional_Decoder.java +++ b/approximations/src/main/java/decoders/java/util/Optional_Decoder.java @@ -1,8 +1,8 @@ package decoders.java.util; -import org.jacodb.api.JcClassOrInterface; -import org.jacodb.api.JcField; -import org.jacodb.api.JcMethod; +import org.jacodb.api.jvm.JcClassOrInterface; +import org.jacodb.api.jvm.JcField; +import org.jacodb.api.jvm.JcMethod; import org.usvm.api.decoder.DecoderApi; import org.usvm.api.decoder.DecoderFor; import org.usvm.api.decoder.ObjectData; diff --git a/approximations/src/main/java/decoders/java/util/Random_Decoder.java b/approximations/src/main/java/decoders/java/util/Random_Decoder.java index 8c705b54..ba494088 100644 --- a/approximations/src/main/java/decoders/java/util/Random_Decoder.java +++ b/approximations/src/main/java/decoders/java/util/Random_Decoder.java @@ -1,8 +1,8 @@ package decoders.java.util; -import org.jacodb.api.JcClassOrInterface; -import org.jacodb.api.JcMethod; +import org.jacodb.api.jvm.JcClassOrInterface; +import org.jacodb.api.jvm.JcMethod; import org.usvm.api.decoder.DecoderApi; import org.usvm.api.decoder.DecoderFor; import org.usvm.api.decoder.ObjectData; diff --git a/approximations/src/main/java/decoders/java/util/concurrent/atomic/AtomicBoolean_Decoder.java b/approximations/src/main/java/decoders/java/util/concurrent/atomic/AtomicBoolean_Decoder.java index d0c5ffc6..f49d0da5 100644 --- a/approximations/src/main/java/decoders/java/util/concurrent/atomic/AtomicBoolean_Decoder.java +++ b/approximations/src/main/java/decoders/java/util/concurrent/atomic/AtomicBoolean_Decoder.java @@ -1,9 +1,9 @@ package decoders.java.util.concurrent.atomic; -import org.jacodb.api.JcClassOrInterface; -import org.jacodb.api.JcField; -import org.jacodb.api.JcMethod; -import org.jacodb.api.JcParameter; +import org.jacodb.api.jvm.JcClassOrInterface; +import org.jacodb.api.jvm.JcField; +import org.jacodb.api.jvm.JcMethod; +import org.jacodb.api.jvm.JcParameter; import org.usvm.api.decoder.DecoderApi; import org.usvm.api.decoder.DecoderFor; import org.usvm.api.decoder.ObjectData; diff --git a/approximations/src/main/java/decoders/java/util/concurrent/atomic/AtomicInteger_Decoder.java b/approximations/src/main/java/decoders/java/util/concurrent/atomic/AtomicInteger_Decoder.java index 975403d3..51ccf0a8 100644 --- a/approximations/src/main/java/decoders/java/util/concurrent/atomic/AtomicInteger_Decoder.java +++ b/approximations/src/main/java/decoders/java/util/concurrent/atomic/AtomicInteger_Decoder.java @@ -1,9 +1,9 @@ package decoders.java.util.concurrent.atomic; -import org.jacodb.api.JcClassOrInterface; -import org.jacodb.api.JcField; -import org.jacodb.api.JcMethod; -import org.jacodb.api.JcParameter; +import org.jacodb.api.jvm.JcClassOrInterface; +import org.jacodb.api.jvm.JcField; +import org.jacodb.api.jvm.JcMethod; +import org.jacodb.api.jvm.JcParameter; import org.usvm.api.decoder.DecoderApi; import org.usvm.api.decoder.DecoderFor; import org.usvm.api.decoder.ObjectData; diff --git a/approximations/src/main/java/decoders/java/util/concurrent/atomic/AtomicLong_Decoder.java b/approximations/src/main/java/decoders/java/util/concurrent/atomic/AtomicLong_Decoder.java index ab0c2814..8d35b12e 100644 --- a/approximations/src/main/java/decoders/java/util/concurrent/atomic/AtomicLong_Decoder.java +++ b/approximations/src/main/java/decoders/java/util/concurrent/atomic/AtomicLong_Decoder.java @@ -1,9 +1,9 @@ package decoders.java.util.concurrent.atomic; -import org.jacodb.api.JcClassOrInterface; -import org.jacodb.api.JcField; -import org.jacodb.api.JcMethod; -import org.jacodb.api.JcParameter; +import org.jacodb.api.jvm.JcClassOrInterface; +import org.jacodb.api.jvm.JcField; +import org.jacodb.api.jvm.JcMethod; +import org.jacodb.api.jvm.JcParameter; import org.usvm.api.decoder.DecoderApi; import org.usvm.api.decoder.DecoderFor; import org.usvm.api.decoder.ObjectData; diff --git a/approximations/src/main/java/decoders/java/util/concurrent/atomic/AtomicReference_Decoder.java b/approximations/src/main/java/decoders/java/util/concurrent/atomic/AtomicReference_Decoder.java index 624f48bb..9ae77a6a 100644 --- a/approximations/src/main/java/decoders/java/util/concurrent/atomic/AtomicReference_Decoder.java +++ b/approximations/src/main/java/decoders/java/util/concurrent/atomic/AtomicReference_Decoder.java @@ -1,9 +1,9 @@ package decoders.java.util.concurrent.atomic; -import org.jacodb.api.JcClassOrInterface; -import org.jacodb.api.JcField; -import org.jacodb.api.JcMethod; -import org.jacodb.api.JcParameter; +import org.jacodb.api.jvm.JcClassOrInterface; +import org.jacodb.api.jvm.JcField; +import org.jacodb.api.jvm.JcMethod; +import org.jacodb.api.jvm.JcParameter; import org.usvm.api.decoder.DecoderApi; import org.usvm.api.decoder.DecoderFor; import org.usvm.api.decoder.ObjectData; diff --git a/usvm-api/usvm-api.jar b/usvm-api/usvm-api.jar index a35f4f6e907e699169733e90d13dae73310a59d3..f596e33f9f062bd54efda23291732f8be639f969 100644 GIT binary patch literal 8926 zcmaia1z40@*EZeFNQZzkNQ-ngNOwp&3^mf-Al)e?-KcaUAdSQ*B_Sb=2-1i&e8ca5 z^vL_3^DeGuc;>p+y7!(nd*6FK_Zl@tWE21b0tNpUf_lazm#RPB-rFt zWI2!#)c$a+@kiRBggcPKFL?NGM`Z~Wd081vEp}zuL*@4{B}F#&QCvkf=Ark)wHgn` zxfa)!*N|?3!Q+38iUPm4ce4DC0sroEGqW2XS7$fde|5zDyCc{E`mfG+ZabTqL+s7W zo&FW}v&XT+hNFjt=n!GI^9$T=!?UimRRwQ@D!*?7~i z(V#td@ipX&6eHF6b8AP9ZKe?B#LhE^vV{vl6<7WUu7QC=A4zB$Q*6BmRjCGPo0E1U zt$jWXGVl1x6bl>LGP{7J3)BK0jFPiVh$TcY8df) z#49-r#4~gb-(56%YlgL;jvLwqJ@Rnr0pw%|LKWSRGKjpm-D)ns&Es2Jl9Lq^`YCcB z%|A);i2MZj5N;GPX#$V9~^$m>)ur1Uz_@fJQ21VnZ%8Iwo$O+*r z#o_!q3I@b1?`V*-we0 zp`j6@iMpYIWYLN)@?9>+mTL?zdjgd%lg3vslE&$MuM5k@SBXe5;<5rl5+v@jRI{p! zF>-QHGY|B4q#7or>m_c!&^1gv9N#+YQpu+nTjvuD}#ntr%7 zaXi1SXI0CZ)+Ys&a&K7;!8HydQCwe)-|SsRPR<|1_3@BMQ6cJ?-9{~Db(a=Ij*WCC zI9P9%&;=x&42m~1BN%)SV;xX>KTsx#RV}y~LKbR*83ra}kP;IK#C$|Rt|3n9h`OFi z0xW4Z|ANphhXJJ944@i(*Wc0K@g4z5sl#Ppumf$iHpl~qN?eo?nKW}4*KGgU40z$=2{XOiBks4h8o=?65`MWuk^R7UG;(xV43+;*>dZ$8RN`d^ zhI2{_GsBh8%{ogG7=2C}zlx=5iI4%a(H?mc)jLWW9@7R#Q87+ZfK|O+b4nL1JvPkq z=>@+4#rqhHyB$1at-SjiPRR8A>VH5IQ`~jK4Jj<@DfWipAc>6BUKHDl=lX7c} z5Bd(#f>awmemE_?SRnPX(Q4mbum`>;EnYZ&LQdeLObI`<;Rutv?U_pq@!=+P?V)@< z_6c!I)cfA6#QZ=}DN*zn{89GTv*`VvQ*qa~R&C-AmFsu--gkoYz(1Y_|9{oW+B^MR zwYKps3djL`qS`8#Uw>BA??ob^CT7F}Cgft40Z$R}#c z>YZ##`_6U?ZyZEL7v>QSP5C6E99E_BUe_4kf6M*!-J2XoHTQP6RjEK;x~y;dETu+y zJ0;FTkU&?cZOx1TttN!kyrKQX;toCympHQr7$P)uPRDQE@goP=hqRXht>gJ z#3mt`a__Jv?01?^iZRjSlA|m-Rg1YbVIK|>9r%qspA<`Vs>{+=R^YR7eCpkD9YCtD zT@PEr45$Ka_OCypNqi!eUm?x*T{=T-o}{6-SYw(H$Z=Pec7ya!>V#+P*O^apn>wL( zF6K^lV4MFqdNrRfj&~!&YZD9v1lE6y()6@7wYPynl%UQo^0p2(KXV?VrS43u4Y;y% zYncU6zU%~88$el7?$t>%)AQDce^TIP)&o)dnm*qOW|QZwopvc3z9KUA*q5+$N$ZMU zsTJ!GTWohA+i!8_Q%pxVh@Y!n_gfcQ5Lll-UvH1|LwCSTzDG2o^pynk1Vd?e7TvAd z+&#Uw()wIQgx~@1=U7S`Osh9O6Fr3;OsJdacBLL4j<>rbXR#9>dO0TU`l z*HPjIyjYjj0q)siTNVMj-DlrmR{>U6Z%FNwWT1B;pTkG>fR6XcZ@!d9I|_;Pr5;*7Xg_M6 z5&`H@yfWkWd}XMk_7N&zThgt!l-NWkBy^nkK=%8^S?q2-l#p6q7Pi41)RM;{+!e(E zA_rv6<8Gb3<=D0xuS-t-iVLA1<>PJSdv{*LvvcN;J783~JC#MPi`5?+yB=uPLuBuW zBusW;zN-91f6+Rj!_(M_juz{xa?F{Sg6&E39zp&d*_TFq&Lhgi_K^~B%=LjMA}9}n zMQZh!jz*>xcC^enET~Io@72@Rt-S-pZm0JQh6d!A8cS^#hVeg#WDcY~uS9ZvG-O~{ zl%KSkDb%HeBo-HM0oYK&hJHu^c1RlgLsV z!r~m2lk37%n=;fUUG>vzM2m{JzK}GKbLQ!*k$?_j<=WfTd6EW9U>v3X;bI(TNpXHkdu23c7a1HlHJfP^R zpgflw{*VrfpR2QheKuA5?xWp%ue%I=vstJ6e&kTC$mnFQq&yvNg=r*&Vx2riU*+>x zH8XOHd=R2wF7GR=>a**_MNdb8CjVW2p%a}F@1~6 zYslpjFM(|Zv)C1SMmAIU*iEG@Z>Glb>Yv0yq z8>`F(<9=hVfCciAJ#@tA&J@j`X%v|6Y`Le|qWEHgg8t*DuFs22Om|cTEoxm&6{gUs z8u#d=nkQ?Fz|&cY@~(ztlhINU91b?i4Eeb>4U|dlvb1DK0uHoXhSAX)3n-k0%sQV* z?56U-{W7ZdG)Y+K6J0t1#cOuoJ|%HkOnroF9e&JLKqR?K_I}mYDX&NrW z>sIhA!vvk3-dC)=qg%FWLaC(a3$t1mA!B9NaC_@;2gtpAZGEE>iygh1HD~0vpW~C7WZfZ1I0oNg z{pSgjLN3URRWb548wW+}jH{sbmbSS7v4{ESJoV9l3~%{@GfH!vU$)|oGn(hy~-7Z z`pWBcVS9%%hrZMZKZ{iJW3Cy@;K$JLqzHeHoUowS!<8V_@Tr6wpKFP;$dfEbF6kVnowj)62g3 z&RBM%)OdtT?RKXZGrQ5l-)i04R1aqkoe{$;XFM4)$hpG)lNL6o7ei;@v=9ZS1+M=| z3-V^>b}mpC&s+3h1g8gph;@;Ujs4iT9YjI%5wf!Rx|B~{-8dZ(pn)!=92GQM?4#wV zrCZMWlODu+kl!O@b>MV!iA65$C}^|7UT}8@)lVH~iyY6_>RMkP?$Y`rHeoTupaAYb zs7m6^(!A`pD4T8hm3^&`-%Rh3C9p#fW^|XRS2hZ64;0 zQK4W?0z6z~2JwR&)4{K{d5?_U+lwfv6&tCBU8uV!tuH6-W*aCf$*hiLOCem*+vM4u z4$WR^A*Mw*Lw8H*`y5Hu$w2h#GZXcG56ojIkzTBOAg^zDe=H>VQore7QY1MCy+6%3z@ErcxzeLB@ToW#cZ0kV*~_mSDHD2GSO(5Cx)auq+eyBbZS+SDwVTx87nLl zN$LuND(Gz7>BnTIXtztSUFphW+p+4TcSt1KtP!E9Bx{G(kIE>yhUTCB2`C`o2PNsyEu&p#<}}Lzoodv zc57yJKxY=WyMnR;*oHpDx%*b@qz3{NOPlrieu!zaL1e^*-AT>nK=1o978eHm7xi#r?0N}Lyf z1CY6y=`$|s6{WCD7h6s0z(daR{QT%eL;emIBr*I13*bf_KK7%K`T!0lKSm;!uxf?- z8p&nKtmv5562zYE5q#u$dnq2Rusxy3?tw#O>NN=UT2PW-e#`1?KGz=cQMepodjAj! zelCm010Mn|X&3e4w4+Y2Ke2>=SF@^)WU+{JvXmB3+E?a&J79E;#|FJf7*qO7KtC;L zIXRpzgHkO$EO{?&O!)mUgMz;@$t4+;V;wEf^zh-eSX_h3B(g9L(bfH{FC*y&CzLOg z6I|7^_dlTEwPYp5qk2I}pfxFIb;BX3t9uwi2fgWq?2`;L>s=Zsn;8V!c=gx3b#2|p zPQC}Ue^LdvJm&dBxZhq&~^B0piZ#%!9 z5g3oT))#%fV^BS@92GiK&-1ZK{4m;1Aj#|s$~3LM-7u}>b|xYOO>?WM0P(Dh`&95k z03}hv>oT&iR|f=!)odTE%s=wTE(K0Y^B$Tn;+VCWYDjJ z)8qwF5GUD)Q5^KohpfcLjurYJ?79idt=Och&q<^y-)t7_6E^l8IJH8lM&&(;gorxwDcvn(6 z^({~GicmH`M>&;T2r=YN3hMpuK-Ii8hk@?(qm-3%nzs8btl~!;ak?ftTV4jQk4Bm% zw7gvW2f%=xrC_J)ux~!d(X3^R3aO(L^1RYu{`b@;(c0cw`-p?u_%##h{Z9(%i;ACq zN*5t`F_(!FuZ1vv+QTbJ5Sk%FDMfIf363bur%!WV*z1H+cd1!OV zz7gNIR>oaNw(=!Ddg%-25VGsXosO99K^tZM8-o@pX-$+YLcCD zREZUS+y4YW!eVR;ACDD9OhXhwIU<~Laj(2lTX{Q*;Gc73@D&**w~6^JbPmXtkq@3+n(x8L>CBf z1I-Hrh&&Zp;aau&JT`qj*E7?A;UYr#j+H~hW+czq-SmTRohykhdnE?W%LBd`{WKYU z5Y!zjJ#d#ng+BhSwaA*f2EF@B3LUgf&#JHJ@|j$OmPd~UPiF0@u-TTO;l6z?4c5u7 zvl*WkvOc7J6kO-uS>YYi_0XKC@G{mYMD!;XMe9_S7vN`!Q9aW>2FNeY7U$I;HCV++$yWegRdlkX;qA)z) z1@L@>{wd#oEB$`vJwzR*(*1zIFcq{BBo{z3sJM)D54}HxIL1r*wMGw}Hs0La6PXH% zl0ikRoOc2Eiv-QHIl zVO6b?fMvd6u>QhOuBqN!c5j3)d6@g7BwKUQ*tW`2@!s*MihgcT*-@~JV?Z0SwjR^V zgD0c7rU~loW6X&fS3em0B%}0*OcyAfn{5lV&(F67EvdZ?H>mr3XQCHbnyR0=QF9DE zesPqWI9g%C@+`fzWSXGFrU9g%Hywx2gQs0q7;XI`omADw51PBgfHf|g;Y zJNF%9xGGq0g=_BHCKdbZ^MhOJUTLkL)=gt%7=F?IQ~qz{xu1#mjTcdcCqC4qu`_S2 z6ji^cKQJ?dRjF=M=bmB$S>UIS{gH-i1(DAmt(CYgqVE+DtlwoGM@q3-ci)_nGir4*woF^ei)^k~mErq#)jHmPz)}q z;dwbMo7P)25q9SEsutRe&ibb@U2>hH^}1YDnT%{TR-A#=Q>(qknUc9LUhEHzWd@`N z8)bq#5b%WLNy7?{A8qHVUJ=GNUSXb=2wjn*+0GHH8(aqdNOg@+_l9c+YKn+R0OWse z$HFrSHv)uhiJSkwnzOgVZZ~IdoNuf!fC>KkE9`Hr+S>>>-tevS|LmqC`_pa)c7xyE zlu7>zx^ZhuTJi5 zh})gqzd#BDfbfO;Um8Z)ebNb@KKAw;xk}53md8 zia%!l_lK6-Ft>}4-!OXcpK<&F^S96alc8^8-9BJ{WA#(~1J>U@>VL<)eQ5l~d_?sR an7@w@HAPgkn*bvCpAh_q88Os1@BRtQ&Q$8I zi=gqRVsV9wUbR2sJ_THX41N**RZ&$^O;Ju(OPgC&?u+V&K^0{#?lCN7F81LMBQ=^l z9|0>HYa57v0W-gKDiR#*sf*2T2j14X`DQmdZqM8u{#6m{uZm_)cK@nObX(cd%HpY| zmCOG#Vu7R^bei}PKd&7M6=h&OsREqX_UB6O)b$mQU#(f2?*Q4?I){6EK`x*};H3)kH6GR)-Vqc>5cR#8OT(8PjrIXT% zP9-Yt_x@Z0FogI7vx+BjO`C!gUGQQTlGPud398!4)5P@QofsSF5xrIeZdKB5do1dJ zJM(60Dd*`ceW`BB&W-#U0-s(WW>SFt=F8&euE+-e_b z-brJ61C3uwd-(j=0Gh_Y&(SRKLn}zyx8zwVpYqPtT@IX{Ea&hRx3R`*wu)VX>99|M zN3QZ(`C7{Wj4RJ84q5SHN_ApuZOG=J@qB~ld-uaYwGALQ^S2R$Q{%V9Bux#_&skp> z3|CSq1w*YGQ{D=uPe=rjZMWsGZQ=@W{vHpK>_IIkfci!z3jM3b0>3x~8~azGoR z^;QLs$d9QWv9!PR!PzGemsko2gGNOQnZ5L+_|7Xz=NEB_>HZ>!25Cjw)%GKQR~`tEj|Gb~tHx zh5(B9)Nw*;5oS#Kvauk&ByPNn@Ww)7LM3aSl|a#S>kQ^zLC*B5I=@x0q#_Kl zEu6a?eGE`_k=ZERW?3ZeJVwGl66+~gEY}>bO+~)Y)1cPntPPOCIgRz60|Y6Y{UgD4diK`bnO>B zV@DL%PhEBw#mC*Q)IHmh=^Py0uuCY!)|{IARvre*Boo;!gOLSRLWb0T_nT`^|3C-a zXW_{I;x~13dn*f988cV2pMJ~NHc(%aAQf9LDHAf)BRR;~msJrwMK%c_y&sIEwJz;- z?7$kQsVP!`&3q|9bBcPF`@t_=7y1P6!o{Uv>kTmOZFgP$SpPK4F8JBuaTzLp$nYg}v%6)R2m4vUHd&aK48StU0&~5lkXQAM1OuJgs z*b2#DhN+_Fs8+3w$!DWv$)X%*3r9x7?}XqKl4>VkWP9#heq7l!_C4@yzSyOkZQsfD zTNfqZ6 z+)$j)i*0@W+>$-PHoD%NZAMb z6KDi?WX&Mcp9K_!9B_#0LQYbZ=S;>yu2)syOhrNdW#(gJh{G#!X(}t(@Qy=+^~~$v zBY;?lzyJjv0h{oI&-zcv{*MUwneu-Ifyl|zX%Gqu3IPhp9fjH*#aIrd9hUPE8mm3h zx)uvbmBSbNtlIjUQ-d3NYNYak74HY_4dB zH%etBNT-`@zgM*SAT1jAiAbPYaM3tYY$T>sidPC#N;oh@M}ba9Ha)uYkYTkF!@_dA z!0iy>9=$Z$HhIO$<#-NEyWs<+X(O8CtH7d(yTI5O$$OdkxYP_m2+d(Lq-3OI$)pki z;UO`Q6bN#k4e}A`On{F&3bt@2LEjo;P2-*4ec6pknIHf!@amX98;3t@_)Te+b+oZ_ zwEE)>O8oqcT!*k{1Q{Rweclj;YMq_pJZVw=Ozo7uEm%rI(H0+h3`&-c>~1=5MUupn zc&Xa%SCR`jUlboWYVuHQKXZc30lz(`Qf71uX7n)J`bLD{sAGULdPXaBP^~Y=%_@l-?I1W^n(&I;Cq|wBgrc zy`!H#reFQl5cqJs*_?j@NY$>Qv;!;>)7uq%q2*=-6ti-*QyFFjrJ8j-OSD?x8rEe` zQ5B}QDz{^G9|_zxu0Qtlfeux*Qa(lJ%0>3VpD!pbji5shzh_Jte&V2mRBr?^RIZYt z4FmQ=Tn1~wcx)B|FoiLv^OxM({rsu)mAg_zu3FBV$eg*9v%KCp5@??rRSXjIzmkP@`>k+lzeoE(oQqVUZ58P} zDk2ZH2vVKR+chZOd}ngxj>4cw8%YA$9#r0ks@sG(JCHBOv z0^Kf%s!R@b2UFuaL{3;bUpNr*}@gW z_(}=ma2<;BxpOSr_g1Sj%7^TjBl_()miRGI-&;w)ILGfX%K?|nuqR(nn?#+sqb^rs z-%4i$`%rxr_T7|Ex-{xLkjTiHr~W#dX?W}%{Z!%ycI0p@H7#{=Z640iDdf@knQ4@; z@<7L8c1xw2{sKRW7fu%txae^};k9nXqu_42?8LvUPSJUm8BmA-_Cll{z3@ZuLO{<5 z2up6qdB=_5oe?1aHJj$$9fYuqfZn1g9Ep(Y-cR@X#tFm&7!Y2I-AVfzL-TGL!Ds!R zXT;>aNC&Gs(ci480(wj@z+H*CRO0o-;JJ5+VdWAu7gcp;0F-)lQx0>y^v9qWwP4|) zV@|G_W(F4XD5W5RBg|!C^Xtp%O`A;roDQu+ThP~tf*+#lT}@RT(%!T^!k4JO=Nfpb z{&SKczMZ%299^wk9L>Q0ueF!lguNKQi-7PFK4Jj=(Mrq9!Tc%M&O*`B%F)%%)l1dP zNzuUx{73H6anPdBA@p-xN@T?7&SRQF)Ff=aSG%iRS0~A?TZI;H&r?@^zb)9I*{!A@ zEcgL>{|BA;cI2F-4W;-+F6GFqQ6jh+lh1D@qYF3!+B#Xfyc#+1M{LAS>0)%`IHL_i za|o*VxR43%KpF`8X0+n*{e4IU^uFtj!O|{ut?MkW+k`t-Z(^eHZo}zZ;_S?f z5O~`4g3v2>vWj&_JHC7wXx{29SOSsKH2UJ*#bFUNT(FAHY410iSete}y!0%0Rd+C# zIndwcYZFwML>8BHLLr_FUqEH8nJWBX*;wJ znb^b{Xajfgi{7BqkgiQm0Pc;w8JkELGRT#kvH+LzJ`r=dv9U<>ow!-0V&)(i6 z#O@l}7Sd2GZ_`Z2-rh|B>0jMJ-c;i-F%>!L#RTSfk1`(HruRquj1ge)Z{(hBOk75P(dj zHJ+9v#dDoOH}ZZYv6YXA=NyNuiW!ATVh{{chV%mUtwGDCC`P+?mK(@28#s*A?Gnd& zd49|W_#~fTnFynLY?eppb|q20Oe%42!XH^Hq8q0K_@*;nxFncFKakO1>5Udz_v%3v ze#Y>oDLPIt`q*^1ml2pN`iz^3KJJ~mbRKe)>p&QCURhh{biX*k(NJi6NTuS-JR=A( zQW>&r{3SghL^|>)hUg5dX>}zZ5~0LEln@y0m&G^B{sZ6X-_hLhawAVs`+8IcyxJQk z^v=1CfZFn&-HsmQf&0RRd9nnakW*aIM6h2JIH>J@Xfe-@?u%3`ZxgIKqSk}{N&j0- zjL2v4xej=WxQB*-!1+H@go@oW*I&8emCn4&yf&dxuVxsL7B|NY?o#$EnHT2c zfNY**)=kePF?^rx=(xJGA{HN4sli{BD1+FI$9QzaI#orNqz-eD=FS}0Cg$Pf3~~yF>$yEUf5};FgmDDpy~5+C`66cmJA3waBVX!9`OeiNQ^G z1@{^qhI8<&!vhmH3ZmYQr+T8#H8*r8Pu;=G2_rFDIMmHl5OCARG{)kvU#@AxV&FU` zWrv-2$mbxr{Ea4^Vm

u>sYLJfQ8jB3pOaK4Pajr?UJyUygZ8?+ho0B2Eks$yW-Y#l ze)bR?-p&IVgxahlo#r5w86$R)pP$$~?p)yY<(O(P_kAL<9C1>9=Zf-pY|lLhWbiOk z9zW>hzJ~wNqZ-tcs8omUn%2OLO1T(@c^=;uy&p0zZmfWhEzHmCuHIYZ#YeB$E}ENcZaBw{E`wp!HZ&1jy%a82`O?GgQ)E-G z_!b*xF){4ZJ+GubifYwf@If3GRGq-zXi?z`h)K|oF%pA&&C}&1Lj&zP$E7LuJrV!C z!#E4^UhRb^0sy>M;P{`3;P)Ou+vwT6Hm=yTNrVHF>Sz9aJt+zWdY0@!KdrEM4Kysp z)W9HR1J*WYZM||%Z%ZIxHAEbG_X9$DJXxrXA7NKT9%~}kh-E11a?6s~gBEZ1eE%Q5 z7bF3@(ZI;{ia>Q2g%w9)i$_E2S_|vz01#-z0?P#EOtTC03CB8hIIimMy^B2WBd&dz z5cn2Z(|bGtu~5*Y-?!MqXkxsqT!Up=Jtx-lIpDa5i9x4$aejOe8J${GU*x+uywit6SJ6M%`K2Y+QkCY=kMGM>C?V~c@lj3l zT57?!ZhPJ*B_3lI`E+!1AtVKD4fYc#YI3CY^A)o>#Gh6>vy!ID7W2P0sGs&g+n$rr zKdO6CoOR-RH6TF#p48V?5%HYJ)74ddltdT;Af-zyP}zEXEGiSrY3j3z1?|jK5cLa! z9VlEWwKEQn^=I0TYOz^5XK+sTt|M}fixC~EOmKP1BAyB~0}~C-u!`Yz-w)dhU~E|% z1`v9ef&sK!FT&pRQ4-RNw;Ar1w!}ZnkE&gXQ9G{;h%fgzqV6uFulmFzND;v=KP6gA zYbIcu0~5+dqcjhWDtkxMcfxZ2#8sPoyNEFFD?vhkLqIp}!z9nxvheBIak^tg(H$D7 zEPd*+rs45>Gyhyke=t`}!r?e|Zh`bi@Qde}8h&hgeTC~mS@BztK6~2gRMIjSU$Njs zZY{ZP4mN9f==aGN<213dG%x6KsZ=rd1{ZERgKEbW>*zz4=EoUpYs;kbYh}tyk?KrN z3!jrwAIqeEWsf%Rog?W&jA#s*mq};-Di7P8Y$r|ZEE1u!fAFy#Uw`my2A;j{{+)F&%&jl(&&9^-RQ0&XI69w`YE z=K_}7IA%82r=Ywa{Qsc@j_RS@miVbETYf?|`@od%KfYfg9=_n9B6+|~R#J6|izyNc z%;{jk4>hn5-QsZM@?3fRwx-D`uDxm2+*WuT!!uTnKg&^NuN|18X|OJ7{W3D!f;DOq zGp-g!yyfVDE);SdzvqJC()WZ5->;E=xq=g3|Z-%r_CK_vxcH zmq^!nj?4IszZ07%4fbC?Zj9dFHbM$lsU~UX>{)&~jWtyj7UIWKnJLJiLe!SMv!AM# zELY)~h%qpul`IAeBdur%F}J;@dCSYA9qs=-Ap=z>;FO$yXZK@ymfC_u4UG7R`&4O( z1tie|lU`$>Oj@AZU(17O>F<_=)tHN4Bme#YJeNLspu!)(2>hb?rw4G;kp1+$ug0KS z7Y{CF!~5)wNkp!-K4c(?%c@N2QiLTNei-e(qor)canTy1=J#4^_;MS)>Ryf%mude} z`qAFr+yPCR5W=@c7hV@$Yo{`=Nlc?v#RnEfe38Ll1M^D~GK)A*Gl`X{5(q+#ZP!#1 zbR?gvrEURZjOODbLl)j18j~8*DNb1~Sn87GZG@g1+R3q^+&v`fFLT|;`A_f$<2(ZsJQ&7(n;q1C?IcIyNi*li79_R z9jdw}&eAd-NI9VYQWkduHlGy2g{(u({=kv2U;!tNJy!e2DMz6cmdxJRLN;%>`N%-5 zXyw^lLxF7N3*GjM&gsdSw8gDc=FP_O+4?Vy4#1?ZJ=G2N>bacm-Ekc`DvRRG-|~~q zDmjpfucIbNNy%Bojk34G5JxMda@*AwQBt8?wNLhO57x6b;nC{)1jGz_Z#N{i1{$^p z71kA_G!~r>(r75(K_tBU&x|YF=WxMA_$+zz`%nJ$uV#P8zuqX{NFIa@{`sfbU)b2c zBHSiaZ%Egla&xdd{Pt!w`)?NTp63s_u}J;H;y;A!znR?-vOndwkm%D~)j*_4W$?7pgIQ9{vsWuM7R#FgIrK4D%nk z+0Olxn+H1p=LUX*`Eyry8{_t_?!PE`5CnLb{XNFtl;K~~`RxO4Px`+OV8Hud2mC(w z-$uSYI{ZTBgopXRfA!x6iQB-pdyrqiqVWIJ_zn1PT=6rh-^RRMR)1l(k^ckcuOfRJ j>~?+m1$Kw>AHe>sHX6#vC^!1}@E;NQYvDw7^Vk0Y7wzL= From 5f137507d6d0bc69c63e32ec6b1470365b5902b9 Mon Sep 17 00:00:00 2001 From: Mikhail Kosticyn Date: Tue, 13 Aug 2024 16:37:58 +0300 Subject: [PATCH 03/10] Style and bug fixes for approximations (#13) * [feat] added Spring approximations * [feat] updated USVM API * [feat] implemented encoders * [feat] added approximation for LogFactory * [feat] updated JDK version * [feat] updated usvm-api * [fix] fixed approximations * [feat] added 'warning as error' * [fix] added 'typeIs' check for 'equals' - added 'typeIs' function into Engine - fixed 'equals' methods to use 'typeIs' * updated jacodb version * [fix] implemented adding all elements via internal copy - implemented List.addAll via SymbolicList.copy - implemented Map.addAll and Set.addAll via SymbolicMap.union * [feat] added Map.Entry encoder * [feat] added 'Log' interface approximation - disabled logging by default * [fix] deleted 'PrimitiveTypeUtils' * [fix] fixed decoders * [fix] fixed System_PrintStream * [fix] fixed 'System' approximation * [fix] fixed spliterator approximation * [fix] fixed 'AtomicBoolean' approximation * [fix] fixed 'Log' approximation --- approximations/build.gradle.kts | 10 +- .../java/lang/SecurityManager_Decoder.java | 2 +- .../decoders/java/util/HashSet_Decoder.java | 2 +- .../java/util/LinkedHashSet_Decoder.java | 2 +- .../java/util/OptionalDouble_Decoder.java | 4 +- .../java/util/OptionalInt_Decoder.java | 2 +- .../java/util/OptionalLong_Decoder.java | 2 +- .../java/util/AbstractMap_Entry_Encoder.java | 17 + .../encoders/java/util/ArrayList_Encoder.java | 18 + .../java/util/ConcurrentHashMap_Encoder.java | 18 + .../encoders/java/util/HashMap_Encoder.java | 19 + .../encoders/java/util/HashSet_Encoder.java | 20 + .../java/util/LinkedHashMap_Encoder.java | 19 + .../encoders/java/util/String_Encoder.java | 14 + .../java/util/ThreadLocal_Encoder.java | 14 + .../generated/java/lang/AutoCloseable.java | 38 +- .../{Character.java => CharacterImpl.java} | 128 +- .../main/java/generated/java/lang/Double.java | 615 ------- .../java/generated/java/lang/DoubleImpl.java | 285 ++++ .../main/java/generated/java/lang/Float.java | 628 -------- .../java/generated/java/lang/FloatImpl.java | 289 ++++ .../java/generated/java/lang/Integer.java | 577 ------- .../java/generated/java/lang/IntegerImpl.java | 266 +++ .../main/java/generated/java/lang/Object.java | 82 - .../java/generated/java/lang/ObjectImpl.java | 30 + .../generated/java/lang/SecurityManager.java | 457 ------ .../java/lang/SecurityManagerImpl.java | 194 +++ .../main/java/generated/java/lang/String.java | 313 ---- .../generated/java/lang/StringBuffer.java | 1333 --------------- .../generated/java/lang/StringBufferImpl.java | 643 ++++++++ .../generated/java/lang/StringBuilder.java | 1357 ---------------- .../java/lang/StringBuilderImpl.java | 654 ++++++++ .../java/generated/java/lang/StringImpl.java | 139 ++ .../main/java/generated/java/lang/System.java | 588 ------- .../java/generated/java/lang/SystemImpl.java | 329 ++++ .../java/lang/System_PrintStream.java | 496 ------ .../java/lang/System_PrintStreamImpl.java | 204 +++ .../generated/java/lang/ThreadLocalImpl.java | 28 + .../java/generated/java/lang/Throwable.java | 125 -- .../generated/java/lang/ThrowableImpl.java | 53 + .../generated/java/security/SecureRandom.java | 840 ---------- .../java/security/SecureRandomImpl.java | 258 +++ .../java/util/AbstractCollectionImpl.java | 62 + .../java/util/AbstractIteratorImpl.java | 24 + .../java/util/AbstractMap_SimpleEntry.java | 178 -- .../java/util/AbstractSpliteratorImpl.java | 75 + .../java/generated/java/util/ArrayList.java | 1119 ------------- .../java/util/ArrayList_ListItr.java | 264 --- .../java/util/ArrayList_Spliterator.java | 231 --- .../util/ArrayList_SubList$ListIterator.java | 277 ---- .../util/ArrayList_SubList$Spliterator.java | 212 --- .../java/util/ArrayList_SubList.java | 908 ----------- .../java/generated/java/util/HashMap.java | 862 ---------- .../java/util/HashMap_EntryIterator.java | 152 -- .../generated/java/util/HashMap_EntrySet.java | 600 ------- .../java/util/HashMap_EntrySpliterator.java | 220 --- .../java/util/HashMap_KeyIterator.java | 144 -- .../generated/java/util/HashMap_KeySet.java | 612 ------- .../java/util/HashMap_KeySpliterator.java | 219 --- .../java/util/HashMap_ValueIterator.java | 147 -- .../java/util/HashMap_ValueSpliterator.java | 218 --- .../generated/java/util/HashMap_Values.java | 581 ------- .../java/generated/java/util/HashSet.java | 759 --------- .../java/util/HashSet_KeyIterator.java | 193 --- .../java/util/HashSet_KeySpliterator.java | 255 --- .../generated/java/util/LinkedHashSet.java | 745 --------- .../java/util/LinkedHashSet_KeyIterator.java | 190 --- .../util/LinkedHashSet_KeySpliterator.java | 254 --- .../java/generated/java/util/LinkedList.java | 1425 ----------------- .../util/LinkedList_DescendingIterator.java | 158 -- .../java/util/LinkedList_ListItr.java | 264 --- .../java/util/LinkedList_Spliterator.java | 231 --- .../util/LinkedList_SubList$ListIterator.java | 277 ---- .../util/LinkedList_SubList$Spliterator.java | 212 --- .../java/util/LinkedList_SubList.java | 908 ----------- .../main/java/generated/java/util/List.java | 333 ---- .../java/generated/java/util/Optional.java | 480 ------ .../generated/java/util/OptionalDouble.java | 370 ----- .../java/generated/java/util/OptionalInt.java | 370 ----- .../generated/java/util/OptionalLong.java | 370 ----- .../main/java/generated/java/util/Random.java | 607 ------- .../java/generated/java/util/RandomImpl.java | 237 +++ .../generated/java/util/Spliterators.java | 204 --- .../generated/java/util/SpliteratorsImpl.java | 58 + .../util/Spliterators_ArraySpliterator.java | 256 --- .../Spliterators_DoubleArraySpliterator.java | 304 ---- .../Spliterators_IntArraySpliterator.java | 304 ---- .../Spliterators_LongArraySpliterator.java | 304 ---- .../util/array/AbstractArrayIteratorImpl.java | 60 + .../array/AbstractArraySpliteratorImpl.java | 91 ++ .../java/util/array/ArrayIteratorImpl.java | 54 + .../java/util/array/ArraySpliteratorImpl.java | 67 + .../util/array/DoubleArrayIteratorImpl.java | 79 + .../array/DoubleArraySpliteratorImpl.java | 102 ++ .../java/util/array/IntArrayIteratorImpl.java | 79 + .../util/array/IntArraySpliteratorImpl.java | 102 ++ .../util/array/LongArrayIteratorImpl.java | 79 + .../util/array/LongArraySpliteratorImpl.java | 102 ++ .../util/concurrent/atomic/AtomicBoolean.java | 449 ------ .../concurrent/atomic/AtomicBooleanImpl.java | 137 ++ .../util/concurrent/atomic/AtomicInteger.java | 579 ------- .../concurrent/atomic/AtomicIntegerImpl.java | 213 +++ .../util/concurrent/atomic/AtomicLong.java | 513 +----- .../concurrent/atomic/AtomicReference.java | 373 +---- .../java/util/list/AbstractListImpl.java | 579 +++++++ .../java/util/list/ArrayListImpl.java | 201 +++ .../java/util/list/LinkedListImpl.java | 342 ++++ .../LinkedList_DescendingIteratorImpl.java | 50 + .../generated/java/util/list/ListImpl.java | 137 ++ .../java/util/list/ListIteratorStubImpl.java | 145 ++ .../util/list/ListSpliteratorStubImpl.java | 92 ++ .../generated/java/util/list/SubListImpl.java | 462 ++++++ .../util/list/SubListIteratorStubImpl.java | 95 ++ .../util/list/SubListSpliteratorStubImpl.java | 66 + .../java/util/map/AbstractMapImpl.java | 499 ++++++ .../java/util/map/AbstractMap_EntryImpl.java | 66 + .../java/util/map/ConcurrentHashMapImpl.java | 155 ++ .../generated/java/util/map/HashMapImpl.java | 157 ++ .../java/util/map/LinkedHashMapImpl.java | 157 ++ .../java/util/map/Map_ContentsImpl.java | 275 ++++ .../java/util/map/Map_ContentsSetImpl.java | 113 ++ .../map/Map_ContentsSet_SpliteratorImpl.java | 66 + .../util/map/Map_Contents_IteratorImpl.java | 99 ++ .../map/Map_Contents_SpliteratorImpl.java | 203 +++ .../java/util/map/Map_EntrySetImpl.java | 146 ++ .../java/util/map/Map_KeySetImpl.java | 131 ++ .../java/util/map/Map_ValuesImpl.java | 145 ++ .../util/optional/OptionalDoubleImpl.java | 169 ++ .../java/util/optional/OptionalImpl.java | 216 +++ .../java/util/optional/OptionalIntImpl.java | 168 ++ .../java/util/optional/OptionalLongImpl.java | 167 ++ .../java/util/set/AbstractSetImpl.java | 385 +++++ .../generated/java/util/set/HashSetImpl.java | 143 ++ .../java/util/set/LinkedHashSetImpl.java | 137 ++ .../java/util/set/Set_IteratorImpl.java | 93 ++ .../java/util/set/Set_SpliteratorImpl.java | 179 +++ .../java/util/stream/BaseStreamImpl.java | 106 ++ .../java/util/stream/DoubleStreamImpl.java | 655 ++++++++ .../java/util/stream/DoubleStreamLSL.java | 1286 --------------- .../util/stream/DoubleStreamLSLIterator.java | 169 -- .../java/util/stream/IntStreamImpl.java | 654 ++++++++ .../java/util/stream/IntStreamLSL.java | 1337 ---------------- .../util/stream/IntStreamLSLIterator.java | 169 -- .../java/util/stream/LongStreamImpl.java | 646 ++++++++ .../java/util/stream/LongStreamLSL.java | 1295 --------------- .../util/stream/LongStreamLSLIterator.java | 169 -- .../generated/java/util/stream/StreamLSL.java | 1369 ---------------- .../java/util/stream/StreamLSLIterator.java | 122 -- .../java/util/stream/StreamStubImpl.java | 699 ++++++++ .../java/generated/java/util/zip/CRC32.java | 266 +-- .../libsl/utils/SymbolicInputStream.java | 415 ----- .../libsl/utils/SymbolicInputStreamImpl.java | 232 +++ .../libsl/utils/VoidInputStream.java | 256 --- .../libsl/utils/VoidInputStreamImpl.java | 116 ++ .../libsl/utils/VoidOutputStream.java | 120 -- .../libsl/utils/VoidOutputStreamImpl.java | 47 + .../org/apache/commons/logging/LogImpl.java | 56 + .../springframework/boot/ClassUtilsImpl.java | 19 + .../ErrorsMethodArgumentResolverImpl.java | 28 + .../springframework/boot/LogFactoryImpl.java | 17 + .../boot/MergedContextConfigurationImpl.java | 26 + ...athVariableMethodArgumentResolverImpl.java | 20 + ...equestParamMethodArgumentResolverImpl.java | 20 + .../boot/SpringApplicationImpl.java | 74 + .../org/springframework/boot/StartSpring.java | 11 + .../boot/SymbolicValueFactory.java | 24 + .../org/springframework/boot/TestClass.java | 12 + .../boot/TestContextManagerImpl.java | 57 + .../java/generated/runtime/LibSLGlobals.java | 84 +- .../src/main/java/runtime/LibSLRuntime.java | 189 ++- .../stub/java/lang/System_PrintStream.java | 37 +- .../java/stub/java/util/AbstractIterator.java | 17 + .../java/util/AbstractMap_SimpleEntry.java | 53 - .../stub/java/util/ArrayList_ListItr.java | 60 - .../stub/java/util/ArrayList_Spliterator.java | 48 - .../util/ArrayList_SubList$ListIterator.java | 60 - .../util/ArrayList_SubList$Spliterator.java | 43 - .../stub/java/util/ArrayList_SubList.java | 177 -- .../stub/java/util/HashMap_EntryIterator.java | 36 - .../java/stub/java/util/HashMap_EntrySet.java | 115 -- .../java/util/HashMap_EntrySpliterator.java | 43 - .../stub/java/util/HashMap_KeyIterator.java | 36 - .../java/util/HashMap_KeySpliterator.java | 43 - .../stub/java/util/HashMap_ValueIterator.java | 36 - .../java/util/HashMap_ValueSpliterator.java | 43 - .../java/stub/java/util/HashMap_Values.java | 107 -- .../stub/java/util/HashSet_KeyIterator.java | 41 - .../java/util/HashSet_KeySpliterator.java | 45 - .../java/util/LinkedHashSet_KeyIterator.java | 41 - .../util/LinkedHashSet_KeySpliterator.java | 45 - .../util/LinkedList_DescendingIterator.java | 36 - .../stub/java/util/LinkedList_ListItr.java | 60 - .../java/util/LinkedList_Spliterator.java | 48 - .../util/LinkedList_SubList$ListIterator.java | 60 - .../util/LinkedList_SubList$Spliterator.java | 43 - .../stub/java/util/LinkedList_SubList.java | 177 -- .../util/Spliterators_ArraySpliterator.java | 62 - .../Spliterators_DoubleArraySpliterator.java | 70 - .../Spliterators_IntArraySpliterator.java | 70 - .../Spliterators_LongArraySpliterator.java | 70 - .../util/array/AbstractArrayIterator.java | 43 + .../util/array/AbstractArraySpliterator.java | 64 + .../stub/java/util/array/ArrayIterator.java | 46 + .../java/util/array/ArraySpliterator.java | 69 + .../java/util/array/DoubleArrayIterator.java | 54 + .../util/array/DoubleArraySpliterator.java | 74 + .../java/util/array/IntArrayIterator.java | 54 + .../java/util/array/IntArraySpliterator.java | 77 + .../java/util/array/LongArrayIterator.java | 54 + .../java/util/array/LongArraySpliterator.java | 75 + .../list/LinkedList_DescendingIterator.java | 34 + .../stub/java/util/list/ListIteratorStub.java | 88 + .../java/util/list/ListSpliteratorStub.java | 60 + .../java/stub/java/util/list/SubList.java | 207 +++ .../java/util/list/SubListIteratorStub.java | 91 ++ .../util/list/SubListSpliteratorStub.java | 76 + .../stub/java/util/map/AbstractMap_Entry.java | 40 + .../java/stub/java/util/map/Map_Contents.java | 123 ++ .../stub/java/util/map/Map_ContentsSet.java | 110 ++ .../util/map/Map_ContentsSet_Spliterator.java | 71 + .../java/util/map/Map_Contents_Iterator.java | 41 + .../util/map/Map_Contents_Spliterator.java | 83 + .../java/stub/java/util/map/Map_EntrySet.java | 118 ++ .../java/stub/java/util/map/Map_KeySet.java | 122 ++ .../Map_Values.java} | 69 +- .../java/stub/java/util/set/Set_Iterator.java | 43 + .../stub/java/util/set/Set_Spliterator.java | 72 + .../stub/java/util/stream/BaseStreamStub.java | 69 + .../util/stream/DoubleStreamLSLIterator.java | 45 - ...leStreamLSL.java => DoubleStreamStub.java} | 107 +- .../util/stream/IntStreamLSLIterator.java | 45 - .../{IntStreamLSL.java => IntStreamStub.java} | 112 +- .../util/stream/LongStreamLSLIterator.java | 45 - ...LongStreamLSL.java => LongStreamStub.java} | 110 +- .../java/stub/java/util/stream/StreamLSL.java | 208 --- .../java/util/stream/StreamLSLIterator.java | 36 - .../stub/java/util/stream/StreamStub.java | 252 +++ .../stub/libsl/utils/SymbolicInputStream.java | 41 +- .../stub/libsl/utils/VoidInputStream.java | 24 +- .../stub/libsl/utils/VoidOutputStream.java | 22 +- jitpack.yml | 2 +- usvm-api/usvm-api.jar | Bin 8926 -> 11342 bytes 242 files changed, 17711 insertions(+), 35454 deletions(-) create mode 100644 approximations/src/main/java/encoders/java/util/AbstractMap_Entry_Encoder.java create mode 100644 approximations/src/main/java/encoders/java/util/ArrayList_Encoder.java create mode 100644 approximations/src/main/java/encoders/java/util/ConcurrentHashMap_Encoder.java create mode 100644 approximations/src/main/java/encoders/java/util/HashMap_Encoder.java create mode 100644 approximations/src/main/java/encoders/java/util/HashSet_Encoder.java create mode 100644 approximations/src/main/java/encoders/java/util/LinkedHashMap_Encoder.java create mode 100644 approximations/src/main/java/encoders/java/util/String_Encoder.java create mode 100644 approximations/src/main/java/encoders/java/util/ThreadLocal_Encoder.java rename approximations/src/main/java/generated/java/lang/{Character.java => CharacterImpl.java} (59%) delete mode 100644 approximations/src/main/java/generated/java/lang/Double.java create mode 100644 approximations/src/main/java/generated/java/lang/DoubleImpl.java delete mode 100644 approximations/src/main/java/generated/java/lang/Float.java create mode 100644 approximations/src/main/java/generated/java/lang/FloatImpl.java delete mode 100644 approximations/src/main/java/generated/java/lang/Integer.java create mode 100644 approximations/src/main/java/generated/java/lang/IntegerImpl.java delete mode 100644 approximations/src/main/java/generated/java/lang/Object.java create mode 100644 approximations/src/main/java/generated/java/lang/ObjectImpl.java delete mode 100644 approximations/src/main/java/generated/java/lang/SecurityManager.java create mode 100644 approximations/src/main/java/generated/java/lang/SecurityManagerImpl.java delete mode 100644 approximations/src/main/java/generated/java/lang/String.java delete mode 100644 approximations/src/main/java/generated/java/lang/StringBuffer.java create mode 100644 approximations/src/main/java/generated/java/lang/StringBufferImpl.java delete mode 100644 approximations/src/main/java/generated/java/lang/StringBuilder.java create mode 100644 approximations/src/main/java/generated/java/lang/StringBuilderImpl.java create mode 100644 approximations/src/main/java/generated/java/lang/StringImpl.java delete mode 100644 approximations/src/main/java/generated/java/lang/System.java create mode 100644 approximations/src/main/java/generated/java/lang/SystemImpl.java delete mode 100644 approximations/src/main/java/generated/java/lang/System_PrintStream.java create mode 100644 approximations/src/main/java/generated/java/lang/System_PrintStreamImpl.java create mode 100644 approximations/src/main/java/generated/java/lang/ThreadLocalImpl.java delete mode 100644 approximations/src/main/java/generated/java/lang/Throwable.java create mode 100644 approximations/src/main/java/generated/java/lang/ThrowableImpl.java delete mode 100644 approximations/src/main/java/generated/java/security/SecureRandom.java create mode 100644 approximations/src/main/java/generated/java/security/SecureRandomImpl.java create mode 100644 approximations/src/main/java/generated/java/util/AbstractCollectionImpl.java create mode 100644 approximations/src/main/java/generated/java/util/AbstractIteratorImpl.java delete mode 100644 approximations/src/main/java/generated/java/util/AbstractMap_SimpleEntry.java create mode 100644 approximations/src/main/java/generated/java/util/AbstractSpliteratorImpl.java delete mode 100644 approximations/src/main/java/generated/java/util/ArrayList.java delete mode 100644 approximations/src/main/java/generated/java/util/ArrayList_ListItr.java delete mode 100644 approximations/src/main/java/generated/java/util/ArrayList_Spliterator.java delete mode 100644 approximations/src/main/java/generated/java/util/ArrayList_SubList$ListIterator.java delete mode 100644 approximations/src/main/java/generated/java/util/ArrayList_SubList$Spliterator.java delete mode 100644 approximations/src/main/java/generated/java/util/ArrayList_SubList.java delete mode 100644 approximations/src/main/java/generated/java/util/HashMap.java delete mode 100644 approximations/src/main/java/generated/java/util/HashMap_EntryIterator.java delete mode 100644 approximations/src/main/java/generated/java/util/HashMap_EntrySet.java delete mode 100644 approximations/src/main/java/generated/java/util/HashMap_EntrySpliterator.java delete mode 100644 approximations/src/main/java/generated/java/util/HashMap_KeyIterator.java delete mode 100644 approximations/src/main/java/generated/java/util/HashMap_KeySet.java delete mode 100644 approximations/src/main/java/generated/java/util/HashMap_KeySpliterator.java delete mode 100644 approximations/src/main/java/generated/java/util/HashMap_ValueIterator.java delete mode 100644 approximations/src/main/java/generated/java/util/HashMap_ValueSpliterator.java delete mode 100644 approximations/src/main/java/generated/java/util/HashMap_Values.java delete mode 100644 approximations/src/main/java/generated/java/util/HashSet.java delete mode 100644 approximations/src/main/java/generated/java/util/HashSet_KeyIterator.java delete mode 100644 approximations/src/main/java/generated/java/util/HashSet_KeySpliterator.java delete mode 100644 approximations/src/main/java/generated/java/util/LinkedHashSet.java delete mode 100644 approximations/src/main/java/generated/java/util/LinkedHashSet_KeyIterator.java delete mode 100644 approximations/src/main/java/generated/java/util/LinkedHashSet_KeySpliterator.java delete mode 100644 approximations/src/main/java/generated/java/util/LinkedList.java delete mode 100644 approximations/src/main/java/generated/java/util/LinkedList_DescendingIterator.java delete mode 100644 approximations/src/main/java/generated/java/util/LinkedList_ListItr.java delete mode 100644 approximations/src/main/java/generated/java/util/LinkedList_Spliterator.java delete mode 100644 approximations/src/main/java/generated/java/util/LinkedList_SubList$ListIterator.java delete mode 100644 approximations/src/main/java/generated/java/util/LinkedList_SubList$Spliterator.java delete mode 100644 approximations/src/main/java/generated/java/util/LinkedList_SubList.java delete mode 100644 approximations/src/main/java/generated/java/util/List.java delete mode 100644 approximations/src/main/java/generated/java/util/Optional.java delete mode 100644 approximations/src/main/java/generated/java/util/OptionalDouble.java delete mode 100644 approximations/src/main/java/generated/java/util/OptionalInt.java delete mode 100644 approximations/src/main/java/generated/java/util/OptionalLong.java delete mode 100644 approximations/src/main/java/generated/java/util/Random.java create mode 100644 approximations/src/main/java/generated/java/util/RandomImpl.java delete mode 100644 approximations/src/main/java/generated/java/util/Spliterators.java create mode 100644 approximations/src/main/java/generated/java/util/SpliteratorsImpl.java delete mode 100644 approximations/src/main/java/generated/java/util/Spliterators_ArraySpliterator.java delete mode 100644 approximations/src/main/java/generated/java/util/Spliterators_DoubleArraySpliterator.java delete mode 100644 approximations/src/main/java/generated/java/util/Spliterators_IntArraySpliterator.java delete mode 100644 approximations/src/main/java/generated/java/util/Spliterators_LongArraySpliterator.java create mode 100644 approximations/src/main/java/generated/java/util/array/AbstractArrayIteratorImpl.java create mode 100644 approximations/src/main/java/generated/java/util/array/AbstractArraySpliteratorImpl.java create mode 100644 approximations/src/main/java/generated/java/util/array/ArrayIteratorImpl.java create mode 100644 approximations/src/main/java/generated/java/util/array/ArraySpliteratorImpl.java create mode 100644 approximations/src/main/java/generated/java/util/array/DoubleArrayIteratorImpl.java create mode 100644 approximations/src/main/java/generated/java/util/array/DoubleArraySpliteratorImpl.java create mode 100644 approximations/src/main/java/generated/java/util/array/IntArrayIteratorImpl.java create mode 100644 approximations/src/main/java/generated/java/util/array/IntArraySpliteratorImpl.java create mode 100644 approximations/src/main/java/generated/java/util/array/LongArrayIteratorImpl.java create mode 100644 approximations/src/main/java/generated/java/util/array/LongArraySpliteratorImpl.java delete mode 100644 approximations/src/main/java/generated/java/util/concurrent/atomic/AtomicBoolean.java create mode 100644 approximations/src/main/java/generated/java/util/concurrent/atomic/AtomicBooleanImpl.java delete mode 100644 approximations/src/main/java/generated/java/util/concurrent/atomic/AtomicInteger.java create mode 100644 approximations/src/main/java/generated/java/util/concurrent/atomic/AtomicIntegerImpl.java create mode 100644 approximations/src/main/java/generated/java/util/list/AbstractListImpl.java create mode 100644 approximations/src/main/java/generated/java/util/list/ArrayListImpl.java create mode 100644 approximations/src/main/java/generated/java/util/list/LinkedListImpl.java create mode 100644 approximations/src/main/java/generated/java/util/list/LinkedList_DescendingIteratorImpl.java create mode 100644 approximations/src/main/java/generated/java/util/list/ListImpl.java create mode 100644 approximations/src/main/java/generated/java/util/list/ListIteratorStubImpl.java create mode 100644 approximations/src/main/java/generated/java/util/list/ListSpliteratorStubImpl.java create mode 100644 approximations/src/main/java/generated/java/util/list/SubListImpl.java create mode 100644 approximations/src/main/java/generated/java/util/list/SubListIteratorStubImpl.java create mode 100644 approximations/src/main/java/generated/java/util/list/SubListSpliteratorStubImpl.java create mode 100644 approximations/src/main/java/generated/java/util/map/AbstractMapImpl.java create mode 100644 approximations/src/main/java/generated/java/util/map/AbstractMap_EntryImpl.java create mode 100644 approximations/src/main/java/generated/java/util/map/ConcurrentHashMapImpl.java create mode 100644 approximations/src/main/java/generated/java/util/map/HashMapImpl.java create mode 100644 approximations/src/main/java/generated/java/util/map/LinkedHashMapImpl.java create mode 100644 approximations/src/main/java/generated/java/util/map/Map_ContentsImpl.java create mode 100644 approximations/src/main/java/generated/java/util/map/Map_ContentsSetImpl.java create mode 100644 approximations/src/main/java/generated/java/util/map/Map_ContentsSet_SpliteratorImpl.java create mode 100644 approximations/src/main/java/generated/java/util/map/Map_Contents_IteratorImpl.java create mode 100644 approximations/src/main/java/generated/java/util/map/Map_Contents_SpliteratorImpl.java create mode 100644 approximations/src/main/java/generated/java/util/map/Map_EntrySetImpl.java create mode 100644 approximations/src/main/java/generated/java/util/map/Map_KeySetImpl.java create mode 100644 approximations/src/main/java/generated/java/util/map/Map_ValuesImpl.java create mode 100644 approximations/src/main/java/generated/java/util/optional/OptionalDoubleImpl.java create mode 100644 approximations/src/main/java/generated/java/util/optional/OptionalImpl.java create mode 100644 approximations/src/main/java/generated/java/util/optional/OptionalIntImpl.java create mode 100644 approximations/src/main/java/generated/java/util/optional/OptionalLongImpl.java create mode 100644 approximations/src/main/java/generated/java/util/set/AbstractSetImpl.java create mode 100644 approximations/src/main/java/generated/java/util/set/HashSetImpl.java create mode 100644 approximations/src/main/java/generated/java/util/set/LinkedHashSetImpl.java create mode 100644 approximations/src/main/java/generated/java/util/set/Set_IteratorImpl.java create mode 100644 approximations/src/main/java/generated/java/util/set/Set_SpliteratorImpl.java create mode 100644 approximations/src/main/java/generated/java/util/stream/BaseStreamImpl.java create mode 100644 approximations/src/main/java/generated/java/util/stream/DoubleStreamImpl.java delete mode 100644 approximations/src/main/java/generated/java/util/stream/DoubleStreamLSL.java delete mode 100644 approximations/src/main/java/generated/java/util/stream/DoubleStreamLSLIterator.java create mode 100644 approximations/src/main/java/generated/java/util/stream/IntStreamImpl.java delete mode 100644 approximations/src/main/java/generated/java/util/stream/IntStreamLSL.java delete mode 100644 approximations/src/main/java/generated/java/util/stream/IntStreamLSLIterator.java create mode 100644 approximations/src/main/java/generated/java/util/stream/LongStreamImpl.java delete mode 100644 approximations/src/main/java/generated/java/util/stream/LongStreamLSL.java delete mode 100644 approximations/src/main/java/generated/java/util/stream/LongStreamLSLIterator.java delete mode 100644 approximations/src/main/java/generated/java/util/stream/StreamLSL.java delete mode 100644 approximations/src/main/java/generated/java/util/stream/StreamLSLIterator.java create mode 100644 approximations/src/main/java/generated/java/util/stream/StreamStubImpl.java delete mode 100644 approximations/src/main/java/generated/libsl/utils/SymbolicInputStream.java create mode 100644 approximations/src/main/java/generated/libsl/utils/SymbolicInputStreamImpl.java delete mode 100644 approximations/src/main/java/generated/libsl/utils/VoidInputStream.java create mode 100644 approximations/src/main/java/generated/libsl/utils/VoidInputStreamImpl.java delete mode 100644 approximations/src/main/java/generated/libsl/utils/VoidOutputStream.java create mode 100644 approximations/src/main/java/generated/libsl/utils/VoidOutputStreamImpl.java create mode 100644 approximations/src/main/java/generated/org/apache/commons/logging/LogImpl.java create mode 100644 approximations/src/main/java/generated/org/springframework/boot/ClassUtilsImpl.java create mode 100644 approximations/src/main/java/generated/org/springframework/boot/ErrorsMethodArgumentResolverImpl.java create mode 100644 approximations/src/main/java/generated/org/springframework/boot/LogFactoryImpl.java create mode 100644 approximations/src/main/java/generated/org/springframework/boot/MergedContextConfigurationImpl.java create mode 100644 approximations/src/main/java/generated/org/springframework/boot/PathVariableMethodArgumentResolverImpl.java create mode 100644 approximations/src/main/java/generated/org/springframework/boot/RequestParamMethodArgumentResolverImpl.java create mode 100644 approximations/src/main/java/generated/org/springframework/boot/SpringApplicationImpl.java create mode 100644 approximations/src/main/java/generated/org/springframework/boot/StartSpring.java create mode 100644 approximations/src/main/java/generated/org/springframework/boot/SymbolicValueFactory.java create mode 100644 approximations/src/main/java/generated/org/springframework/boot/TestClass.java create mode 100644 approximations/src/main/java/generated/org/springframework/boot/TestContextManagerImpl.java create mode 100644 approximations/src/main/java/stub/java/util/AbstractIterator.java delete mode 100644 approximations/src/main/java/stub/java/util/AbstractMap_SimpleEntry.java delete mode 100644 approximations/src/main/java/stub/java/util/ArrayList_ListItr.java delete mode 100644 approximations/src/main/java/stub/java/util/ArrayList_Spliterator.java delete mode 100644 approximations/src/main/java/stub/java/util/ArrayList_SubList$ListIterator.java delete mode 100644 approximations/src/main/java/stub/java/util/ArrayList_SubList$Spliterator.java delete mode 100644 approximations/src/main/java/stub/java/util/ArrayList_SubList.java delete mode 100644 approximations/src/main/java/stub/java/util/HashMap_EntryIterator.java delete mode 100644 approximations/src/main/java/stub/java/util/HashMap_EntrySet.java delete mode 100644 approximations/src/main/java/stub/java/util/HashMap_EntrySpliterator.java delete mode 100644 approximations/src/main/java/stub/java/util/HashMap_KeyIterator.java delete mode 100644 approximations/src/main/java/stub/java/util/HashMap_KeySpliterator.java delete mode 100644 approximations/src/main/java/stub/java/util/HashMap_ValueIterator.java delete mode 100644 approximations/src/main/java/stub/java/util/HashMap_ValueSpliterator.java delete mode 100644 approximations/src/main/java/stub/java/util/HashMap_Values.java delete mode 100644 approximations/src/main/java/stub/java/util/HashSet_KeyIterator.java delete mode 100644 approximations/src/main/java/stub/java/util/HashSet_KeySpliterator.java delete mode 100644 approximations/src/main/java/stub/java/util/LinkedHashSet_KeyIterator.java delete mode 100644 approximations/src/main/java/stub/java/util/LinkedHashSet_KeySpliterator.java delete mode 100644 approximations/src/main/java/stub/java/util/LinkedList_DescendingIterator.java delete mode 100644 approximations/src/main/java/stub/java/util/LinkedList_ListItr.java delete mode 100644 approximations/src/main/java/stub/java/util/LinkedList_Spliterator.java delete mode 100644 approximations/src/main/java/stub/java/util/LinkedList_SubList$ListIterator.java delete mode 100644 approximations/src/main/java/stub/java/util/LinkedList_SubList$Spliterator.java delete mode 100644 approximations/src/main/java/stub/java/util/LinkedList_SubList.java delete mode 100644 approximations/src/main/java/stub/java/util/Spliterators_ArraySpliterator.java delete mode 100644 approximations/src/main/java/stub/java/util/Spliterators_DoubleArraySpliterator.java delete mode 100644 approximations/src/main/java/stub/java/util/Spliterators_IntArraySpliterator.java delete mode 100644 approximations/src/main/java/stub/java/util/Spliterators_LongArraySpliterator.java create mode 100644 approximations/src/main/java/stub/java/util/array/AbstractArrayIterator.java create mode 100644 approximations/src/main/java/stub/java/util/array/AbstractArraySpliterator.java create mode 100644 approximations/src/main/java/stub/java/util/array/ArrayIterator.java create mode 100644 approximations/src/main/java/stub/java/util/array/ArraySpliterator.java create mode 100644 approximations/src/main/java/stub/java/util/array/DoubleArrayIterator.java create mode 100644 approximations/src/main/java/stub/java/util/array/DoubleArraySpliterator.java create mode 100644 approximations/src/main/java/stub/java/util/array/IntArrayIterator.java create mode 100644 approximations/src/main/java/stub/java/util/array/IntArraySpliterator.java create mode 100644 approximations/src/main/java/stub/java/util/array/LongArrayIterator.java create mode 100644 approximations/src/main/java/stub/java/util/array/LongArraySpliterator.java create mode 100644 approximations/src/main/java/stub/java/util/list/LinkedList_DescendingIterator.java create mode 100644 approximations/src/main/java/stub/java/util/list/ListIteratorStub.java create mode 100644 approximations/src/main/java/stub/java/util/list/ListSpliteratorStub.java create mode 100644 approximations/src/main/java/stub/java/util/list/SubList.java create mode 100644 approximations/src/main/java/stub/java/util/list/SubListIteratorStub.java create mode 100644 approximations/src/main/java/stub/java/util/list/SubListSpliteratorStub.java create mode 100644 approximations/src/main/java/stub/java/util/map/AbstractMap_Entry.java create mode 100644 approximations/src/main/java/stub/java/util/map/Map_Contents.java create mode 100644 approximations/src/main/java/stub/java/util/map/Map_ContentsSet.java create mode 100644 approximations/src/main/java/stub/java/util/map/Map_ContentsSet_Spliterator.java create mode 100644 approximations/src/main/java/stub/java/util/map/Map_Contents_Iterator.java create mode 100644 approximations/src/main/java/stub/java/util/map/Map_Contents_Spliterator.java create mode 100644 approximations/src/main/java/stub/java/util/map/Map_EntrySet.java create mode 100644 approximations/src/main/java/stub/java/util/map/Map_KeySet.java rename approximations/src/main/java/stub/java/util/{HashMap_KeySet.java => map/Map_Values.java} (50%) create mode 100644 approximations/src/main/java/stub/java/util/set/Set_Iterator.java create mode 100644 approximations/src/main/java/stub/java/util/set/Set_Spliterator.java create mode 100644 approximations/src/main/java/stub/java/util/stream/BaseStreamStub.java delete mode 100644 approximations/src/main/java/stub/java/util/stream/DoubleStreamLSLIterator.java rename approximations/src/main/java/stub/java/util/stream/{DoubleStreamLSL.java => DoubleStreamStub.java} (55%) delete mode 100644 approximations/src/main/java/stub/java/util/stream/IntStreamLSLIterator.java rename approximations/src/main/java/stub/java/util/stream/{IntStreamLSL.java => IntStreamStub.java} (55%) delete mode 100644 approximations/src/main/java/stub/java/util/stream/LongStreamLSLIterator.java rename approximations/src/main/java/stub/java/util/stream/{LongStreamLSL.java => LongStreamStub.java} (55%) delete mode 100644 approximations/src/main/java/stub/java/util/stream/StreamLSL.java delete mode 100644 approximations/src/main/java/stub/java/util/stream/StreamLSLIterator.java create mode 100644 approximations/src/main/java/stub/java/util/stream/StreamStub.java diff --git a/approximations/build.gradle.kts b/approximations/build.gradle.kts index 23559ac0..b22d5130 100644 --- a/approximations/build.gradle.kts +++ b/approximations/build.gradle.kts @@ -1,6 +1,7 @@ plugins { java `maven-publish` + id("org.springframework.boot") version "3.2.0" apply false } repositories { @@ -9,12 +10,17 @@ repositories { } private val jacodbPackage = "com.github.UnitTestBot.jacodb" -private val jacodbVersion = "890624770b" // jacodb neo branch +private val jacodbVersion = "00164e304b" // jacodb neo branch dependencies { compileOnly("$jacodbPackage:jacodb-api-jvm:$jacodbVersion") compileOnly("$jacodbPackage:jacodb-approximations:$jacodbVersion") compileOnly(files(rootDir.resolve("usvm-api/usvm-api.jar"))) + compileOnly("org.springframework.boot:spring-boot-starter-web:3.2.0") + compileOnly("org.springframework.boot:spring-boot-starter-test:3.2.0") + compileOnly("org.springframework.boot:spring-boot-starter-data-jpa:3.2.0") + // Fixes "unknown enum constant 'When.MAYBE'" warning + compileOnly("com.google.code.findbugs:jsr305:3.0.2") } group = "org.usvm.approximations.java.stdlib" @@ -28,6 +34,8 @@ tasks.withType { options.compilerArgs.add("-source") options.compilerArgs.add("1.8") options.compilerArgs.add("-Xlint:unchecked") + options.compilerArgs.add("-Xlint:all") + options.compilerArgs.add("-Werror") } publishing { diff --git a/approximations/src/main/java/decoders/java/lang/SecurityManager_Decoder.java b/approximations/src/main/java/decoders/java/lang/SecurityManager_Decoder.java index 7fa402fc..7ed663e1 100644 --- a/approximations/src/main/java/decoders/java/lang/SecurityManager_Decoder.java +++ b/approximations/src/main/java/decoders/java/lang/SecurityManager_Decoder.java @@ -10,7 +10,7 @@ import java.util.Collections; import java.util.List; -@SuppressWarnings("ForLoopReplaceableByForEach") +@SuppressWarnings({"ForLoopReplaceableByForEach", "removal"}) @DecoderFor(SecurityManager.class) public final class SecurityManager_Decoder implements ObjectDecoder { private volatile JcMethod cached_SecurityManager_ctor = null; diff --git a/approximations/src/main/java/decoders/java/util/HashSet_Decoder.java b/approximations/src/main/java/decoders/java/util/HashSet_Decoder.java index 0f787250..4a7634ed 100644 --- a/approximations/src/main/java/decoders/java/util/HashSet_Decoder.java +++ b/approximations/src/main/java/decoders/java/util/HashSet_Decoder.java @@ -153,7 +153,7 @@ public void initializeInstance(final JcClassOrInterface approximation, decoder.invokeMethod(m_add, args); map.remove(key); - length -= 1; + length--; } } } diff --git a/approximations/src/main/java/decoders/java/util/LinkedHashSet_Decoder.java b/approximations/src/main/java/decoders/java/util/LinkedHashSet_Decoder.java index 2ba5090a..35c9f296 100644 --- a/approximations/src/main/java/decoders/java/util/LinkedHashSet_Decoder.java +++ b/approximations/src/main/java/decoders/java/util/LinkedHashSet_Decoder.java @@ -153,7 +153,7 @@ public void initializeInstance(final JcClassOrInterface approximation, decoder.invokeMethod(m_add, args); map.remove(key); - length -= 1; + length--; } } } diff --git a/approximations/src/main/java/decoders/java/util/OptionalDouble_Decoder.java b/approximations/src/main/java/decoders/java/util/OptionalDouble_Decoder.java index bc23ed21..0ede685d 100644 --- a/approximations/src/main/java/decoders/java/util/OptionalDouble_Decoder.java +++ b/approximations/src/main/java/decoders/java/util/OptionalDouble_Decoder.java @@ -35,7 +35,7 @@ public T createInstance(final JcClassOrInterface approximation, if ("value".equals(name)) { f_value = f; - } else if ("present".equals(name)) { + } else if ("isPresent".equals(name)) { f_present = f; } @@ -92,4 +92,4 @@ public void initializeInstance(final JcClassOrInterface approximation, final DecoderApi decoder) { // nothing } -} \ No newline at end of file +} diff --git a/approximations/src/main/java/decoders/java/util/OptionalInt_Decoder.java b/approximations/src/main/java/decoders/java/util/OptionalInt_Decoder.java index 0524167c..a38f60d3 100644 --- a/approximations/src/main/java/decoders/java/util/OptionalInt_Decoder.java +++ b/approximations/src/main/java/decoders/java/util/OptionalInt_Decoder.java @@ -36,7 +36,7 @@ public T createInstance(final JcClassOrInterface approx, // NOTE: this is an example on how to join discovery process for multiple targets if ("value".equals(name)) { f_value = f; - } else if ("present".equals(name)) { + } else if ("isPresent".equals(name)) { f_present = f; } if (f_value != null && f_present != null) diff --git a/approximations/src/main/java/decoders/java/util/OptionalLong_Decoder.java b/approximations/src/main/java/decoders/java/util/OptionalLong_Decoder.java index 5863f529..8fb40749 100644 --- a/approximations/src/main/java/decoders/java/util/OptionalLong_Decoder.java +++ b/approximations/src/main/java/decoders/java/util/OptionalLong_Decoder.java @@ -35,7 +35,7 @@ public T createInstance(final JcClassOrInterface approx, if ("value".equals(name)) { f_value = f; - } else if ("present".equals(name)) { + } else if ("isPresent".equals(name)) { f_present = f; } diff --git a/approximations/src/main/java/encoders/java/util/AbstractMap_Entry_Encoder.java b/approximations/src/main/java/encoders/java/util/AbstractMap_Entry_Encoder.java new file mode 100644 index 00000000..2b79b6cd --- /dev/null +++ b/approximations/src/main/java/encoders/java/util/AbstractMap_Entry_Encoder.java @@ -0,0 +1,17 @@ +package encoders.java.util; + +import generated.java.util.map.AbstractMap_EntryImpl; +import org.usvm.api.encoder.EncoderFor; +import org.usvm.api.encoder.ObjectEncoder; +import stub.java.util.map.AbstractMap_Entry; + +import java.util.Map; + +@EncoderFor(AbstractMap_Entry.class) +public class AbstractMap_Entry_Encoder implements ObjectEncoder { + + @Override + public Object encode(Object list) { + return new AbstractMap_EntryImpl<>((Map.Entry) list); + } +} diff --git a/approximations/src/main/java/encoders/java/util/ArrayList_Encoder.java b/approximations/src/main/java/encoders/java/util/ArrayList_Encoder.java new file mode 100644 index 00000000..09904b22 --- /dev/null +++ b/approximations/src/main/java/encoders/java/util/ArrayList_Encoder.java @@ -0,0 +1,18 @@ +package encoders.java.util; + +import generated.java.util.list.ArrayListImpl; +import org.usvm.api.encoder.EncoderFor; +import org.usvm.api.encoder.ObjectEncoder; + +import java.util.ArrayList; + +@EncoderFor(ArrayList.class) +public class ArrayList_Encoder implements ObjectEncoder { + + @Override + public Object encode(Object list) { + ArrayListImpl result = new ArrayListImpl<>(); + result.addAll(((ArrayList) list).stream().toList()); + return result; + } +} diff --git a/approximations/src/main/java/encoders/java/util/ConcurrentHashMap_Encoder.java b/approximations/src/main/java/encoders/java/util/ConcurrentHashMap_Encoder.java new file mode 100644 index 00000000..c66ad9f4 --- /dev/null +++ b/approximations/src/main/java/encoders/java/util/ConcurrentHashMap_Encoder.java @@ -0,0 +1,18 @@ +package encoders.java.util; + +import generated.java.util.map.ConcurrentHashMapImpl; +import org.usvm.api.encoder.EncoderFor; +import org.usvm.api.encoder.ObjectEncoder; + +import java.util.concurrent.ConcurrentHashMap; + +@EncoderFor(ConcurrentHashMap.class) +public class ConcurrentHashMap_Encoder implements ObjectEncoder { + + @SuppressWarnings("unchecked") + @Override + public Object encode(Object object) { + ConcurrentHashMap map = (ConcurrentHashMap) object; + return new ConcurrentHashMapImpl<>(map); + } +} diff --git a/approximations/src/main/java/encoders/java/util/HashMap_Encoder.java b/approximations/src/main/java/encoders/java/util/HashMap_Encoder.java new file mode 100644 index 00000000..e247518f --- /dev/null +++ b/approximations/src/main/java/encoders/java/util/HashMap_Encoder.java @@ -0,0 +1,19 @@ +package encoders.java.util; + +import generated.java.util.map.HashMapImpl; +import org.usvm.api.encoder.EncoderFor; +import org.usvm.api.encoder.ObjectEncoder; + +import java.util.HashMap; + +@SuppressWarnings("unused") +@EncoderFor(HashMap.class) +public class HashMap_Encoder implements ObjectEncoder { + + @SuppressWarnings("unchecked") + @Override + public Object encode(Object object) { + HashMap map = (HashMap) object; + return new HashMapImpl<>(map); + } +} diff --git a/approximations/src/main/java/encoders/java/util/HashSet_Encoder.java b/approximations/src/main/java/encoders/java/util/HashSet_Encoder.java new file mode 100644 index 00000000..5c02fc20 --- /dev/null +++ b/approximations/src/main/java/encoders/java/util/HashSet_Encoder.java @@ -0,0 +1,20 @@ +package encoders.java.util; + +import generated.java.util.set.HashSetImpl; +import org.usvm.api.encoder.EncoderFor; +import org.usvm.api.encoder.ObjectEncoder; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +@EncoderFor(HashSet.class) +public class HashSet_Encoder implements ObjectEncoder { + + @Override + public Object encode(Object object) { + HashSetImpl result = new HashSetImpl<>(); + result.addAll(Arrays.asList(((Set) object).toArray())); + return result; + } +} diff --git a/approximations/src/main/java/encoders/java/util/LinkedHashMap_Encoder.java b/approximations/src/main/java/encoders/java/util/LinkedHashMap_Encoder.java new file mode 100644 index 00000000..1012a65d --- /dev/null +++ b/approximations/src/main/java/encoders/java/util/LinkedHashMap_Encoder.java @@ -0,0 +1,19 @@ +package encoders.java.util; + +import generated.java.util.map.LinkedHashMapImpl; +import org.usvm.api.encoder.EncoderFor; +import org.usvm.api.encoder.ObjectEncoder; + +import java.util.LinkedHashMap; + +@SuppressWarnings("unused") +@EncoderFor(LinkedHashMap.class) +public class LinkedHashMap_Encoder implements ObjectEncoder { + + @SuppressWarnings("unchecked") + @Override + public Object encode(Object object) { + LinkedHashMap map = (LinkedHashMap) object; + return new LinkedHashMapImpl<>(map); + } +} diff --git a/approximations/src/main/java/encoders/java/util/String_Encoder.java b/approximations/src/main/java/encoders/java/util/String_Encoder.java new file mode 100644 index 00000000..d8c3b59c --- /dev/null +++ b/approximations/src/main/java/encoders/java/util/String_Encoder.java @@ -0,0 +1,14 @@ +package encoders.java.util; + +import generated.java.lang.StringImpl; +import org.usvm.api.encoder.EncoderFor; +import org.usvm.api.encoder.ObjectEncoder; + +@EncoderFor(java.lang.String.class) +public class String_Encoder implements ObjectEncoder { + + @Override + public Object encode(Object object) { + return new StringImpl(((String) object).getBytes()); + } +} diff --git a/approximations/src/main/java/encoders/java/util/ThreadLocal_Encoder.java b/approximations/src/main/java/encoders/java/util/ThreadLocal_Encoder.java new file mode 100644 index 00000000..0f5964a7 --- /dev/null +++ b/approximations/src/main/java/encoders/java/util/ThreadLocal_Encoder.java @@ -0,0 +1,14 @@ +package encoders.java.util; + +import generated.java.lang.ThreadLocalImpl; +import org.usvm.api.encoder.EncoderFor; +import org.usvm.api.encoder.ObjectEncoder; + +@EncoderFor(java.lang.ThreadLocal.class) +public class ThreadLocal_Encoder implements ObjectEncoder { + + @Override + public Object encode(Object object) { + return new ThreadLocalImpl<>(); + } +} diff --git a/approximations/src/main/java/generated/java/lang/AutoCloseable.java b/approximations/src/main/java/generated/java/lang/AutoCloseable.java index 2454d0b1..f82dcfb3 100644 --- a/approximations/src/main/java/generated/java/lang/AutoCloseable.java +++ b/approximations/src/main/java/generated/java/lang/AutoCloseable.java @@ -1,42 +1,10 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/lang/AutoCloseable.lsl:26 -// - java/lang/AutoCloseable.main.lsl:16 -// package generated.java.lang; -import java.lang.Class; -import java.lang.SuppressWarnings; -import java.lang.Void; import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; -/** - * AutoCloseableAutomaton for LSLAutoCloseable ~> java.lang.AutoCloseable - */ -@SuppressWarnings({"all", "unchecked"}) +@SuppressWarnings("unused") @Approximate(java.lang.AutoCloseable.class) -public interface AutoCloseable extends LibSLRuntime.Automaton { - Class __$_lsl_INIT_INTERFACE_AutoCloseableAutomaton_d61c3b46 = Void.class; +public interface AutoCloseable { - /** - * [FUNCTION] AutoCloseableAutomaton::close(LSLAutoCloseable) -> void - * Source: java/lang/AutoCloseable.main.lsl:39 - */ - default void close() { - /* body */ { - } - } - - final class __$lsl_States { - public static final byte Initialized = (byte) 0; - } - - @Approximate(AutoCloseable.class) - final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } + default void close() { } } diff --git a/approximations/src/main/java/generated/java/lang/Character.java b/approximations/src/main/java/generated/java/lang/CharacterImpl.java similarity index 59% rename from approximations/src/main/java/generated/java/lang/Character.java rename to approximations/src/main/java/generated/java/lang/CharacterImpl.java index 9139f17c..35492621 100644 --- a/approximations/src/main/java/generated/java/lang/Character.java +++ b/approximations/src/main/java/generated/java/lang/CharacterImpl.java @@ -1,33 +1,22 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/lang/Character.lsl:62 -// - java/lang/Character.patch.lsl:17 -// package generated.java.lang; +import java.io.Serial; import java.io.Serializable; -import java.lang.Class; -import java.lang.Object; -import java.lang.SuppressWarnings; -import java.lang.Void; + import org.jacodb.approximation.annotation.Approximate; import org.usvm.api.Engine; -import runtime.LibSLRuntime; -/** - * CharacterAutomaton for LSLCharacter ~> java.lang.Character - */ -@SuppressWarnings({"all", "unchecked"}) +@SuppressWarnings("unused") @Approximate(java.lang.Character.class) -public final class Character implements LibSLRuntime.Automaton, Serializable { +public final class CharacterImpl implements Serializable { + + @Serial private static final long serialVersionUID = 3786198910865385080L; public static final int BYTES = 2; public static final int SIZE = 16; - public static final Class TYPE = java.lang.Character.class; - public static final byte COMBINING_SPACING_MARK = 8; public static final byte CONNECTOR_PUNCTUATION = 23; @@ -176,110 +165,33 @@ public final class Character implements LibSLRuntime.Automaton, Serializable { public char value; - @LibSLRuntime.AutomatonConstructor - public Character(Void __$lsl_token, final byte p0, final char p1) { - this.value = p1; - } - - @LibSLRuntime.AutomatonConstructor - public Character(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Initialized, '?'); - } - - /** - * [CONSTRUCTOR] CharacterAutomaton::(LSLCharacter, char) -> void - * Source: java/lang/Character.patch.lsl:47 - */ - public Character(char c) { - this((Void) null); - /* body */ { - this.value = c; - } + public CharacterImpl(char value) { + this.value = value; } - /** - * [FUNCTION] CharacterAutomaton::isWhitespace(char) -> boolean - * Source: java/lang/Character.patch.lsl:55 - */ public static boolean isWhitespace(char ch) { - boolean result = false; - /* body */ { - if ((ch == ' ') || (ch == CHAR_SN) || (ch == CHAR_ST) || (ch == CHAR_SF) || (ch == CHAR_SR)) { - result = true; - } else { - result = false; - } - } - return result; + return ch == ' ' || ch == CHAR_SN || ch == CHAR_ST || ch == CHAR_SF || ch == CHAR_SR; } - /** - * [FUNCTION] CharacterAutomaton::toLowerCase(char) -> char - * Source: java/lang/Character.patch.lsl:65 - */ public static char toLowerCase(char ch) { - char result = '?'; - /* body */ { - if ((ch >= 'A') && (ch <= 'Z')) { - result = ((char) ((ch - 'A') + 'a')); - } else { - result = ch; - } - } - return result; - } + if (ch >= 'A' && ch <= 'Z') + return (char) (ch - 'A' + 'a'); - /** - * [FUNCTION] CharacterAutomaton::toUpperCase(char) -> char - * Source: java/lang/Character.patch.lsl:74 - */ - public static char toUpperCase(char ch) { - char result = '?'; - /* body */ { - if ((ch >= 'a') && (ch <= 'z')) { - result = ((char) ((ch - 'a') + 'A')); - } else { - result = ch; - } - } - return result; + return ch; } - /** - * [FUNCTION] CharacterAutomaton::valueOf(char) -> Character - * Source: java/lang/Character.patch.lsl:83 - */ - public static java.lang.Character valueOf(char c) { - java.lang.Character result = null; - /* body */ { - result = (java.lang.Character) ((Object) new Character((Void) null, - /* state = */ Character.__$lsl_States.Initialized, - /* value = */ c - )); - } - return result; - } + public static char toUpperCase(char ch) { + if (ch >= 'a' && ch <= 'z') + return (char) (ch - 'a' + 'A'); - /** - * [FUNCTION] CharacterAutomaton::charValue(LSLCharacter) -> char - * Source: java/lang/Character.patch.lsl:93 - */ - public char charValue() { - char result = '?'; - /* body */ { - result = this.value; - } - return result; + return ch; } - public static final class __$lsl_States { - public static final byte Initialized = (byte) 0; + public static CharacterImpl valueOf(char c) { + return new CharacterImpl(c); } - @Approximate(Character.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } + public char charValue() { + return this.value; } } diff --git a/approximations/src/main/java/generated/java/lang/Double.java b/approximations/src/main/java/generated/java/lang/Double.java deleted file mode 100644 index 754164f4..00000000 --- a/approximations/src/main/java/generated/java/lang/Double.java +++ /dev/null @@ -1,615 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/lang/Double.lsl:35 -// - java/lang/Double.main.lsl:19 -// -package generated.java.lang; - -import java.lang.Class; -import java.lang.Comparable; -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.lang.Void; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; - -/** - * DoubleAutomaton for LSLDouble ~> java.lang.Double - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(java.lang.Double.class) -public final class Double implements LibSLRuntime.Automaton, Comparable { - private static final long serialVersionUID = -9172774392245257468L; - - public static final int BYTES = 8; - - public static final int SIZE = 64; - - public static final int MAX_EXPONENT = 1023; - - public static final int MIN_EXPONENT = -1022; - - public static final double MAX_VALUE = 1.7976931348623157E308d; - - public static final double MIN_VALUE = 4.9E-324d; - - public static final double MIN_NORMAL = 2.2250738585072014E-308d; - - public static final double POSITIVE_INFINITY = 1.0d / 0.0d; - - public static final double NEGATIVE_INFINITY = -1.0d / 0.0d; - - public static final double NaN = 0.0d / 0.0d; - - public static final Class TYPE = java.lang.Double.class; - - static { - Engine.assume(true); - } - - private byte __$lsl_state = __$lsl_States.Allocated; - - public double value; - - @LibSLRuntime.AutomatonConstructor - public Double(Void __$lsl_token, final byte p0, final double p1) { - this.__$lsl_state = p0; - this.value = p1; - } - - @LibSLRuntime.AutomatonConstructor - public Double(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Allocated, 0.0d); - } - - /** - * [CONSTRUCTOR] DoubleAutomaton::(LSLDouble, double) -> void - * Source: java/lang/Double.main.lsl:125 - */ - public Double(double v) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - this.value = v; - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [SUBROUTINE] DoubleAutomaton::_getRawBits(double) -> long - * Source: java/lang/Double.main.lsl:74 - */ - private static long _getRawBits(double v) { - long result = 0L; - /* body */ { - if (v != v) { - result = 9221120237041090560L; - } else { - if ((1.0d / v) == NEGATIVE_INFINITY) { - result = -9223372036854775808L; - } else { - if (v == 0.0d) { - result = 0L; - } else { - if (v == POSITIVE_INFINITY) { - result = 9218868437227405312L; - } else { - if (v == NEGATIVE_INFINITY) { - result = -4503599627370496L; - } else { - result = Engine.makeSymbolicLong(); - Engine.assume(result != 9221120237041090560L); - Engine.assume(result != -9223372036854775808L); - Engine.assume(result != 0L); - Engine.assume(result != 9218868437227405312L); - Engine.assume(result != -4503599627370496L); - if (v < 0.0d) { - Engine.assume(result < 0L); - } else { - Engine.assume(result > 0L); - } - } - } - } - } - } - } - return result; - } - - /** - * [SUBROUTINE] DoubleAutomaton::_parse(String) -> double - * Source: java/lang/Double.main.lsl:105 - */ - private static double _parse(String str) throws java.lang.NumberFormatException { - double result = 0.0d; - /* body */ { - if (str == null) { - throw new NullPointerException(); - } - LibSLRuntime.todo(); - } - return result; - } - - /** - * [FUNCTION] DoubleAutomaton::compare(double, double) -> int - * Source: java/lang/Double.main.lsl:133 - */ - public static int compare(double a, double b) { - int result = 0; - // WARNING: no state checks in static context - /* body */ { - if ((a == b) || (a != a) || (b != b)) { - result = 0; - } else { - if (a < b) { - result = -1; - } else { - result = 1; - } - } - } - // WARNING: no state transitions in static context - return result; - } - - /** - * [FUNCTION] DoubleAutomaton::doubleToLongBits(double) -> long - * Source: java/lang/Double.main.lsl:150 - */ - public static long doubleToLongBits(double value) { - long result = 0L; - // WARNING: no state checks in static context - /* body */ { - result = _getRawBits(value); - } - // WARNING: no state transitions in static context - return result; - } - - /** - * [FUNCTION] DoubleAutomaton::doubleToRawLongBits(double) -> long - * Source: java/lang/Double.main.lsl:156 - */ - public static long doubleToRawLongBits(double value) { - long result = 0L; - // WARNING: no state checks in static context - /* body */ { - result = _getRawBits(value); - } - // WARNING: no state transitions in static context - return result; - } - - /** - * [FUNCTION] DoubleAutomaton::hashCode(double) -> int - * Source: java/lang/Double.main.lsl:162 - */ - public static int hashCode(double value) { - int result = 0; - // WARNING: no state checks in static context - /* body */ { - result = ((int) _getRawBits(value)); - } - // WARNING: no state transitions in static context - return result; - } - - /** - * [FUNCTION] DoubleAutomaton::isFinite(double) -> boolean - * Source: java/lang/Double.main.lsl:168 - */ - public static boolean isFinite(double d) { - boolean result = false; - // WARNING: no state checks in static context - /* body */ { - if (d <= 0.0d) { - d = 0.0d - d; - } - result = d <= MAX_VALUE; - } - // WARNING: no state transitions in static context - return result; - } - - /** - * [FUNCTION] DoubleAutomaton::isInfinite(double) -> boolean - * Source: java/lang/Double.main.lsl:178 - */ - public static boolean isInfinite(double v) { - boolean result = false; - // WARNING: no state checks in static context - /* body */ { - result = (v == POSITIVE_INFINITY) || (v == NEGATIVE_INFINITY); - } - // WARNING: no state transitions in static context - return result; - } - - /** - * [FUNCTION] DoubleAutomaton::isNaN(double) -> boolean - * Source: java/lang/Double.main.lsl:185 - */ - public static boolean isNaN(double v) { - boolean result = false; - // WARNING: no state checks in static context - /* body */ { - result = v != v; - } - // WARNING: no state transitions in static context - return result; - } - - /** - * [FUNCTION] DoubleAutomaton::longBitsToDouble(long) -> double - * Source: java/lang/Double.main.lsl:191 - */ - public static double longBitsToDouble(long value) { - double result = 0.0d; - // WARNING: no state checks in static context - /* body */ { - if (value == 9221120237041090560L) { - result = NaN; - } else { - if (value == -9223372036854775808L) { - result = -0.0d; - } else { - if (value == 0L) { - result = 0.0d; - } else { - if (value == 9218868437227405312L) { - result = POSITIVE_INFINITY; - } else { - if (value == -4503599627370496L) { - result = NEGATIVE_INFINITY; - } else { - result = Engine.makeSymbolicDouble(); - Engine.assume(result != 0.0d); - Engine.assume(result == result); - Engine.assume(result != POSITIVE_INFINITY); - Engine.assume(result != NEGATIVE_INFINITY); - if (value < 0L) { - Engine.assume(result < 0.0d); - } else { - Engine.assume(result > 0.0d); - } - } - } - } - } - } - } - // WARNING: no state transitions in static context - return result; - } - - /** - * [FUNCTION] DoubleAutomaton::max(double, double) -> double - * Source: java/lang/Double.main.lsl:221 - */ - public static double max(double a, double b) { - double result = 0.0d; - // WARNING: no state checks in static context - /* body */ { - if (a != a) { - result = a; - } else { - if ((a == 0.0d) && (b == 0.0d) && ((1.0d / a) == NEGATIVE_INFINITY)) { - result = b; - } else { - if (a >= b) { - result = a; - } else { - result = b; - } - } - } - } - // WARNING: no state transitions in static context - return result; - } - - /** - * [FUNCTION] DoubleAutomaton::min(double, double) -> double - * Source: java/lang/Double.main.lsl:234 - */ - public static double min(double a, double b) { - double result = 0.0d; - // WARNING: no state checks in static context - /* body */ { - if (a != a) { - result = a; - } else { - if ((a == 0.0d) && (b == 0.0d) && ((1.0d / b) == NEGATIVE_INFINITY)) { - result = b; - } else { - if (a <= b) { - result = a; - } else { - result = b; - } - } - } - } - // WARNING: no state transitions in static context - return result; - } - - /** - * [FUNCTION] DoubleAutomaton::sum(double, double) -> double - * Source: java/lang/Double.main.lsl:255 - */ - public static double sum(double a, double b) { - double result = 0.0d; - // WARNING: no state checks in static context - /* body */ { - result = a + b; - } - // WARNING: no state transitions in static context - return result; - } - - /** - * [FUNCTION] DoubleAutomaton::toHexString(double) -> String - * Source: java/lang/Double.main.lsl:261 - */ - public static String toHexString(double d) { - String result = null; - // WARNING: no state checks in static context - /* body */ { - if (d != d) { - result = "NaN"; - } else { - if (d == POSITIVE_INFINITY) { - result = "Infinity"; - } else { - if (d == NEGATIVE_INFINITY) { - result = "-Infinity"; - } else { - if ((1.0d / d) == NEGATIVE_INFINITY) { - result = "-0x0.0p0"; - } else { - if (d == 0.0f) { - result = "0x0.0p0"; - } else { - if (d == 1.0f) { - result = "0x1.0p0"; - } else { - if (d == -1.0f) { - result = "-0x1.0p0"; - } else { - result = Engine.makeSymbolic(String.class); - Engine.assume(result != null); - final int len = result.length(); - Engine.assume(len >= 7); - Engine.assume(len <= 22); - } - } - } - } - } - } - } - } - // WARNING: no state transitions in static context - return result; - } - - /** - * [FUNCTION] DoubleAutomaton::toString(double) -> String - * Source: java/lang/Double.main.lsl:282 - */ - public static String toString(double d) { - String result = null; - // WARNING: no state checks in static context - /* body */ { - result = LibSLRuntime.toString(d); - } - // WARNING: no state transitions in static context - return result; - } - - /** - * [FUNCTION] DoubleAutomaton::valueOf(double) -> Double - * Source: java/lang/Double.main.lsl:298 - */ - public static java.lang.Double valueOf(double d) { - java.lang.Double result = null; - // WARNING: no state checks in static context - /* body */ { - result = (java.lang.Double) ((Object) new Double((Void) null, - /* state = */ Double.__$lsl_States.Initialized, - /* value = */ d - )); - } - // WARNING: no state transitions in static context - return result; - } - - /** - * [FUNCTION] DoubleAutomaton::byteValue(LSLDouble) -> byte - * Source: java/lang/Double.main.lsl:308 - */ - public byte byteValue() { - byte result = ((byte) 0); - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = ((byte) this.value); - } - return result; - } - - /** - * [FUNCTION] DoubleAutomaton::compareTo(LSLDouble, LSLDouble) -> int - * Source: java/lang/Double.main.lsl:314 - */ - public int compareTo(Double anotherDouble) { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final double a = this.value; - final double b = ((Double) ((Object) anotherDouble)).value; - if ((a == b) || (a != a) || (b != b)) { - result = 0; - } else { - if (a < b) { - result = -1; - } else { - result = 1; - } - } - } - return result; - } - - /** - * [FUNCTION] DoubleAutomaton::doubleValue(LSLDouble) -> double - * Source: java/lang/Double.main.lsl:334 - */ - public double doubleValue() { - double result = 0.0d; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value; - } - return result; - } - - /** - * [FUNCTION] DoubleAutomaton::equals(LSLDouble, Object) -> boolean - * Source: java/lang/Double.main.lsl:340 - */ - public boolean equals(Object obj) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if ((obj instanceof java.lang.Double)) { - result = this.value == ((Double) ((Object) obj)).value; - } else { - result = false; - } - } - return result; - } - - /** - * [FUNCTION] DoubleAutomaton::floatValue(LSLDouble) -> float - * Source: java/lang/Double.main.lsl:349 - */ - public float floatValue() { - float result = 0.0f; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = ((float) this.value); - } - return result; - } - - /** - * [FUNCTION] DoubleAutomaton::hashCode(LSLDouble) -> int - * Source: java/lang/Double.main.lsl:355 - */ - public int hashCode() { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = ((int) _getRawBits(this.value)); - } - return result; - } - - /** - * [FUNCTION] DoubleAutomaton::intValue(LSLDouble) -> int - * Source: java/lang/Double.main.lsl:361 - */ - public int intValue() { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = ((int) this.value); - } - return result; - } - - /** - * [FUNCTION] DoubleAutomaton::isInfinite(LSLDouble) -> boolean - * Source: java/lang/Double.main.lsl:367 - */ - public boolean isInfinite() { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = (this.value == POSITIVE_INFINITY) || (this.value == NEGATIVE_INFINITY); - } - return result; - } - - /** - * [FUNCTION] DoubleAutomaton::isNaN(LSLDouble) -> boolean - * Source: java/lang/Double.main.lsl:374 - */ - public boolean isNaN() { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value != this.value; - } - return result; - } - - /** - * [FUNCTION] DoubleAutomaton::longValue(LSLDouble) -> long - * Source: java/lang/Double.main.lsl:380 - */ - public long longValue() { - long result = 0L; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = ((long) this.value); - } - return result; - } - - /** - * [FUNCTION] DoubleAutomaton::shortValue(LSLDouble) -> short - * Source: java/lang/Double.main.lsl:386 - */ - public short shortValue() { - short result = ((short) 0); - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = ((short) this.value); - } - return result; - } - - /** - * [FUNCTION] DoubleAutomaton::toString(LSLDouble) -> String - * Source: java/lang/Double.main.lsl:392 - */ - public String toString() { - String result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = LibSLRuntime.toString(this.value); - } - return result; - } - - public static final class __$lsl_States { - public static final byte Allocated = (byte) 0; - - public static final byte Initialized = (byte) 1; - } - - @Approximate(Double.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/lang/DoubleImpl.java b/approximations/src/main/java/generated/java/lang/DoubleImpl.java new file mode 100644 index 00000000..e02e9acd --- /dev/null +++ b/approximations/src/main/java/generated/java/lang/DoubleImpl.java @@ -0,0 +1,285 @@ +package generated.java.lang; + +import java.io.Serial; +import java.io.Serializable; +import java.lang.Comparable; +import java.lang.NullPointerException; +import java.lang.Object; +import java.lang.String; + +import org.jacodb.approximation.annotation.Approximate; +import org.usvm.api.Engine; +import runtime.LibSLRuntime; + +@SuppressWarnings("unused") +@Approximate(java.lang.Double.class) +public final class DoubleImpl implements Comparable, Serializable { + + @Serial + private static final long serialVersionUID = -9172774392245257468L; + + public static final int BYTES = 8; + + public static final int SIZE = 64; + + public static final int MAX_EXPONENT = 1023; + + public static final int MIN_EXPONENT = -1022; + + public static final double MAX_VALUE = 1.7976931348623157E308d; + + public static final double MIN_VALUE = 4.9E-324d; + + public static final double MIN_NORMAL = 2.2250738585072014E-308d; + + @SuppressWarnings({"divzero", "NumericOverflow"}) + public static final double POSITIVE_INFINITY = 1.0d / 0.0d; + + @SuppressWarnings({"divzero", "NumericOverflow"}) + public static final double NEGATIVE_INFINITY = -1.0d / 0.0d; + + @SuppressWarnings("divzero") + public static final double NaN = 0.0d / 0.0d; + + static { + Engine.assume(true); + } + + public double value; + + public DoubleImpl(double value) { + this.value = value; + } + + private static boolean _isNan(double d) { + return d != d; + } + + private static long _getRawBits(double v) { + if (_isNan(v)) + return 9221120237041090560L; + + if (1.0d / v == NEGATIVE_INFINITY) + return -9223372036854775808L; + + if (v == 0.0d) + return 0L; + + if (v == POSITIVE_INFINITY) + return 9218868437227405312L; + + if (v == NEGATIVE_INFINITY) + return -4503599627370496L; + + long result = Engine.makeSymbolicLong(); + Engine.assume(result != 9221120237041090560L); + Engine.assume(result != -9223372036854775808L); + Engine.assume(result != 0L); + Engine.assume(result != 9218868437227405312L); + Engine.assume(result != -4503599627370496L); + if (v < 0.0d) { + Engine.assume(result < 0L); + } else { + Engine.assume(result > 0L); + } + + return result; + } + + private static double _parse(String str) throws java.lang.NumberFormatException { + if (str == null) { + throw new NullPointerException(); + } + + LibSLRuntime.todo(); + return 0.0d; + } + + public static int compare(double a, double b) { + if (a == b || _isNan(a) || _isNan(b)) + return 0; + + if (a < b) + return -1; + + return 1; + } + + public static long doubleToLongBits(double value) { + return _getRawBits(value); + } + + public static long doubleToRawLongBits(double value) { + return _getRawBits(value); + } + + public static int hashCode(double value) { + return (int) _getRawBits(value); + } + + public static boolean isFinite(double d) { + if (d <= 0.0d) + d = 0.0d - d; + return d <= MAX_VALUE; + } + + public static boolean isInfinite(double v) { + return (v == POSITIVE_INFINITY) || (v == NEGATIVE_INFINITY); + } + + public static boolean isNaN(double v) { + return _isNan(v); + } + + public static double longBitsToDouble(long value) { + if (value == 9221120237041090560L) + return NaN; + + if (value == -9223372036854775808L) + return -0.0d; + + if (value == 0L) + return 0.0d; + + if (value == 9218868437227405312L) + return POSITIVE_INFINITY; + + if (value == -4503599627370496L) + return NEGATIVE_INFINITY; + + double result = Engine.makeSymbolicDouble(); + Engine.assume(result != 0.0d); + Engine.assume(result == result); + Engine.assume(result != POSITIVE_INFINITY); + Engine.assume(result != NEGATIVE_INFINITY); + if (value < 0L) { + Engine.assume(result < 0.0d); + } else { + Engine.assume(result > 0.0d); + } + return result; + } + + @SuppressWarnings("ManualMinMaxCalculation") + public static double max(double a, double b) { + if (_isNan(a)) + return a; + + if (a == 0.0d && b == 0.0d && (1.0d / a) == NEGATIVE_INFINITY) + return b; + + if (a >= b) + return a; + + return b; + } + + @SuppressWarnings("ManualMinMaxCalculation") + public static double min(double a, double b) { + if (_isNan(a)) + return a; + + if (a == 0.0d && b == 0.0d && (1.0d / b) == NEGATIVE_INFINITY) + return b; + + if (a <= b) + return a; + + return b; + } + + public static double sum(double a, double b) { + return a + b; + } + + @SuppressWarnings({"ConstantValue", "DataFlowIssue"}) + public static String toHexString(double d) { + if (_isNan(d)) + return "NaN"; + + if (d == POSITIVE_INFINITY) + return "Infinity"; + + if (d == NEGATIVE_INFINITY) + return "-Infinity"; + + if ((1.0d / d) == NEGATIVE_INFINITY) + return "-0x0.0p0"; + + if (d == 0.0f) + return "0x0.0p0"; + + if (d == 1.0f) + return "0x1.0p0"; + + if (d == -1.0f) + return "-0x1.0p0"; + + String result = Engine.makeSymbolic(String.class); + Engine.assume(result != null); + int len = result.length(); + Engine.assume(len >= 7); + Engine.assume(len <= 22); + return result; + } + + public static String toString(double d) { + return LibSLRuntime.toString(d); + } + + public static DoubleImpl valueOf(double d) { + return new DoubleImpl(d); + } + + public byte byteValue() { + return (byte) this.value; + } + + public int compareTo(DoubleImpl anotherDoubleImpl) { + return compare(this.value, anotherDoubleImpl.value); + } + + public double doubleValue() { + return this.value; + } + + @SuppressWarnings("EqualsWhichDoesntCheckParameterClass") + public boolean equals(Object obj) { + if (Engine.typeIs(obj, DoubleImpl.class)) + return this.value == ((DoubleImpl) obj).value; + + return false; + } + + public float floatValue() { + return (float) this.value; + } + + public int hashCode() { + return (int) _getRawBits(this.value); + } + + public int intValue() { + return (int) this.value; + } + + public boolean isInfinite() { + return isInfinite(this.value); + } + + public boolean isNaN() { + return isNaN(this.value); + } + + public long longValue() { + return (long) this.value; + } + + public short shortValue() { + return (short) this.value; + } + + public String toString() { + return LibSLRuntime.toString(this.value); + } +} diff --git a/approximations/src/main/java/generated/java/lang/Float.java b/approximations/src/main/java/generated/java/lang/Float.java deleted file mode 100644 index a91df9f6..00000000 --- a/approximations/src/main/java/generated/java/lang/Float.java +++ /dev/null @@ -1,628 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/lang/Float.lsl:35 -// - java/lang/Float.main.lsl:18 -// -package generated.java.lang; - -import java.lang.Class; -import java.lang.Comparable; -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.lang.Void; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; - -/** - * FloatAutomaton for LSLFloat ~> java.lang.Float - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(java.lang.Float.class) -public final class Float implements LibSLRuntime.Automaton, Comparable { - private static final long serialVersionUID = -2671257302660747028L; - - public static final int BYTES = 4; - - public static final int SIZE = 32; - - public static final int MAX_EXPONENT = 127; - - public static final int MIN_EXPONENT = -126; - - public static final float MAX_VALUE = 3.4028235E38f; - - public static final float MIN_VALUE = 1.4E-45f; - - public static final float MIN_NORMAL = 1.17549435E-38f; - - public static final float NEGATIVE_INFINITY = -1.0f / 0.0f; - - public static final float POSITIVE_INFINITY = 1.0f / 0.0f; - - public static final float NaN = 0.0f / 0.0f; - - public static final Class TYPE = java.lang.Float.class; - - static { - Engine.assume(true); - } - - private byte __$lsl_state = __$lsl_States.Allocated; - - public float value; - - @LibSLRuntime.AutomatonConstructor - public Float(Void __$lsl_token, final byte p0, final float p1) { - this.__$lsl_state = p0; - this.value = p1; - } - - @LibSLRuntime.AutomatonConstructor - public Float(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Allocated, 0.0f); - } - - /** - * [CONSTRUCTOR] FloatAutomaton::(LSLFloat, double) -> void - * Source: java/lang/Float.main.lsl:126 - */ - public Float(double v) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - this.value = ((float) v); - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [CONSTRUCTOR] FloatAutomaton::(LSLFloat, float) -> void - * Source: java/lang/Float.main.lsl:132 - */ - public Float(float v) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - this.value = v; - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [SUBROUTINE] FloatAutomaton::_getRawBits(float) -> int - * Source: java/lang/Float.main.lsl:74 - */ - private static int _getRawBits(float v) { - int result = 0; - /* body */ { - if (v != v) { - result = 2143289344; - } else { - if ((1.0f / v) == NEGATIVE_INFINITY) { - result = -2147483648; - } else { - if (v == 0.0f) { - result = 0; - } else { - if (v == POSITIVE_INFINITY) { - result = 2139095040; - } else { - if (v == NEGATIVE_INFINITY) { - result = -8388608; - } else { - result = Engine.makeSymbolicInt(); - Engine.assume(result != 2143289344); - Engine.assume(result != -2147483648); - Engine.assume(result != 0); - Engine.assume(result != 2139095040); - Engine.assume(result != -8388608); - if (v < 0.0f) { - Engine.assume(result < 0); - } else { - Engine.assume(result > 0); - } - } - } - } - } - } - } - return result; - } - - /** - * [SUBROUTINE] FloatAutomaton::_parse(String) -> float - * Source: java/lang/Float.main.lsl:105 - */ - private static float _parse(String str) throws java.lang.NumberFormatException { - float result = 0.0f; - /* body */ { - if (str == null) { - throw new NullPointerException(); - } - LibSLRuntime.todo(); - } - return result; - } - - /** - * [FUNCTION] FloatAutomaton::compare(float, float) -> int - * Source: java/lang/Float.main.lsl:140 - */ - public static int compare(float a, float b) { - int result = 0; - // WARNING: no state checks in static context - /* body */ { - if ((a == b) || (a != a) || (b != b)) { - result = 0; - } else { - if (a < b) { - result = -1; - } else { - result = 1; - } - } - } - // WARNING: no state transitions in static context - return result; - } - - /** - * [FUNCTION] FloatAutomaton::floatToIntBits(float) -> int - * Source: java/lang/Float.main.lsl:157 - */ - public static int floatToIntBits(float value) { - int result = 0; - // WARNING: no state checks in static context - /* body */ { - result = _getRawBits(value); - } - // WARNING: no state transitions in static context - return result; - } - - /** - * [FUNCTION] FloatAutomaton::floatToRawIntBits(float) -> int - * Source: java/lang/Float.main.lsl:163 - */ - public static int floatToRawIntBits(float value) { - int result = 0; - // WARNING: no state checks in static context - /* body */ { - result = _getRawBits(value); - } - // WARNING: no state transitions in static context - return result; - } - - /** - * [FUNCTION] FloatAutomaton::hashCode(float) -> int - * Source: java/lang/Float.main.lsl:169 - */ - public static int hashCode(float value) { - int result = 0; - // WARNING: no state checks in static context - /* body */ { - result = _getRawBits(value); - } - // WARNING: no state transitions in static context - return result; - } - - /** - * [FUNCTION] FloatAutomaton::intBitsToFloat(int) -> float - * Source: java/lang/Float.main.lsl:175 - */ - public static float intBitsToFloat(int value) { - float result = 0.0f; - // WARNING: no state checks in static context - /* body */ { - if (value == 2143289344) { - result = NaN; - } else { - if (value == -2147483648) { - result = -0.0f; - } else { - if (value == 0) { - result = 0.0f; - } else { - if (value == 2139095040) { - result = POSITIVE_INFINITY; - } else { - if (value == -8388608) { - result = NEGATIVE_INFINITY; - } else { - result = Engine.makeSymbolicFloat(); - Engine.assume(result != 0.0f); - Engine.assume(result == result); - Engine.assume(result != POSITIVE_INFINITY); - Engine.assume(result != NEGATIVE_INFINITY); - if (value < 0) { - Engine.assume(result < 0.0f); - } else { - Engine.assume(result > 0.0f); - } - } - } - } - } - } - } - // WARNING: no state transitions in static context - return result; - } - - /** - * [FUNCTION] FloatAutomaton::isFinite(float) -> boolean - * Source: java/lang/Float.main.lsl:205 - */ - public static boolean isFinite(float f) { - boolean result = false; - // WARNING: no state checks in static context - /* body */ { - if (f <= 0.0f) { - f = 0.0f - f; - } - result = f <= MAX_VALUE; - } - // WARNING: no state transitions in static context - return result; - } - - /** - * [FUNCTION] FloatAutomaton::isInfinite(float) -> boolean - * Source: java/lang/Float.main.lsl:215 - */ - public static boolean isInfinite(float v) { - boolean result = false; - // WARNING: no state checks in static context - /* body */ { - result = (v == POSITIVE_INFINITY) || (v == NEGATIVE_INFINITY); - } - // WARNING: no state transitions in static context - return result; - } - - /** - * [FUNCTION] FloatAutomaton::isNaN(float) -> boolean - * Source: java/lang/Float.main.lsl:222 - */ - public static boolean isNaN(float v) { - boolean result = false; - // WARNING: no state checks in static context - /* body */ { - result = v != v; - } - // WARNING: no state transitions in static context - return result; - } - - /** - * [FUNCTION] FloatAutomaton::max(float, float) -> float - * Source: java/lang/Float.main.lsl:228 - */ - public static float max(float a, float b) { - float result = 0.0f; - // WARNING: no state checks in static context - /* body */ { - if (a != a) { - result = a; - } else { - if ((a == 0.0f) && (b == 0.0f) && ((1.0f / a) == NEGATIVE_INFINITY)) { - result = b; - } else { - if (a >= b) { - result = a; - } else { - result = b; - } - } - } - } - // WARNING: no state transitions in static context - return result; - } - - /** - * [FUNCTION] FloatAutomaton::min(float, float) -> float - * Source: java/lang/Float.main.lsl:241 - */ - public static float min(float a, float b) { - float result = 0.0f; - // WARNING: no state checks in static context - /* body */ { - if (a != a) { - result = a; - } else { - if ((a == 0.0f) && (b == 0.0f) && ((1.0f / b) == NEGATIVE_INFINITY)) { - result = b; - } else { - if (a <= b) { - result = a; - } else { - result = b; - } - } - } - } - // WARNING: no state transitions in static context - return result; - } - - /** - * [FUNCTION] FloatAutomaton::sum(float, float) -> float - * Source: java/lang/Float.main.lsl:262 - */ - public static float sum(float a, float b) { - float result = 0.0f; - // WARNING: no state checks in static context - /* body */ { - result = a + b; - } - // WARNING: no state transitions in static context - return result; - } - - /** - * [FUNCTION] FloatAutomaton::toHexString(float) -> String - * Source: java/lang/Float.main.lsl:268 - */ - public static String toHexString(float f) { - String result = null; - // WARNING: no state checks in static context - /* body */ { - if (f != f) { - result = "NaN"; - } else { - if (f == POSITIVE_INFINITY) { - result = "Infinity"; - } else { - if (f == NEGATIVE_INFINITY) { - result = "-Infinity"; - } else { - if ((1.0f / f) == NEGATIVE_INFINITY) { - result = "-0x0.0p0"; - } else { - if (f == 0.0f) { - result = "0x0.0p0"; - } else { - if (f == 1.0f) { - result = "0x1.0p0"; - } else { - if (f == -1.0f) { - result = "-0x1.0p0"; - } else { - result = Engine.makeSymbolic(String.class); - Engine.assume(result != null); - final int len = result.length(); - Engine.assume(len >= 7); - Engine.assume(len <= 14); - } - } - } - } - } - } - } - } - // WARNING: no state transitions in static context - return result; - } - - /** - * [FUNCTION] FloatAutomaton::toString(float) -> String - * Source: java/lang/Float.main.lsl:289 - */ - public static String toString(float f) { - String result = null; - // WARNING: no state checks in static context - /* body */ { - result = LibSLRuntime.toString(f); - } - // WARNING: no state transitions in static context - return result; - } - - /** - * [FUNCTION] FloatAutomaton::valueOf(float) -> Float - * Source: java/lang/Float.main.lsl:305 - */ - public static java.lang.Float valueOf(float f) { - java.lang.Float result = null; - // WARNING: no state checks in static context - /* body */ { - result = (java.lang.Float) ((Object) new Float((Void) null, - /* state = */ Float.__$lsl_States.Initialized, - /* value = */ f - )); - } - // WARNING: no state transitions in static context - return result; - } - - /** - * [FUNCTION] FloatAutomaton::byteValue(LSLFloat) -> byte - * Source: java/lang/Float.main.lsl:315 - */ - public byte byteValue() { - byte result = ((byte) 0); - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = ((byte) this.value); - } - return result; - } - - /** - * [FUNCTION] FloatAutomaton::compareTo(LSLFloat, LSLFloat) -> int - * Source: java/lang/Float.main.lsl:321 - */ - public int compareTo(Float anotherFloat) { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final float a = this.value; - final float b = ((Float) ((Object) anotherFloat)).value; - if ((a == b) || (a != a) || (b != b)) { - result = 0; - } else { - if (a < b) { - result = -1; - } else { - result = 1; - } - } - } - return result; - } - - /** - * [FUNCTION] FloatAutomaton::doubleValue(LSLFloat) -> double - * Source: java/lang/Float.main.lsl:341 - */ - public double doubleValue() { - double result = 0.0d; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = ((double) this.value); - } - return result; - } - - /** - * [FUNCTION] FloatAutomaton::equals(LSLFloat, Object) -> boolean - * Source: java/lang/Float.main.lsl:347 - */ - public boolean equals(Object obj) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if ((obj instanceof java.lang.Float)) { - result = this.value == ((Float) ((Object) obj)).value; - } else { - result = false; - } - } - return result; - } - - /** - * [FUNCTION] FloatAutomaton::floatValue(LSLFloat) -> float - * Source: java/lang/Float.main.lsl:356 - */ - public float floatValue() { - float result = 0.0f; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value; - } - return result; - } - - /** - * [FUNCTION] FloatAutomaton::hashCode(LSLFloat) -> int - * Source: java/lang/Float.main.lsl:362 - */ - public int hashCode() { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = _getRawBits(this.value); - } - return result; - } - - /** - * [FUNCTION] FloatAutomaton::intValue(LSLFloat) -> int - * Source: java/lang/Float.main.lsl:368 - */ - public int intValue() { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = ((int) this.value); - } - return result; - } - - /** - * [FUNCTION] FloatAutomaton::isInfinite(LSLFloat) -> boolean - * Source: java/lang/Float.main.lsl:374 - */ - public boolean isInfinite() { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = (this.value == POSITIVE_INFINITY) || (this.value == NEGATIVE_INFINITY); - } - return result; - } - - /** - * [FUNCTION] FloatAutomaton::isNaN(LSLFloat) -> boolean - * Source: java/lang/Float.main.lsl:381 - */ - public boolean isNaN() { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value != this.value; - } - return result; - } - - /** - * [FUNCTION] FloatAutomaton::longValue(LSLFloat) -> long - * Source: java/lang/Float.main.lsl:387 - */ - public long longValue() { - long result = 0L; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = ((long) this.value); - } - return result; - } - - /** - * [FUNCTION] FloatAutomaton::shortValue(LSLFloat) -> short - * Source: java/lang/Float.main.lsl:393 - */ - public short shortValue() { - short result = ((short) 0); - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = ((short) this.value); - } - return result; - } - - /** - * [FUNCTION] FloatAutomaton::toString(LSLFloat) -> String - * Source: java/lang/Float.main.lsl:399 - */ - public String toString() { - String result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = LibSLRuntime.toString(this.value); - } - return result; - } - - public static final class __$lsl_States { - public static final byte Allocated = (byte) 0; - - public static final byte Initialized = (byte) 1; - } - - @Approximate(Float.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/lang/FloatImpl.java b/approximations/src/main/java/generated/java/lang/FloatImpl.java new file mode 100644 index 00000000..4e39306c --- /dev/null +++ b/approximations/src/main/java/generated/java/lang/FloatImpl.java @@ -0,0 +1,289 @@ +package generated.java.lang; + +import java.io.Serial; +import java.io.Serializable; +import java.lang.Comparable; +import java.lang.NullPointerException; +import java.lang.Object; +import java.lang.String; +import java.lang.SuppressWarnings; + +import org.jacodb.approximation.annotation.Approximate; +import org.usvm.api.Engine; +import runtime.LibSLRuntime; + +@SuppressWarnings("unused") +@Approximate(java.lang.Float.class) +public final class FloatImpl implements Comparable, Serializable { + + @Serial + private static final long serialVersionUID = -2671257302660747028L; + + public static final int BYTES = 4; + + public static final int SIZE = 32; + + public static final int MAX_EXPONENT = 127; + + public static final int MIN_EXPONENT = -126; + + public static final float MAX_VALUE = 3.4028235E38f; + + public static final float MIN_VALUE = 1.4E-45f; + + public static final float MIN_NORMAL = 1.17549435E-38f; + + @SuppressWarnings({"NumericOverflow", "divzero"}) + public static final float NEGATIVE_INFINITY = -1.0f / 0.0f; + + @SuppressWarnings({"divzero", "NumericOverflow"}) + public static final float POSITIVE_INFINITY = 1.0f / 0.0f; + + @SuppressWarnings("divzero") + public static final float NaN = 0.0f / 0.0f; + + static { + Engine.assume(true); + } + + public float value; + + public FloatImpl(float value) { + this.value = value; + } + + public FloatImpl(double v) { + this.value = ((float) v); + } + + private static boolean _isNan(float f) { + return f != f; + } + + private static int _getRawBits(float v) { + if (_isNan(v)) + return 2143289344; + + if (1.0f / v == NEGATIVE_INFINITY) + return -2147483648; + + if (v == 0.0f) + return 0; + + if (v == POSITIVE_INFINITY) + return 2139095040; + + if (v == NEGATIVE_INFINITY) + return -8388608; + + int result = Engine.makeSymbolicInt(); + Engine.assume(result != 2143289344); + Engine.assume(result != -2147483648); + Engine.assume(result != 0); + Engine.assume(result != 2139095040); + Engine.assume(result != -8388608); + if (v < 0.0f) { + Engine.assume(result < 0); + } else { + Engine.assume(result > 0); + } + return result; + } + + private static float _parse(String str) throws java.lang.NumberFormatException { + if (str == null) { + throw new NullPointerException(); + } + LibSLRuntime.todo(); + return 0.0f; + } + + public static int compare(float a, float b) { + if (a == b || _isNan(a) || _isNan(b)) + return 0; + + if (a < b) + return -1; + + return 1; + } + + public static int floatToIntBits(float value) { + return _getRawBits(value); + } + + public static int floatToRawIntBits(float value) { + return _getRawBits(value); + } + + public static int hashCode(float value) { + return _getRawBits(value); + } + + public static float intBitsToFloat(int value) { + if (value == 2143289344) + return NaN; + + if (value == -2147483648) + return -0.0f; + + if (value == 0) + return 0.0f; + + if (value == 2139095040) + return POSITIVE_INFINITY; + + if (value == -8388608) + return NEGATIVE_INFINITY; + + float result = Engine.makeSymbolicFloat(); + Engine.assume(result != 0.0f); + Engine.assume(result == result); + Engine.assume(result != POSITIVE_INFINITY); + Engine.assume(result != NEGATIVE_INFINITY); + if (value < 0) { + Engine.assume(result < 0.0f); + } else { + Engine.assume(result > 0.0f); + } + return result; + } + + public static boolean isFinite(float f) { + if (f <= 0.0f) + f = 0.0f - f; + + return f <= MAX_VALUE; + } + + public static boolean isInfinite(float v) { + return v == POSITIVE_INFINITY || v == NEGATIVE_INFINITY; + } + + public static boolean isNaN(float v) { + return _isNan(v); + } + + @SuppressWarnings("ManualMinMaxCalculation") + public static float max(float a, float b) { + if (_isNan(a)) + return a; + + if (a == 0.0f && b == 0.0f && (1.0f / a) == NEGATIVE_INFINITY) + return b; + + if (a >= b) + return a; + + return b; + } + + @SuppressWarnings("ManualMinMaxCalculation") + public static float min(float a, float b) { + if (_isNan(a)) + return a; + + if (a == 0.0f && b == 0.0f && (1.0f / b) == NEGATIVE_INFINITY) + return b; + + if (a <= b) + return a; + + return b; + } + + public static float sum(float a, float b) { + return a + b; + } + + @SuppressWarnings({"ConstantValue", "DataFlowIssue"}) + public static String toHexString(float f) { + if (f != f) + return "NaN"; + + if (f == POSITIVE_INFINITY) + return "Infinity"; + + if (f == NEGATIVE_INFINITY) + return "-Infinity"; + + if (1.0f / f == NEGATIVE_INFINITY) + return "-0x0.0p0"; + + if (f == 0.0f) + return "0x0.0p0"; + + if (f == 1.0f) + return "0x1.0p0"; + + if (f == -1.0f) + return "-0x1.0p0"; + + String result = Engine.makeSymbolic(String.class); + Engine.assume(result != null); + int len = result.length(); + Engine.assume(len >= 7); + Engine.assume(len <= 14); + return result; + } + + public static String toString(float f) { + return LibSLRuntime.toString(f); + } + + public static FloatImpl valueOf(float f) { + return new FloatImpl(f); + } + + public byte byteValue() { + return (byte) this.value; + } + + public int compareTo(FloatImpl anotherFloatImpl) { + return compare(this.value, anotherFloatImpl.value); + } + + public double doubleValue() { + return this.value; + } + + @SuppressWarnings("EqualsWhichDoesntCheckParameterClass") + public boolean equals(Object obj) { + if (Engine.typeIs(obj, FloatImpl.class)) + return this.value == ((FloatImpl) obj).value; + + return false; + } + + public float floatValue() { + return this.value; + } + + public int hashCode() { + return _getRawBits(this.value); + } + + public int intValue() { + return (int) this.value; + } + + public boolean isInfinite() { + return isInfinite(this.value); + } + + public boolean isNaN() { + return _isNan(this.value); + } + + public long longValue() { + return (long) this.value; + } + + public short shortValue() { + return (short) this.value; + } + + public String toString() { + return LibSLRuntime.toString(this.value); + } +} diff --git a/approximations/src/main/java/generated/java/lang/Integer.java b/approximations/src/main/java/generated/java/lang/Integer.java deleted file mode 100644 index 01758490..00000000 --- a/approximations/src/main/java/generated/java/lang/Integer.java +++ /dev/null @@ -1,577 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/lang/Integer.lsl:30 -// - java/lang/Integer.main.lsl:20 -// -package generated.java.lang; - -import java.lang.Class; -import java.lang.Comparable; -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.lang.Void; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; - -/** - * IntegerAutomaton for LSLInteger ~> java.lang.Integer - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(java.lang.Integer.class) -public final class Integer implements LibSLRuntime.Automaton, Comparable { - private static final long serialVersionUID = 1360826667806852920L; - - public static final int MIN_VALUE = -2147483648; - - public static final int MAX_VALUE = 2147483647; - - public static final Class TYPE = java.lang.Integer.class; - - public static final int SIZE = 32; - - public static final int BYTES = 4; - - public static final char[] digits = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' }; - - public static final char[] DigitTens = { '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '3', '3', '3', '3', '3', '3', '3', '3', '3', '3', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '5', '5', '5', '5', '5', '5', '5', '5', '5', '5', '6', '6', '6', '6', '6', '6', '6', '6', '6', '6', '7', '7', '7', '7', '7', '7', '7', '7', '7', '7', '8', '8', '8', '8', '8', '8', '8', '8', '8', '8', '9', '9', '9', '9', '9', '9', '9', '9', '9', '9' }; - - public static final char[] DigitOnes = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' }; - - public static final int[] sizeTable = { 9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999, 2147483647 }; - - static { - Engine.assume(true); - } - - private int value; - - @LibSLRuntime.AutomatonConstructor - public Integer(Void __$lsl_token, final byte p0, final int p1) { - this.value = p1; - } - - @LibSLRuntime.AutomatonConstructor - public Integer(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Initialized, 0); - } - - /** - * [CONSTRUCTOR] IntegerAutomaton::(LSLInteger, int) -> void - * Source: java/lang/Integer.main.lsl:114 - */ - public Integer(int v) { - this((Void) null); - /* body */ { - this.value = v; - } - } - - /** - * [SUBROUTINE] IntegerAutomaton::_parse(String) -> int - * Source: java/lang/Integer.main.lsl:93 - */ - private static int _parse(String str) throws java.lang.NumberFormatException { - int result = 0; - /* body */ { - if (str == null) { - throw new NullPointerException(); - } - LibSLRuntime.todo(); - } - return result; - } - - /** - * [FUNCTION] IntegerAutomaton::bitCount(int) -> int - * Source: java/lang/Integer.main.lsl:122 - */ - public static int bitCount(int i) { - int result = 0; - /* body */ { - i = i - ((i >>> 1) & 1431655765); - i = (i & 858993459) + ((i >>> 2) & 858993459); - i = (i + (i >>> 4)) & 252645135; - i = i + (i >>> 8); - i = i + (i >>> 16); - result = i & 63; - } - return result; - } - - /** - * [FUNCTION] IntegerAutomaton::compare(int, int) -> int - * Source: java/lang/Integer.main.lsl:134 - */ - public static int compare(int x, int y) { - int result = 0; - /* body */ { - if (x == y) { - result = 0; - } else { - if (x < y) { - result = -1; - } else { - result = 1; - } - } - } - return result; - } - - /** - * [FUNCTION] IntegerAutomaton::compareUnsigned(int, int) -> int - * Source: java/lang/Integer.main.lsl:150 - */ - public static int compareUnsigned(int x, int y) { - int result = 0; - /* body */ { - x += MIN_VALUE; - y += MIN_VALUE; - if (x == y) { - result = 0; - } else { - if (x < y) { - result = -1; - } else { - result = 1; - } - } - } - return result; - } - - /** - * [FUNCTION] IntegerAutomaton::divideUnsigned(int, int) -> int - * Source: java/lang/Integer.main.lsl:176 - */ - public static int divideUnsigned(int dividend, int divisor) { - int result = 0; - /* body */ { - final long unsignedDividend = ((long) dividend) & 4294967295L; - final long unsignedDivisor = ((long) divisor) & 4294967295L; - result = ((int) (unsignedDividend / unsignedDivisor)); - } - return result; - } - - /** - * [FUNCTION] IntegerAutomaton::hashCode(int) -> int - * Source: java/lang/Integer.main.lsl:202 - */ - public static int hashCode(int value) { - int result = 0; - /* body */ { - result = value; - } - return result; - } - - /** - * [FUNCTION] IntegerAutomaton::highestOneBit(int) -> int - * Source: java/lang/Integer.main.lsl:208 - */ - public static int highestOneBit(int i) { - int result = 0; - /* body */ { - i |= i >> 1; - i |= i >> 2; - i |= i >> 4; - i |= i >> 8; - i |= i >> 16; - result = i - (i >>> 1); - } - return result; - } - - /** - * [FUNCTION] IntegerAutomaton::lowestOneBit(int) -> int - * Source: java/lang/Integer.main.lsl:220 - */ - public static int lowestOneBit(int i) { - int result = 0; - /* body */ { - result = i & -i; - } - return result; - } - - /** - * [FUNCTION] IntegerAutomaton::max(int, int) -> int - * Source: java/lang/Integer.main.lsl:227 - */ - public static int max(int a, int b) { - int result = 0; - /* body */ { - if (a > b) { - result = a; - } else { - result = b; - } - } - return result; - } - - /** - * [FUNCTION] IntegerAutomaton::min(int, int) -> int - * Source: java/lang/Integer.main.lsl:236 - */ - public static int min(int a, int b) { - int result = 0; - /* body */ { - if (a < b) { - result = a; - } else { - result = b; - } - } - return result; - } - - /** - * [FUNCTION] IntegerAutomaton::numberOfLeadingZeros(int) -> int - * Source: java/lang/Integer.main.lsl:245 - */ - public static int numberOfLeadingZeros(int i) { - int result = 0; - /* body */ { - if (i == 0) { - result = 32; - } else { - result = 1; - if ((i >>> 16) == 0) { - result += 16; - i <<= 16; - } - if ((i >>> 24) == 0) { - result += 8; - i <<= 8; - } - if ((i >>> 28) == 0) { - result += 4; - i <<= 4; - } - if ((i >>> 30) == 0) { - result += 2; - i <<= 2; - } - result -= i >>> 31; - } - } - return result; - } - - /** - * [FUNCTION] IntegerAutomaton::numberOfTrailingZeros(int) -> int - * Source: java/lang/Integer.main.lsl:266 - */ - public static int numberOfTrailingZeros(int i) { - int result = 0; - /* body */ { - if (i == 0) { - result = 32; - } else { - int y = 0; - result = 31; - y = i << 16; - if (y != 0) { - result -= 16; - i = y; - } - y = i << 8; - if (y != 0) { - result -= 8; - i = y; - } - y = i << 4; - if (y != 0) { - result -= 4; - i = y; - } - y = i << 2; - if (y != 0) { - result -= 2; - i = y; - } - result -= (i << 1) >>> 31; - } - } - return result; - } - - /** - * [FUNCTION] IntegerAutomaton::remainderUnsigned(int, int) -> int - * Source: java/lang/Integer.main.lsl:330 - */ - public static int remainderUnsigned(int dividend, int divisor) { - int result = 0; - /* body */ { - final long unsignedDividend = ((long) dividend) & 4294967295L; - final long unsignedDivisor = ((long) divisor) & 4294967295L; - result = ((int) (unsignedDividend % unsignedDivisor)); - } - return result; - } - - /** - * [FUNCTION] IntegerAutomaton::reverse(int) -> int - * Source: java/lang/Integer.main.lsl:338 - */ - public static int reverse(int i) { - int result = 0; - /* body */ { - i = (((i & 1431655765) << 1) | (i >>> 1)) & 1431655765; - i = (((i & 858993459) << 2) | (i >>> 2)) & 858993459; - i = (((i & 252645135) << 4) | (i >>> 4)) & 252645135; - i = (i << 24) | ((i & 65280) << 8) | ((i >>> 8) & 65280) | (i >>> 24); - result = i; - } - return result; - } - - /** - * [FUNCTION] IntegerAutomaton::reverseBytes(int) -> int - * Source: java/lang/Integer.main.lsl:351 - */ - public static int reverseBytes(int i) { - int result = 0; - /* body */ { - result = (i >>> 24) | ((i >> 8) & 65280) | ((i << 8) & 16711680) | (i << 24); - } - return result; - } - - /** - * [FUNCTION] IntegerAutomaton::rotateLeft(int, int) -> int - * Source: java/lang/Integer.main.lsl:361 - */ - public static int rotateLeft(int i, int distance) { - int result = 0; - /* body */ { - result = (i << distance) | (i >>> -distance); - } - return result; - } - - /** - * [FUNCTION] IntegerAutomaton::rotateRight(int, int) -> int - * Source: java/lang/Integer.main.lsl:368 - */ - public static int rotateRight(int i, int distance) { - int result = 0; - /* body */ { - result = (i >>> distance) | (i << -distance); - } - return result; - } - - /** - * [FUNCTION] IntegerAutomaton::signum(int) -> int - * Source: java/lang/Integer.main.lsl:375 - */ - public static int signum(int i) { - int result = 0; - /* body */ { - result = (i >> 31) | (-i >>> 31); - } - return result; - } - - /** - * [FUNCTION] IntegerAutomaton::sum(int, int) -> int - * Source: java/lang/Integer.main.lsl:382 - */ - public static int sum(int a, int b) { - int result = 0; - /* body */ { - result = a + b; - } - return result; - } - - /** - * [FUNCTION] IntegerAutomaton::toString(int) -> String - * Source: java/lang/Integer.main.lsl:406 - */ - public static String toString(int i) { - String result = null; - /* body */ { - result = LibSLRuntime.toString(i); - } - return result; - } - - /** - * [FUNCTION] IntegerAutomaton::toUnsignedLong(int) -> long - * Source: java/lang/Integer.main.lsl:418 - */ - public static long toUnsignedLong(int x) { - long result = 0L; - /* body */ { - result = ((long) x) & 4294967295L; - } - return result; - } - - /** - * [FUNCTION] IntegerAutomaton::valueOf(int) -> Integer - * Source: java/lang/Integer.main.lsl:451 - */ - public static java.lang.Integer valueOf(int i) { - java.lang.Integer result = null; - /* body */ { - result = (java.lang.Integer) ((Object) new Integer((Void) null, - /* state = */ Integer.__$lsl_States.Initialized, - /* value = */ i - )); - } - return result; - } - - /** - * [FUNCTION] IntegerAutomaton::byteValue(LSLInteger) -> byte - * Source: java/lang/Integer.main.lsl:461 - */ - public byte byteValue() { - byte result = ((byte) 0); - /* body */ { - result = ((byte) this.value); - } - return result; - } - - /** - * [FUNCTION] IntegerAutomaton::compareTo(LSLInteger, LSLInteger) -> int - * Source: java/lang/Integer.main.lsl:467 - */ - public int compareTo(Integer anotherInteger) { - int result = 0; - /* body */ { - final int x = this.value; - final int y = ((Integer) ((Object) anotherInteger)).value; - if (x == y) { - result = 0; - } else { - if (x < y) { - result = -1; - } else { - result = 1; - } - } - } - return result; - } - - /** - * [FUNCTION] IntegerAutomaton::doubleValue(LSLInteger) -> double - * Source: java/lang/Integer.main.lsl:486 - */ - public double doubleValue() { - double result = 0.0d; - /* body */ { - result = ((double) this.value); - } - return result; - } - - /** - * [FUNCTION] IntegerAutomaton::equals(LSLInteger, Object) -> boolean - * Source: java/lang/Integer.main.lsl:492 - */ - public boolean equals(Object obj) { - boolean result = false; - /* body */ { - if ((obj instanceof java.lang.Integer)) { - result = this.value == ((Integer) ((Object) obj)).value; - } else { - result = false; - } - } - return result; - } - - /** - * [FUNCTION] IntegerAutomaton::floatValue(LSLInteger) -> float - * Source: java/lang/Integer.main.lsl:501 - */ - public float floatValue() { - float result = 0.0f; - /* body */ { - result = ((float) this.value); - } - return result; - } - - /** - * [FUNCTION] IntegerAutomaton::hashCode(LSLInteger) -> int - * Source: java/lang/Integer.main.lsl:507 - */ - public int hashCode() { - int result = 0; - /* body */ { - result = this.value; - } - return result; - } - - /** - * [FUNCTION] IntegerAutomaton::intValue(LSLInteger) -> int - * Source: java/lang/Integer.main.lsl:513 - */ - public int intValue() { - int result = 0; - /* body */ { - result = this.value; - } - return result; - } - - /** - * [FUNCTION] IntegerAutomaton::longValue(LSLInteger) -> long - * Source: java/lang/Integer.main.lsl:519 - */ - public long longValue() { - long result = 0L; - /* body */ { - result = ((long) this.value); - } - return result; - } - - /** - * [FUNCTION] IntegerAutomaton::shortValue(LSLInteger) -> short - * Source: java/lang/Integer.main.lsl:525 - */ - public short shortValue() { - short result = ((short) 0); - /* body */ { - result = ((short) this.value); - } - return result; - } - - /** - * [FUNCTION] IntegerAutomaton::toString(LSLInteger) -> String - * Source: java/lang/Integer.main.lsl:531 - */ - public String toString() { - String result = null; - /* body */ { - result = LibSLRuntime.toString(this.value); - } - return result; - } - - public static final class __$lsl_States { - public static final byte Initialized = (byte) 0; - } - - @Approximate(Integer.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/lang/IntegerImpl.java b/approximations/src/main/java/generated/java/lang/IntegerImpl.java new file mode 100644 index 00000000..168d659a --- /dev/null +++ b/approximations/src/main/java/generated/java/lang/IntegerImpl.java @@ -0,0 +1,266 @@ +package generated.java.lang; + +import java.io.Serial; +import java.io.Serializable; +import java.lang.Comparable; +import java.lang.NullPointerException; +import java.lang.Object; +import java.lang.String; + +import org.jacodb.approximation.annotation.Approximate; +import org.usvm.api.Engine; +import runtime.LibSLRuntime; + +@SuppressWarnings("unused") +@Approximate(java.lang.Integer.class) +public final class IntegerImpl implements Comparable, Serializable { + + @Serial + private static final long serialVersionUID = 1360826667806852920L; + + public static final int MIN_VALUE = -2147483648; + + public static final int MAX_VALUE = 2147483647; + + public static final int SIZE = 32; + + public static final int BYTES = 4; + + public static final char[] digits = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' }; + + public static final char[] DigitTens = { '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '3', '3', '3', '3', '3', '3', '3', '3', '3', '3', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '5', '5', '5', '5', '5', '5', '5', '5', '5', '5', '6', '6', '6', '6', '6', '6', '6', '6', '6', '6', '7', '7', '7', '7', '7', '7', '7', '7', '7', '7', '8', '8', '8', '8', '8', '8', '8', '8', '8', '8', '9', '9', '9', '9', '9', '9', '9', '9', '9', '9' }; + + public static final char[] DigitOnes = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' }; + + public static final int[] sizeTable = { 9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999, 2147483647 }; + + static { + Engine.assume(true); + } + + private final int value; + + public IntegerImpl(int value) { + this.value = value; + } + + private static int _parse(String str) throws java.lang.NumberFormatException { + if (str == null) + throw new NullPointerException(); + LibSLRuntime.todo(); + return 0; + } + + public static int bitCount(int i) { + i = i - ((i >>> 1) & 1431655765); + i = (i & 858993459) + ((i >>> 2) & 858993459); + i = (i + (i >>> 4)) & 252645135; + i = i + (i >>> 8); + i = i + (i >>> 16); + return i & 63; + } + + @SuppressWarnings("UseCompareMethod") + public static int compare(int x, int y) { + if (x == y) + return 0; + + if (x < y) + return -1; + + return 1; + } + + public static int compareUnsigned(int x, int y) { + x += MIN_VALUE; + y += MIN_VALUE; + return compare(x, y); + } + + public static int divideUnsigned(int dividend, int divisor) { + long unsignedDividend = ((long) dividend) & 4294967295L; + long unsignedDivisor = ((long) divisor) & 4294967295L; + return (int) (unsignedDividend / unsignedDivisor); + } + + public static int hashCode(int value) { + return value; + } + + public static int highestOneBit(int i) { + i |= i >> 1; + i |= i >> 2; + i |= i >> 4; + i |= i >> 8; + i |= i >> 16; + return i - (i >>> 1); + } + + public static int lowestOneBit(int i) { + return i & -i; + } + + @SuppressWarnings("ManualMinMaxCalculation") + public static int max(int a, int b) { + if (a > b) + return a; + + return b; + } + + @SuppressWarnings("ManualMinMaxCalculation") + public static int min(int a, int b) { + if (a < b) + return a; + + return b; + } + + public static int numberOfLeadingZeros(int i) { + if (i == 0) + return 32; + + int result = 1; + if ((i >>> 16) == 0) { + result += 16; + i <<= 16; + } + if ((i >>> 24) == 0) { + result += 8; + i <<= 8; + } + if ((i >>> 28) == 0) { + result += 4; + i <<= 4; + } + if ((i >>> 30) == 0) { + result += 2; + i <<= 2; + } + result -= i >>> 31; + + return result; + } + + public static int numberOfTrailingZeros(int i) { + if (i == 0) + return 32; + + int y; + int result = 31; + y = i << 16; + if (y != 0) { + result -= 16; + i = y; + } + y = i << 8; + if (y != 0) { + result -= 8; + i = y; + } + y = i << 4; + if (y != 0) { + result -= 4; + i = y; + } + y = i << 2; + if (y != 0) { + result -= 2; + i = y; + } + result -= (i << 1) >>> 31; + + return result; + } + + public static int remainderUnsigned(int dividend, int divisor) { + long unsignedDividend = ((long) dividend) & 4294967295L; + long unsignedDivisor = ((long) divisor) & 4294967295L; + return (int) (unsignedDividend % unsignedDivisor); + } + + public static int reverse(int i) { + i = (((i & 1431655765) << 1) | (i >>> 1)) & 1431655765; + i = (((i & 858993459) << 2) | (i >>> 2)) & 858993459; + i = (((i & 252645135) << 4) | (i >>> 4)) & 252645135; + i = (i << 24) | ((i & 65280) << 8) | ((i >>> 8) & 65280) | (i >>> 24); + return i; + } + + public static int reverseBytes(int i) { + return (i >>> 24) | ((i >> 8) & 65280) | ((i << 8) & 16711680) | (i << 24); + } + + public static int rotateLeft(int i, int distance) { + return (i << distance) | (i >>> -distance); + } + + public static int rotateRight(int i, int distance) { + return (i >>> distance) | (i << -distance); + } + + public static int signum(int i) { + return (i >> 31) | (-i >>> 31); + } + + public static int sum(int a, int b) { + return a + b; + } + + public static String toString(int i) { + return LibSLRuntime.toString(i); + } + + public static long toUnsignedLong(int x) { + return ((long) x) & 4294967295L; + } + + // TODO: intern values from -128 to 128 + public static IntegerImpl valueOf(int i) { + return new IntegerImpl(i); + } + + public byte byteValue() { + return (byte) this.value; + } + + public int compareTo(IntegerImpl anotherInteger) { + return compare(this.value, anotherInteger.value); + } + + public double doubleValue() { + return this.value; + } + + @SuppressWarnings("EqualsWhichDoesntCheckParameterClass") + public boolean equals(Object obj) { + if (Engine.typeIs(obj, IntegerImpl.class)) + return this.value == ((IntegerImpl) obj).value; + + return false; + } + + public float floatValue() { + return (float) this.value; + } + + public int hashCode() { + return this.value; + } + + public int intValue() { + return this.value; + } + + public long longValue() { + return this.value; + } + + public short shortValue() { + return (short) this.value; + } + + public String toString() { + return LibSLRuntime.toString(this.value); + } +} diff --git a/approximations/src/main/java/generated/java/lang/Object.java b/approximations/src/main/java/generated/java/lang/Object.java deleted file mode 100644 index 361f86d7..00000000 --- a/approximations/src/main/java/generated/java/lang/Object.java +++ /dev/null @@ -1,82 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/lang/Object.lsl:30 -// - java/lang/Object.main.lsl:19 -// -package generated.java.lang; - -import java.lang.String; -import java.lang.SuppressWarnings; -import java.lang.Void; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; - -/** - * ObjectAutomaton for LSLObject ~> java.lang.Object - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(java.lang.Object.class) -public class Object implements LibSLRuntime.Automaton { - static { - /* ObjectAutomaton::() */ { - Engine.assume(true); - } - } - - @LibSLRuntime.AutomatonConstructor - public Object(Void __$lsl_token, final byte p0) { - } - - @LibSLRuntime.AutomatonConstructor - public Object(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Initialized); - } - - /** - * [FUNCTION] ObjectAutomaton::equals(LSLObject, Object) -> boolean - * Source: java/lang/Object.main.lsl:61 - */ - public boolean equals(java.lang.Object obj) { - boolean result = false; - /* body */ { - result = this == obj; - } - return result; - } - - /** - * [FUNCTION] ObjectAutomaton::hashCode(LSLObject) -> int - * Source: java/lang/Object.main.lsl:87 - */ - public int hashCode() { - int result = 0; - /* body */ { - result = Engine.makeSymbolicInt(); - } - return result; - } - - /** - * [FUNCTION] ObjectAutomaton::toString(LSLObject) -> String - * Source: java/lang/Object.main.lsl:105 - */ - public String toString() { - String result = null; - /* body */ { - result = "java.lang.Object@735b5592"; - } - return result; - } - - public static final class __$lsl_States { - public static final byte Initialized = (byte) 0; - } - - @Approximate(Object.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/lang/ObjectImpl.java b/approximations/src/main/java/generated/java/lang/ObjectImpl.java new file mode 100644 index 00000000..5c9c5fb6 --- /dev/null +++ b/approximations/src/main/java/generated/java/lang/ObjectImpl.java @@ -0,0 +1,30 @@ +package generated.java.lang; + +import java.lang.String; + +import org.jacodb.approximation.annotation.Approximate; +import org.usvm.api.Engine; + +@SuppressWarnings("unused") +@Approximate(java.lang.Object.class) +public class ObjectImpl { + + static { + Engine.assume(true); + } + + // Do not delete this constructor! + public ObjectImpl(Void dummy) {} + + public boolean equals(ObjectImpl obj) { + return this == obj; + } + + public int hashCode() { + return Engine.makeSymbolicInt(); + } + + public String toString() { + return "java.lang.Object@735b5592"; + } +} diff --git a/approximations/src/main/java/generated/java/lang/SecurityManager.java b/approximations/src/main/java/generated/java/lang/SecurityManager.java deleted file mode 100644 index e07f0cc7..00000000 --- a/approximations/src/main/java/generated/java/lang/SecurityManager.java +++ /dev/null @@ -1,457 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/lang/SecurityManager.lsl:31 -// - java/lang/SecurityManager.main.lsl:24 -// -package generated.java.lang; - -import java.io.FileDescriptor; -import java.lang.IllegalArgumentException; -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.SecurityException; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.lang.Thread; -import java.lang.ThreadGroup; -import java.lang.Void; -import java.net.InetAddress; -import java.security.AccessControlContext; -import java.security.AccessControlException; -import java.security.Permission; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; - -/** - * SecurityManagerAutomaton for LSLSecurityManager ~> java.lang.SecurityManager - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(java.lang.SecurityManager.class) -public class SecurityManager implements LibSLRuntime.Automaton { - static { - Engine.assume(true); - } - - private byte __$lsl_state = __$lsl_States.Allocated; - - @LibSLRuntime.AutomatonConstructor - public SecurityManager(Void __$lsl_token, final byte p0) { - this.__$lsl_state = p0; - } - - @LibSLRuntime.AutomatonConstructor - public SecurityManager(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Allocated); - } - - /** - * [CONSTRUCTOR] SecurityManagerAutomaton::(LSLSecurityManager) -> void - * Source: java/lang/SecurityManager.main.lsl:100 - */ - public SecurityManager() { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - _do_checkPermission(new RuntimePermission("createSecurityManager")); - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [SUBROUTINE] SecurityManagerAutomaton::_do_checkPermission(Permission) -> void - * Source: java/lang/SecurityManager.main.lsl:88 - */ - private void _do_checkPermission(Permission perm) { - /* body */ { - if (Engine.makeSymbolicBoolean()) { - throw new AccessControlException("access denied ", perm); - } - } - } - - /** - * [FUNCTION] SecurityManagerAutomaton::checkAccept(LSLSecurityManager, String, int) -> void - * Source: java/lang/SecurityManager.main.lsl:112 - */ - public void checkAccept(String host, int port) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (host == null) { - throw new NullPointerException(); - } - if (Engine.makeSymbolicBoolean()) { - throw new IllegalArgumentException(); - } - _do_checkPermission(null); - } - } - - /** - * [FUNCTION] SecurityManagerAutomaton::checkAccess(LSLSecurityManager, Thread) -> void - * Source: java/lang/SecurityManager.main.lsl:127 - */ - public void checkAccess(Thread t) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (t == null) { - throw new NullPointerException("thread can\'t be null"); - } - _do_checkPermission(null); - } - } - - /** - * [FUNCTION] SecurityManagerAutomaton::checkAccess(LSLSecurityManager, ThreadGroup) -> void - * Source: java/lang/SecurityManager.main.lsl:140 - */ - public void checkAccess(ThreadGroup g) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (g == null) { - throw new NullPointerException("thread group can\'t be null"); - } - _do_checkPermission(null); - } - } - - /** - * [FUNCTION] SecurityManagerAutomaton::checkConnect(LSLSecurityManager, String, int) -> void - * Source: java/lang/SecurityManager.main.lsl:153 - */ - public void checkConnect(String host, int port) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (host == null) { - throw new NullPointerException("host can\'t be null"); - } - if (Engine.makeSymbolicBoolean()) { - throw new IllegalArgumentException(); - } - _do_checkPermission(null); - } - } - - /** - * [FUNCTION] SecurityManagerAutomaton::checkConnect(LSLSecurityManager, String, int, Object) -> void - * Source: java/lang/SecurityManager.main.lsl:168 - */ - public void checkConnect(String host, int port, Object context) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (host == null) { - throw new NullPointerException("host can\'t be null"); - } - if (Engine.makeSymbolicBoolean()) { - throw new IllegalArgumentException(); - } - _do_checkPermission(null); - } - } - - /** - * [FUNCTION] SecurityManagerAutomaton::checkCreateClassLoader(LSLSecurityManager) -> void - * Source: java/lang/SecurityManager.main.lsl:183 - */ - public void checkCreateClassLoader() { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - _do_checkPermission(null); - } - } - - /** - * [FUNCTION] SecurityManagerAutomaton::checkDelete(LSLSecurityManager, String) -> void - * Source: java/lang/SecurityManager.main.lsl:191 - */ - public void checkDelete(String file) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (file == null) { - throw new NullPointerException(); - } - _do_checkPermission(null); - } - } - - /** - * [FUNCTION] SecurityManagerAutomaton::checkExec(LSLSecurityManager, String) -> void - * Source: java/lang/SecurityManager.main.lsl:204 - */ - public void checkExec(String cmd) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (cmd == null) { - throw new NullPointerException(); - } - _do_checkPermission(null); - } - } - - /** - * [FUNCTION] SecurityManagerAutomaton::checkExit(LSLSecurityManager, int) -> void - * Source: java/lang/SecurityManager.main.lsl:217 - */ - public void checkExit(int status) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - _do_checkPermission(null); - } - } - - /** - * [FUNCTION] SecurityManagerAutomaton::checkLink(LSLSecurityManager, String) -> void - * Source: java/lang/SecurityManager.main.lsl:225 - */ - public void checkLink(String lib) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (lib == null) { - throw new NullPointerException(); - } - _do_checkPermission(null); - } - } - - /** - * [FUNCTION] SecurityManagerAutomaton::checkListen(LSLSecurityManager, int) -> void - * Source: java/lang/SecurityManager.main.lsl:236 - */ - public void checkListen(int port) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - _do_checkPermission(null); - } - } - - /** - * [FUNCTION] SecurityManagerAutomaton::checkMulticast(LSLSecurityManager, InetAddress) -> void - * Source: java/lang/SecurityManager.main.lsl:244 - */ - public void checkMulticast(InetAddress maddr) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (maddr == null) { - throw new NullPointerException(); - } - _do_checkPermission(null); - } - } - - /** - * [FUNCTION] SecurityManagerAutomaton::checkMulticast(LSLSecurityManager, InetAddress, byte) -> void - * Source: java/lang/SecurityManager.main.lsl:255 - */ - public void checkMulticast(InetAddress maddr, byte ttl) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (maddr == null) { - throw new NullPointerException(); - } - _do_checkPermission(null); - } - } - - /** - * [FUNCTION] SecurityManagerAutomaton::checkPackageAccess(LSLSecurityManager, String) -> void - * Source: java/lang/SecurityManager.main.lsl:266 - */ - public void checkPackageAccess(String pkg) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (pkg == null) { - throw new NullPointerException(); - } - _do_checkPermission(null); - } - } - - /** - * [FUNCTION] SecurityManagerAutomaton::checkPackageDefinition(LSLSecurityManager, String) -> void - * Source: java/lang/SecurityManager.main.lsl:277 - */ - public void checkPackageDefinition(String pkg) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (pkg == null) { - throw new NullPointerException(); - } - _do_checkPermission(null); - } - } - - /** - * [FUNCTION] SecurityManagerAutomaton::checkPermission(LSLSecurityManager, Permission) -> void - * Source: java/lang/SecurityManager.main.lsl:288 - */ - public void checkPermission(Permission perm) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (perm == null) { - throw new NullPointerException(); - } - _do_checkPermission(perm); - } - } - - /** - * [FUNCTION] SecurityManagerAutomaton::checkPermission(LSLSecurityManager, Permission, Object) -> void - * Source: java/lang/SecurityManager.main.lsl:297 - */ - public void checkPermission(Permission perm, Object context) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if ((context instanceof AccessControlContext)) { - if (perm == null) { - throw new NullPointerException(); - } - _do_checkPermission(perm); - } else { - throw new SecurityException(); - } - } - } - - /** - * [FUNCTION] SecurityManagerAutomaton::checkPrintJobAccess(LSLSecurityManager) -> void - * Source: java/lang/SecurityManager.main.lsl:313 - */ - public void checkPrintJobAccess() { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - _do_checkPermission(null); - } - } - - /** - * [FUNCTION] SecurityManagerAutomaton::checkPropertiesAccess(LSLSecurityManager) -> void - * Source: java/lang/SecurityManager.main.lsl:321 - */ - public void checkPropertiesAccess() { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - _do_checkPermission(null); - } - } - - /** - * [FUNCTION] SecurityManagerAutomaton::checkPropertyAccess(LSLSecurityManager, String) -> void - * Source: java/lang/SecurityManager.main.lsl:329 - */ - public void checkPropertyAccess(String key) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - _do_checkPermission(null); - } - } - - /** - * [FUNCTION] SecurityManagerAutomaton::checkRead(LSLSecurityManager, FileDescriptor) -> void - * Source: java/lang/SecurityManager.main.lsl:337 - */ - public void checkRead(FileDescriptor fd) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - _do_checkPermission(null); - } - } - - /** - * [FUNCTION] SecurityManagerAutomaton::checkRead(LSLSecurityManager, String) -> void - * Source: java/lang/SecurityManager.main.lsl:345 - */ - public void checkRead(String file) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - _do_checkPermission(null); - } - } - - /** - * [FUNCTION] SecurityManagerAutomaton::checkRead(LSLSecurityManager, String, Object) -> void - * Source: java/lang/SecurityManager.main.lsl:353 - */ - public void checkRead(String file, Object context) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - _do_checkPermission(null); - } - } - - /** - * [FUNCTION] SecurityManagerAutomaton::checkSecurityAccess(LSLSecurityManager, String) -> void - * Source: java/lang/SecurityManager.main.lsl:361 - */ - public void checkSecurityAccess(String _target) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (_target == null) { - throw new NullPointerException(); - } - if (_target.isEmpty()) { - throw new IllegalArgumentException(); - } - _do_checkPermission(null); - } - } - - /** - * [FUNCTION] SecurityManagerAutomaton::checkSetFactory(LSLSecurityManager) -> void - * Source: java/lang/SecurityManager.main.lsl:375 - */ - public void checkSetFactory() { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - _do_checkPermission(null); - } - } - - /** - * [FUNCTION] SecurityManagerAutomaton::checkWrite(LSLSecurityManager, FileDescriptor) -> void - * Source: java/lang/SecurityManager.main.lsl:383 - */ - public void checkWrite(FileDescriptor fd) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - _do_checkPermission(null); - } - } - - /** - * [FUNCTION] SecurityManagerAutomaton::checkWrite(LSLSecurityManager, String) -> void - * Source: java/lang/SecurityManager.main.lsl:391 - */ - public void checkWrite(String file) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - _do_checkPermission(null); - } - } - - /** - * [FUNCTION] SecurityManagerAutomaton::getSecurityContext(LSLSecurityManager) -> Object - * Source: java/lang/SecurityManager.main.lsl:399 - */ - public Object getSecurityContext() { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = Engine.makeSymbolic(AccessControlContext.class); - Engine.assume(result != null); - } - return result; - } - - public static final class __$lsl_States { - public static final byte Allocated = (byte) 0; - - public static final byte Initialized = (byte) 1; - } - - @Approximate(SecurityManager.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/lang/SecurityManagerImpl.java b/approximations/src/main/java/generated/java/lang/SecurityManagerImpl.java new file mode 100644 index 00000000..8b1620df --- /dev/null +++ b/approximations/src/main/java/generated/java/lang/SecurityManagerImpl.java @@ -0,0 +1,194 @@ +package generated.java.lang; + +import java.io.FileDescriptor; +import java.lang.IllegalArgumentException; +import java.lang.NullPointerException; +import java.lang.Object; +import java.lang.SecurityException; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.lang.Thread; +import java.lang.ThreadGroup; +import java.net.InetAddress; +import java.security.Permission; +import org.jacodb.approximation.annotation.Approximate; +import org.usvm.api.Engine; + +@SuppressWarnings({"removal", "unused"}) +@Approximate(java.lang.SecurityManager.class) +public class SecurityManagerImpl { + + static { + Engine.assume(true); + } + + public SecurityManagerImpl() { + _do_checkPermission(new RuntimePermission("createSecurityManager")); + } + + private void _do_checkPermission(Permission perm) { + if (Engine.makeSymbolicBoolean()) + throw new java.security.AccessControlException("access denied ", perm); + } + + private void _do_checkPermission() { + _do_checkPermission(null); + } + + public void checkAccept(String host, int port) { + if (host == null) + throw new NullPointerException(); + if (Engine.makeSymbolicBoolean()) + throw new IllegalArgumentException(); + _do_checkPermission(); + } + + public void checkAccess(Thread t) { + if (t == null) + throw new NullPointerException("thread can't be null"); + _do_checkPermission(); + } + + public void checkAccess(ThreadGroup g) { + if (g == null) + throw new NullPointerException("thread group can't be null"); + _do_checkPermission(); + } + + public void checkConnect(String host, int port) { + if (host == null) + throw new NullPointerException("host can't be null"); + if (Engine.makeSymbolicBoolean()) + throw new IllegalArgumentException(); + _do_checkPermission(); + } + + public void checkConnect(String host, int port, Object context) { + if (host == null) + throw new NullPointerException("host can't be null"); + if (Engine.makeSymbolicBoolean()) + throw new IllegalArgumentException(); + _do_checkPermission(); + } + + public void checkCreateClassLoader() { + _do_checkPermission(); + } + + public void checkDelete(String file) { + if (file == null) + throw new NullPointerException(); + _do_checkPermission(); + } + + public void checkExec(String cmd) { + if (cmd == null) + throw new NullPointerException(); + _do_checkPermission(); + } + + public void checkExit(int status) { + _do_checkPermission(); + } + + public void checkLink(String lib) { + if (lib == null) + throw new NullPointerException(); + _do_checkPermission(); + } + + public void checkListen(int port) { + _do_checkPermission(); + } + + public void checkMulticast(InetAddress maddr) { + if (maddr == null) + throw new NullPointerException(); + _do_checkPermission(); + } + + public void checkMulticast(InetAddress maddr, byte ttl) { + if (maddr == null) + throw new NullPointerException(); + _do_checkPermission(); + } + + public void checkPackageAccess(String pkg) { + if (pkg == null) + throw new NullPointerException(); + _do_checkPermission(); + } + + public void checkPackageDefinition(String pkg) { + if (pkg == null) + throw new NullPointerException(); + _do_checkPermission(); + } + + public void checkPermission(Permission perm) { + if (perm == null) + throw new NullPointerException(); + _do_checkPermission(perm); + } + + public void checkPermission(Permission perm, Object context) { + if (context instanceof java.security.AccessControlContext) { + if (perm == null) + throw new NullPointerException(); + _do_checkPermission(perm); + } else { + throw new SecurityException(); + } + } + + public void checkPrintJobAccess() { + _do_checkPermission(); + } + + public void checkPropertiesAccess() { + _do_checkPermission(); + } + + public void checkPropertyAccess(String key) { + _do_checkPermission(); + } + + public void checkRead(FileDescriptor fd) { + _do_checkPermission(); + } + + public void checkRead(String file) { + _do_checkPermission(); + } + + public void checkRead(String file, Object context) { + _do_checkPermission(); + } + + public void checkSecurityAccess(String _target) { + if (_target == null) + throw new NullPointerException(); + if (_target.isEmpty()) + throw new IllegalArgumentException(); + _do_checkPermission(); + } + + public void checkSetFactory() { + _do_checkPermission(); + } + + public void checkWrite(FileDescriptor fd) { + _do_checkPermission(); + } + + public void checkWrite(String file) { + _do_checkPermission(); + } + + @SuppressWarnings("ConstantValue") + public Object getSecurityContext() { + Object result = Engine.makeSymbolic(java.security.AccessControlContext.class); + Engine.assume(result != null); + return result; + } +} diff --git a/approximations/src/main/java/generated/java/lang/String.java b/approximations/src/main/java/generated/java/lang/String.java deleted file mode 100644 index 11a02398..00000000 --- a/approximations/src/main/java/generated/java/lang/String.java +++ /dev/null @@ -1,313 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/lang/String.lsl:144 -// - java/lang/String.patch.lsl:18 -// -package generated.java.lang; - -import java.io.Serializable; -import java.lang.Object; -import java.lang.StringIndexOutOfBoundsException; -import java.lang.SuppressWarnings; -import java.lang.Void; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; - -/** - * StringAutomaton for LSLString ~> java.lang.String - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(java.lang.String.class) -public class String implements LibSLRuntime.Automaton, Serializable { - public byte[] value; - - public int length; - - @LibSLRuntime.AutomatonConstructor - public String(Void __$lsl_token, final byte p0, final byte[] p1, final int p2) { - this.value = p1; - this.length = p2; - } - - @LibSLRuntime.AutomatonConstructor - public String(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Initialized, null, 0); - } - - /** - * [CONSTRUCTOR] StringAutomaton::(LSLString) -> void - * Source: java/lang/String.patch.lsl:71 - */ - public String() { - this((Void) null); - /* body */ { - this.value = new byte[0]; - this.length = 0; - } - } - - /** - * [CONSTRUCTOR] StringAutomaton::(LSLString, String) -> void - * Source: java/lang/String.patch.lsl:78 - */ - public String(java.lang.String original) { - this((Void) null); - /* body */ { - this.value = ((String) ((Object) original)).value; - this.length = this.value.length; - } - } - - /** - * [CONSTRUCTOR] StringAutomaton::(LSLString, array) -> void - * Source: java/lang/String.patch.lsl:85 - */ - public String(byte[] bytes) { - this((Void) null); - /* body */ { - final int len = bytes.length; - this.length = len; - this.value = new byte[len]; - LibSLRuntime.ArrayActions.copy(bytes, 0, this.value, 0, len); - } - } - - /** - * [FUNCTION] StringAutomaton::copyValueOf(array) -> String - * Source: java/lang/String.patch.lsl:97 - */ - public static java.lang.String copyValueOf(char[] data) { - java.lang.String result = null; - /* body */ { - result = LibSLRuntime.toString(data); - } - return result; - } - - /** - * [FUNCTION] StringAutomaton::copyValueOf(array, int, int) -> String - * Source: java/lang/String.patch.lsl:103 - */ - public static java.lang.String copyValueOf(char[] data, int offset, int count) { - java.lang.String result = null; - /* body */ { - final char[] segment = new char[count]; - LibSLRuntime.ArrayActions.copy(data, offset, segment, 0, count); - result = LibSLRuntime.toString(segment); - } - return result; - } - - /** - * [FUNCTION] StringAutomaton::valueOf(Object) -> String - * Source: java/lang/String.patch.lsl:112 - */ - public static java.lang.String valueOf(Object x) { - java.lang.String result = null; - /* body */ { - result = LibSLRuntime.toString(x); - } - return result; - } - - /** - * [FUNCTION] StringAutomaton::valueOf(boolean) -> String - * Source: java/lang/String.patch.lsl:118 - */ - public static java.lang.String valueOf(boolean x) { - java.lang.String result = null; - /* body */ { - result = LibSLRuntime.toString(x); - } - return result; - } - - /** - * [FUNCTION] StringAutomaton::valueOf(char) -> String - * Source: java/lang/String.patch.lsl:124 - */ - public static java.lang.String valueOf(char x) { - java.lang.String result = null; - /* body */ { - result = LibSLRuntime.toString(x); - } - return result; - } - - /** - * [FUNCTION] StringAutomaton::valueOf(array) -> String - * Source: java/lang/String.patch.lsl:130 - */ - public static java.lang.String valueOf(char[] data) { - java.lang.String result = null; - /* body */ { - result = LibSLRuntime.toString(data); - } - return result; - } - - /** - * [FUNCTION] StringAutomaton::valueOf(array, int, int) -> String - * Source: java/lang/String.patch.lsl:136 - */ - public static java.lang.String valueOf(char[] data, int offset, int count) { - java.lang.String result = null; - /* body */ { - final char[] segment = new char[count]; - LibSLRuntime.ArrayActions.copy(data, offset, segment, 0, count); - result = LibSLRuntime.toString(segment); - } - return result; - } - - /** - * [FUNCTION] StringAutomaton::valueOf(double) -> String - * Source: java/lang/String.patch.lsl:145 - */ - public static java.lang.String valueOf(double x) { - java.lang.String result = null; - /* body */ { - result = LibSLRuntime.toString(x); - } - return result; - } - - /** - * [FUNCTION] StringAutomaton::valueOf(float) -> String - * Source: java/lang/String.patch.lsl:151 - */ - public static java.lang.String valueOf(float x) { - java.lang.String result = null; - /* body */ { - result = LibSLRuntime.toString(x); - } - return result; - } - - /** - * [FUNCTION] StringAutomaton::valueOf(int) -> String - * Source: java/lang/String.patch.lsl:157 - */ - public static java.lang.String valueOf(int x) { - java.lang.String result = null; - /* body */ { - result = LibSLRuntime.toString(x); - } - return result; - } - - /** - * [FUNCTION] StringAutomaton::valueOf(long) -> String - * Source: java/lang/String.patch.lsl:163 - */ - public static java.lang.String valueOf(long x) { - java.lang.String result = null; - /* body */ { - result = LibSLRuntime.toString(x); - } - return result; - } - - /** - * [FUNCTION] StringAutomaton::concat(LSLString, String) -> String - * Source: java/lang/String.patch.lsl:171 - */ - public java.lang.String concat(java.lang.String str) { - java.lang.String result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= 50); - Engine.assume(this.length == this.value.length); - final byte[] otherVal = ((String) ((Object) str)).value; - final int otherLen = otherVal.length; - if (otherLen == 0) { - result = ((java.lang.String) ((Object) this)); - } else { - final int newLength = this.length + otherLen; - final byte[] newValue = new byte[newLength]; - LibSLRuntime.ArrayActions.copy(this.value, 0, newValue, 0, this.length); - LibSLRuntime.ArrayActions.copy(otherVal, 0, newValue, this.length, otherLen); - result = (java.lang.String) ((Object) new String((Void) null, - /* state = */ String.__$lsl_States.Initialized, - /* value = */ newValue, - /* length = */ newLength - )); - } - } - return result; - } - - /** - * [FUNCTION] StringAutomaton::getBytes(LSLString) -> array - * Source: java/lang/String.patch.lsl:198 - */ - public byte[] getBytes() { - byte[] result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= 50); - Engine.assume(this.length == this.value.length); - result = this.value; - } - return result; - } - - /** - * [FUNCTION] StringAutomaton::getBytes(LSLString, int, int, array, int) -> void - * Source: java/lang/String.patch.lsl:206 - */ - public void getBytes(int srcBegin, int srcEnd, byte[] dst, int dstBegin) { - /* body */ { - if (srcBegin < 0) { - throw new StringIndexOutOfBoundsException(srcBegin); - } - if (this.length < srcEnd) { - throw new StringIndexOutOfBoundsException(srcEnd); - } - final int count = srcEnd - srcBegin; - if (count < 0) { - throw new StringIndexOutOfBoundsException(count); - } - Engine.assume(this.value != null); - Engine.assume(this.value.length <= 50); - Engine.assume(this.length == this.value.length); - LibSLRuntime.ArrayActions.copy(this.value, srcBegin, dst, dstBegin, count); - } - } - - /** - * [FUNCTION] StringAutomaton::isEmpty(LSLString) -> boolean - * Source: java/lang/String.patch.lsl:223 - */ - public boolean isEmpty() { - boolean result = false; - /* body */ { - result = this.length == 0; - } - return result; - } - - /** - * [FUNCTION] StringAutomaton::length(LSLString) -> int - * Source: java/lang/String.patch.lsl:229 - */ - public int length() { - int result = 0; - /* body */ { - result = this.length; - } - return result; - } - - public static final class __$lsl_States { - public static final byte Initialized = (byte) 0; - } - - @Approximate(String.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/lang/StringBuffer.java b/approximations/src/main/java/generated/java/lang/StringBuffer.java deleted file mode 100644 index 2aacd208..00000000 --- a/approximations/src/main/java/generated/java/lang/StringBuffer.java +++ /dev/null @@ -1,1333 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/lang/StringBuffer.lsl:31 -// - java/lang/StringBuffer.main.lsl:20 -// -package generated.java.lang; - -import java.io.Serializable; -import java.lang.CharSequence; -import java.lang.Character; -import java.lang.Comparable; -import java.lang.IllegalArgumentException; -import java.lang.IndexOutOfBoundsException; -import java.lang.NegativeArraySizeException; -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.OutOfMemoryError; -import java.lang.String; -import java.lang.StringIndexOutOfBoundsException; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.stream.IntStream; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; -import stub.java.util.stream.IntStreamLSL; - -/** - * StringBufferAutomaton for LSLStringBuffer ~> java.lang.StringBuffer - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(java.lang.StringBuffer.class) -public final class StringBuffer implements LibSLRuntime.Automaton, Serializable, Comparable, CharSequence { - private static final long serialVersionUID = 3388685877147921107L; - - private static final int STRINGBUFFER_LENGTH_MAX = 50; - - static { - Engine.assume(true); - } - - public char[] value; - - public int count; - - @LibSLRuntime.AutomatonConstructor - public StringBuffer(Void __$lsl_token, final byte p0, final char[] p1, final int p2) { - this.value = p1; - this.count = p2; - } - - @LibSLRuntime.AutomatonConstructor - public StringBuffer(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Initialized, null, 0); - } - - /** - * [CONSTRUCTOR] StringBufferAutomaton::(LSLStringBuffer) -> void - * Source: java/lang/StringBuffer.main.lsl:238 - */ - public StringBuffer() { - this((Void) null); - /* body */ { - this.value = new char[STRINGBUFFER_LENGTH_MAX]; - } - } - - /** - * [CONSTRUCTOR] StringBufferAutomaton::(LSLStringBuffer, CharSequence) -> void - * Source: java/lang/StringBuffer.main.lsl:244 - */ - public StringBuffer(CharSequence seq) { - this((Void) null); - /* body */ { - if (seq == null) { - throw new NullPointerException(); - } - this.value = new char[STRINGBUFFER_LENGTH_MAX]; - _appendCharSequence(seq, 0, seq.length()); - } - } - - /** - * [CONSTRUCTOR] StringBufferAutomaton::(LSLStringBuffer, String) -> void - * Source: java/lang/StringBuffer.main.lsl:255 - */ - public StringBuffer(String str) { - this((Void) null); - /* body */ { - if (str == null) { - throw new NullPointerException(); - } - this.value = new char[STRINGBUFFER_LENGTH_MAX]; - _appendCharSequence(str, 0, str.length()); - } - } - - /** - * [CONSTRUCTOR] StringBufferAutomaton::(LSLStringBuffer, int) -> void - * Source: java/lang/StringBuffer.main.lsl:266 - */ - public StringBuffer(int cap) { - this((Void) null); - /* body */ { - if (cap < 0) { - throw new NegativeArraySizeException(); - } - if (cap > 1073741823) { - throw new OutOfMemoryError("Requested array size exceeds VM limit"); - } - this.value = new char[STRINGBUFFER_LENGTH_MAX]; - } - } - - /** - * [SUBROUTINE] StringBufferAutomaton::_appendCharSequence(CharSequence, int, int) -> void - * Source: java/lang/StringBuffer.main.lsl:117 - */ - private void _appendCharSequence(CharSequence seq, int seqStart, int seqEnd) { - /* body */ { - if ((seqStart < 0) || (seqStart > seqEnd) || (seqEnd > seq.length())) { - throw new IndexOutOfBoundsException(); - } - final int avaiable = this.value.length - this.count; - int len = seqEnd - seqStart; - if (len > avaiable) { - len = avaiable; - } - if (len > 0) { - String str = null; - if ((seq instanceof String)) { - str = ((String) seq); - } else { - str = LibSLRuntime.toString(seq); - } - final char[] chars = str.toCharArray(); - LibSLRuntime.ArrayActions.copy(chars, seqStart, this.value, this.count, len); - this.count += len; - } - } - } - - /** - * [SUBROUTINE] StringBufferAutomaton::_asString(int, int) -> String - * Source: java/lang/StringBuffer.main.lsl:146 - */ - private String _asString(int posStart, int posEnd) { - String result = null; - /* body */ { - final int len = posEnd - posStart; - if (len == 0) { - result = ""; - } else { - final char[] symbols = new char[len]; - LibSLRuntime.ArrayActions.copy(this.value, posStart, symbols, 0, len); - result = LibSLRuntime.toString(this.value); - } - } - return result; - } - - /** - * [SUBROUTINE] StringBufferAutomaton::_asString() -> String - * Source: java/lang/StringBuffer.main.lsl:162 - */ - public String _asString() { - String result = null; - /* body */ { - final int len = this.count; - if (len == 0) { - result = ""; - } else { - if (len == this.value.length) { - result = LibSLRuntime.toString(this.value); - } else { - final char[] symbols = new char[len]; - LibSLRuntime.ArrayActions.copy(this.value, 0, symbols, 0, len); - result = LibSLRuntime.toString(this.value); - } - } - } - return result; - } - - /** - * [SUBROUTINE] StringBufferAutomaton::_insertCharSequence(int, CharSequence, int, int) -> void - * Source: java/lang/StringBuffer.main.lsl:182 - */ - private void _insertCharSequence(int offset, CharSequence seq, int seqStart, int seqEnd) { - /* body */ { - if ((seqStart < 0) || (seqStart > seqEnd) || (seqEnd > seq.length()) || (offset > this.count)) { - throw new IndexOutOfBoundsException(); - } - final int avaiable = this.value.length - offset; - int len = seqEnd - seqStart; - if (len > avaiable) { - len = avaiable; - } - if (len > 0) { - final int avaiableForLeftovers = avaiable - len; - if (avaiableForLeftovers > 0) { - int rightLeftovers = this.count - offset; - if (rightLeftovers > avaiableForLeftovers) { - rightLeftovers = avaiableForLeftovers; - } - if (rightLeftovers > 0) { - final int rightIndex = offset + 1; - LibSLRuntime.ArrayActions.copy(this.value, rightIndex, this.value, rightIndex + len, rightLeftovers); - } - } - String str = null; - if ((seq instanceof String)) { - str = ((String) seq); - } else { - str = LibSLRuntime.toString(seq); - } - final char[] chars = str.toCharArray(); - LibSLRuntime.ArrayActions.copy(chars, seqStart, this.value, offset, len); - this.count += len; - } - } - } - - /** - * [SUBROUTINE] StringBufferAutomaton::_deleteChars(int, int) -> void - * Source: java/lang/StringBuffer.main.lsl:223 - */ - private void _deleteChars(int start, int end) { - /* body */ { - if ((start < 0) || (start > end) || (end > this.count)) { - throw new IndexOutOfBoundsException(); - } - final int leftovers = this.count - end; - if (leftovers > 0) { - LibSLRuntime.ArrayActions.copy(this.value, end, this.value, start, leftovers); - } - this.count -= end - start; - } - } - - /** - * [FUNCTION] StringBufferAutomaton::append(LSLStringBuffer, CharSequence) -> LSLStringBuffer - * Source: java/lang/StringBuffer.main.lsl:281 - */ - public synchronized StringBuffer append(CharSequence seq) { - StringBuffer result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - if (seq == null) { - _appendCharSequence("null", 0, 4); - } else { - _appendCharSequence(seq, 0, seq.length()); - } - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::append(LSLStringBuffer, CharSequence, int, int) -> LSLStringBuffer - * Source: java/lang/StringBuffer.main.lsl:294 - */ - public synchronized StringBuffer append(CharSequence seq, int start, int end) { - StringBuffer result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - if (seq == null) { - _appendCharSequence("null", start, end); - } else { - _appendCharSequence(seq, start, end); - } - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::append(LSLStringBuffer, Object) -> LSLStringBuffer - * Source: java/lang/StringBuffer.main.lsl:307 - */ - public synchronized StringBuffer append(Object obj) { - StringBuffer result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - if (obj == null) { - _appendCharSequence("null", 0, 4); - } else { - final String seq = LibSLRuntime.toString(obj); - _appendCharSequence(seq, 0, seq.length()); - } - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::append(LSLStringBuffer, String) -> LSLStringBuffer - * Source: java/lang/StringBuffer.main.lsl:325 - */ - public synchronized StringBuffer append(String str) { - StringBuffer result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - if (str == null) { - _appendCharSequence("null", 0, 4); - } else { - _appendCharSequence(str, 0, str.length()); - } - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::append(LSLStringBuffer, StringBuffer) -> LSLStringBuffer - * Source: java/lang/StringBuffer.main.lsl:338 - */ - public synchronized StringBuffer append(java.lang.StringBuffer sb) { - StringBuffer result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - if (sb == null) { - _appendCharSequence("null", 0, 4); - } else { - final String seq = LibSLRuntime.toString(sb); - _appendCharSequence(seq, 0, seq.length()); - } - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::append(LSLStringBuffer, boolean) -> LSLStringBuffer - * Source: java/lang/StringBuffer.main.lsl:356 - */ - public synchronized StringBuffer append(boolean x) { - StringBuffer result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - if (x) { - _appendCharSequence("true", 0, 4); - } else { - _appendCharSequence("false", 0, 5); - } - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::append(LSLStringBuffer, char) -> LSLStringBuffer - * Source: java/lang/StringBuffer.main.lsl:369 - */ - public synchronized StringBuffer append(char x) { - StringBuffer result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - if (this.count < this.value.length) { - value[this.count] = x; - this.count += 1; - } - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::append(LSLStringBuffer, array) -> LSLStringBuffer - * Source: java/lang/StringBuffer.main.lsl:383 - */ - public synchronized StringBuffer append(char[] str) { - StringBuffer result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - final String seq = LibSLRuntime.toString(str); - _appendCharSequence(seq, 0, seq.length()); - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::append(LSLStringBuffer, array, int, int) -> LSLStringBuffer - * Source: java/lang/StringBuffer.main.lsl:394 - */ - public synchronized StringBuffer append(char[] str, int offset, int len) { - StringBuffer result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - final String seq = LibSLRuntime.toString(str); - _appendCharSequence(seq, offset, len); - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::append(LSLStringBuffer, double) -> LSLStringBuffer - * Source: java/lang/StringBuffer.main.lsl:405 - */ - public synchronized StringBuffer append(double x) { - StringBuffer result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - final String seq = LibSLRuntime.toString(x); - _appendCharSequence(seq, 0, seq.length()); - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::append(LSLStringBuffer, float) -> LSLStringBuffer - * Source: java/lang/StringBuffer.main.lsl:416 - */ - public synchronized StringBuffer append(float x) { - StringBuffer result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - final String seq = LibSLRuntime.toString(x); - _appendCharSequence(seq, 0, seq.length()); - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::append(LSLStringBuffer, int) -> LSLStringBuffer - * Source: java/lang/StringBuffer.main.lsl:427 - */ - public synchronized StringBuffer append(int x) { - StringBuffer result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - final String seq = LibSLRuntime.toString(x); - _appendCharSequence(seq, 0, seq.length()); - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::append(LSLStringBuffer, long) -> LSLStringBuffer - * Source: java/lang/StringBuffer.main.lsl:438 - */ - public synchronized StringBuffer append(long x) { - StringBuffer result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - final String seq = LibSLRuntime.toString(x); - _appendCharSequence(seq, 0, seq.length()); - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::appendCodePoint(LSLStringBuffer, int) -> LSLStringBuffer - * Source: java/lang/StringBuffer.main.lsl:449 - */ - public synchronized StringBuffer appendCodePoint(int codePoint) { - StringBuffer result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - final int cnt = this.count; - final int len = this.value.length; - if (Character.isBmpCodePoint(codePoint)) { - if ((cnt + 1) <= len) { - value[cnt] = ((char) codePoint); - this.count = cnt + 1; - } - } else { - if (Character.isValidCodePoint(codePoint)) { - if ((cnt + 2) <= len) { - value[cnt + 1] = Character.lowSurrogate(codePoint); - value[cnt] = Character.highSurrogate(codePoint); - this.count = cnt + 2; - } - } else { - throw new IllegalArgumentException(); - } - } - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::capacity(LSLStringBuffer) -> int - * Source: java/lang/StringBuffer.main.lsl:486 - */ - public synchronized int capacity() { - int result = 0; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - result = this.value.length; - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::charAt(LSLStringBuffer, int) -> char - * Source: java/lang/StringBuffer.main.lsl:494 - */ - public synchronized char charAt(int index) { - char result = '?'; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - if ((index < 0) || (index >= this.count)) { - throw new StringIndexOutOfBoundsException(); - } - result = value[index]; - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::chars(LSLStringBuffer) -> IntStream - * Source: java/lang/StringBuffer.main.lsl:506 - */ - public IntStream chars() { - IntStream result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - final int len = this.count; - final int[] intValues = new int[len]; - int i = 0; - for (i = 0; i < len; i += 1) { - intValues[i] = ((int) value[i]); - } - ; - result = (IntStreamLSL) ((Object) new generated.java.util.stream.IntStreamLSL((Void) null, - /* state = */ generated.java.util.stream.IntStreamLSL.__$lsl_States.Initialized, - /* storage = */ intValues, - /* length = */ len, - /* closeHandlers = */ Engine.makeSymbolicList(), - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::codePointAt(LSLStringBuffer, int) -> int - * Source: java/lang/StringBuffer.main.lsl:532 - */ - public synchronized int codePointAt(int index) { - int result = 0; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - if ((index < 0) || (index >= this.count)) { - throw new StringIndexOutOfBoundsException(index); - } - result = Character.codePointAt(this.value, index, this.count); - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::codePointBefore(LSLStringBuffer, int) -> int - * Source: java/lang/StringBuffer.main.lsl:543 - */ - public synchronized int codePointBefore(int index) { - int result = 0; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - final int i = index - 1; - if ((i < 0) || (i >= this.count)) { - throw new StringIndexOutOfBoundsException(index); - } - result = Character.codePointBefore(this.value, index, 0); - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::codePointCount(LSLStringBuffer, int, int) -> int - * Source: java/lang/StringBuffer.main.lsl:555 - */ - public synchronized int codePointCount(int beginIndex, int endIndex) { - int result = 0; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - if ((beginIndex < 0) || (beginIndex > endIndex) || (endIndex > this.count)) { - throw new IndexOutOfBoundsException(); - } - result = Character.codePointCount(this.value, beginIndex, endIndex - beginIndex); - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::codePoints(LSLStringBuffer) -> IntStream - * Source: java/lang/StringBuffer.main.lsl:567 - */ - public IntStream codePoints() { - IntStream result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - final int len = this.count; - final int[] intValues = new int[len]; - int i = 0; - for (i = 0; i < len; i += 1) { - intValues[i] = ((int) value[i]); - } - ; - result = (IntStreamLSL) ((Object) new generated.java.util.stream.IntStreamLSL((Void) null, - /* state = */ generated.java.util.stream.IntStreamLSL.__$lsl_States.Initialized, - /* storage = */ intValues, - /* length = */ len, - /* closeHandlers = */ Engine.makeSymbolicList(), - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::compareTo(LSLStringBuffer, LSLStringBuffer) -> int - * Source: java/lang/StringBuffer.main.lsl:588 - */ - public synchronized int compareTo(StringBuffer another) { - int result = 0; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - if (another == this) { - result = 0; - } else { - final String thisString = _asString(); - final String anotherString = ((StringBuffer) ((Object) another))._asString(); - result = thisString.compareTo(anotherString); - } - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::delete(LSLStringBuffer, int, int) -> LSLStringBuffer - * Source: java/lang/StringBuffer.main.lsl:606 - */ - public synchronized StringBuffer delete(int start, int end) { - StringBuffer result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - _deleteChars(start, end); - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::deleteCharAt(LSLStringBuffer, int) -> LSLStringBuffer - * Source: java/lang/StringBuffer.main.lsl:616 - */ - public synchronized StringBuffer deleteCharAt(int index) { - StringBuffer result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - _deleteChars(index, index + 1); - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::ensureCapacity(LSLStringBuffer, int) -> void - * Source: java/lang/StringBuffer.main.lsl:626 - */ - public synchronized void ensureCapacity(int minimumCapacity) { - /* body */ { - Engine.assume(true); - } - } - - /** - * [FUNCTION] StringBufferAutomaton::getChars(LSLStringBuffer, int, int, array, int) -> void - * Source: java/lang/StringBuffer.main.lsl:633 - */ - public synchronized void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) { - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - if ((srcBegin < 0) || (srcBegin > srcEnd) || (srcEnd > this.count)) { - throw new StringIndexOutOfBoundsException(); - } - final int len = srcEnd - srcBegin; - if (dst == null) { - throw new NullPointerException(); - } - if ((dstBegin < 0) || ((dstBegin + len) > dst.length)) { - throw new IndexOutOfBoundsException(); - } - if (len > 0) { - LibSLRuntime.ArrayActions.copy(this.value, srcBegin, dst, dstBegin, len); - } - } - } - - /** - * [FUNCTION] StringBufferAutomaton::getValue(LSLStringBuffer) -> array - * Source: java/lang/StringBuffer.main.lsl:654 - */ - public char[] getValue() { - char[] result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - result = this.value; - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::indexOf(LSLStringBuffer, String) -> int - * Source: java/lang/StringBuffer.main.lsl:662 - */ - public int indexOf(String str) { - int result = 0; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - result = _asString().indexOf(str, 0); - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::indexOf(LSLStringBuffer, String, int) -> int - * Source: java/lang/StringBuffer.main.lsl:671 - */ - public synchronized int indexOf(String str, int fromIndex) { - int result = 0; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - result = _asString().indexOf(str, fromIndex); - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::insert(LSLStringBuffer, int, CharSequence) -> LSLStringBuffer - * Source: java/lang/StringBuffer.main.lsl:680 - */ - public StringBuffer insert(int dstOffset, CharSequence s) { - StringBuffer result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - if (s == null) { - _insertCharSequence(dstOffset, "null", 0, 4); - } else { - _insertCharSequence(dstOffset, s, 0, s.length()); - } - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::insert(LSLStringBuffer, int, CharSequence, int, int) -> LSLStringBuffer - * Source: java/lang/StringBuffer.main.lsl:693 - */ - public synchronized StringBuffer insert(int dstOffset, CharSequence s, int start, int end) { - StringBuffer result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - if (s == null) { - _insertCharSequence(dstOffset, "null", start, end); - } else { - _insertCharSequence(dstOffset, s, start, end); - } - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::insert(LSLStringBuffer, int, Object) -> LSLStringBuffer - * Source: java/lang/StringBuffer.main.lsl:706 - */ - public synchronized StringBuffer insert(int dstOffset, Object obj) { - StringBuffer result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - if (obj == null) { - _insertCharSequence(dstOffset, "null", 0, 4); - } else { - final String s = LibSLRuntime.toString(obj); - _insertCharSequence(dstOffset, s, 0, s.length()); - } - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::insert(LSLStringBuffer, int, String) -> LSLStringBuffer - * Source: java/lang/StringBuffer.main.lsl:724 - */ - public synchronized StringBuffer insert(int dstOffset, String s) { - StringBuffer result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - if (s == null) { - _insertCharSequence(dstOffset, "null", 0, 4); - } else { - _insertCharSequence(dstOffset, s, 0, s.length()); - } - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::insert(LSLStringBuffer, int, boolean) -> LSLStringBuffer - * Source: java/lang/StringBuffer.main.lsl:737 - */ - public StringBuffer insert(int dstOffset, boolean x) { - StringBuffer result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - final String s = LibSLRuntime.toString(x); - _insertCharSequence(dstOffset, s, 0, s.length()); - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::insert(LSLStringBuffer, int, char) -> LSLStringBuffer - * Source: java/lang/StringBuffer.main.lsl:748 - */ - public synchronized StringBuffer insert(int dstOffset, char x) { - StringBuffer result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - final String s = LibSLRuntime.toString(x); - _insertCharSequence(dstOffset, s, 0, 1); - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::insert(LSLStringBuffer, int, array) -> LSLStringBuffer - * Source: java/lang/StringBuffer.main.lsl:759 - */ - public synchronized StringBuffer insert(int dstOffset, char[] x) { - StringBuffer result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - final String s = LibSLRuntime.toString(x); - _insertCharSequence(dstOffset, s, 0, s.length()); - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::insert(LSLStringBuffer, int, array, int, int) -> LSLStringBuffer - * Source: java/lang/StringBuffer.main.lsl:770 - */ - public synchronized StringBuffer insert(int index, char[] str, int offset, int len) { - StringBuffer result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - final char[] arr = new char[len]; - LibSLRuntime.ArrayActions.copy(str, offset, arr, 0, len); - final String s = LibSLRuntime.toString(arr); - _insertCharSequence(index, s, 0, len); - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::insert(LSLStringBuffer, int, double) -> LSLStringBuffer - * Source: java/lang/StringBuffer.main.lsl:784 - */ - public StringBuffer insert(int dstOffset, double x) { - StringBuffer result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - final String s = LibSLRuntime.toString(x); - _insertCharSequence(dstOffset, s, 0, s.length()); - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::insert(LSLStringBuffer, int, float) -> LSLStringBuffer - * Source: java/lang/StringBuffer.main.lsl:795 - */ - public StringBuffer insert(int dstOffset, float x) { - StringBuffer result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - final String s = LibSLRuntime.toString(x); - _insertCharSequence(dstOffset, s, 0, s.length()); - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::insert(LSLStringBuffer, int, int) -> LSLStringBuffer - * Source: java/lang/StringBuffer.main.lsl:806 - */ - public StringBuffer insert(int dstOffset, int x) { - StringBuffer result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - final String s = LibSLRuntime.toString(x); - _insertCharSequence(dstOffset, s, 0, s.length()); - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::insert(LSLStringBuffer, int, long) -> LSLStringBuffer - * Source: java/lang/StringBuffer.main.lsl:817 - */ - public StringBuffer insert(int dstOffset, long x) { - StringBuffer result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - final String s = LibSLRuntime.toString(x); - _insertCharSequence(dstOffset, s, 0, s.length()); - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::lastIndexOf(LSLStringBuffer, String) -> int - * Source: java/lang/StringBuffer.main.lsl:828 - */ - public int lastIndexOf(String str) { - int result = 0; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - result = _asString().lastIndexOf(str, this.count); - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::lastIndexOf(LSLStringBuffer, String, int) -> int - * Source: java/lang/StringBuffer.main.lsl:837 - */ - public synchronized int lastIndexOf(String str, int fromIndex) { - int result = 0; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - result = _asString().lastIndexOf(str, fromIndex); - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::length(LSLStringBuffer) -> int - * Source: java/lang/StringBuffer.main.lsl:846 - */ - public synchronized int length() { - int result = 0; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - result = this.count; - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::offsetByCodePoints(LSLStringBuffer, int, int) -> int - * Source: java/lang/StringBuffer.main.lsl:854 - */ - public synchronized int offsetByCodePoints(int index, int codePointOffset) { - int result = 0; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - if ((index < 0) || (index > this.count)) { - throw new IndexOutOfBoundsException(); - } - result = Character.offsetByCodePoints(this.value, 0, this.count, index, codePointOffset); - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::replace(LSLStringBuffer, int, int, String) -> LSLStringBuffer - * Source: java/lang/StringBuffer.main.lsl:865 - */ - public synchronized StringBuffer replace(int start, int end, String s) { - StringBuffer result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - _deleteChars(start, end); - if (s == null) { - _insertCharSequence(start, "null", 0, 4); - } else { - _insertCharSequence(start, s, 0, s.length()); - } - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::reverse(LSLStringBuffer) -> LSLStringBuffer - * Source: java/lang/StringBuffer.main.lsl:880 - */ - public synchronized StringBuffer reverse() { - StringBuffer result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - if (this.count != 0) { - boolean hasSurrogates = false; - final int n = this.count - 1; - int j = 0; - for (j = (n - 1) >> 1; j > -1; j += -1) { - int k = n - j; - char cj = value[j]; - char ck = value[k]; - value[j] = ck; - value[k] = cj; - if (Character.isSurrogate(cj) || Character.isSurrogate(ck)) { - hasSurrogates = true; - } - } - ; - if (hasSurrogates) { - int i = 0; - for (i = 0; i < n; i += 1) { - char c2 = value[i]; - if (Character.isLowSurrogate(c2)) { - char c1 = value[i + 1]; - if (Character.isHighSurrogate(c1)) { - value[i] = c1; - i += 1; - value[i] = c2; - } - } - } - ; - } - } - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::setCharAt(LSLStringBuffer, int, char) -> void - * Source: java/lang/StringBuffer.main.lsl:942 - */ - public synchronized void setCharAt(int index, char x) { - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - if ((index < 0) || (index >= this.count)) { - throw new StringIndexOutOfBoundsException(); - } - value[index] = x; - } - } - - /** - * [FUNCTION] StringBufferAutomaton::setLength(LSLStringBuffer, int) -> void - * Source: java/lang/StringBuffer.main.lsl:953 - */ - public synchronized void setLength(int newLength) { - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - final int maxLength = this.value.length; - if (newLength > maxLength) { - newLength = maxLength; - } - if (newLength < 0) { - throw new StringIndexOutOfBoundsException(); - } else { - if (newLength < this.count) { - this.count = newLength; - } else { - if (newLength > this.count) { - LibSLRuntime.ArrayActions.fillRange(this.value, this.count, newLength, ((char) 0)); - this.count = newLength; - } - } - } - } - } - - /** - * [FUNCTION] StringBufferAutomaton::subSequence(LSLStringBuffer, int, int) -> CharSequence - * Source: java/lang/StringBuffer.main.lsl:978 - */ - public synchronized CharSequence subSequence(int start, int end) { - CharSequence result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - if ((start < 0) || (start > end) || (end > this.count)) { - throw new StringIndexOutOfBoundsException(); - } - result = _asString(start, end); - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::substring(LSLStringBuffer, int) -> String - * Source: java/lang/StringBuffer.main.lsl:989 - */ - public synchronized String substring(int start) { - String result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - if ((start < 0) || (start > this.count)) { - throw new StringIndexOutOfBoundsException(); - } - result = _asString(start, this.count); - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::substring(LSLStringBuffer, int, int) -> String - * Source: java/lang/StringBuffer.main.lsl:1000 - */ - public synchronized String substring(int start, int end) { - String result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - if ((start < 0) || (start > end) || (end > this.count)) { - throw new StringIndexOutOfBoundsException(); - } - result = _asString(start, end); - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::toString(LSLStringBuffer) -> String - * Source: java/lang/StringBuffer.main.lsl:1011 - */ - public synchronized String toString() { - String result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - result = _asString(); - } - return result; - } - - /** - * [FUNCTION] StringBufferAutomaton::trimToSize(LSLStringBuffer) -> void - * Source: java/lang/StringBuffer.main.lsl:1019 - */ - public synchronized void trimToSize() { - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUFFER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - } - } - - public static final class __$lsl_States { - public static final byte Initialized = (byte) 0; - } - - @Approximate(StringBuffer.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/lang/StringBufferImpl.java b/approximations/src/main/java/generated/java/lang/StringBufferImpl.java new file mode 100644 index 00000000..d3410548 --- /dev/null +++ b/approximations/src/main/java/generated/java/lang/StringBufferImpl.java @@ -0,0 +1,643 @@ +package generated.java.lang; + +import java.io.Serial; +import java.io.Serializable; +import java.lang.CharSequence; +import java.lang.Character; +import java.lang.Comparable; +import java.lang.IllegalArgumentException; +import java.lang.IndexOutOfBoundsException; +import java.lang.NegativeArraySizeException; +import java.lang.NullPointerException; +import java.lang.Object; +import java.lang.OutOfMemoryError; +import java.lang.String; +import java.lang.StringIndexOutOfBoundsException; +import java.util.stream.IntStream; + +import generated.java.util.stream.IntStreamImpl; +import org.jacodb.approximation.annotation.Approximate; +import org.jetbrains.annotations.NotNull; +import org.usvm.api.Engine; +import runtime.LibSLRuntime; + +@SuppressWarnings("unused") +@Approximate(java.lang.StringBuffer.class) +public final class StringBufferImpl implements Serializable, Comparable, CharSequence { + + @Serial + private static final long serialVersionUID = 3388685877147921107L; + + private static final int STRING_BUFFER_LENGTH_MAX = 50; + + static { + Engine.assume(true); + } + + public char[] value; + + public int count = 0; + + public StringBufferImpl(char[] value, int count) { + this.value = value; + this.count = count; + } + + public StringBufferImpl() { + this(new char[STRING_BUFFER_LENGTH_MAX], 0); + } + + public StringBufferImpl(CharSequence seq) { + if (seq == null) + throw new NullPointerException(); + this.value = new char[STRING_BUFFER_LENGTH_MAX]; + _appendCharSequence(seq, 0, seq.length()); + } + + public StringBufferImpl(String str) { + if (str == null) { + throw new NullPointerException(); + } + this.value = new char[STRING_BUFFER_LENGTH_MAX]; + _appendCharSequence(str, 0, str.length()); + } + + public StringBufferImpl(int cap) { + if (cap < 0) + throw new NegativeArraySizeException(); + if (cap > 1073741823) + throw new OutOfMemoryError("Requested array size exceeds VM limit"); + this.value = new char[STRING_BUFFER_LENGTH_MAX]; + } + + private void _appendCharSequence(CharSequence seq, int seqStart, int seqEnd) { + if (seqStart < 0 || seqStart > seqEnd || seqEnd > seq.length()) + throw new IndexOutOfBoundsException(); + int available = this.value.length - this.count; + int len = seqEnd - seqStart; + if (len > available) + len = available; + if (len <= 0) + return; + + String str; + if (seq instanceof String) { + str = (String) seq; + } else { + str = LibSLRuntime.toString(seq); + } + char[] chars = str.toCharArray(); + LibSLRuntime.ArrayActions.copy(chars, seqStart, this.value, this.count, len); + this.count += len; + } + + private String _asString(int posStart, int posEnd) { + int len = posEnd - posStart; + if (len == 0) + return ""; + + char[] symbols = new char[len]; + LibSLRuntime.ArrayActions.copy(this.value, posStart, symbols, 0, len); + return LibSLRuntime.toString(this.value); + } + + public String _asString() { + int len = this.count; + if (len == 0) + return ""; + + if (len == this.value.length) + return LibSLRuntime.toString(this.value); + + char[] symbols = new char[len]; + LibSLRuntime.ArrayActions.copy(this.value, 0, symbols, 0, len); + return LibSLRuntime.toString(this.value); + } + + private void _insertCharSequence(int offset, CharSequence seq, int seqStart, int seqEnd) { + if (seqStart < 0 || seqStart > seqEnd || seqEnd > seq.length() || offset > this.count) + throw new IndexOutOfBoundsException(); + + int available = this.value.length - offset; + int len = seqEnd - seqStart; + if (len > available) + len = available; + + if (len <= 0) + return; + + int availableForLeftovers = available - len; + if (availableForLeftovers > 0) { + int rightLeftovers = this.count - offset; + if (rightLeftovers > availableForLeftovers) + rightLeftovers = availableForLeftovers; + if (rightLeftovers > 0) { + int rightIndex = offset + 1; + LibSLRuntime.ArrayActions.copy(this.value, rightIndex, this.value, rightIndex + len, rightLeftovers); + } + } + String str; + if (seq instanceof String) { + str = (String) seq; + } else { + str = LibSLRuntime.toString(seq); + } + char[] chars = str.toCharArray(); + LibSLRuntime.ArrayActions.copy(chars, seqStart, this.value, offset, len); + this.count += len; + } + + private void _deleteChars(int start, int end) { + if (start < 0 || start > end || end > this.count) + throw new IndexOutOfBoundsException(); + + int leftovers = this.count - end; + if (leftovers > 0) + LibSLRuntime.ArrayActions.copy(this.value, end, this.value, start, leftovers); + this.count -= end - start; + } + + @SuppressWarnings("DataFlowIssue") + private void _assumeInvariants() { + Engine.assume(this.value != null); + Engine.assume(this.value.length <= STRING_BUFFER_LENGTH_MAX); + Engine.assume(this.count <= this.value.length); + Engine.assume(this.count >= 0); + } + + public synchronized StringBufferImpl append(CharSequence seq) { + _assumeInvariants(); + if (seq == null) { + _appendCharSequence("null", 0, 4); + } else { + _appendCharSequence(seq, 0, seq.length()); + } + return this; + } + + @SuppressWarnings("ReplaceNullCheck") + public synchronized StringBufferImpl append(CharSequence seq, int start, int end) { + _assumeInvariants(); + if (seq == null) { + _appendCharSequence("null", start, end); + } else { + _appendCharSequence(seq, start, end); + } + return this; + } + + public synchronized StringBufferImpl append(Object obj) { + _assumeInvariants(); + if (obj == null) { + _appendCharSequence("null", 0, 4); + } else { + String seq = LibSLRuntime.toString(obj); + _appendCharSequence(seq, 0, seq.length()); + } + return this; + } + + public synchronized StringBufferImpl append(String str) { + _assumeInvariants(); + if (str == null) { + _appendCharSequence("null", 0, 4); + } else { + _appendCharSequence(str, 0, str.length()); + } + return this; + } + + public synchronized StringBufferImpl append(java.lang.StringBuffer sb) { + _assumeInvariants(); + if (sb == null) { + _appendCharSequence("null", 0, 4); + } else { + String seq = LibSLRuntime.toString(sb); + _appendCharSequence(seq, 0, seq.length()); + } + return this; + } + + public synchronized StringBufferImpl append(boolean x) { + _assumeInvariants(); + if (x) { + _appendCharSequence("true", 0, 4); + } else { + _appendCharSequence("false", 0, 5); + } + return this; + } + + public synchronized StringBufferImpl append(char x) { + _assumeInvariants(); + if (this.count < this.value.length) { + value[this.count] = x; + this.count++; + } + return this; + } + + public synchronized StringBufferImpl append(char[] str) { + _assumeInvariants(); + String seq = LibSLRuntime.toString(str); + _appendCharSequence(seq, 0, seq.length()); + return this; + } + + public synchronized StringBufferImpl append(char[] str, int offset, int len) { + _assumeInvariants(); + String seq = LibSLRuntime.toString(str); + _appendCharSequence(seq, offset, len); + return this; + } + + public synchronized StringBufferImpl append(double x) { + _assumeInvariants(); + String seq = LibSLRuntime.toString(x); + _appendCharSequence(seq, 0, seq.length()); + return this; + } + + public synchronized StringBufferImpl append(float x) { + _assumeInvariants(); + String seq = LibSLRuntime.toString(x); + _appendCharSequence(seq, 0, seq.length()); + return this; + } + + public synchronized StringBufferImpl append(int x) { + _assumeInvariants(); + String seq = LibSLRuntime.toString(x); + _appendCharSequence(seq, 0, seq.length()); + return this; + } + + public synchronized StringBufferImpl append(long x) { + _assumeInvariants(); + String seq = LibSLRuntime.toString(x); + _appendCharSequence(seq, 0, seq.length()); + return this; + } + + public synchronized StringBufferImpl appendCodePoint(int codePoint) { + _assumeInvariants(); + int cnt = this.count; + int len = this.value.length; + if (Character.isBmpCodePoint(codePoint)) { + if (cnt + 1 <= len) { + value[cnt] = (char) codePoint; + this.count = cnt + 1; + } + } else { + if (Character.isValidCodePoint(codePoint)) { + if (cnt + 2 <= len) { + value[cnt + 1] = Character.lowSurrogate(codePoint); + value[cnt] = Character.highSurrogate(codePoint); + this.count = cnt + 2; + } + } else { + throw new IllegalArgumentException(); + } + } + return this; + } + + public synchronized int capacity() { + _assumeInvariants(); + return this.value.length; + } + + public synchronized char charAt(int index) { + _assumeInvariants(); + if (index < 0 || index >= this.count) + throw new StringIndexOutOfBoundsException(); + return value[index]; + } + + @NotNull + public IntStream chars() { + _assumeInvariants(); + int len = this.count; + int[] intValues = new int[len]; + for (int i = 0; i < len; i++) { + intValues[i] = value[i]; + } + + return new IntStreamImpl(intValues); + } + + public synchronized int codePointAt(int index) { + _assumeInvariants(); + if (index < 0 || index >= this.count) + throw new StringIndexOutOfBoundsException(index); + return Character.codePointAt(this.value, index, this.count); + } + + public synchronized int codePointBefore(int index) { + _assumeInvariants(); + int i = index - 1; + if (i < 0 || i >= this.count) + throw new StringIndexOutOfBoundsException(index); + return Character.codePointBefore(this.value, index, 0); + } + + public synchronized int codePointCount(int beginIndex, int endIndex) { + _assumeInvariants(); + if (beginIndex < 0 || beginIndex > endIndex || endIndex > this.count) + throw new IndexOutOfBoundsException(); + return Character.codePointCount(this.value, beginIndex, endIndex - beginIndex); + } + + @NotNull + public IntStream codePoints() { + _assumeInvariants(); + int len = this.count; + int[] intValues = new int[len]; + for (int i = 0; i < len; i++) { + intValues[i] = value[i]; + } + return new IntStreamImpl(intValues); + } + + public synchronized int compareTo(@NotNull StringBufferImpl another) { + _assumeInvariants(); + if (another == this) + return 0; + + String thisString = _asString(); + String anotherString = another._asString(); + return thisString.compareTo(anotherString); + } + + public synchronized StringBufferImpl delete(int start, int end) { + _assumeInvariants(); + _deleteChars(start, end); + return this; + } + + public synchronized StringBufferImpl deleteCharAt(int index) { + _assumeInvariants(); + _deleteChars(index, index + 1); + return this; + } + + public synchronized void ensureCapacity(int minimumCapacity) { + Engine.assume(true); + } + + public synchronized void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) { + _assumeInvariants(); + if (srcBegin < 0 || srcBegin > srcEnd || srcEnd > this.count) + throw new StringIndexOutOfBoundsException(); + int len = srcEnd - srcBegin; + if (dst == null) + throw new NullPointerException(); + if (dstBegin < 0 || dstBegin + len > dst.length) + throw new IndexOutOfBoundsException(); + if (len > 0) + LibSLRuntime.ArrayActions.copy(this.value, srcBegin, dst, dstBegin, len); + } + + public char[] getValue() { + _assumeInvariants(); + return this.value; + } + + public int indexOf(String str) { + _assumeInvariants(); + return _asString().indexOf(str); + } + + public synchronized int indexOf(String str, int fromIndex) { + _assumeInvariants(); + return _asString().indexOf(str, fromIndex); + } + + public StringBufferImpl insert(int dstOffset, CharSequence s) { + _assumeInvariants(); + if (s == null) { + _insertCharSequence(dstOffset, "null", 0, 4); + } else { + _insertCharSequence(dstOffset, s, 0, s.length()); + } + return this; + } + + @SuppressWarnings("ReplaceNullCheck") + public synchronized StringBufferImpl insert(int dstOffset, CharSequence s, int start, int end) { + _assumeInvariants(); + if (s == null) { + _insertCharSequence(dstOffset, "null", start, end); + } else { + _insertCharSequence(dstOffset, s, start, end); + } + return this; + } + + public synchronized StringBufferImpl insert(int dstOffset, Object obj) { + _assumeInvariants(); + if (obj == null) { + _insertCharSequence(dstOffset, "null", 0, 4); + } else { + String s = LibSLRuntime.toString(obj); + _insertCharSequence(dstOffset, s, 0, s.length()); + } + return this; + } + + public synchronized StringBufferImpl insert(int dstOffset, String s) { + _assumeInvariants(); + if (s == null) { + _insertCharSequence(dstOffset, "null", 0, 4); + } else { + _insertCharSequence(dstOffset, s, 0, s.length()); + } + return this; + } + + public StringBufferImpl insert(int dstOffset, boolean x) { + _assumeInvariants(); + String s = LibSLRuntime.toString(x); + _insertCharSequence(dstOffset, s, 0, s.length()); + return this; + } + + public synchronized StringBufferImpl insert(int dstOffset, char x) { + _assumeInvariants(); + String s = LibSLRuntime.toString(x); + _insertCharSequence(dstOffset, s, 0, 1); + return this; + } + + public synchronized StringBufferImpl insert(int dstOffset, char[] x) { + _assumeInvariants(); + String s = LibSLRuntime.toString(x); + _insertCharSequence(dstOffset, s, 0, s.length()); + return this; + } + + public synchronized StringBufferImpl insert(int index, char[] str, int offset, int len) { + _assumeInvariants(); + char[] arr = new char[len]; + LibSLRuntime.ArrayActions.copy(str, offset, arr, 0, len); + String s = LibSLRuntime.toString(arr); + _insertCharSequence(index, s, 0, len); + return this; + } + + public StringBufferImpl insert(int dstOffset, double x) { + _assumeInvariants(); + String s = LibSLRuntime.toString(x); + _insertCharSequence(dstOffset, s, 0, s.length()); + return this; + } + + public StringBufferImpl insert(int dstOffset, float x) { + _assumeInvariants(); + String s = LibSLRuntime.toString(x); + _insertCharSequence(dstOffset, s, 0, s.length()); + return this; + } + + public StringBufferImpl insert(int dstOffset, int x) { + _assumeInvariants(); + String s = LibSLRuntime.toString(x); + _insertCharSequence(dstOffset, s, 0, s.length()); + return this; + } + + public StringBufferImpl insert(int dstOffset, long x) { + _assumeInvariants(); + String s = LibSLRuntime.toString(x); + _insertCharSequence(dstOffset, s, 0, s.length()); + return this; + } + + public int lastIndexOf(String str) { + _assumeInvariants(); + return _asString().lastIndexOf(str, this.count); + } + + public synchronized int lastIndexOf(String str, int fromIndex) { + _assumeInvariants(); + return _asString().lastIndexOf(str, fromIndex); + } + + public synchronized int length() { + _assumeInvariants(); + return this.count; + } + + public synchronized int offsetByCodePoints(int index, int codePointOffset) { + _assumeInvariants(); + if (index < 0 || index > this.count) + throw new IndexOutOfBoundsException(); + return Character.offsetByCodePoints(this.value, 0, this.count, index, codePointOffset); + } + + public synchronized StringBufferImpl replace(int start, int end, String s) { + _assumeInvariants(); + _deleteChars(start, end); + if (s == null) { + _insertCharSequence(start, "null", 0, 4); + } else { + _insertCharSequence(start, s, 0, s.length()); + } + return this; + } + + public synchronized StringBufferImpl reverse() { + _assumeInvariants(); + if (this.count == 0) + return this; + + boolean hasSurrogates = false; + int n = this.count - 1; + for (int i = (n - 1) >> 1; i > -1; i--) { + int k = n - i; + char cj = value[i]; + char ck = value[k]; + value[i] = ck; + value[k] = cj; + if (Character.isSurrogate(cj) || Character.isSurrogate(ck)) + hasSurrogates = true; + } + + if (!hasSurrogates) + return this; + + for (int i = 0; i < n; i++) { + char c2 = value[i]; + if (Character.isLowSurrogate(c2)) { + char c1 = value[i + 1]; + if (Character.isHighSurrogate(c1)) { + value[i] = c1; + i++; + value[i] = c2; + } + } + } + return this; + } + + public synchronized void setCharAt(int index, char x) { + _assumeInvariants(); + if (index < 0 || index >= this.count) + throw new StringIndexOutOfBoundsException(); + value[index] = x; + } + + public synchronized void setLength(int newLength) { + _assumeInvariants(); + int maxLength = this.value.length; + if (newLength > maxLength) + newLength = maxLength; + if (newLength < 0) + throw new StringIndexOutOfBoundsException(); + + if (newLength < this.count) { + this.count = newLength; + return; + } + + if (newLength > this.count) { + LibSLRuntime.ArrayActions.fillRange(this.value, this.count, newLength, ((char) 0)); + this.count = newLength; + } + } + + @NotNull + public synchronized CharSequence subSequence(int start, int end) { + _assumeInvariants(); + if (start < 0 || start > end || end > this.count) + throw new StringIndexOutOfBoundsException(); + + return _asString(start, end); + } + + public synchronized String substring(int start) { + _assumeInvariants(); + if (start < 0 || start > this.count) + throw new StringIndexOutOfBoundsException(); + + return _asString(start, this.count); + } + + public synchronized String substring(int start, int end) { + _assumeInvariants(); + if (start < 0 || start > end || end > this.count) + throw new StringIndexOutOfBoundsException(); + + return _asString(start, end); + } + + @NotNull + public synchronized String toString() { + _assumeInvariants(); + return _asString(); + } + + public synchronized void trimToSize() { + _assumeInvariants(); + } +} diff --git a/approximations/src/main/java/generated/java/lang/StringBuilder.java b/approximations/src/main/java/generated/java/lang/StringBuilder.java deleted file mode 100644 index 276313f8..00000000 --- a/approximations/src/main/java/generated/java/lang/StringBuilder.java +++ /dev/null @@ -1,1357 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/lang/StringBuilder.lsl:30 -// - java/lang/StringBuilder.main.lsl:22 -// -package generated.java.lang; - -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; -import java.lang.CharSequence; -import java.lang.Character; -import java.lang.Comparable; -import java.lang.IllegalArgumentException; -import java.lang.IndexOutOfBoundsException; -import java.lang.NegativeArraySizeException; -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.OutOfMemoryError; -import java.lang.String; -import java.lang.StringBuffer; -import java.lang.StringIndexOutOfBoundsException; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.stream.IntStream; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; -import stub.java.util.stream.IntStreamLSL; - -/** - * StringBuilderAutomaton for LSLStringBuilder ~> java.lang.StringBuilder - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(java.lang.StringBuilder.class) -public final class StringBuilder implements LibSLRuntime.Automaton, Serializable, Comparable, CharSequence { - private static final long serialVersionUID = 4383685877147921099L; - - private static final int STRINGBUILDER_LENGTH_MAX = 50; - - static { - Engine.assume(true); - } - - public char[] value; - - public int count; - - @LibSLRuntime.AutomatonConstructor - public StringBuilder(Void __$lsl_token, final byte p0, final char[] p1, final int p2) { - this.value = p1; - this.count = p2; - } - - @LibSLRuntime.AutomatonConstructor - public StringBuilder(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Initialized, null, 0); - } - - /** - * [CONSTRUCTOR] StringBuilderAutomaton::(LSLStringBuilder) -> void - * Source: java/lang/StringBuilder.main.lsl:240 - */ - public StringBuilder() { - this((Void) null); - /* body */ { - this.value = new char[STRINGBUILDER_LENGTH_MAX]; - } - } - - /** - * [CONSTRUCTOR] StringBuilderAutomaton::(LSLStringBuilder, CharSequence) -> void - * Source: java/lang/StringBuilder.main.lsl:246 - */ - public StringBuilder(CharSequence seq) { - this((Void) null); - /* body */ { - if (seq == null) { - throw new NullPointerException(); - } - this.value = new char[STRINGBUILDER_LENGTH_MAX]; - _appendCharSequence(seq, 0, seq.length()); - } - } - - /** - * [CONSTRUCTOR] StringBuilderAutomaton::(LSLStringBuilder, String) -> void - * Source: java/lang/StringBuilder.main.lsl:257 - */ - public StringBuilder(String str) { - this((Void) null); - /* body */ { - if (str == null) { - throw new NullPointerException(); - } - this.value = new char[STRINGBUILDER_LENGTH_MAX]; - _appendCharSequence(str, 0, str.length()); - } - } - - /** - * [CONSTRUCTOR] StringBuilderAutomaton::(LSLStringBuilder, int) -> void - * Source: java/lang/StringBuilder.main.lsl:268 - */ - public StringBuilder(int cap) { - this((Void) null); - /* body */ { - if (cap < 0) { - throw new NegativeArraySizeException(); - } - if (cap > 1073741823) { - throw new OutOfMemoryError("Requested array size exceeds VM limit"); - } - this.value = new char[STRINGBUILDER_LENGTH_MAX]; - } - } - - /** - * [SUBROUTINE] StringBuilderAutomaton::_appendCharSequence(CharSequence, int, int) -> void - * Source: java/lang/StringBuilder.main.lsl:119 - */ - private void _appendCharSequence(CharSequence seq, int seqStart, int seqEnd) { - /* body */ { - if ((seqStart < 0) || (seqStart > seqEnd) || (seqEnd > seq.length())) { - throw new IndexOutOfBoundsException(); - } - final int avaiable = this.value.length - this.count; - int len = seqEnd - seqStart; - if (len > avaiable) { - len = avaiable; - } - if (len > 0) { - String str = null; - if ((seq instanceof String)) { - str = ((String) seq); - } else { - str = LibSLRuntime.toString(seq); - } - final char[] chars = str.toCharArray(); - LibSLRuntime.ArrayActions.copy(chars, seqStart, this.value, this.count, len); - this.count += len; - } - } - } - - /** - * [SUBROUTINE] StringBuilderAutomaton::_asString(int, int) -> String - * Source: java/lang/StringBuilder.main.lsl:148 - */ - private String _asString(int posStart, int posEnd) { - String result = null; - /* body */ { - final int len = posEnd - posStart; - if (len == 0) { - result = ""; - } else { - final char[] symbols = new char[len]; - LibSLRuntime.ArrayActions.copy(this.value, posStart, symbols, 0, len); - result = LibSLRuntime.toString(this.value); - } - } - return result; - } - - /** - * [SUBROUTINE] StringBuilderAutomaton::_asString() -> String - * Source: java/lang/StringBuilder.main.lsl:164 - */ - public String _asString() { - String result = null; - /* body */ { - final int len = this.count; - if (len == 0) { - result = ""; - } else { - if (len == this.value.length) { - result = LibSLRuntime.toString(this.value); - } else { - final char[] symbols = new char[len]; - LibSLRuntime.ArrayActions.copy(this.value, 0, symbols, 0, len); - result = LibSLRuntime.toString(this.value); - } - } - } - return result; - } - - /** - * [SUBROUTINE] StringBuilderAutomaton::_insertCharSequence(int, CharSequence, int, int) -> void - * Source: java/lang/StringBuilder.main.lsl:184 - */ - private void _insertCharSequence(int offset, CharSequence seq, int seqStart, int seqEnd) { - /* body */ { - if ((seqStart < 0) || (seqStart > seqEnd) || (seqEnd > seq.length()) || (offset > this.count)) { - throw new IndexOutOfBoundsException(); - } - final int avaiable = this.value.length - offset; - int len = seqEnd - seqStart; - if (len > avaiable) { - len = avaiable; - } - if (len > 0) { - final int avaiableForLeftovers = avaiable - len; - if (avaiableForLeftovers > 0) { - int rightLeftovers = this.count - offset; - if (rightLeftovers > avaiableForLeftovers) { - rightLeftovers = avaiableForLeftovers; - } - if (rightLeftovers > 0) { - final int rightIndex = offset + 1; - LibSLRuntime.ArrayActions.copy(this.value, rightIndex, this.value, rightIndex + len, rightLeftovers); - } - } - String str = null; - if ((seq instanceof String)) { - str = ((String) seq); - } else { - str = LibSLRuntime.toString(seq); - } - final char[] chars = str.toCharArray(); - LibSLRuntime.ArrayActions.copy(chars, seqStart, this.value, offset, len); - this.count += len; - } - } - } - - /** - * [SUBROUTINE] StringBuilderAutomaton::_deleteChars(int, int) -> void - * Source: java/lang/StringBuilder.main.lsl:225 - */ - private void _deleteChars(int start, int end) { - /* body */ { - if ((start < 0) || (start > end) || (end > this.count)) { - throw new IndexOutOfBoundsException(); - } - final int leftovers = this.count - end; - if (leftovers > 0) { - LibSLRuntime.ArrayActions.copy(this.value, end, this.value, start, leftovers); - } - this.count -= end - start; - } - } - - /** - * [FUNCTION] StringBuilderAutomaton::append(LSLStringBuilder, CharSequence) -> LSLStringBuilder - * Source: java/lang/StringBuilder.main.lsl:283 - */ - public StringBuilder append(CharSequence seq) { - StringBuilder result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - if (seq == null) { - _appendCharSequence("null", 0, 4); - } else { - _appendCharSequence(seq, 0, seq.length()); - } - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::append(LSLStringBuilder, CharSequence, int, int) -> LSLStringBuilder - * Source: java/lang/StringBuilder.main.lsl:296 - */ - public StringBuilder append(CharSequence seq, int start, int end) { - StringBuilder result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - if (seq == null) { - _appendCharSequence("null", start, end); - } else { - _appendCharSequence(seq, start, end); - } - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::append(LSLStringBuilder, Object) -> LSLStringBuilder - * Source: java/lang/StringBuilder.main.lsl:309 - */ - public StringBuilder append(Object obj) { - StringBuilder result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - if (obj == null) { - _appendCharSequence("null", 0, 4); - } else { - final String seq = LibSLRuntime.toString(obj); - _appendCharSequence(seq, 0, seq.length()); - } - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::append(LSLStringBuilder, String) -> LSLStringBuilder - * Source: java/lang/StringBuilder.main.lsl:327 - */ - public StringBuilder append(String str) { - StringBuilder result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - if (str == null) { - _appendCharSequence("null", 0, 4); - } else { - _appendCharSequence(str, 0, str.length()); - } - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::append(LSLStringBuilder, StringBuffer) -> LSLStringBuilder - * Source: java/lang/StringBuilder.main.lsl:340 - */ - public StringBuilder append(StringBuffer sb) { - StringBuilder result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - if (sb == null) { - _appendCharSequence("null", 0, 4); - } else { - final String seq = LibSLRuntime.toString(sb); - _appendCharSequence(seq, 0, seq.length()); - } - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::append(LSLStringBuilder, boolean) -> LSLStringBuilder - * Source: java/lang/StringBuilder.main.lsl:358 - */ - public StringBuilder append(boolean x) { - StringBuilder result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - if (x) { - _appendCharSequence("true", 0, 4); - } else { - _appendCharSequence("false", 0, 5); - } - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::append(LSLStringBuilder, char) -> LSLStringBuilder - * Source: java/lang/StringBuilder.main.lsl:371 - */ - public StringBuilder append(char x) { - StringBuilder result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - if (this.count < this.value.length) { - value[this.count] = x; - this.count += 1; - } - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::append(LSLStringBuilder, array) -> LSLStringBuilder - * Source: java/lang/StringBuilder.main.lsl:385 - */ - public StringBuilder append(char[] str) { - StringBuilder result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - final String seq = LibSLRuntime.toString(str); - _appendCharSequence(seq, 0, seq.length()); - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::append(LSLStringBuilder, array, int, int) -> LSLStringBuilder - * Source: java/lang/StringBuilder.main.lsl:396 - */ - public StringBuilder append(char[] str, int offset, int len) { - StringBuilder result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - final String seq = LibSLRuntime.toString(str); - _appendCharSequence(seq, offset, len); - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::append(LSLStringBuilder, double) -> LSLStringBuilder - * Source: java/lang/StringBuilder.main.lsl:407 - */ - public StringBuilder append(double x) { - StringBuilder result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - final String seq = LibSLRuntime.toString(x); - _appendCharSequence(seq, 0, seq.length()); - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::append(LSLStringBuilder, float) -> LSLStringBuilder - * Source: java/lang/StringBuilder.main.lsl:418 - */ - public StringBuilder append(float x) { - StringBuilder result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - final String seq = LibSLRuntime.toString(x); - _appendCharSequence(seq, 0, seq.length()); - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::append(LSLStringBuilder, int) -> LSLStringBuilder - * Source: java/lang/StringBuilder.main.lsl:429 - */ - public StringBuilder append(int x) { - StringBuilder result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - final String seq = LibSLRuntime.toString(x); - _appendCharSequence(seq, 0, seq.length()); - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::append(LSLStringBuilder, long) -> LSLStringBuilder - * Source: java/lang/StringBuilder.main.lsl:440 - */ - public StringBuilder append(long x) { - StringBuilder result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - final String seq = LibSLRuntime.toString(x); - _appendCharSequence(seq, 0, seq.length()); - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::appendCodePoint(LSLStringBuilder, int) -> LSLStringBuilder - * Source: java/lang/StringBuilder.main.lsl:451 - */ - public StringBuilder appendCodePoint(int codePoint) { - StringBuilder result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - final int cnt = this.count; - final int len = this.value.length; - if (Character.isBmpCodePoint(codePoint)) { - if ((cnt + 1) <= len) { - value[cnt] = ((char) codePoint); - this.count = cnt + 1; - } - } else { - if (Character.isValidCodePoint(codePoint)) { - if ((cnt + 2) <= len) { - value[cnt + 1] = Character.lowSurrogate(codePoint); - value[cnt] = Character.highSurrogate(codePoint); - this.count = cnt + 2; - } - } else { - throw new IllegalArgumentException(); - } - } - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::capacity(LSLStringBuilder) -> int - * Source: java/lang/StringBuilder.main.lsl:488 - */ - public int capacity() { - int result = 0; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - result = this.value.length; - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::charAt(LSLStringBuilder, int) -> char - * Source: java/lang/StringBuilder.main.lsl:496 - */ - public char charAt(int index) { - char result = '?'; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - if ((index < 0) || (index >= this.count)) { - throw new StringIndexOutOfBoundsException(); - } - result = value[index]; - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::chars(LSLStringBuilder) -> IntStream - * Source: java/lang/StringBuilder.main.lsl:508 - */ - public IntStream chars() { - IntStream result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - final int len = this.count; - final int[] intValues = new int[len]; - int i = 0; - for (i = 0; i < len; i += 1) { - intValues[i] = ((int) value[i]); - } - ; - result = (IntStreamLSL) ((Object) new generated.java.util.stream.IntStreamLSL((Void) null, - /* state = */ generated.java.util.stream.IntStreamLSL.__$lsl_States.Initialized, - /* storage = */ intValues, - /* length = */ len, - /* closeHandlers = */ Engine.makeSymbolicList(), - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::codePointAt(LSLStringBuilder, int) -> int - * Source: java/lang/StringBuilder.main.lsl:534 - */ - public int codePointAt(int index) { - int result = 0; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - if ((index < 0) || (index >= this.count)) { - throw new StringIndexOutOfBoundsException(index); - } - result = Character.codePointAt(this.value, index, this.count); - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::codePointBefore(LSLStringBuilder, int) -> int - * Source: java/lang/StringBuilder.main.lsl:545 - */ - public int codePointBefore(int index) { - int result = 0; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - final int i = index - 1; - if ((i < 0) || (i >= this.count)) { - throw new StringIndexOutOfBoundsException(index); - } - result = Character.codePointBefore(this.value, index, 0); - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::codePointCount(LSLStringBuilder, int, int) -> int - * Source: java/lang/StringBuilder.main.lsl:557 - */ - public int codePointCount(int beginIndex, int endIndex) { - int result = 0; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - if ((beginIndex < 0) || (beginIndex > endIndex) || (endIndex > this.count)) { - throw new IndexOutOfBoundsException(); - } - result = Character.codePointCount(this.value, beginIndex, endIndex - beginIndex); - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::codePoints(LSLStringBuilder) -> IntStream - * Source: java/lang/StringBuilder.main.lsl:569 - */ - public IntStream codePoints() { - IntStream result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - final int len = this.count; - final int[] intValues = new int[len]; - int i = 0; - for (i = 0; i < len; i += 1) { - intValues[i] = ((int) value[i]); - } - ; - result = (IntStreamLSL) ((Object) new generated.java.util.stream.IntStreamLSL((Void) null, - /* state = */ generated.java.util.stream.IntStreamLSL.__$lsl_States.Initialized, - /* storage = */ intValues, - /* length = */ len, - /* closeHandlers = */ Engine.makeSymbolicList(), - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::compareTo(LSLStringBuilder, LSLStringBuilder) -> int - * Source: java/lang/StringBuilder.main.lsl:590 - */ - public int compareTo(StringBuilder another) { - int result = 0; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - if (another == this) { - result = 0; - } else { - final String thisString = _asString(); - final String anotherString = ((StringBuilder) ((Object) another))._asString(); - result = thisString.compareTo(anotherString); - } - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::delete(LSLStringBuilder, int, int) -> LSLStringBuilder - * Source: java/lang/StringBuilder.main.lsl:608 - */ - public StringBuilder delete(int start, int end) { - StringBuilder result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - _deleteChars(start, end); - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::deleteCharAt(LSLStringBuilder, int) -> LSLStringBuilder - * Source: java/lang/StringBuilder.main.lsl:618 - */ - public StringBuilder deleteCharAt(int index) { - StringBuilder result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - _deleteChars(index, index + 1); - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::ensureCapacity(LSLStringBuilder, int) -> void - * Source: java/lang/StringBuilder.main.lsl:628 - */ - public void ensureCapacity(int minimumCapacity) { - /* body */ { - Engine.assume(true); - } - } - - /** - * [FUNCTION] StringBuilderAutomaton::getChars(LSLStringBuilder, int, int, array, int) -> void - * Source: java/lang/StringBuilder.main.lsl:635 - */ - public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) { - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - if ((srcBegin < 0) || (srcBegin > srcEnd) || (srcEnd > this.count)) { - throw new StringIndexOutOfBoundsException(); - } - final int len = srcEnd - srcBegin; - if (dst == null) { - throw new NullPointerException(); - } - if ((dstBegin < 0) || ((dstBegin + len) > dst.length)) { - throw new IndexOutOfBoundsException(); - } - if (len > 0) { - LibSLRuntime.ArrayActions.copy(this.value, srcBegin, dst, dstBegin, len); - } - } - } - - /** - * [FUNCTION] StringBuilderAutomaton::getValue(LSLStringBuilder) -> array - * Source: java/lang/StringBuilder.main.lsl:656 - */ - public char[] getValue() { - char[] result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - result = this.value; - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::indexOf(LSLStringBuilder, String) -> int - * Source: java/lang/StringBuilder.main.lsl:664 - */ - public int indexOf(String str) { - int result = 0; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - result = _asString().indexOf(str, 0); - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::indexOf(LSLStringBuilder, String, int) -> int - * Source: java/lang/StringBuilder.main.lsl:673 - */ - public int indexOf(String str, int fromIndex) { - int result = 0; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - result = _asString().indexOf(str, fromIndex); - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::insert(LSLStringBuilder, int, CharSequence) -> LSLStringBuilder - * Source: java/lang/StringBuilder.main.lsl:682 - */ - public StringBuilder insert(int dstOffset, CharSequence s) { - StringBuilder result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - if (s == null) { - _insertCharSequence(dstOffset, "null", 0, 4); - } else { - _insertCharSequence(dstOffset, s, 0, s.length()); - } - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::insert(LSLStringBuilder, int, CharSequence, int, int) -> LSLStringBuilder - * Source: java/lang/StringBuilder.main.lsl:695 - */ - public StringBuilder insert(int dstOffset, CharSequence s, int start, int end) { - StringBuilder result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - if (s == null) { - _insertCharSequence(dstOffset, "null", start, end); - } else { - _insertCharSequence(dstOffset, s, start, end); - } - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::insert(LSLStringBuilder, int, Object) -> LSLStringBuilder - * Source: java/lang/StringBuilder.main.lsl:708 - */ - public StringBuilder insert(int dstOffset, Object obj) { - StringBuilder result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - if (obj == null) { - _insertCharSequence(dstOffset, "null", 0, 4); - } else { - final String s = LibSLRuntime.toString(obj); - _insertCharSequence(dstOffset, s, 0, s.length()); - } - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::insert(LSLStringBuilder, int, String) -> LSLStringBuilder - * Source: java/lang/StringBuilder.main.lsl:726 - */ - public StringBuilder insert(int dstOffset, String s) { - StringBuilder result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - if (s == null) { - _insertCharSequence(dstOffset, "null", 0, 4); - } else { - _insertCharSequence(dstOffset, s, 0, s.length()); - } - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::insert(LSLStringBuilder, int, boolean) -> LSLStringBuilder - * Source: java/lang/StringBuilder.main.lsl:739 - */ - public StringBuilder insert(int dstOffset, boolean x) { - StringBuilder result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - final String s = LibSLRuntime.toString(x); - _insertCharSequence(dstOffset, s, 0, s.length()); - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::insert(LSLStringBuilder, int, char) -> LSLStringBuilder - * Source: java/lang/StringBuilder.main.lsl:750 - */ - public StringBuilder insert(int dstOffset, char x) { - StringBuilder result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - final String s = LibSLRuntime.toString(x); - _insertCharSequence(dstOffset, s, 0, 1); - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::insert(LSLStringBuilder, int, array) -> LSLStringBuilder - * Source: java/lang/StringBuilder.main.lsl:761 - */ - public StringBuilder insert(int dstOffset, char[] x) { - StringBuilder result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - final String s = LibSLRuntime.toString(x); - _insertCharSequence(dstOffset, s, 0, s.length()); - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::insert(LSLStringBuilder, int, array, int, int) -> LSLStringBuilder - * Source: java/lang/StringBuilder.main.lsl:772 - */ - public StringBuilder insert(int index, char[] str, int offset, int len) { - StringBuilder result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - final char[] arr = new char[len]; - LibSLRuntime.ArrayActions.copy(str, offset, arr, 0, len); - final String s = LibSLRuntime.toString(arr); - _insertCharSequence(index, s, 0, len); - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::insert(LSLStringBuilder, int, double) -> LSLStringBuilder - * Source: java/lang/StringBuilder.main.lsl:786 - */ - public StringBuilder insert(int dstOffset, double x) { - StringBuilder result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - final String s = LibSLRuntime.toString(x); - _insertCharSequence(dstOffset, s, 0, s.length()); - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::insert(LSLStringBuilder, int, float) -> LSLStringBuilder - * Source: java/lang/StringBuilder.main.lsl:797 - */ - public StringBuilder insert(int dstOffset, float x) { - StringBuilder result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - final String s = LibSLRuntime.toString(x); - _insertCharSequence(dstOffset, s, 0, s.length()); - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::insert(LSLStringBuilder, int, int) -> LSLStringBuilder - * Source: java/lang/StringBuilder.main.lsl:808 - */ - public StringBuilder insert(int dstOffset, int x) { - StringBuilder result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - final String s = LibSLRuntime.toString(x); - _insertCharSequence(dstOffset, s, 0, s.length()); - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::insert(LSLStringBuilder, int, long) -> LSLStringBuilder - * Source: java/lang/StringBuilder.main.lsl:819 - */ - public StringBuilder insert(int dstOffset, long x) { - StringBuilder result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - final String s = LibSLRuntime.toString(x); - _insertCharSequence(dstOffset, s, 0, s.length()); - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::lastIndexOf(LSLStringBuilder, String) -> int - * Source: java/lang/StringBuilder.main.lsl:830 - */ - public int lastIndexOf(String str) { - int result = 0; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - result = _asString().lastIndexOf(str, this.count); - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::lastIndexOf(LSLStringBuilder, String, int) -> int - * Source: java/lang/StringBuilder.main.lsl:839 - */ - public int lastIndexOf(String str, int fromIndex) { - int result = 0; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - result = _asString().lastIndexOf(str, fromIndex); - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::length(LSLStringBuilder) -> int - * Source: java/lang/StringBuilder.main.lsl:848 - */ - public int length() { - int result = 0; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - result = this.count; - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::offsetByCodePoints(LSLStringBuilder, int, int) -> int - * Source: java/lang/StringBuilder.main.lsl:856 - */ - public int offsetByCodePoints(int index, int codePointOffset) { - int result = 0; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - if ((index < 0) || (index > this.count)) { - throw new IndexOutOfBoundsException(); - } - result = Character.offsetByCodePoints(this.value, 0, this.count, index, codePointOffset); - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::replace(LSLStringBuilder, int, int, String) -> LSLStringBuilder - * Source: java/lang/StringBuilder.main.lsl:867 - */ - public StringBuilder replace(int start, int end, String s) { - StringBuilder result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - _deleteChars(start, end); - if (s == null) { - _insertCharSequence(start, "null", 0, 4); - } else { - _insertCharSequence(start, s, 0, s.length()); - } - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::reverse(LSLStringBuilder) -> LSLStringBuilder - * Source: java/lang/StringBuilder.main.lsl:882 - */ - public StringBuilder reverse() { - StringBuilder result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - if (this.count != 0) { - boolean hasSurrogates = false; - final int n = this.count - 1; - int j = 0; - for (j = (n - 1) >> 1; j > -1; j += -1) { - int k = n - j; - char cj = value[j]; - char ck = value[k]; - value[j] = ck; - value[k] = cj; - if (Character.isSurrogate(cj) || Character.isSurrogate(ck)) { - hasSurrogates = true; - } - } - ; - if (hasSurrogates) { - int i = 0; - for (i = 0; i < n; i += 1) { - char c2 = value[i]; - if (Character.isLowSurrogate(c2)) { - char c1 = value[i + 1]; - if (Character.isHighSurrogate(c1)) { - value[i] = c1; - i += 1; - value[i] = c2; - } - } - } - ; - } - } - result = this; - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::setCharAt(LSLStringBuilder, int, char) -> void - * Source: java/lang/StringBuilder.main.lsl:944 - */ - public void setCharAt(int index, char x) { - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - if ((index < 0) || (index >= this.count)) { - throw new StringIndexOutOfBoundsException(); - } - value[index] = x; - } - } - - /** - * [FUNCTION] StringBuilderAutomaton::setLength(LSLStringBuilder, int) -> void - * Source: java/lang/StringBuilder.main.lsl:955 - */ - public void setLength(int newLength) { - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - final int maxLength = this.value.length; - if (newLength > maxLength) { - newLength = maxLength; - } - if (newLength < 0) { - throw new StringIndexOutOfBoundsException(); - } else { - if (newLength < this.count) { - this.count = newLength; - } else { - if (newLength > this.count) { - LibSLRuntime.ArrayActions.fillRange(this.value, this.count, newLength, ((char) 0)); - this.count = newLength; - } - } - } - } - } - - /** - * [FUNCTION] StringBuilderAutomaton::subSequence(LSLStringBuilder, int, int) -> CharSequence - * Source: java/lang/StringBuilder.main.lsl:980 - */ - public CharSequence subSequence(int start, int end) { - CharSequence result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - if ((start < 0) || (start > end) || (end > this.count)) { - throw new StringIndexOutOfBoundsException(); - } - result = _asString(start, end); - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::substring(LSLStringBuilder, int) -> String - * Source: java/lang/StringBuilder.main.lsl:991 - */ - public String substring(int start) { - String result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - if ((start < 0) || (start > this.count)) { - throw new StringIndexOutOfBoundsException(); - } - result = _asString(start, this.count); - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::substring(LSLStringBuilder, int, int) -> String - * Source: java/lang/StringBuilder.main.lsl:1002 - */ - public String substring(int start, int end) { - String result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - if ((start < 0) || (start > end) || (end > this.count)) { - throw new StringIndexOutOfBoundsException(); - } - result = _asString(start, end); - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::toString(LSLStringBuilder) -> String - * Source: java/lang/StringBuilder.main.lsl:1013 - */ - public String toString() { - String result = null; - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - result = _asString(); - } - return result; - } - - /** - * [FUNCTION] StringBuilderAutomaton::trimToSize(LSLStringBuilder) -> void - * Source: java/lang/StringBuilder.main.lsl:1021 - */ - public void trimToSize() { - /* body */ { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRINGBUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); - } - } - - /** - * [FUNCTION] StringBuilderAutomaton::writeObject(LSLStringBuilder, ObjectOutputStream) -> void - * Source: java/lang/StringBuilder.main.lsl:1034 - */ - private void writeObject(ObjectOutputStream s) throws java.io.IOException { - /* body */ { - LibSLRuntime.not_implemented(/* no serialization support yet */); - } - } - - /** - * [FUNCTION] StringBuilderAutomaton::readObject(LSLStringBuilder, ObjectInputStream) -> void - * Source: java/lang/StringBuilder.main.lsl:1042 - */ - private void readObject(ObjectInputStream s) throws java.io.IOException, - java.lang.ClassNotFoundException { - /* body */ { - LibSLRuntime.not_implemented(/* no serialization support yet */); - } - } - - public static final class __$lsl_States { - public static final byte Initialized = (byte) 0; - } - - @Approximate(StringBuilder.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/lang/StringBuilderImpl.java b/approximations/src/main/java/generated/java/lang/StringBuilderImpl.java new file mode 100644 index 00000000..98d52929 --- /dev/null +++ b/approximations/src/main/java/generated/java/lang/StringBuilderImpl.java @@ -0,0 +1,654 @@ +package generated.java.lang; + +import java.io.Serial; +import java.io.Serializable; +import java.lang.CharSequence; +import java.lang.Character; +import java.lang.Comparable; +import java.lang.IllegalArgumentException; +import java.lang.IndexOutOfBoundsException; +import java.lang.NegativeArraySizeException; +import java.lang.NullPointerException; +import java.lang.Object; +import java.lang.OutOfMemoryError; +import java.lang.String; +import java.lang.StringBuffer; +import java.lang.StringIndexOutOfBoundsException; +import java.util.stream.IntStream; + +import generated.java.util.stream.IntStreamImpl; +import org.jacodb.approximation.annotation.Approximate; +import org.jetbrains.annotations.NotNull; +import org.usvm.api.Engine; +import runtime.LibSLRuntime; + +@SuppressWarnings("unused") +@Approximate(java.lang.StringBuilder.class) +public final class StringBuilderImpl implements Serializable, Comparable, CharSequence { + // TODO: unify with StringBufferImpl: create approximation on 'AbstractStringBuilder' (it's private) + + @Serial + private static final long serialVersionUID = 4383685877147921099L; + + private static final int STRING_BUILDER_LENGTH_MAX = 50; + + static { + Engine.assume(true); + } + + public char[] value; + + public int count = 0; + + public StringBuilderImpl(char[] value, int count) { + this.value = value; + this.count = count; + } + + public StringBuilderImpl() { + this(new char[STRING_BUILDER_LENGTH_MAX], 0); + } + + public StringBuilderImpl(CharSequence seq) { + if (seq == null) + throw new NullPointerException(); + this.value = new char[STRING_BUILDER_LENGTH_MAX]; + _appendCharSequence(seq, 0, seq.length()); + } + + public StringBuilderImpl(String str) { + if (str == null) + throw new NullPointerException(); + this.value = new char[STRING_BUILDER_LENGTH_MAX]; + _appendCharSequence(str, 0, str.length()); + } + + public StringBuilderImpl(int cap) { + if (cap < 0) + throw new NegativeArraySizeException(); + if (cap > 1073741823) + throw new OutOfMemoryError("Requested array size exceeds VM limit"); + this.value = new char[STRING_BUILDER_LENGTH_MAX]; + } + + private void _appendCharSequence(CharSequence seq, int seqStart, int seqEnd) { + if (seqStart < 0 || seqStart > seqEnd || seqEnd > seq.length()) + throw new IndexOutOfBoundsException(); + int available = this.value.length - this.count; + int len = seqEnd - seqStart; + if (len > available) + len = available; + if (len <= 0) + return; + + String str; + if (seq instanceof String) { + str = (String) seq; + } else { + str = LibSLRuntime.toString(seq); + } + char[] chars = str.toCharArray(); + LibSLRuntime.ArrayActions.copy(chars, seqStart, this.value, this.count, len); + this.count += len; + } + + private String _asString(int posStart, int posEnd) { + int len = posEnd - posStart; + if (len == 0) + return ""; + + char[] symbols = new char[len]; + LibSLRuntime.ArrayActions.copy(this.value, posStart, symbols, 0, len); + return LibSLRuntime.toString(this.value); + } + + public String _asString() { + int len = this.count; + if (len == 0) + return ""; + + if (len == this.value.length) + return LibSLRuntime.toString(this.value); + + char[] symbols = new char[len]; + LibSLRuntime.ArrayActions.copy(this.value, 0, symbols, 0, len); + return LibSLRuntime.toString(this.value); + } + + private void _insertCharSequence(int offset, CharSequence seq, int seqStart, int seqEnd) { + if (seqStart < 0 || seqStart > seqEnd || seqEnd > seq.length() || offset > this.count) + throw new IndexOutOfBoundsException(); + + int available = this.value.length - offset; + int len = seqEnd - seqStart; + if (len > available) + len = available; + + if (len <= 0) + return; + + int availableForLeftovers = available - len; + if (availableForLeftovers > 0) { + int rightLeftovers = this.count - offset; + if (rightLeftovers > availableForLeftovers) { + rightLeftovers = availableForLeftovers; + } + if (rightLeftovers > 0) { + int rightIndex = offset + 1; + LibSLRuntime.ArrayActions.copy(this.value, rightIndex, this.value, rightIndex + len, rightLeftovers); + } + } + String str; + if (seq instanceof String) { + str = (String) seq; + } else { + str = LibSLRuntime.toString(seq); + } + char[] chars = str.toCharArray(); + LibSLRuntime.ArrayActions.copy(chars, seqStart, this.value, offset, len); + this.count += len; + } + + private void _deleteChars(int start, int end) { + if (start < 0 || start > end || end > this.count) + throw new IndexOutOfBoundsException(); + + int leftovers = this.count - end; + if (leftovers > 0) + LibSLRuntime.ArrayActions.copy(this.value, end, this.value, start, leftovers); + this.count -= end - start; + } + + @SuppressWarnings("DataFlowIssue") + private void _assumeInvariants() { + Engine.assume(this.value != null); + Engine.assume(this.value.length <= STRING_BUILDER_LENGTH_MAX); + Engine.assume(this.count <= this.value.length); + Engine.assume(this.count >= 0); + } + + public StringBuilderImpl append(CharSequence seq) { + _assumeInvariants(); + if (seq == null) { + _appendCharSequence("null", 0, 4); + } else { + _appendCharSequence(seq, 0, seq.length()); + } + + return this; + } + + @SuppressWarnings("ReplaceNullCheck") + public StringBuilderImpl append(CharSequence seq, int start, int end) { + _assumeInvariants(); + if (seq == null) { + _appendCharSequence("null", start, end); + } else { + _appendCharSequence(seq, start, end); + } + return this; + } + + public StringBuilderImpl append(Object obj) { + _assumeInvariants(); + if (obj == null) { + _appendCharSequence("null", 0, 4); + } else { + String seq = LibSLRuntime.toString(obj); + _appendCharSequence(seq, 0, seq.length()); + } + return this; + } + + public StringBuilderImpl append(String str) { + _assumeInvariants(); + if (str == null) { + _appendCharSequence("null", 0, 4); + } else { + _appendCharSequence(str, 0, str.length()); + } + return this; + } + + public StringBuilderImpl append(StringBuffer sb) { + _assumeInvariants(); + if (sb == null) { + _appendCharSequence("null", 0, 4); + } else { + String seq = LibSLRuntime.toString(sb); + _appendCharSequence(seq, 0, seq.length()); + } + return this; + } + + public StringBuilderImpl append(boolean x) { + _assumeInvariants(); + if (x) { + _appendCharSequence("true", 0, 4); + } else { + _appendCharSequence("false", 0, 5); + } + return this; + } + + public StringBuilderImpl append(char x) { + _assumeInvariants(); + if (this.count < this.value.length) { + value[this.count] = x; + this.count++; + } + return this; + } + + public StringBuilderImpl append(char[] str) { + _assumeInvariants(); + String seq = LibSLRuntime.toString(str); + _appendCharSequence(seq, 0, seq.length()); + return this; + } + + public StringBuilderImpl append(char[] str, int offset, int len) { + _assumeInvariants(); + String seq = LibSLRuntime.toString(str); + _appendCharSequence(seq, offset, len); + return this; + } + + public StringBuilderImpl append(double x) { + _assumeInvariants(); + String seq = LibSLRuntime.toString(x); + _appendCharSequence(seq, 0, seq.length()); + return this; + } + + public StringBuilderImpl append(float x) { + _assumeInvariants(); + String seq = LibSLRuntime.toString(x); + _appendCharSequence(seq, 0, seq.length()); + return this; + } + + public StringBuilderImpl append(int x) { + _assumeInvariants(); + String seq = LibSLRuntime.toString(x); + _appendCharSequence(seq, 0, seq.length()); + return this; + } + + public StringBuilderImpl append(long x) { + _assumeInvariants(); + String seq = LibSLRuntime.toString(x); + _appendCharSequence(seq, 0, seq.length()); + return this; + } + + public StringBuilderImpl appendCodePoint(int codePoint) { + _assumeInvariants(); + int cnt = this.count; + int len = this.value.length; + if (Character.isBmpCodePoint(codePoint)) { + if (cnt + 1 <= len) { + value[cnt] = ((char) codePoint); + this.count = cnt + 1; + } + } else { + if (Character.isValidCodePoint(codePoint)) { + if (cnt + 2 <= len) { + value[cnt + 1] = Character.lowSurrogate(codePoint); + value[cnt] = Character.highSurrogate(codePoint); + this.count = cnt + 2; + } + } else { + throw new IllegalArgumentException(); + } + } + return this; + } + + public int capacity() { + _assumeInvariants(); + return this.value.length; + } + + public char charAt(int index) { + _assumeInvariants(); + if (index < 0 || index >= this.count) + throw new StringIndexOutOfBoundsException(); + + return value[index]; + } + + @NotNull + public IntStream chars() { + _assumeInvariants(); + int len = this.count; + int[] intValues = new int[len]; + for (int i = 0; i < len; i++) { + intValues[i] = value[i]; + } + + return new IntStreamImpl(intValues); + } + + public int codePointAt(int index) { + _assumeInvariants(); + if (index < 0 || index >= this.count) + throw new StringIndexOutOfBoundsException(index); + + return Character.codePointAt(this.value, index, this.count); + } + + public int codePointBefore(int index) { + _assumeInvariants(); + int i = index - 1; + if (i < 0 || i >= this.count) + throw new StringIndexOutOfBoundsException(index); + + return Character.codePointBefore(this.value, index, 0); + } + + public int codePointCount(int beginIndex, int endIndex) { + _assumeInvariants(); + if (beginIndex < 0 || beginIndex > endIndex || endIndex > this.count) + throw new IndexOutOfBoundsException(); + + return Character.codePointCount(this.value, beginIndex, endIndex - beginIndex); + } + + @NotNull + public IntStream codePoints() { + _assumeInvariants(); + int len = this.count; + int[] intValues = new int[len]; + for (int i = 0; i < len; i++) { + intValues[i] = value[i]; + } + return new IntStreamImpl(intValues); + } + + public int compareTo(@NotNull StringBuilderImpl another) { + _assumeInvariants(); + if (another == this) + return 0; + + String thisString = _asString(); + String anotherString = another._asString(); + return thisString.compareTo(anotherString); + } + + public StringBuilderImpl delete(int start, int end) { + _assumeInvariants(); + _deleteChars(start, end); + return this; + } + + public StringBuilderImpl deleteCharAt(int index) { + _assumeInvariants(); + _deleteChars(index, index + 1); + return this; + } + + public void ensureCapacity(int minimumCapacity) { + Engine.assume(true); + } + + public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) { + _assumeInvariants(); + if (srcBegin < 0 || srcBegin > srcEnd || srcEnd > this.count) + throw new StringIndexOutOfBoundsException(); + int len = srcEnd - srcBegin; + if (dst == null) + throw new NullPointerException(); + if (dstBegin < 0 || dstBegin + len > dst.length) + throw new IndexOutOfBoundsException(); + if (len > 0) + LibSLRuntime.ArrayActions.copy(this.value, srcBegin, dst, dstBegin, len); + } + + public char[] getValue() { + _assumeInvariants(); + return this.value; + } + + public int indexOf(String str) { + _assumeInvariants(); + return _asString().indexOf(str); + } + + public int indexOf(String str, int fromIndex) { + _assumeInvariants(); + return _asString().indexOf(str, fromIndex); + } + + public StringBuilderImpl insert(int dstOffset, CharSequence s) { + _assumeInvariants(); + if (s == null) { + _insertCharSequence(dstOffset, "null", 0, 4); + } else { + _insertCharSequence(dstOffset, s, 0, s.length()); + } + return this; + } + + @SuppressWarnings("ReplaceNullCheck") + public StringBuilderImpl insert(int dstOffset, CharSequence s, int start, int end) { + _assumeInvariants(); + if (s == null) { + _insertCharSequence(dstOffset, "null", start, end); + } else { + _insertCharSequence(dstOffset, s, start, end); + } + return this; + } + + public StringBuilderImpl insert(int dstOffset, Object obj) { + _assumeInvariants(); + if (obj == null) { + _insertCharSequence(dstOffset, "null", 0, 4); + } else { + String s = LibSLRuntime.toString(obj); + _insertCharSequence(dstOffset, s, 0, s.length()); + } + return this; + } + + public StringBuilderImpl insert(int dstOffset, String s) { + _assumeInvariants(); + if (s == null) { + _insertCharSequence(dstOffset, "null", 0, 4); + } else { + _insertCharSequence(dstOffset, s, 0, s.length()); + } + return this; + } + + public StringBuilderImpl insert(int dstOffset, boolean x) { + _assumeInvariants(); + String s = LibSLRuntime.toString(x); + _insertCharSequence(dstOffset, s, 0, s.length()); + return this; + } + + public StringBuilderImpl insert(int dstOffset, char x) { + _assumeInvariants(); + String s = LibSLRuntime.toString(x); + _insertCharSequence(dstOffset, s, 0, 1); + return this; + } + + public StringBuilderImpl insert(int dstOffset, char[] x) { + _assumeInvariants(); + String s = LibSLRuntime.toString(x); + _insertCharSequence(dstOffset, s, 0, s.length()); + return this; + } + + public StringBuilderImpl insert(int index, char[] str, int offset, int len) { + _assumeInvariants(); + char[] arr = new char[len]; + LibSLRuntime.ArrayActions.copy(str, offset, arr, 0, len); + String s = LibSLRuntime.toString(arr); + _insertCharSequence(index, s, 0, len); + return this; + } + + public StringBuilderImpl insert(int dstOffset, double x) { + _assumeInvariants(); + String s = LibSLRuntime.toString(x); + _insertCharSequence(dstOffset, s, 0, s.length()); + return this; + } + + public StringBuilderImpl insert(int dstOffset, float x) { + _assumeInvariants(); + String s = LibSLRuntime.toString(x); + _insertCharSequence(dstOffset, s, 0, s.length()); + return this; + } + + public StringBuilderImpl insert(int dstOffset, int x) { + _assumeInvariants(); + String s = LibSLRuntime.toString(x); + _insertCharSequence(dstOffset, s, 0, s.length()); + return this; + } + + public StringBuilderImpl insert(int dstOffset, long x) { + _assumeInvariants(); + String s = LibSLRuntime.toString(x); + _insertCharSequence(dstOffset, s, 0, s.length()); + return this; + } + + public int lastIndexOf(String str) { + _assumeInvariants(); + return _asString().lastIndexOf(str, this.count); + } + + public int lastIndexOf(String str, int fromIndex) { + _assumeInvariants(); + return _asString().lastIndexOf(str, fromIndex); + } + + public int length() { + _assumeInvariants(); + return this.count; + } + + public int offsetByCodePoints(int index, int codePointOffset) { + _assumeInvariants(); + if (index < 0 || index > this.count) + throw new IndexOutOfBoundsException(); + + return Character.offsetByCodePoints(this.value, 0, this.count, index, codePointOffset); + } + + public StringBuilderImpl replace(int start, int end, String s) { + _assumeInvariants(); + _deleteChars(start, end); + if (s == null) { + _insertCharSequence(start, "null", 0, 4); + } else { + _insertCharSequence(start, s, 0, s.length()); + } + return this; + } + + public StringBuilderImpl reverse() { + _assumeInvariants(); + if (this.count == 0) + return this; + + boolean hasSurrogates = false; + int n = this.count - 1; + for (int i = (n - 1) >> 1; i > -1; i--) { + int k = n - i; + char cj = value[i]; + char ck = value[k]; + value[i] = ck; + value[k] = cj; + if (Character.isSurrogate(cj) || Character.isSurrogate(ck)) { + hasSurrogates = true; + } + } + if (!hasSurrogates) + return this; + + for (int i = 0; i < n; i++) { + char c2 = value[i]; + if (Character.isLowSurrogate(c2)) { + char c1 = value[i + 1]; + if (Character.isHighSurrogate(c1)) { + value[i] = c1; + i++; + value[i] = c2; + } + } + } + + return this; + } + + public void setCharAt(int index, char x) { + _assumeInvariants(); + if (index < 0 || index >= this.count) + throw new StringIndexOutOfBoundsException(); + + value[index] = x; + } + + public void setLength(int newLength) { + _assumeInvariants(); + int maxLength = this.value.length; + if (newLength > maxLength) + newLength = maxLength; + + if (newLength < 0) + throw new StringIndexOutOfBoundsException(); + + if (newLength < this.count) { + this.count = newLength; + return; + } + + if (newLength > this.count) { + LibSLRuntime.ArrayActions.fillRange(this.value, this.count, newLength, ((char) 0)); + this.count = newLength; + } + } + + @NotNull + public CharSequence subSequence(int start, int end) { + _assumeInvariants(); + if (start < 0 || start > end || end > this.count) + throw new StringIndexOutOfBoundsException(); + + return _asString(start, end); + } + + public String substring(int start) { + _assumeInvariants(); + if (start < 0 || start > this.count) + throw new StringIndexOutOfBoundsException(); + + return _asString(start, this.count); + } + + public String substring(int start, int end) { + _assumeInvariants(); + if (start < 0 || start > end || end > this.count) + throw new StringIndexOutOfBoundsException(); + + return _asString(start, end); + } + + @NotNull + public String toString() { + _assumeInvariants(); + return _asString(); + } + + public void trimToSize() { + _assumeInvariants(); + } +} diff --git a/approximations/src/main/java/generated/java/lang/StringImpl.java b/approximations/src/main/java/generated/java/lang/StringImpl.java new file mode 100644 index 00000000..c730a8a7 --- /dev/null +++ b/approximations/src/main/java/generated/java/lang/StringImpl.java @@ -0,0 +1,139 @@ +package generated.java.lang; + +import java.io.Serializable; +import java.lang.Object; +import java.lang.StringIndexOutOfBoundsException; + +import org.jacodb.approximation.annotation.Approximate; +import org.usvm.api.Engine; +import runtime.LibSLRuntime; + +@SuppressWarnings("unused") +@Approximate(java.lang.String.class) +public class StringImpl implements Serializable { + + @java.io.Serial + private static final long serialVersionUID = -6849794470754667710L; + + private static final int STRING_LENGTH_MAX = 50; + + public byte[] value; + + public int length; + + public StringImpl(byte[] value, int length) { + this.value = value; + this.length = length; + } + + public StringImpl() { + this(new byte[0], 0); + } + + public StringImpl(StringImpl original) { + this(original.value, original.length); + } + + public StringImpl(byte[] bytes) { + int len = bytes.length; + this.length = len; + this.value = new byte[len]; + LibSLRuntime.ArrayActions.copy(bytes, 0, this.value, 0, len); + } + + public static java.lang.String copyValueOf(char[] data) { + return LibSLRuntime.toString(data); + } + + public static java.lang.String copyValueOf(char[] data, int offset, int count) { + char[] segment = new char[count]; + LibSLRuntime.ArrayActions.copy(data, offset, segment, 0, count); + return LibSLRuntime.toString(segment); + } + + public static java.lang.String valueOf(Object x) { + return LibSLRuntime.toString(x); + } + + public static java.lang.String valueOf(boolean x) { + return LibSLRuntime.toString(x); + } + + public static java.lang.String valueOf(char x) { + return LibSLRuntime.toString(x); + } + + public static java.lang.String valueOf(char[] data) { + return LibSLRuntime.toString(data); + } + + public static java.lang.String valueOf(char[] data, int offset, int count) { + char[] segment = new char[count]; + LibSLRuntime.ArrayActions.copy(data, offset, segment, 0, count); + return LibSLRuntime.toString(segment); + } + + public static java.lang.String valueOf(double x) { + return LibSLRuntime.toString(x); + } + + public static java.lang.String valueOf(float x) { + return LibSLRuntime.toString(x); + } + + public static java.lang.String valueOf(int x) { + return LibSLRuntime.toString(x); + } + + public static java.lang.String valueOf(long x) { + return LibSLRuntime.toString(x); + } + + @SuppressWarnings("DataFlowIssue") + public StringImpl concat(StringImpl str) { + Engine.assume(this.value != null); + Engine.assume(this.value.length <= STRING_LENGTH_MAX); + Engine.assume(this.length == this.value.length); + byte[] otherVal = str.value; + int otherLen = otherVal.length; + if (otherLen == 0) + return this; + + int newLength = this.length + otherLen; + byte[] newValue = new byte[newLength]; + LibSLRuntime.ArrayActions.copy(this.value, 0, newValue, 0, this.length); + LibSLRuntime.ArrayActions.copy(otherVal, 0, newValue, this.length, otherLen); + return new StringImpl(newValue, newLength); + } + + @SuppressWarnings("DataFlowIssue") + public byte[] getBytes() { + Engine.assume(this.value != null); + Engine.assume(this.value.length <= STRING_LENGTH_MAX); + Engine.assume(this.length == this.value.length); + return this.value; + } + + @SuppressWarnings("DataFlowIssue") + public void getBytes(int srcBegin, int srcEnd, byte[] dst, int dstBegin) { + if (srcBegin < 0) + throw new StringIndexOutOfBoundsException(srcBegin); + if (this.length < srcEnd) + throw new StringIndexOutOfBoundsException(srcEnd); + int count = srcEnd - srcBegin; + if (count < 0) + throw new StringIndexOutOfBoundsException(count); + Engine.assume(this.value != null); + Engine.assume(this.value.length <= STRING_LENGTH_MAX); + Engine.assume(this.length == this.value.length); + LibSLRuntime.ArrayActions.copy(this.value, srcBegin, dst, dstBegin, count); + } + + public boolean isEmpty() { + return this.length == 0; + } + + public int length() { + return this.length; + } +} diff --git a/approximations/src/main/java/generated/java/lang/System.java b/approximations/src/main/java/generated/java/lang/System.java deleted file mode 100644 index 8f00e51a..00000000 --- a/approximations/src/main/java/generated/java/lang/System.java +++ /dev/null @@ -1,588 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/lang/System.lsl:56 -// - java/lang/System.main.lsl:33 -// -package generated.java.lang; - -import generated.runtime.LibSLGlobals; -import java.io.Console; -import java.io.InputStream; -import java.io.PrintStream; -import java.lang.IllegalArgumentException; -import java.lang.Integer; -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.SecurityException; -import java.lang.SecurityManager; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.lang.UnsatisfiedLinkError; -import java.lang.Void; -import java.util.Properties; -import jdk.internal.misc.VM; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; -import stub.libsl.utils.SymbolicInputStream; - -/** - * SystemAutomaton for LSLSystem ~> java.lang.System - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(java.lang.System.class) -public final class System implements LibSLRuntime.Automaton { - private static final LibSLRuntime.Map propsMap = new LibSLRuntime.Map<>(new LibSLRuntime.HashMapContainer<>()); - - private static volatile SecurityManager security = null; - - private static Properties props = null; - - private static Console console = null; - - public static InputStream in = null; - - public static PrintStream out = null; - - public static PrintStream err = null; - - private static final long NANOTIME_BEGINNING_OF_TIME = 1000L; - - private static final long NANOTIME_WARP_MAX = 1000L; - - private static final LibSLRuntime.Map identityHashCodeMap = new LibSLRuntime.Map<>(new LibSLRuntime.IdentityMapContainer<>()); - - static { - /* SystemAutomaton::() */ { - initPhase1(); - initPhase2(); - initPhase3(); - } - } - - @LibSLRuntime.AutomatonConstructor - public System(Void __$lsl_token, final byte p0) { - } - - @LibSLRuntime.AutomatonConstructor - public System(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Initialized); - } - - /** - * [CONSTRUCTOR] SystemAutomaton::(LSLSystem) -> void - * Source: java/lang/System.main.lsl:226 - */ - private System() { - this((Void) null); - /* body */ { - } - } - - /** - * [SUBROUTINE] SystemAutomaton::_initProperties() -> void - * Source: java/lang/System.main.lsl:97 - */ - private static void _initProperties() { - /* body */ { - final LibSLRuntime.Map pm = propsMap; - final int javaVersion = 8; - final String userName = "Admin"; - pm.set("file.encoding", "Cp1251"); - pm.set("sun.io.unicode.encoding", "UnicodeLittle"); - pm.set("sun.jnu.encoding", "Cp1251"); - pm.set("sun.stderr.encoding", "cp866"); - pm.set("sun.stdout.encoding", "cp866"); - final String[] versionStrings = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15" }; - final String versionString = versionStrings[javaVersion]; - pm.set("java.specification.name", "Java Platform API Specification"); - pm.set("java.specification.vendor", "Oracle Corporation"); - pm.set("java.specification.version", versionString); - pm.set("java.vm.info", "mixed mode"); - pm.set("java.vm.name", "OpenJDK 64-Bit Server VM"); - pm.set("java.vm.specification.name", "Java Virtual Machine Specification"); - pm.set("java.vm.specification.vendor", "Oracle Corporation"); - pm.set("java.vm.specification.version", versionString); - pm.set("java.vm.vendor", "Eclipse Adoptium"); - pm.set("java.vm.version", versionString.concat(".0.362+9")); - pm.set("java.library.path", "C:\\Program Files\\Eclipse Adoptium\\jdk-8.0.362.9-hotspot\\bin;C:\\Windows\\Sun\\Java\\bin;C:\\Windows\\system32;."); - pm.set("java.home", "C:\\Program Files\\Eclipse Adoptium\\jdk-8.0.362.9-hotspot"); - pm.set("sun.boot.library.path", "C:\\Program Files\\Eclipse Adoptium\\jdk-8.0.362.9-hotspot\\bin"); - pm.set("java.io.tmpdir", "T:\\Temp\\"); - pm.set("java.class.path", "."); - if (LibSLGlobals.SYSTEM_IS_WINDOWS) { - pm.set("file.separator", "\\"); - pm.set("line.separator", "\r\n"); - pm.set("path.separator", ";"); - } else { - pm.set("file.separator", "/"); - pm.set("line.separator", "\n"); - pm.set("path.separator", ":"); - } - pm.set("user.country", "RU"); - pm.set("user.country.format", "US"); - pm.set("user.language", "ru"); - final String[] bytecodeVersions = { "?", "?", "?", "?", "?", "49.0", "50.0", "51.0", "52.0", "53.0", "54.0", "55.0", "?", "?", "?", "?" }; - pm.set("java.class.version", bytecodeVersions[javaVersion]); - pm.set("os.arch", "amd64"); - pm.set("os.name", "Windows 10"); - pm.set("os.version", "10.0"); - pm.set("sun.arch.data.model", "64"); - pm.set("sun.cpu.endian", "little"); - pm.set("sun.cpu.isalist", "amd64"); - pm.set("sun.desktop", "windows"); - pm.set("user.dir", "D:\\Company\\Prod\\Service"); - pm.set("user.home", "C:\\Users\\".concat(userName)); - pm.set("user.name", userName); - pm.set("user.script", ""); - pm.set("user.timezone", ""); - pm.set("user.variant", ""); - pm.set("sun.java.command", "org.example.MainClass"); - pm.set("awt.toolkit", "sun.awt.windows.WToolkit"); - pm.set("java.awt.graphicsenv", "sun.awt.Win32GraphicsEnvironment"); - pm.set("java.awt.printerjob", "sun.awt.windows.WPrinterJob"); - pm.set("sun.java.launcher", "SUN_STANDARD"); - pm.set("sun.management.compiler", "HotSpot 64-Bit Tiered Compilers"); - pm.set("sun.nio.MaxDirectMemorySize", "-1"); - pm.set("sun.os.patch.level", ""); - pm.set("java.vm.compressedOopsMode", "Zero based"); - pm.set("jdk.boot.class.path.append", ""); - pm.set("jdk.debug", "release"); - props = null; - } - } - - /** - * [SUBROUTINE] SystemAutomaton::initPhase1() -> void - * Source: java/lang/System.main.lsl:541 - */ - private static void initPhase1() { - /* body */ { - _initProperties(); - final InputStream newInput = (SymbolicInputStream) ((Object) new generated.libsl.utils.SymbolicInputStream((Void) null, - /* state = */ generated.libsl.utils.SymbolicInputStream.__$lsl_States.Initialized, - /* maxSize = */ 1000, - /* supportMarks = */ false, - /* dataSize = */ -1, - /* data = */ null, - /* closed = */ false, - /* pos = */ 0, - /* markPos = */ -1, - /* markLimit = */ 0 - )); - in = newInput; - out = (stub.java.lang.System_PrintStream) ((Object) new System_PrintStream((Void) null, - /* state = */ System_PrintStream.__$lsl_States.Initialized, - /* closed = */ false, - /* error = */ false - )); - err = (stub.java.lang.System_PrintStream) ((Object) new System_PrintStream((Void) null, - /* state = */ System_PrintStream.__$lsl_States.Initialized, - /* closed = */ false, - /* error = */ false - )); - VM.initLevel(1); - } - } - - /** - * [SUBROUTINE] SystemAutomaton::initPhase2() -> int - * Source: java/lang/System.main.lsl:581 - */ - private static int initPhase2() { - int result = 0; - /* body */ { - VM.initLevel(2); - result = 0; - } - return result; - } - - /** - * [SUBROUTINE] SystemAutomaton::initPhase3() -> void - * Source: java/lang/System.main.lsl:593 - */ - private static void initPhase3() { - /* body */ { - security = null; - VM.initLevel(3); - VM.initLevel(4); - } - } - - /** - * [FUNCTION] SystemAutomaton::clearProperty(String) -> String - * Source: java/lang/System.main.lsl:240 - */ - public static String clearProperty(String key) { - String result = null; - /* body */ { - if (key == null) { - throw new NullPointerException("key can\'t be null"); - } - if (key.length() == 0) { - throw new NullPointerException("key can\'t be empty"); - } - final SecurityManager sm = security; - if (sm != null) { - sm.checkPermission(new java.util.PropertyPermission(key, "write")); - } - final LibSLRuntime.Map pm = propsMap; - if (pm.hasKey(key)) { - result = pm.get(key); - pm.remove(key); - } - } - return result; - } - - /** - * [FUNCTION] SystemAutomaton::console() -> Console - * Source: java/lang/System.main.lsl:262 - */ - public static Console console() { - Console result = null; - /* body */ { - result = console; - } - return result; - } - - /** - * [FUNCTION] SystemAutomaton::exit(int) -> void - * Source: java/lang/System.main.lsl:275 - */ - public static void exit(int status) { - /* body */ { - LibSLRuntime.error("Unexpected shutdown"); - } - } - - /** - * [FUNCTION] SystemAutomaton::gc() -> void - * Source: java/lang/System.main.lsl:282 - */ - public static void gc() { - /* body */ { - } - } - - /** - * [FUNCTION] SystemAutomaton::getProperties() -> Properties - * Source: java/lang/System.main.lsl:300 - */ - public static Properties getProperties() { - Properties result = null; - /* body */ { - final SecurityManager sm = security; - if (sm != null) { - sm.checkPropertiesAccess(); - } - result = props; - } - return result; - } - - /** - * [FUNCTION] SystemAutomaton::getProperty(String) -> String - * Source: java/lang/System.main.lsl:310 - */ - public static String getProperty(String key) { - String result = null; - /* body */ { - if (key == null) { - throw new NullPointerException("key can\'t be null"); - } - if (key.length() == 0) { - throw new NullPointerException("key can\'t be empty"); - } - final SecurityManager sm = security; - if (sm != null) { - sm.checkPropertyAccess(key); - } - final LibSLRuntime.Map pm = propsMap; - if (pm.hasKey(key)) { - result = pm.get(key); - } else { - result = null; - } - } - return result; - } - - /** - * [FUNCTION] SystemAutomaton::getProperty(String, String) -> String - * Source: java/lang/System.main.lsl:326 - */ - public static String getProperty(String key, String def) { - String result = null; - /* body */ { - if (key == null) { - throw new NullPointerException("key can\'t be null"); - } - if (key.length() == 0) { - throw new NullPointerException("key can\'t be empty"); - } - final SecurityManager sm = security; - if (sm != null) { - sm.checkPropertyAccess(key); - } - final LibSLRuntime.Map pm = propsMap; - if (pm.hasKey(key)) { - result = pm.get(key); - } else { - result = def; - } - } - return result; - } - - /** - * [FUNCTION] SystemAutomaton::getSecurityManager() -> SecurityManager - * Source: java/lang/System.main.lsl:342 - */ - public static SecurityManager getSecurityManager() { - SecurityManager result = null; - /* body */ { - result = security; - } - return result; - } - - /** - * [FUNCTION] SystemAutomaton::getenv(String) -> String - * Source: java/lang/System.main.lsl:362 - */ - public static String getenv(String name) { - String result = null; - /* body */ { - final SecurityManager sm = security; - if (sm != null) { - sm.checkPermission(new RuntimePermission("getenv.".concat(name))); - } - result = Engine.makeSymbolic(String.class); - Engine.assume(result != null); - final int len = result.length(); - Engine.assume(len >= 0); - Engine.assume(len < 250); - } - return result; - } - - /** - * [FUNCTION] SystemAutomaton::identityHashCode(Object) -> int - * Source: java/lang/System.main.lsl:379 - */ - public static int identityHashCode(Object x) { - int result = 0; - /* body */ { - if (x == null) { - result = 0; - } else { - if (identityHashCodeMap.hasKey(x)) { - final Integer value = identityHashCodeMap.get(x); - Engine.assume(value != null); - result = value.intValue(); - } else { - result = identityHashCodeMap.size(); - final Integer hash = Integer.valueOf(result); - identityHashCodeMap.set(x, hash); - } - } - } - return result; - } - - /** - * [FUNCTION] SystemAutomaton::lineSeparator() -> String - * Source: java/lang/System.main.lsl:409 - */ - public static String lineSeparator() { - String result = null; - /* body */ { - result = propsMap.get("line.separator"); - } - return result; - } - - /** - * [FUNCTION] SystemAutomaton::load(String) -> void - * Source: java/lang/System.main.lsl:415 - */ - public static void load(String filename) { - /* body */ { - if (filename == null) { - throw new NullPointerException(); - } - if (Engine.makeSymbolicBoolean()) { - throw new SecurityException(""); - } - if (Engine.makeSymbolicBoolean()) { - throw new UnsatisfiedLinkError(""); - } - } - } - - /** - * [FUNCTION] SystemAutomaton::loadLibrary(String) -> void - * Source: java/lang/System.main.lsl:426 - */ - public static void loadLibrary(String libname) { - /* body */ { - if (libname == null) { - throw new NullPointerException(); - } - if (Engine.makeSymbolicBoolean()) { - throw new SecurityException(""); - } - if (Engine.makeSymbolicBoolean()) { - throw new UnsatisfiedLinkError(""); - } - } - } - - /** - * [FUNCTION] SystemAutomaton::mapLibraryName(String) -> String - * Source: java/lang/System.main.lsl:437 - */ - public static String mapLibraryName(String libname) { - String result = null; - /* body */ { - if (libname == null) { - throw new NullPointerException(); - } - final int len = libname.length(); - if (len > 240) { - throw new IllegalArgumentException("name too long"); - } - if (LibSLGlobals.SYSTEM_IS_WINDOWS) { - result = libname.concat(".dll"); - } else { - if (LibSLGlobals.SYSTEM_IS_MAC) { - result = "lib".concat(libname).concat(".dylib"); - } else { - result = "lib".concat(libname).concat(".so"); - } - } - } - return result; - } - - /** - * [FUNCTION] SystemAutomaton::runFinalization() -> void - * Source: java/lang/System.main.lsl:463 - */ - public static void runFinalization() { - /* body */ { - } - } - - /** - * [FUNCTION] SystemAutomaton::setErr(PrintStream) -> void - * Source: java/lang/System.main.lsl:469 - */ - public static void setErr(PrintStream stream) { - /* body */ { - final SecurityManager sm = security; - if (sm != null) { - sm.checkPermission(new RuntimePermission("setIO")); - } - err = stream; - } - } - - /** - * [FUNCTION] SystemAutomaton::setIn(InputStream) -> void - * Source: java/lang/System.main.lsl:476 - */ - public static void setIn(InputStream stream) { - /* body */ { - final SecurityManager sm = security; - if (sm != null) { - sm.checkPermission(new RuntimePermission("setIO")); - } - in = stream; - } - } - - /** - * [FUNCTION] SystemAutomaton::setOut(PrintStream) -> void - * Source: java/lang/System.main.lsl:483 - */ - public static void setOut(PrintStream stream) { - /* body */ { - final SecurityManager sm = security; - if (sm != null) { - sm.checkPermission(new RuntimePermission("setIO")); - } - out = stream; - } - } - - /** - * [FUNCTION] SystemAutomaton::setProperties(Properties) -> void - * Source: java/lang/System.main.lsl:490 - */ - public static void setProperties(Properties p) { - /* body */ { - final SecurityManager sm = security; - if (sm != null) { - sm.checkPropertiesAccess(); - } - props = p; - } - } - - /** - * [FUNCTION] SystemAutomaton::setProperty(String, String) -> String - * Source: java/lang/System.main.lsl:501 - */ - public static String setProperty(String key, String value) { - String result = null; - /* body */ { - if (key == null) { - throw new NullPointerException("key can\'t be null"); - } - if (key.length() == 0) { - throw new NullPointerException("key can\'t be empty"); - } - final SecurityManager sm = security; - if (sm != null) { - sm.checkPermission(new java.util.PropertyPermission(key, "write")); - } - final LibSLRuntime.Map pm = propsMap; - if (pm.hasKey(key)) { - result = pm.get(key); - } else { - result = null; - } - pm.set(key, value); - } - return result; - } - - /** - * [FUNCTION] SystemAutomaton::setSecurityManager(SecurityManager) -> void - * Source: java/lang/System.main.lsl:523 - */ - public static void setSecurityManager(SecurityManager s) { - /* body */ { - final SecurityManager sm = security; - if (sm != null) { - sm.checkPermission(new RuntimePermission("setSecurityManager")); - } - security = s; - } - } - - public static final class __$lsl_States { - public static final byte Initialized = (byte) 0; - } - - @Approximate(System.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/lang/SystemImpl.java b/approximations/src/main/java/generated/java/lang/SystemImpl.java new file mode 100644 index 00000000..b91d594a --- /dev/null +++ b/approximations/src/main/java/generated/java/lang/SystemImpl.java @@ -0,0 +1,329 @@ +package generated.java.lang; + +import generated.libsl.utils.SymbolicInputStreamImpl; +import generated.runtime.LibSLGlobals; +import java.io.Console; +import java.io.InputStream; +import java.io.PrintStream; +import java.lang.IllegalArgumentException; +import java.lang.Integer; +import java.lang.NullPointerException; +import java.lang.Object; +import java.lang.SecurityException; +import java.lang.String; +import java.lang.UnsatisfiedLinkError; +import java.util.Properties; +import jdk.internal.misc.VM; +import org.jacodb.approximation.annotation.Approximate; +import org.usvm.api.Engine; +import runtime.LibSLRuntime; + +@SuppressWarnings({"unused", "removal"}) +@Approximate(java.lang.System.class) +public final class SystemImpl { + private static final LibSLRuntime.Map propsMap = new LibSLRuntime.Map<>(new LibSLRuntime.HashMapContainer<>()); + + private static volatile SecurityManager security = null; + + private static Properties props = null; + + @SuppressWarnings("FieldMayBeFinal") + private static Console console = null; + + public static InputStream in = null; + + public static PrintStream out = null; + + public static PrintStream err = null; + + private static final long NANOTIME_BEGINNING_OF_TIME = 1000L; + + private static final long NANOTIME_WARP_MAX = 1000L; + + private static final LibSLRuntime.Map identityHashCodeMap = new LibSLRuntime.Map<>(new LibSLRuntime.IdentityMapContainer<>()); + + static { + initPhase1(); + initPhase2(); + initPhase3(); + } + + private SystemImpl() { } + + private static void _initProperties() { + LibSLRuntime.Map pm = propsMap; + int javaVersion = 8; + String userName = "Admin"; + pm.set("file.encoding", "Cp1251"); + pm.set("sun.io.unicode.encoding", "UnicodeLittle"); + pm.set("sun.jnu.encoding", "Cp1251"); + pm.set("sun.stderr.encoding", "cp866"); + pm.set("sun.stdout.encoding", "cp866"); + String[] versionStrings = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15" }; + String versionString = versionStrings[javaVersion]; + pm.set("java.specification.name", "Java Platform API Specification"); + pm.set("java.specification.vendor", "Oracle Corporation"); + pm.set("java.specification.version", versionString); + pm.set("java.vm.info", "mixed mode"); + pm.set("java.vm.name", "OpenJDK 64-Bit Server VM"); + pm.set("java.vm.specification.name", "Java Virtual Machine Specification"); + pm.set("java.vm.specification.vendor", "Oracle Corporation"); + pm.set("java.vm.specification.version", versionString); + pm.set("java.vm.vendor", "Eclipse Adoptium"); + pm.set("java.vm.version", versionString.concat(".0.362+9")); + pm.set("java.library.path", "C:\\Program Files\\Eclipse Adoptium\\jdk-8.0.362.9-hotspot\\bin;C:\\Windows\\Sun\\Java\\bin;C:\\Windows\\system32;."); + pm.set("java.home", "C:\\Program Files\\Eclipse Adoptium\\jdk-8.0.362.9-hotspot"); + pm.set("sun.boot.library.path", "C:\\Program Files\\Eclipse Adoptium\\jdk-8.0.362.9-hotspot\\bin"); + pm.set("java.io.tmpdir", "T:\\Temp\\"); + pm.set("java.class.path", "."); + if (LibSLGlobals.SYSTEM_IS_WINDOWS) { + pm.set("file.separator", "\\"); + pm.set("line.separator", "\r\n"); + pm.set("path.separator", ";"); + } else { + pm.set("file.separator", "/"); + pm.set("line.separator", "\n"); + pm.set("path.separator", ":"); + } + pm.set("user.country", "RU"); + pm.set("user.country.format", "US"); + pm.set("user.language", "ru"); + String[] bytecodeVersions = { "?", "?", "?", "?", "?", "49.0", "50.0", "51.0", "52.0", "53.0", "54.0", "55.0", "?", "?", "?", "?" }; + pm.set("java.class.version", bytecodeVersions[javaVersion]); + pm.set("os.arch", "amd64"); + pm.set("os.name", "Windows 10"); + pm.set("os.version", "10.0"); + pm.set("sun.arch.data.model", "64"); + pm.set("sun.cpu.endian", "little"); + pm.set("sun.cpu.isalist", "amd64"); + pm.set("sun.desktop", "windows"); + pm.set("user.dir", "D:\\Company\\Prod\\Service"); + pm.set("user.home", "C:\\Users\\".concat(userName)); + pm.set("user.name", userName); + pm.set("user.script", ""); + pm.set("user.timezone", ""); + pm.set("user.variant", ""); + pm.set("sun.java.command", "org.example.MainClass"); + pm.set("awt.toolkit", "sun.awt.windows.WToolkit"); + pm.set("java.awt.graphicsenv", "sun.awt.Win32GraphicsEnvironment"); + pm.set("java.awt.printerjob", "sun.awt.windows.WPrinterJob"); + pm.set("sun.java.launcher", "SUN_STANDARD"); + pm.set("sun.management.compiler", "HotSpot 64-Bit Tiered Compilers"); + pm.set("sun.nio.MaxDirectMemorySize", "-1"); + pm.set("sun.os.patch.level", ""); + pm.set("java.vm.compressedOopsMode", "Zero based"); + pm.set("jdk.boot.class.path.append", ""); + pm.set("jdk.debug", "release"); + props = null; + } + + @SuppressWarnings("DataFlowIssue") + private static void initPhase1() { + _initProperties(); + in = new SymbolicInputStreamImpl(1000, false, -1, null, false, 0, -1, 0); + out = (PrintStream) (Object) new System_PrintStreamImpl(false, false); + err = (PrintStream) (Object) new System_PrintStreamImpl(false, false); + VM.initLevel(1); + } + + @SuppressWarnings("UnusedReturnValue") + private static int initPhase2() { + VM.initLevel(2); + return 0; + } + + private static void initPhase3() { + security = null; + VM.initLevel(3); + VM.initLevel(4); + } + + private static void _checkKey(String key) { + if (key == null) + throw new NullPointerException("key can't be null"); + if (key.isEmpty()) + throw new NullPointerException("key can't be empty"); + } + + public static String clearProperty(String key) { + _checkKey(key); + SecurityManager sm = security; + if (sm != null) + sm.checkPermission(new java.util.PropertyPermission(key, "write")); + LibSLRuntime.Map pm = propsMap; + if (!pm.hasKey(key)) + return null; + + String result = pm.get(key); + pm.remove(key); + return result; + } + + public static Console console() { + return console; + } + + public static void exit(int status) { + LibSLRuntime.error("Unexpected shutdown"); + } + + public static void gc() { } + + public static Properties getProperties() { + SecurityManager sm = security; + if (sm != null) + sm.checkPropertiesAccess(); + return props; + } + + public static String getProperty(String key) { + _checkKey(key); + SecurityManager sm = security; + if (sm != null) + sm.checkPropertyAccess(key); + LibSLRuntime.Map pm = propsMap; + if (!pm.hasKey(key)) + return null; + + return pm.get(key); + } + + public static String getProperty(String key, String def) { + _checkKey(key); + SecurityManager sm = security; + if (sm != null) { + sm.checkPropertyAccess(key); + } + LibSLRuntime.Map pm = propsMap; + if (pm.hasKey(key)) + return pm.get(key); + + return def; + } + + public static SecurityManager getSecurityManager() { + return security; + } + + @SuppressWarnings({"ConstantValue", "DataFlowIssue"}) + public static String getenv(String name) { + SecurityManager sm = security; + if (sm != null) + sm.checkPermission(new RuntimePermission("getenv.".concat(name))); + String result = Engine.makeSymbolic(String.class); + Engine.assume(result != null); + int len = result.length(); + Engine.assume(len >= 0); + Engine.assume(len < 250); + return result; + } + + @SuppressWarnings("DataFlowIssue") + public static int identityHashCode(Object x) { + if (x == null) + return 0; + + if (identityHashCodeMap.hasKey(x)) { + Integer value = identityHashCodeMap.get(x); + Engine.assume(value != null); + return value; + } + + int result = identityHashCodeMap.size(); + identityHashCodeMap.set(x, result); + return result; + } + + public static String lineSeparator() { + return propsMap.get("line.separator"); + } + + @SuppressWarnings({"DuplicateCondition", "ConstantValue"}) + public static void load(String filename) { + if (filename == null) + throw new NullPointerException(); + if (Engine.makeSymbolicBoolean()) + throw new SecurityException(""); + if (Engine.makeSymbolicBoolean()) + throw new UnsatisfiedLinkError(""); + } + + @SuppressWarnings({"DuplicateCondition", "ConstantValue"}) + public static void loadLibrary(String libName) { + if (libName == null) + throw new NullPointerException(); + if (Engine.makeSymbolicBoolean()) { + throw new SecurityException(""); + } + if (Engine.makeSymbolicBoolean()) { + throw new UnsatisfiedLinkError(""); + } + } + + public static String mapLibraryName(String libName) { + if (libName == null) + throw new NullPointerException(); + + int len = libName.length(); + if (len > 240) + throw new IllegalArgumentException("name too long"); + + if (LibSLGlobals.SYSTEM_IS_WINDOWS) + return libName.concat(".dll"); + + if (LibSLGlobals.SYSTEM_IS_MAC) + return "lib".concat(libName).concat(".dylib"); + + return "lib".concat(libName).concat(".so"); + } + + public static void runFinalization() { } + + public static void setErr(PrintStream stream) { + if (security != null) + security.checkPermission(new RuntimePermission("setIO")); + err = stream; + } + + public static void setIn(InputStream stream) { + if (security != null) + security.checkPermission(new RuntimePermission("setIO")); + in = stream; + } + + public static void setOut(PrintStream stream) { + if (security != null) + security.checkPermission(new RuntimePermission("setIO")); + out = stream; + } + + public static void setProperties(Properties p) { + if (security != null) + security.checkPropertiesAccess(); + props = p; + } + + public static String setProperty(String key, String value) { + if (key == null) + throw new NullPointerException("key can't be null"); + if (key.isEmpty()) + throw new NullPointerException("key can't be empty"); + if (security != null) + security.checkPermission(new java.util.PropertyPermission(key, "write")); + LibSLRuntime.Map pm = propsMap; + String result; + if (pm.hasKey(key)) { + result = pm.get(key); + } else { + result = null; + } + pm.set(key, value); + return result; + } + + public static void setSecurityManager(SecurityManager s) { + if (security != null) + security.checkPermission(new RuntimePermission("setSecurityManager")); + security = s; + } +} diff --git a/approximations/src/main/java/generated/java/lang/System_PrintStream.java b/approximations/src/main/java/generated/java/lang/System_PrintStream.java deleted file mode 100644 index 21623644..00000000 --- a/approximations/src/main/java/generated/java/lang/System_PrintStream.java +++ /dev/null @@ -1,496 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/lang/System.lsl:83 -// - java/lang/System.StdOut.lsl:22 -// -package generated.java.lang; - -import java.io.PrintStream; -import java.lang.CharSequence; -import java.lang.IndexOutOfBoundsException; -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.String; -import java.lang.StringIndexOutOfBoundsException; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.Locale; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; - -/** - * System_PrintStreamAutomaton for System_PrintStream ~> java.lang.System_PrintStream - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(stub.java.lang.System_PrintStream.class) -public final class System_PrintStream implements LibSLRuntime.Automaton { - static { - Engine.assume(true); - } - - public boolean closed; - - public boolean error; - - @LibSLRuntime.AutomatonConstructor - public System_PrintStream(Void __$lsl_token, final byte p0, final boolean p1, - final boolean p2) { - this.closed = p1; - this.error = p2; - } - - @LibSLRuntime.AutomatonConstructor - public System_PrintStream(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Initialized, false, false); - } - - /** - * [FUNCTION] System_PrintStreamAutomaton::append(System_PrintStream, CharSequence) -> PrintStream - * Source: java/lang/System.StdOut.lsl:94 - */ - public PrintStream append(CharSequence csq) { - PrintStream result = null; - /* body */ { - if (this.closed) { - this.error = true; - } - result = ((PrintStream) ((Object) this)); - } - return result; - } - - /** - * [FUNCTION] System_PrintStreamAutomaton::append(System_PrintStream, CharSequence, int, int) -> PrintStream - * Source: java/lang/System.StdOut.lsl:102 - */ - public PrintStream append(CharSequence csq, int start, int end) { - PrintStream result = null; - /* body */ { - if (csq == null) { - csq = "null"; - } - final int size = csq.length(); - if ((start < 0) || (end >= size)) { - throw new StringIndexOutOfBoundsException(); - } - if (this.closed) { - this.error = true; - } - result = ((PrintStream) ((Object) this)); - } - return result; - } - - /** - * [FUNCTION] System_PrintStreamAutomaton::append(System_PrintStream, char) -> PrintStream - * Source: java/lang/System.StdOut.lsl:117 - */ - public PrintStream append(char c) { - PrintStream result = null; - /* body */ { - if (this.closed) { - this.error = true; - } - result = ((PrintStream) ((Object) this)); - } - return result; - } - - /** - * [FUNCTION] System_PrintStreamAutomaton::checkError(System_PrintStream) -> boolean - * Source: java/lang/System.StdOut.lsl:125 - */ - public boolean checkError() { - boolean result = false; - /* body */ { - result = this.error; - } - return result; - } - - /** - * [FUNCTION] System_PrintStreamAutomaton::close(System_PrintStream) -> void - * Source: java/lang/System.StdOut.lsl:131 - */ - public void close() { - /* body */ { - this.closed = true; - } - } - - /** - * [FUNCTION] System_PrintStreamAutomaton::flush(System_PrintStream) -> void - * Source: java/lang/System.StdOut.lsl:138 - */ - public void flush() { - /* body */ { - if (this.closed) { - this.error = true; - } - } - } - - /** - * [FUNCTION] System_PrintStreamAutomaton::format(System_PrintStream, Locale, String, array) -> PrintStream - * Source: java/lang/System.StdOut.lsl:145 - */ - public PrintStream format(Locale l, String format, Object[] args) { - PrintStream result = null; - /* body */ { - if (format == null) { - throw new NullPointerException(); - } - if (this.closed) { - this.error = true; - } - result = ((PrintStream) ((Object) this)); - } - return result; - } - - /** - * [FUNCTION] System_PrintStreamAutomaton::format(System_PrintStream, String, array) -> PrintStream - * Source: java/lang/System.StdOut.lsl:156 - */ - public PrintStream format(String format, Object[] args) { - PrintStream result = null; - /* body */ { - if (format == null) { - throw new NullPointerException(); - } - if (this.closed) { - this.error = true; - } - result = ((PrintStream) ((Object) this)); - } - return result; - } - - /** - * [FUNCTION] System_PrintStreamAutomaton::print(System_PrintStream, Object) -> void - * Source: java/lang/System.StdOut.lsl:167 - */ - public void print(Object obj) { - /* body */ { - if (this.closed) { - this.error = true; - } - } - } - - /** - * [FUNCTION] System_PrintStreamAutomaton::print(System_PrintStream, String) -> void - * Source: java/lang/System.StdOut.lsl:173 - */ - public void print(String s) { - /* body */ { - if (this.closed) { - this.error = true; - } - } - } - - /** - * [FUNCTION] System_PrintStreamAutomaton::print(System_PrintStream, boolean) -> void - * Source: java/lang/System.StdOut.lsl:179 - */ - public void print(boolean b) { - /* body */ { - if (this.closed) { - this.error = true; - } - } - } - - /** - * [FUNCTION] System_PrintStreamAutomaton::print(System_PrintStream, char) -> void - * Source: java/lang/System.StdOut.lsl:185 - */ - public void print(char c) { - /* body */ { - if (this.closed) { - this.error = true; - } - } - } - - /** - * [FUNCTION] System_PrintStreamAutomaton::print(System_PrintStream, array) -> void - * Source: java/lang/System.StdOut.lsl:191 - */ - public void print(char[] s) { - /* body */ { - if (s == null) { - throw new NullPointerException(); - } - if (this.closed) { - this.error = true; - } - } - } - - /** - * [FUNCTION] System_PrintStreamAutomaton::print(System_PrintStream, double) -> void - * Source: java/lang/System.StdOut.lsl:200 - */ - public void print(double d) { - /* body */ { - if (this.closed) { - this.error = true; - } - } - } - - /** - * [FUNCTION] System_PrintStreamAutomaton::print(System_PrintStream, float) -> void - * Source: java/lang/System.StdOut.lsl:206 - */ - public void print(float f) { - /* body */ { - if (this.closed) { - this.error = true; - } - } - } - - /** - * [FUNCTION] System_PrintStreamAutomaton::print(System_PrintStream, int) -> void - * Source: java/lang/System.StdOut.lsl:212 - */ - public void print(int i) { - /* body */ { - if (this.closed) { - this.error = true; - } - } - } - - /** - * [FUNCTION] System_PrintStreamAutomaton::print(System_PrintStream, long) -> void - * Source: java/lang/System.StdOut.lsl:218 - */ - public void print(long l) { - /* body */ { - if (this.closed) { - this.error = true; - } - } - } - - /** - * [FUNCTION] System_PrintStreamAutomaton::printf(System_PrintStream, Locale, String, array) -> PrintStream - * Source: java/lang/System.StdOut.lsl:224 - */ - public PrintStream printf(Locale l, String format, Object[] args) { - PrintStream result = null; - /* body */ { - if ((l == null) || (format == null) || (args == null)) { - throw new NullPointerException(); - } - if (this.closed) { - this.error = true; - } - result = ((PrintStream) ((Object) this)); - } - return result; - } - - /** - * [FUNCTION] System_PrintStreamAutomaton::printf(System_PrintStream, String, array) -> PrintStream - * Source: java/lang/System.StdOut.lsl:235 - */ - public PrintStream printf(String format, Object[] args) { - PrintStream result = null; - /* body */ { - if ((format == null) || (args == null)) { - throw new NullPointerException(); - } - if (this.closed) { - this.error = true; - } - result = ((PrintStream) ((Object) this)); - } - return result; - } - - /** - * [FUNCTION] System_PrintStreamAutomaton::println(System_PrintStream) -> void - * Source: java/lang/System.StdOut.lsl:246 - */ - public void println() { - /* body */ { - if (this.closed) { - this.error = true; - } - } - } - - /** - * [FUNCTION] System_PrintStreamAutomaton::println(System_PrintStream, Object) -> void - * Source: java/lang/System.StdOut.lsl:252 - */ - public void println(Object x) { - /* body */ { - if (this.closed) { - this.error = true; - } - } - } - - /** - * [FUNCTION] System_PrintStreamAutomaton::println(System_PrintStream, String) -> void - * Source: java/lang/System.StdOut.lsl:258 - */ - public void println(String x) { - /* body */ { - if (this.closed) { - this.error = true; - } - } - } - - /** - * [FUNCTION] System_PrintStreamAutomaton::println(System_PrintStream, boolean) -> void - * Source: java/lang/System.StdOut.lsl:264 - */ - public void println(boolean x) { - /* body */ { - if (this.closed) { - this.error = true; - } - } - } - - /** - * [FUNCTION] System_PrintStreamAutomaton::println(System_PrintStream, char) -> void - * Source: java/lang/System.StdOut.lsl:270 - */ - public void println(char x) { - /* body */ { - if (this.closed) { - this.error = true; - } - } - } - - /** - * [FUNCTION] System_PrintStreamAutomaton::println(System_PrintStream, array) -> void - * Source: java/lang/System.StdOut.lsl:276 - */ - public void println(char[] x) { - /* body */ { - if (x == null) { - throw new NullPointerException(); - } - if (this.closed) { - this.error = true; - } - } - } - - /** - * [FUNCTION] System_PrintStreamAutomaton::println(System_PrintStream, double) -> void - * Source: java/lang/System.StdOut.lsl:285 - */ - public void println(double x) { - /* body */ { - if (this.closed) { - this.error = true; - } - } - } - - /** - * [FUNCTION] System_PrintStreamAutomaton::println(System_PrintStream, float) -> void - * Source: java/lang/System.StdOut.lsl:291 - */ - public void println(float x) { - /* body */ { - if (this.closed) { - this.error = true; - } - } - } - - /** - * [FUNCTION] System_PrintStreamAutomaton::println(System_PrintStream, int) -> void - * Source: java/lang/System.StdOut.lsl:297 - */ - public void println(int x) { - /* body */ { - if (this.closed) { - this.error = true; - } - } - } - - /** - * [FUNCTION] System_PrintStreamAutomaton::println(System_PrintStream, long) -> void - * Source: java/lang/System.StdOut.lsl:303 - */ - public void println(long x) { - /* body */ { - if (this.closed) { - this.error = true; - } - } - } - - /** - * [FUNCTION] System_PrintStreamAutomaton::write(System_PrintStream, array) -> void - * Source: java/lang/System.StdOut.lsl:309 - */ - public void write(byte[] b) throws java.io.IOException { - /* body */ { - if (b == null) { - throw new NullPointerException(); - } - if (this.closed) { - this.error = true; - } - } - } - - /** - * [FUNCTION] System_PrintStreamAutomaton::write(System_PrintStream, array, int, int) -> void - * Source: java/lang/System.StdOut.lsl:320 - */ - public void write(byte[] buf, int off, int len) { - /* body */ { - if (buf == null) { - throw new NullPointerException(); - } - final int size = buf.length; - if ((off < 0) || ((off + len) > size)) { - throw new IndexOutOfBoundsException(); - } - if (this.closed) { - this.error = true; - } - } - } - - /** - * [FUNCTION] System_PrintStreamAutomaton::write(System_PrintStream, int) -> void - * Source: java/lang/System.StdOut.lsl:333 - */ - public void write(int b) { - /* body */ { - if (this.closed) { - this.error = true; - } - } - } - - public static final class __$lsl_States { - public static final byte Initialized = (byte) 0; - } - - @Approximate(System_PrintStream.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/lang/System_PrintStreamImpl.java b/approximations/src/main/java/generated/java/lang/System_PrintStreamImpl.java new file mode 100644 index 00000000..fe4ce756 --- /dev/null +++ b/approximations/src/main/java/generated/java/lang/System_PrintStreamImpl.java @@ -0,0 +1,204 @@ +package generated.java.lang; + +import java.io.PrintStream; +import java.lang.CharSequence; +import java.lang.IndexOutOfBoundsException; +import java.lang.NullPointerException; +import java.lang.Object; +import java.lang.String; +import java.lang.StringIndexOutOfBoundsException; +import java.util.Locale; + +import generated.libsl.utils.VoidOutputStreamImpl; +import org.jacodb.approximation.annotation.Approximate; +import org.jetbrains.annotations.NotNull; +import stub.java.lang.System_PrintStream; + +@Approximate(System_PrintStream.class) +public final class System_PrintStreamImpl { + + public boolean closed; + + public boolean error; + + public System_PrintStreamImpl(boolean closed, boolean error) { + this.closed = closed; + this.error = error; + } + + private void _checkClosed() { + if (this.closed) + this.error = true; + } + + public System_PrintStreamImpl append(CharSequence csq) { + _checkClosed(); + return this; + } + + public System_PrintStreamImpl append(CharSequence csq, int start, int end) { + if (csq == null) + csq = "null"; + int size = csq.length(); + if (start < 0 || end >= size) + throw new StringIndexOutOfBoundsException(); + _checkClosed(); + + return this; + } + + public System_PrintStreamImpl append(char c) { + _checkClosed(); + return this; + } + + public boolean checkError() { + return this.error; + } + + public void close() { + this.closed = true; + } + + public void flush() { + _checkClosed(); + } + + @SuppressWarnings("ConstantValue") + public System_PrintStreamImpl format(Locale l, @NotNull String format, Object... args) { + if (format == null) + throw new NullPointerException(); + _checkClosed(); + + return this; + } + + @SuppressWarnings("ConstantValue") + public System_PrintStreamImpl format(@NotNull String format, Object... args) { + if (format == null) + throw new NullPointerException(); + _checkClosed(); + + return this; + } + + public void print(Object obj) { + _checkClosed(); + } + + public void print(String s) { + _checkClosed(); + } + + public void print(boolean b) { + _checkClosed(); + } + + public void print(char c) { + _checkClosed(); + } + + @SuppressWarnings("ConstantValue") + public void print(@NotNull char[] s) { + if (s == null) + throw new NullPointerException(); + _checkClosed(); + } + + public void print(double d) { + _checkClosed(); + } + + public void print(float f) { + _checkClosed(); + } + + public void print(int i) { + _checkClosed(); + } + + public void print(long l) { + _checkClosed(); + } + + @SuppressWarnings("ConstantValue") + public System_PrintStreamImpl printf(Locale l, @NotNull String format, Object... args) { + if (l == null || format == null || args == null) + throw new NullPointerException(); + _checkClosed(); + + return this; + } + + @SuppressWarnings("ConstantValue") + public System_PrintStreamImpl printf(@NotNull String format, Object... args) { + if (format == null || args == null) + throw new NullPointerException(); + _checkClosed(); + return this; + } + + public void println() { + _checkClosed(); + } + + public void println(Object x) { + _checkClosed(); + } + + public void println(String x) { + _checkClosed(); + } + + public void println(boolean x) { + _checkClosed(); + } + + public void println(char x) { + _checkClosed(); + } + + @SuppressWarnings("ConstantValue") + public void println(@NotNull char[] x) { + if (x == null) + throw new NullPointerException(); + _checkClosed(); + } + + public void println(double x) { + _checkClosed(); + } + + public void println(float x) { + _checkClosed(); + } + + public void println(int x) { + _checkClosed(); + } + + public void println(long x) { + _checkClosed(); + } + + @SuppressWarnings("RedundantThrows") + public void write(byte[] b) throws java.io.IOException { + if (b == null) + throw new NullPointerException(); + _checkClosed(); + } + + @SuppressWarnings("ConstantValue") + public void write(@NotNull byte[] buf, int off, int len) { + if (buf == null) + throw new NullPointerException(); + int size = buf.length; + if (off < 0 || off + len > size) + throw new IndexOutOfBoundsException(); + _checkClosed(); + } + + public void write(int b) { + _checkClosed(); + } +} diff --git a/approximations/src/main/java/generated/java/lang/ThreadLocalImpl.java b/approximations/src/main/java/generated/java/lang/ThreadLocalImpl.java new file mode 100644 index 00000000..2fe224f8 --- /dev/null +++ b/approximations/src/main/java/generated/java/lang/ThreadLocalImpl.java @@ -0,0 +1,28 @@ +package generated.java.lang; + +import org.jacodb.approximation.annotation.Approximate; + +import java.util.function.Supplier; + +@Approximate(java.lang.ThreadLocal.class) +public class ThreadLocalImpl { + private T storage = null; + + public static ThreadLocal withInitial(Supplier supplier) { + ThreadLocal local = new ThreadLocal(); + local.set(supplier.get()); + return local; + } + + public T get() { + return storage; + } + + public void set(T value) { + storage = value; + } + + public void remove() { + storage = null; + } +} diff --git a/approximations/src/main/java/generated/java/lang/Throwable.java b/approximations/src/main/java/generated/java/lang/Throwable.java deleted file mode 100644 index e27eddbe..00000000 --- a/approximations/src/main/java/generated/java/lang/Throwable.java +++ /dev/null @@ -1,125 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/lang/Throwable.lsl:25 -// - java/lang/Throwable.main.lsl:20 -// -package generated.java.lang; - -import java.io.Serializable; -import java.lang.StackTraceElement; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.lang.Void; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; - -/** - * ThrowableAutomaton for LSLThrowable ~> java.lang.Throwable - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(java.lang.Throwable.class) -public class Throwable implements LibSLRuntime.Automaton, Serializable { - private static final long serialVersionUID = -3042686055658047285L; - - private static final String NULL_CAUSE_MESSAGE = "Cannot suppress a null exception."; - - private static final String SELF_SUPPRESSION_MESSAGE = "Self-suppression not permitted"; - - private static final String CAUSE_CAPTION = "Caused by: "; - - private static final String SUPPRESSED_CAPTION = "Suppressed: "; - - static { - Engine.assume(true); - } - - @LibSLRuntime.AutomatonConstructor - public Throwable(Void __$lsl_token, final byte p0) { - } - - @LibSLRuntime.AutomatonConstructor - public Throwable(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Initialized); - } - - /** - * [FUNCTION] ThrowableAutomaton::addSuppressed(LSLThrowable, Throwable) -> void - * Source: java/lang/Throwable.main.lsl:100 - */ - public final synchronized void addSuppressed(java.lang.Throwable exception) { - /* body */ { - } - } - - /** - * [FUNCTION] ThrowableAutomaton::fillInStackTrace(LSLThrowable) -> Throwable - * Source: java/lang/Throwable.main.lsl:106 - */ - public synchronized java.lang.Throwable fillInStackTrace() { - java.lang.Throwable result = null; - /* body */ { - result = Engine.makeSymbolic(java.lang.Throwable.class); - } - return result; - } - - /** - * [FUNCTION] ThrowableAutomaton::getStackTrace(LSLThrowable) -> array - * Source: java/lang/Throwable.main.lsl:133 - */ - public StackTraceElement[] getStackTrace() { - StackTraceElement[] result = null; - /* body */ { - final int size = Engine.makeSymbolicInt(); - Engine.assume(size >= 0); - Engine.assume(size < 99); - result = Engine.makeSymbolicArray(StackTraceElement.class, size); - } - return result; - } - - /** - * [FUNCTION] ThrowableAutomaton::getSuppressed(LSLThrowable) -> array - * Source: java/lang/Throwable.main.lsl:143 - */ - public final synchronized java.lang.Throwable[] getSuppressed() { - java.lang.Throwable[] result = null; - /* body */ { - final int size = Engine.makeSymbolicInt(); - Engine.assume(size >= 0); - Engine.assume(size < 99); - result = Engine.makeSymbolicArray(java.lang.Throwable.class, size); - } - return result; - } - - /** - * [FUNCTION] ThrowableAutomaton::printStackTrace(LSLThrowable) -> void - * Source: java/lang/Throwable.main.lsl:160 - */ - public void printStackTrace() { - /* body */ { - } - } - - /** - * [FUNCTION] ThrowableAutomaton::setStackTrace(LSLThrowable, array) -> void - * Source: java/lang/Throwable.main.lsl:180 - */ - public void setStackTrace(StackTraceElement[] stackTrace) { - /* body */ { - } - } - - public static final class __$lsl_States { - public static final byte Initialized = (byte) 0; - } - - @Approximate(Throwable.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/lang/ThrowableImpl.java b/approximations/src/main/java/generated/java/lang/ThrowableImpl.java new file mode 100644 index 00000000..58bea77f --- /dev/null +++ b/approximations/src/main/java/generated/java/lang/ThrowableImpl.java @@ -0,0 +1,53 @@ +package generated.java.lang; + +import java.io.Serial; +import java.io.Serializable; +import java.lang.StackTraceElement; +import java.lang.String; + +import org.jacodb.approximation.annotation.Approximate; +import org.usvm.api.Engine; + +@SuppressWarnings("unused") +@Approximate(java.lang.Throwable.class) +public class ThrowableImpl implements Serializable { + + @Serial + private static final long serialVersionUID = -3042686055658047285L; + + private static final String NULL_CAUSE_MESSAGE = "Cannot suppress a null exception."; + + private static final String SELF_SUPPRESSION_MESSAGE = "Self-suppression not permitted"; + + private static final String CAUSE_CAPTION = "Caused by: "; + + private static final String SUPPRESSED_CAPTION = "Suppressed: "; + + static { + Engine.assume(true); + } + + public final synchronized void addSuppressed(java.lang.Throwable exception) { } + + public synchronized java.lang.Throwable fillInStackTrace() { + return Engine.makeSymbolic(java.lang.Throwable.class); + } + + public StackTraceElement[] getStackTrace() { + int size = Engine.makeSymbolicInt(); + Engine.assume(size >= 0); + Engine.assume(size < 99); + return Engine.makeSymbolicArray(StackTraceElement.class, size); + } + + public final synchronized java.lang.Throwable[] getSuppressed() { + int size = Engine.makeSymbolicInt(); + Engine.assume(size >= 0); + Engine.assume(size < 99); + return Engine.makeSymbolicArray(java.lang.Throwable.class, size); + } + + public void printStackTrace() { } + + public void setStackTrace(StackTraceElement[] stackTrace) { } +} diff --git a/approximations/src/main/java/generated/java/security/SecureRandom.java b/approximations/src/main/java/generated/java/security/SecureRandom.java deleted file mode 100644 index 0ff09e8e..00000000 --- a/approximations/src/main/java/generated/java/security/SecureRandom.java +++ /dev/null @@ -1,840 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/security/SecureRandom.lsl:24 -// - java/security/SecureRandom.main.lsl:25 -// -package generated.java.security; - -import generated.runtime.LibSLGlobals; -import java.lang.IllegalArgumentException; -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; -import java.security.Provider; -import java.security.SecureRandomSpi; -import java.security.Security; -import java.util.stream.DoubleStream; -import java.util.stream.IntStream; -import java.util.stream.LongStream; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; -import stub.java.util.stream.DoubleStreamLSL; -import stub.java.util.stream.IntStreamLSL; -import stub.java.util.stream.LongStreamLSL; - -/** - * SecureRandomAutomaton for SecureRandomLSL ~> java.security.SecureRandom - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(java.security.SecureRandom.class) -public class SecureRandom implements LibSLRuntime.Automaton { - private static final long serialVersionUID = 4940670005562187L; - - private static final LibSLRuntime.Map defaultProvidersMap = new LibSLRuntime.Map<>(new LibSLRuntime.HashMapContainer<>()); - - static { - /* SecureRandomAutomaton::() */ { - final LibSLRuntime.Map dpMap = defaultProvidersMap; - final Object o = LibSLGlobals.SOMETHING; - dpMap.set("SUN", o); - dpMap.set("SunRsaSign", o); - dpMap.set("SunJSSE", o); - dpMap.set("SunJCE", o); - dpMap.set("Apple", o); - dpMap.set("JdkLDAP", o); - dpMap.set("SunJGSS", o); - dpMap.set("SunSASL", o); - dpMap.set("SunPCSC", o); - dpMap.set("XMLDSig", o); - dpMap.set("SunPKCS11", o); - dpMap.set("SunEC", o); - dpMap.set("SunMSCAPI", o); - dpMap.set("OracleUcrypto", o); - dpMap.set("JdkSASL", o); - } - } - - private byte __$lsl_state = __$lsl_States.Allocated; - - public Provider provider; - - public String algorithm; - - public boolean defaultProvider; - - @LibSLRuntime.AutomatonConstructor - public SecureRandom(Void __$lsl_token, final byte p0, final Provider p1, final String p2, - final boolean p3) { - this.__$lsl_state = p0; - this.provider = p1; - this.algorithm = p2; - this.defaultProvider = p3; - } - - @LibSLRuntime.AutomatonConstructor - public SecureRandom(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Allocated, null, null, false); - } - - /** - * [CONSTRUCTOR] SecureRandomAutomaton::(SecureRandom) -> void - * Source: java/security/SecureRandom.main.lsl:218 - */ - public SecureRandom() { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - _getDefaultPRNG(); - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [CONSTRUCTOR] SecureRandomAutomaton::(SecureRandom, SecureRandomSpi, Provider) -> void - * Source: java/security/SecureRandom.main.lsl:224 - */ - protected SecureRandom(SecureRandomSpi secureRandomSpi, Provider provider) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - LibSLRuntime.error("Protected constructor call"); - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [CONSTRUCTOR] SecureRandomAutomaton::(SecureRandom, SecureRandomSpi, Provider, String) -> void - * Source: java/security/SecureRandom.main.lsl:230 - */ - private SecureRandom(SecureRandomSpi secureRandomSpi, Provider provider, String algorithm) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - LibSLRuntime.error("Private constructor call"); - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [CONSTRUCTOR] SecureRandomAutomaton::(SecureRandom, array) -> void - * Source: java/security/SecureRandom.main.lsl:236 - */ - public SecureRandom(byte[] seed) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - _getDefaultPRNG(); - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [SUBROUTINE] SecureRandomAutomaton::_getDefaultPRNG() -> void - * Source: java/security/SecureRandom.main.lsl:115 - */ - private void _getDefaultPRNG() { - /* body */ { - this.provider = null; - this.algorithm = "SHA1PRNG"; - this.defaultProvider = _isDefaultProvider(this.provider); - } - } - - /** - * [SUBROUTINE] SecureRandomAutomaton::_isDefaultProvider(Provider) -> boolean - * Source: java/security/SecureRandom.main.lsl:133 - */ - private static boolean _isDefaultProvider(Provider curProvider) { - boolean result = false; - /* body */ { - if (curProvider == null) { - result = false; - } else { - final String providerName = curProvider.getName(); - result = defaultProvidersMap.hasKey(providerName); - } - } - return result; - } - - /** - * [SUBROUTINE] SecureRandomAutomaton::_generateRandomIntegerArrayWithBounds(int, int, int) -> array - * Source: java/security/SecureRandom.main.lsl:147 - */ - private int[] _generateRandomIntegerArrayWithBounds(int size, int randomNumberOrigin, - int randomNumberBound) { - int[] result = null; - /* body */ { - result = Engine.makeSymbolicIntArray(size); - } - return result; - } - - /** - * [SUBROUTINE] SecureRandomAutomaton::_generateRandomLongArrayWithBounds(int, long, long) -> array - * Source: java/security/SecureRandom.main.lsl:169 - */ - private long[] _generateRandomLongArrayWithBounds(int size, long randomNumberOrigin, - long randomNumberBound) { - long[] result = null; - /* body */ { - result = Engine.makeSymbolicLongArray(size); - } - return result; - } - - /** - * [SUBROUTINE] SecureRandomAutomaton::_generateRandomDoubleArrayWithBounds(int, double, double) -> array - * Source: java/security/SecureRandom.main.lsl:191 - */ - private double[] _generateRandomDoubleArrayWithBounds(int size, double randomNumberOrigin, - double randomNumberBound) { - double[] result = null; - /* body */ { - result = Engine.makeSymbolicDoubleArray(size); - } - return result; - } - - /** - * [FUNCTION] SecureRandomAutomaton::getInstance(String) -> SecureRandom - * Source: java/security/SecureRandom.main.lsl:244 - */ - public static java.security.SecureRandom getInstance(String _algorithm) throws - java.security.NoSuchAlgorithmException { - java.security.SecureRandom result = null; - // WARNING: no state checks in static context - /* body */ { - final Provider resultProvider = Engine.makeSymbolic(Provider.class); - final String resultAlgorithm = Engine.makeSymbolic(String.class); - if (resultAlgorithm == null) { - throw new NoSuchAlgorithmException(); - } - final int resultAlgorithmLength = resultAlgorithm.length(); - Engine.assume(resultAlgorithmLength > 0); - result = (java.security.SecureRandom) ((Object) new SecureRandom((Void) null, - /* state = */ SecureRandom.__$lsl_States.Initialized, - /* provider = */ resultProvider, - /* algorithm = */ resultAlgorithm, - /* defaultProvider = */ _isDefaultProvider(resultProvider) - )); - } - // WARNING: no state transitions in static context - return result; - } - - /** - * [FUNCTION] SecureRandomAutomaton::getInstance(String, Provider) -> SecureRandom - * Source: java/security/SecureRandom.main.lsl:264 - */ - public static java.security.SecureRandom getInstance(String _algorithm, Provider provider) - throws java.security.NoSuchAlgorithmException { - java.security.SecureRandom result = null; - // WARNING: no state checks in static context - /* body */ { - if (provider == null) { - throw new IllegalArgumentException(); - } - final Provider resultProvider = Engine.makeSymbolic(Provider.class); - final String resultAlgorithm = Engine.makeSymbolic(String.class); - if (resultAlgorithm == null) { - throw new NoSuchAlgorithmException(); - } - final int resultAlgorithmLength = resultAlgorithm.length(); - Engine.assume(resultAlgorithmLength > 0); - result = (java.security.SecureRandom) ((Object) new SecureRandom((Void) null, - /* state = */ SecureRandom.__$lsl_States.Initialized, - /* provider = */ resultProvider, - /* algorithm = */ resultAlgorithm, - /* defaultProvider = */ _isDefaultProvider(resultProvider) - )); - } - // WARNING: no state transitions in static context - return result; - } - - /** - * [FUNCTION] SecureRandomAutomaton::getInstance(String, String) -> SecureRandom - * Source: java/security/SecureRandom.main.lsl:287 - */ - public static java.security.SecureRandom getInstance(String _algorithm, String providerName) - throws java.security.NoSuchAlgorithmException, java.security.NoSuchProviderException { - java.security.SecureRandom result = null; - // WARNING: no state checks in static context - /* body */ { - if ((providerName == null) || (providerName.length() == 0)) { - throw new IllegalArgumentException(); - } - final Provider resultProvider = Engine.makeSymbolic(Provider.class); - final String resultAlgorithm = Engine.makeSymbolic(String.class); - if (resultProvider == null) { - throw new NoSuchProviderException(); - } - if (resultAlgorithm == null) { - throw new NoSuchAlgorithmException(); - } - final int resultAlgorithmLength = resultAlgorithm.length(); - Engine.assume(resultAlgorithmLength > 0); - result = (java.security.SecureRandom) ((Object) new SecureRandom((Void) null, - /* state = */ SecureRandom.__$lsl_States.Initialized, - /* provider = */ resultProvider, - /* algorithm = */ resultAlgorithm, - /* defaultProvider = */ _isDefaultProvider(resultProvider) - )); - } - // WARNING: no state transitions in static context - return result; - } - - /** - * [FUNCTION] SecureRandomAutomaton::getInstanceStrong() -> SecureRandom - * Source: java/security/SecureRandom.main.lsl:313 - */ - public static java.security.SecureRandom getInstanceStrong() throws - java.security.NoSuchAlgorithmException { - java.security.SecureRandom result = null; - // WARNING: no state checks in static context - /* body */ { - final String property = Security.getProperty("securerandom.strongAlgorithms"); - if (property == null) { - throw new NoSuchAlgorithmException(); - } - final int propertyLength = property.length(); - if (propertyLength == 0) { - throw new NoSuchAlgorithmException(); - } - final Provider resultProvider = Engine.makeSymbolic(Provider.class); - final String resultAlgorithm = Engine.makeSymbolic(String.class); - if (resultAlgorithm == null) { - throw new NoSuchAlgorithmException(); - } - result = (java.security.SecureRandom) ((Object) new SecureRandom((Void) null, - /* state = */ SecureRandom.__$lsl_States.Initialized, - /* provider = */ resultProvider, - /* algorithm = */ resultAlgorithm, - /* defaultProvider = */ _isDefaultProvider(resultProvider) - )); - } - // WARNING: no state transitions in static context - return result; - } - - /** - * [FUNCTION] SecureRandomAutomaton::getSeed(int) -> array - * Source: java/security/SecureRandom.main.lsl:341 - */ - public static byte[] getSeed(int numBytes) { - byte[] result = null; - // WARNING: no state checks in static context - /* body */ { - if (numBytes < 0) { - throw new IllegalArgumentException(); - } - result = Engine.makeSymbolicByteArray(numBytes); - } - // WARNING: no state transitions in static context - return result; - } - - /** - * [FUNCTION] SecureRandomAutomaton::doubles(SecureRandom) -> DoubleStream - * Source: java/security/SecureRandom.main.lsl:353 - */ - public DoubleStream doubles() { - DoubleStream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = (DoubleStreamLSL) ((Object) new generated.java.util.stream.DoubleStreamLSL((Void) null, - /* state = */ generated.java.util.stream.DoubleStreamLSL.__$lsl_States.Initialized, - /* storage = */ _generateRandomDoubleArrayWithBounds(LibSLGlobals.RANDOM_STREAM_SIZE_MAX, 0, 1), - /* length = */ LibSLGlobals.RANDOM_STREAM_SIZE_MAX, - /* closeHandlers = */ Engine.makeSymbolicList(), - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - return result; - } - - /** - * [FUNCTION] SecureRandomAutomaton::doubles(SecureRandom, double, double) -> DoubleStream - * Source: java/security/SecureRandom.main.lsl:364 - */ - public DoubleStream doubles(double randomNumberOrigin, double randomNumberBound) { - DoubleStream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (randomNumberOrigin >= randomNumberBound) { - throw new IllegalArgumentException(); - } - result = (DoubleStreamLSL) ((Object) new generated.java.util.stream.DoubleStreamLSL((Void) null, - /* state = */ generated.java.util.stream.DoubleStreamLSL.__$lsl_States.Initialized, - /* storage = */ _generateRandomDoubleArrayWithBounds(LibSLGlobals.RANDOM_STREAM_SIZE_MAX, randomNumberOrigin, randomNumberBound), - /* length = */ LibSLGlobals.RANDOM_STREAM_SIZE_MAX, - /* closeHandlers = */ Engine.makeSymbolicList(), - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - return result; - } - - /** - * [FUNCTION] SecureRandomAutomaton::doubles(SecureRandom, long) -> DoubleStream - * Source: java/security/SecureRandom.main.lsl:379 - */ - public DoubleStream doubles(long streamSize) { - DoubleStream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - int size = ((int) streamSize); - if (size < 0) { - throw new IllegalArgumentException(); - } - if (size > LibSLGlobals.RANDOM_STREAM_SIZE_MAX) { - size = LibSLGlobals.RANDOM_STREAM_SIZE_MAX; - } - result = (DoubleStreamLSL) ((Object) new generated.java.util.stream.DoubleStreamLSL((Void) null, - /* state = */ generated.java.util.stream.DoubleStreamLSL.__$lsl_States.Initialized, - /* storage = */ Engine.makeSymbolicDoubleArray(size), - /* length = */ size, - /* closeHandlers = */ Engine.makeSymbolicList(), - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - return result; - } - - /** - * [FUNCTION] SecureRandomAutomaton::doubles(SecureRandom, long, double, double) -> DoubleStream - * Source: java/security/SecureRandom.main.lsl:398 - */ - public DoubleStream doubles(long streamSize, double randomNumberOrigin, - double randomNumberBound) { - DoubleStream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - int size = ((int) streamSize); - if (size < 0) { - throw new IllegalArgumentException(); - } - if (randomNumberOrigin >= randomNumberBound) { - throw new IllegalArgumentException(); - } - if (size > LibSLGlobals.RANDOM_STREAM_SIZE_MAX) { - size = LibSLGlobals.RANDOM_STREAM_SIZE_MAX; - } - result = (DoubleStreamLSL) ((Object) new generated.java.util.stream.DoubleStreamLSL((Void) null, - /* state = */ generated.java.util.stream.DoubleStreamLSL.__$lsl_States.Initialized, - /* storage = */ _generateRandomDoubleArrayWithBounds(size, randomNumberOrigin, randomNumberBound), - /* length = */ size, - /* closeHandlers = */ Engine.makeSymbolicList(), - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - return result; - } - - /** - * [FUNCTION] SecureRandomAutomaton::generateSeed(SecureRandom, int) -> array - * Source: java/security/SecureRandom.main.lsl:418 - */ - public byte[] generateSeed(int numBytes) { - byte[] result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (numBytes < 0) { - throw new IllegalArgumentException(); - } - result = Engine.makeSymbolicByteArray(numBytes); - } - return result; - } - - /** - * [FUNCTION] SecureRandomAutomaton::getAlgorithm(SecureRandom) -> String - * Source: java/security/SecureRandom.main.lsl:427 - */ - public String getAlgorithm() { - String result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.algorithm; - } - return result; - } - - /** - * [FUNCTION] SecureRandomAutomaton::getProvider(SecureRandom) -> Provider - * Source: java/security/SecureRandom.main.lsl:433 - */ - public final Provider getProvider() { - Provider result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.provider; - } - return result; - } - - /** - * [FUNCTION] SecureRandomAutomaton::ints(SecureRandom) -> IntStream - * Source: java/security/SecureRandom.main.lsl:440 - */ - public IntStream ints() { - IntStream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = (IntStreamLSL) ((Object) new generated.java.util.stream.IntStreamLSL((Void) null, - /* state = */ generated.java.util.stream.IntStreamLSL.__$lsl_States.Initialized, - /* storage = */ Engine.makeSymbolicIntArray(LibSLGlobals.RANDOM_STREAM_SIZE_MAX), - /* length = */ LibSLGlobals.RANDOM_STREAM_SIZE_MAX, - /* closeHandlers = */ Engine.makeSymbolicList(), - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - return result; - } - - /** - * [FUNCTION] SecureRandomAutomaton::ints(SecureRandom, int, int) -> IntStream - * Source: java/security/SecureRandom.main.lsl:451 - */ - public IntStream ints(int randomNumberOrigin, int randomNumberBound) { - IntStream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (randomNumberOrigin >= randomNumberBound) { - throw new IllegalArgumentException(); - } - result = (IntStreamLSL) ((Object) new generated.java.util.stream.IntStreamLSL((Void) null, - /* state = */ generated.java.util.stream.IntStreamLSL.__$lsl_States.Initialized, - /* storage = */ _generateRandomIntegerArrayWithBounds(LibSLGlobals.RANDOM_STREAM_SIZE_MAX, randomNumberOrigin, randomNumberBound), - /* length = */ LibSLGlobals.RANDOM_STREAM_SIZE_MAX, - /* closeHandlers = */ Engine.makeSymbolicList(), - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - return result; - } - - /** - * [FUNCTION] SecureRandomAutomaton::ints(SecureRandom, long) -> IntStream - * Source: java/security/SecureRandom.main.lsl:465 - */ - public IntStream ints(long streamSize) { - IntStream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - int size = ((int) streamSize); - if (size < 0) { - throw new IllegalArgumentException(); - } - if (size > LibSLGlobals.RANDOM_STREAM_SIZE_MAX) { - size = LibSLGlobals.RANDOM_STREAM_SIZE_MAX; - } - result = (IntStreamLSL) ((Object) new generated.java.util.stream.IntStreamLSL((Void) null, - /* state = */ generated.java.util.stream.IntStreamLSL.__$lsl_States.Initialized, - /* storage = */ Engine.makeSymbolicIntArray(size), - /* length = */ size, - /* closeHandlers = */ Engine.makeSymbolicList(), - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - return result; - } - - /** - * [FUNCTION] SecureRandomAutomaton::ints(SecureRandom, long, int, int) -> IntStream - * Source: java/security/SecureRandom.main.lsl:484 - */ - public IntStream ints(long streamSize, int randomNumberOrigin, int randomNumberBound) { - IntStream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - int size = ((int) streamSize); - if (size < 0) { - throw new IllegalArgumentException(); - } - if (randomNumberOrigin >= randomNumberBound) { - throw new IllegalArgumentException(); - } - if (size > LibSLGlobals.RANDOM_STREAM_SIZE_MAX) { - size = LibSLGlobals.RANDOM_STREAM_SIZE_MAX; - } - result = (IntStreamLSL) ((Object) new generated.java.util.stream.IntStreamLSL((Void) null, - /* state = */ generated.java.util.stream.IntStreamLSL.__$lsl_States.Initialized, - /* storage = */ _generateRandomIntegerArrayWithBounds(size, randomNumberOrigin, randomNumberBound), - /* length = */ size, - /* closeHandlers = */ Engine.makeSymbolicList(), - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - return result; - } - - /** - * [FUNCTION] SecureRandomAutomaton::longs(SecureRandom) -> LongStream - * Source: java/security/SecureRandom.main.lsl:505 - */ - public LongStream longs() { - LongStream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = (LongStreamLSL) ((Object) new generated.java.util.stream.LongStreamLSL((Void) null, - /* state = */ generated.java.util.stream.LongStreamLSL.__$lsl_States.Initialized, - /* storage = */ Engine.makeSymbolicLongArray(LibSLGlobals.RANDOM_STREAM_SIZE_MAX), - /* length = */ LibSLGlobals.RANDOM_STREAM_SIZE_MAX, - /* closeHandlers = */ Engine.makeSymbolicList(), - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - return result; - } - - /** - * [FUNCTION] SecureRandomAutomaton::longs(SecureRandom, long) -> LongStream - * Source: java/security/SecureRandom.main.lsl:516 - */ - public LongStream longs(long streamSize) { - LongStream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - int size = ((int) streamSize); - if (size < 0) { - throw new IllegalArgumentException(); - } - if (size > LibSLGlobals.RANDOM_STREAM_SIZE_MAX) { - size = LibSLGlobals.RANDOM_STREAM_SIZE_MAX; - } - result = (LongStreamLSL) ((Object) new generated.java.util.stream.LongStreamLSL((Void) null, - /* state = */ generated.java.util.stream.LongStreamLSL.__$lsl_States.Initialized, - /* storage = */ Engine.makeSymbolicLongArray(size), - /* length = */ size, - /* closeHandlers = */ Engine.makeSymbolicList(), - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - return result; - } - - /** - * [FUNCTION] SecureRandomAutomaton::longs(SecureRandom, long, long) -> LongStream - * Source: java/security/SecureRandom.main.lsl:535 - */ - public LongStream longs(long randomNumberOrigin, long randomNumberBound) { - LongStream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (randomNumberOrigin >= randomNumberBound) { - throw new IllegalArgumentException(); - } - result = (LongStreamLSL) ((Object) new generated.java.util.stream.LongStreamLSL((Void) null, - /* state = */ generated.java.util.stream.LongStreamLSL.__$lsl_States.Initialized, - /* storage = */ _generateRandomLongArrayWithBounds(LibSLGlobals.RANDOM_STREAM_SIZE_MAX, randomNumberOrigin, randomNumberBound), - /* length = */ LibSLGlobals.RANDOM_STREAM_SIZE_MAX, - /* closeHandlers = */ Engine.makeSymbolicList(), - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - return result; - } - - /** - * [FUNCTION] SecureRandomAutomaton::longs(SecureRandom, long, long, long) -> LongStream - * Source: java/security/SecureRandom.main.lsl:549 - */ - public LongStream longs(long streamSize, long randomNumberOrigin, long randomNumberBound) { - LongStream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - int size = ((int) streamSize); - if (size < 0) { - throw new IllegalArgumentException(); - } - if (randomNumberOrigin >= randomNumberBound) { - throw new IllegalArgumentException(); - } - if (size > LibSLGlobals.RANDOM_STREAM_SIZE_MAX) { - size = LibSLGlobals.RANDOM_STREAM_SIZE_MAX; - } - result = (LongStreamLSL) ((Object) new generated.java.util.stream.LongStreamLSL((Void) null, - /* state = */ generated.java.util.stream.LongStreamLSL.__$lsl_States.Initialized, - /* storage = */ _generateRandomLongArrayWithBounds(size, randomNumberOrigin, randomNumberBound), - /* length = */ size, - /* closeHandlers = */ Engine.makeSymbolicList(), - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - return result; - } - - /** - * [FUNCTION] SecureRandomAutomaton::nextBoolean(SecureRandom) -> boolean - * Source: java/security/SecureRandom.main.lsl:570 - */ - public boolean nextBoolean() { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = Engine.makeSymbolicBoolean(); - } - return result; - } - - /** - * [FUNCTION] SecureRandomAutomaton::nextBytes(SecureRandom, array) -> void - * Source: java/security/SecureRandom.main.lsl:576 - */ - public void nextBytes(byte[] bytes) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final int len = bytes.length; - final byte[] src = Engine.makeSymbolicByteArray(len); - LibSLRuntime.ArrayActions.copy(src, 0, bytes, 0, len); - } - } - - /** - * [FUNCTION] SecureRandomAutomaton::nextDouble(SecureRandom) -> double - * Source: java/security/SecureRandom.main.lsl:585 - */ - public double nextDouble() { - double result = 0.0d; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = Engine.makeSymbolicDouble(); - Engine.assume(0.0d <= result); - Engine.assume(result < 1.0d); - } - return result; - } - - /** - * [FUNCTION] SecureRandomAutomaton::nextFloat(SecureRandom) -> float - * Source: java/security/SecureRandom.main.lsl:595 - */ - public float nextFloat() { - float result = 0.0f; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = Engine.makeSymbolicFloat(); - Engine.assume(0.0f <= result); - Engine.assume(result < 1.0f); - } - return result; - } - - /** - * [FUNCTION] SecureRandomAutomaton::nextGaussian(SecureRandom) -> double - * Source: java/security/SecureRandom.main.lsl:605 - */ - public synchronized double nextGaussian() { - double result = 0.0d; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = Engine.makeSymbolicDouble(); - final boolean isNaN = result != result; - Engine.assume(!isNaN); - } - return result; - } - - /** - * [FUNCTION] SecureRandomAutomaton::nextInt(SecureRandom) -> int - * Source: java/security/SecureRandom.main.lsl:614 - */ - public int nextInt() { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = Engine.makeSymbolicInt(); - } - return result; - } - - /** - * [FUNCTION] SecureRandomAutomaton::nextInt(SecureRandom, int) -> int - * Source: java/security/SecureRandom.main.lsl:621 - */ - public int nextInt(int bound) { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (bound <= 0) { - throw new IllegalArgumentException(); - } - result = Engine.makeSymbolicInt(); - Engine.assume(0 <= result); - Engine.assume(result < bound); - } - return result; - } - - /** - * [FUNCTION] SecureRandomAutomaton::nextLong(SecureRandom) -> long - * Source: java/security/SecureRandom.main.lsl:634 - */ - public long nextLong() { - long result = 0L; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = Engine.makeSymbolicLong(); - } - return result; - } - - /** - * [FUNCTION] SecureRandomAutomaton::setSeed(SecureRandom, array) -> void - * Source: java/security/SecureRandom.main.lsl:640 - */ - public synchronized void setSeed(byte[] seed) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (seed == null) { - if (Engine.makeSymbolicBoolean()) { - throw new NullPointerException(); - } - } - } - } - - /** - * [FUNCTION] SecureRandomAutomaton::setSeed(SecureRandom, long) -> void - * Source: java/security/SecureRandom.main.lsl:651 - */ - public void setSeed(long seed) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(true); - } - } - - public static final class __$lsl_States { - public static final byte Allocated = (byte) 0; - - public static final byte Initialized = (byte) 1; - } - - @Approximate(SecureRandom.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/security/SecureRandomImpl.java b/approximations/src/main/java/generated/java/security/SecureRandomImpl.java new file mode 100644 index 00000000..a3b3e65b --- /dev/null +++ b/approximations/src/main/java/generated/java/security/SecureRandomImpl.java @@ -0,0 +1,258 @@ +package generated.java.security; + +import generated.java.util.RandomImpl; +import generated.runtime.LibSLGlobals; + +import java.io.Serial; +import java.io.Serializable; +import java.lang.IllegalArgumentException; +import java.lang.NullPointerException; +import java.lang.Object; +import java.lang.String; +import java.security.NoSuchAlgorithmException; +import java.security.NoSuchProviderException; +import java.security.Provider; +import java.security.SecureRandomSpi; +import java.security.Security; +import java.util.stream.DoubleStream; +import java.util.stream.IntStream; +import java.util.stream.LongStream; +import org.jacodb.approximation.annotation.Approximate; +import org.usvm.api.Engine; +import runtime.LibSLRuntime; + +@SuppressWarnings("unused") +@Approximate(java.security.SecureRandom.class) +public class SecureRandomImpl extends RandomImpl implements Serializable { + + @Serial + private static final long serialVersionUID = 4940670005562187L; + + private static final LibSLRuntime.Map defaultProvidersMap = new LibSLRuntime.Map<>(new LibSLRuntime.HashMapContainer<>()); + + static { + LibSLRuntime.Map dpMap = defaultProvidersMap; + Object o = LibSLGlobals.SOMETHING; + dpMap.set("SUN", o); + dpMap.set("SunRsaSign", o); + dpMap.set("SunJSSE", o); + dpMap.set("SunJCE", o); + dpMap.set("Apple", o); + dpMap.set("JdkLDAP", o); + dpMap.set("SunJGSS", o); + dpMap.set("SunSASL", o); + dpMap.set("SunPCSC", o); + dpMap.set("XMLDSig", o); + dpMap.set("SunPKCS11", o); + dpMap.set("SunEC", o); + dpMap.set("SunMSCAPI", o); + dpMap.set("OracleUcrypto", o); + dpMap.set("JdkSASL", o); + } + + public Provider provider; + + public String algorithm; + + public boolean defaultProvider; + + public SecureRandomImpl(Provider provider, String algorithm, boolean defaultProvider) { + this.provider = provider; + this.algorithm = algorithm; + this.defaultProvider = defaultProvider; + } + + public SecureRandomImpl() { + this(null, "SHA1PRNG", false); + } + + protected SecureRandomImpl(SecureRandomSpi secureRandomSpi, Provider provider) { + LibSLRuntime.error("Protected constructor call"); + } + + private SecureRandomImpl(SecureRandomSpi secureRandomSpi, Provider provider, String algorithm) { + LibSLRuntime.error("Private constructor call"); + } + + public SecureRandomImpl(byte[] seed) { + this(); + } + + private static boolean _isDefaultProvider(Provider curProvider) { + if (curProvider == null) + return false; + + String providerName = curProvider.getName(); + return defaultProvidersMap.hasKey(providerName); + } + + @SuppressWarnings("ConstantValue") + public static SecureRandomImpl getInstance(String _algorithm) throws NoSuchAlgorithmException { + Provider resultProvider = Engine.makeSymbolic(Provider.class); + String resultAlgorithm = Engine.makeSymbolic(String.class); + if (resultAlgorithm == null) + throw new NoSuchAlgorithmException(); + + int resultAlgorithmLength = resultAlgorithm.length(); + Engine.assume(resultAlgorithmLength > 0); + return new SecureRandomImpl(resultProvider, resultAlgorithm, _isDefaultProvider(resultProvider)); + } + + @SuppressWarnings("ConstantValue") + public static SecureRandomImpl getInstance(String _algorithm, Provider provider) throws NoSuchAlgorithmException { + if (provider == null) + throw new IllegalArgumentException(); + + // TODO: use arguments '_algorithm' and 'provider'? + Provider resultProvider = Engine.makeSymbolic(Provider.class); + String resultAlgorithm = Engine.makeSymbolic(String.class); + if (resultAlgorithm == null) + throw new NoSuchAlgorithmException(); + + int resultAlgorithmLength = resultAlgorithm.length(); + Engine.assume(resultAlgorithmLength > 0); + return new SecureRandomImpl(resultProvider, resultAlgorithm, _isDefaultProvider(resultProvider)); + } + + @SuppressWarnings("ConstantValue") + public static SecureRandomImpl getInstance(String _algorithm, String providerName) throws NoSuchAlgorithmException, NoSuchProviderException { + if (providerName == null || providerName.isEmpty()) { + throw new IllegalArgumentException(); + } + Provider resultProvider = Engine.makeSymbolic(Provider.class); + String resultAlgorithm = Engine.makeSymbolic(String.class); + if (resultProvider == null) + throw new NoSuchProviderException(); + if (resultAlgorithm == null) + throw new NoSuchAlgorithmException(); + int resultAlgorithmLength = resultAlgorithm.length(); + Engine.assume(resultAlgorithmLength > 0); + return new SecureRandomImpl(resultProvider, resultAlgorithm, _isDefaultProvider(resultProvider)); + } + + @SuppressWarnings("ConstantValue") + public static SecureRandomImpl getInstanceStrong() throws java.security.NoSuchAlgorithmException { + String property = Security.getProperty("securerandom.strongAlgorithms"); + if (property == null) + throw new NoSuchAlgorithmException(); + if (property.isEmpty()) + throw new NoSuchAlgorithmException(); + Provider resultProvider = Engine.makeSymbolic(Provider.class); + String resultAlgorithm = Engine.makeSymbolic(String.class); + if (resultAlgorithm == null) + throw new NoSuchAlgorithmException(); + + return new SecureRandomImpl(resultProvider, resultAlgorithm, _isDefaultProvider(resultProvider)); + } + + public static byte[] getSeed(int numBytes) { + if (numBytes < 0) + throw new IllegalArgumentException(); + + return Engine.makeSymbolicByteArray(numBytes); + } + + public DoubleStream doubles() { + return super.doubles(); + } + + public DoubleStream doubles(double randomNumberOrigin, double randomNumberBound) { + return super.doubles(randomNumberOrigin, randomNumberBound); + } + + public DoubleStream doubles(long streamSize) { + return super.doubles(streamSize); + } + + public DoubleStream doubles(long streamSize, double randomNumberOrigin, double randomNumberBound) { + return super.doubles(streamSize, randomNumberOrigin, randomNumberBound); + } + + public byte[] generateSeed(int numBytes) { + if (numBytes < 0) + throw new IllegalArgumentException(); + + return Engine.makeSymbolicByteArray(numBytes); + } + + public String getAlgorithm() { + return this.algorithm; + } + + public Provider getProvider() { + return this.provider; + } + + public IntStream ints() { + return super.ints(); + } + + public IntStream ints(int randomNumberOrigin, int randomNumberBound) { + return super.ints(randomNumberOrigin, randomNumberBound); + } + + public IntStream ints(long streamSize) { + return super.ints(streamSize); + } + + public IntStream ints(long streamSize, int randomNumberOrigin, int randomNumberBound) { + return super.ints(streamSize, randomNumberOrigin, randomNumberBound); + } + + public LongStream longs() { + return super.longs(); + } + + public LongStream longs(long streamSize) { + return super.longs(streamSize); + } + + public LongStream longs(long randomNumberOrigin, long randomNumberBound) { + return super.longs(randomNumberOrigin, randomNumberBound); + } + + public LongStream longs(long streamSize, long randomNumberOrigin, long randomNumberBound) { + return super.longs(streamSize, randomNumberOrigin, randomNumberBound); + } + + public boolean nextBoolean() { + return super.nextBoolean(); + } + + public void nextBytes(byte[] bytes) { + super.nextBytes(bytes); + } + + public double nextDouble() { + return super.nextDouble(); + } + + public float nextFloat() { + return super.nextFloat(); + } + + public synchronized double nextGaussian() { + return super.nextGaussian(); + } + + public int nextInt() { + return super.nextInt(); + } + + public int nextInt(int bound) { + return super.nextInt(bound); + } + + public long nextLong() { + return super.nextLong(); + } + + public synchronized void setSeed(byte[] seed) { + if (seed == null && Engine.makeSymbolicBoolean()) + throw new NullPointerException(); + } + + public void setSeed(long seed) { + super.setSeed(seed); + } +} diff --git a/approximations/src/main/java/generated/java/util/AbstractCollectionImpl.java b/approximations/src/main/java/generated/java/util/AbstractCollectionImpl.java new file mode 100644 index 00000000..6087d6e1 --- /dev/null +++ b/approximations/src/main/java/generated/java/util/AbstractCollectionImpl.java @@ -0,0 +1,62 @@ +package generated.java.util; + +import org.jacodb.approximation.annotation.Approximate; +import org.jetbrains.annotations.NotNull; +import org.usvm.api.Engine; +import runtime.LibSLRuntime; + +import java.util.Arrays; +import java.util.Collection; +import java.util.ConcurrentModificationException; +import java.util.function.IntFunction; + +@Approximate(java.util.AbstractCollection.class) +public abstract class AbstractCollectionImpl implements Collection { + + public transient int modCount; + + public AbstractCollectionImpl(int modCount) { + this.modCount = modCount; + } + + abstract protected Object[] _mapToArray(); + + protected void _checkForModification(int expectedModCount) { + if (this.modCount != expectedModCount) + throw new ConcurrentModificationException(); + } + + abstract public int size(); + + @NotNull + public Object[] toArray() { + return _mapToArray(); + } + + @SuppressWarnings("unchecked") + private T[] _toArray(T[] array, int size) { + Object[] contents = _mapToArray(); + Engine.assume(size == contents.length); + + if (array.length < size) + return (T[]) Arrays.copyOf(contents, size, array.getClass()); + + LibSLRuntime.ArrayActions.copy(contents, 0, array, 0, size); + return array; + } + + public T[] toArray(IntFunction generator) { + int size = size(); + T[] array = generator.apply(size); + + return _toArray(array, size); + } + + @NotNull + public T[] toArray(@NotNull T[] array) { + int size = size(); + return _toArray(array, size); + } + + abstract public String toString(); +} diff --git a/approximations/src/main/java/generated/java/util/AbstractIteratorImpl.java b/approximations/src/main/java/generated/java/util/AbstractIteratorImpl.java new file mode 100644 index 00000000..143f5f16 --- /dev/null +++ b/approximations/src/main/java/generated/java/util/AbstractIteratorImpl.java @@ -0,0 +1,24 @@ +package generated.java.util; + +import org.jacodb.approximation.annotation.Approximate; +import stub.java.util.AbstractIterator; + +import java.util.ConcurrentModificationException; +import java.util.Iterator; + +@Approximate(AbstractIterator.class) +public abstract class AbstractIteratorImpl implements Iterator { + + public int expectedModCount; + + public AbstractIteratorImpl(int expectedModCount) { + this.expectedModCount = expectedModCount; + } + + abstract protected int _parentModCount(); + + protected void _checkForModification() { + if (_parentModCount() != this.expectedModCount) + throw new ConcurrentModificationException(); + } +} diff --git a/approximations/src/main/java/generated/java/util/AbstractMap_SimpleEntry.java b/approximations/src/main/java/generated/java/util/AbstractMap_SimpleEntry.java deleted file mode 100644 index 65a3ead2..00000000 --- a/approximations/src/main/java/generated/java/util/AbstractMap_SimpleEntry.java +++ /dev/null @@ -1,178 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/AbstractMap.lsl:23 -// - java/util/AbstractMap.SimpleEntry.lsl:19 -// -package generated.java.util; - -import java.io.Serializable; -import java.lang.Object; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.Map; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; - -/** - * AbstractMap_SimpleEntryAutomaton for AbstractMap_SimpleEntry ~> java.util.AbstractMap_SimpleEntry - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(stub.java.util.AbstractMap_SimpleEntry.class) -public class AbstractMap_SimpleEntry implements LibSLRuntime.Automaton, Serializable, Map.Entry { - private static final long serialVersionUID = -8499721149061103585L; - - static { - Engine.assume(true); - } - - private byte __$lsl_state = __$lsl_States.Allocated; - - public Object key; - - public Object value; - - @LibSLRuntime.AutomatonConstructor - public AbstractMap_SimpleEntry(Void __$lsl_token, final byte p0, final Object p1, - final Object p2) { - this.__$lsl_state = p0; - this.key = p1; - this.value = p2; - } - - @LibSLRuntime.AutomatonConstructor - public AbstractMap_SimpleEntry(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Allocated, null, null); - } - - /** - * [CONSTRUCTOR] AbstractMap_SimpleEntryAutomaton::(AbstractMap_SimpleEntry, Map_Entry) -> void - * Source: java/util/AbstractMap.SimpleEntry.lsl:53 - */ - public AbstractMap_SimpleEntry(Map.Entry entry) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - this.key = entry.getKey(); - this.value = entry.getValue(); - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [CONSTRUCTOR] AbstractMap_SimpleEntryAutomaton::(AbstractMap_SimpleEntry, Object, Object) -> void - * Source: java/util/AbstractMap.SimpleEntry.lsl:60 - */ - public AbstractMap_SimpleEntry(Object key, Object value) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - key = key; - value = value; - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [FUNCTION] AbstractMap_SimpleEntryAutomaton::equals(AbstractMap_SimpleEntry, Object) -> boolean - * Source: java/util/AbstractMap.SimpleEntry.lsl:71 - */ - public boolean equals(Object other) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (other == this) { - result = true; - } else { - result = (other instanceof Map.Entry); - if (result) { - final Map.Entry oEntry = ((Map.Entry) other); - final Object otherKey = oEntry.getKey(); - final Object otherValue = oEntry.getValue(); - result = LibSLRuntime.equals(this.key, otherKey) && LibSLRuntime.equals(this.value, otherValue); - } - } - } - return result; - } - - /** - * [FUNCTION] AbstractMap_SimpleEntryAutomaton::getKey(AbstractMap_SimpleEntry) -> Object - * Source: java/util/AbstractMap.SimpleEntry.lsl:91 - */ - public Object getKey() { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.key; - } - return result; - } - - /** - * [FUNCTION] AbstractMap_SimpleEntryAutomaton::getValue(AbstractMap_SimpleEntry) -> Object - * Source: java/util/AbstractMap.SimpleEntry.lsl:97 - */ - public Object getValue() { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value; - } - return result; - } - - /** - * [FUNCTION] AbstractMap_SimpleEntryAutomaton::hashCode(AbstractMap_SimpleEntry) -> int - * Source: java/util/AbstractMap.SimpleEntry.lsl:103 - */ - public int hashCode() { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = LibSLRuntime.hashCode(this.key) ^ LibSLRuntime.hashCode(this.value); - } - return result; - } - - /** - * [FUNCTION] AbstractMap_SimpleEntryAutomaton::setValue(AbstractMap_SimpleEntry, Object) -> Object - * Source: java/util/AbstractMap.SimpleEntry.lsl:109 - */ - public Object setValue(Object value) { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = value; - value = value; - } - return result; - } - - /** - * [FUNCTION] AbstractMap_SimpleEntryAutomaton::toString(AbstractMap_SimpleEntry) -> String - * Source: java/util/AbstractMap.SimpleEntry.lsl:116 - */ - public String toString() { - String result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = LibSLRuntime.toString(this.key).concat("=").concat(LibSLRuntime.toString(this.value)); - } - return result; - } - - public static final class __$lsl_States { - public static final byte Allocated = (byte) 0; - - public static final byte Initialized = (byte) 1; - } - - @Approximate(AbstractMap_SimpleEntry.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/AbstractSpliteratorImpl.java b/approximations/src/main/java/generated/java/util/AbstractSpliteratorImpl.java new file mode 100644 index 00000000..9af3cd78 --- /dev/null +++ b/approximations/src/main/java/generated/java/util/AbstractSpliteratorImpl.java @@ -0,0 +1,75 @@ +package generated.java.util; + +import org.jacodb.approximation.annotation.Approximate; +import org.usvm.api.Engine; + +import java.util.ConcurrentModificationException; +import java.util.Spliterator; +import java.util.function.Consumer; + +@Approximate(java.util.Spliterators.AbstractSpliterator.class) +public abstract class AbstractSpliteratorImpl implements Spliterator { + + public int index; + + public int fence; + + public int expectedModCount; + + public AbstractSpliteratorImpl(int index, int fence, int expectedModCount) { + Engine.assume(index >= 0); + this.index = index; + this.fence = fence; + this.expectedModCount = expectedModCount; + } + + abstract protected AbstractSpliteratorImpl _create(int index, int fence); + + abstract protected int _parentModCount(); + + protected final void _eval() { + this.expectedModCount = _parentModCount(); + } + + abstract protected int _storageSize(); + + protected int _getFence() { + if (this.fence < 0) { + _eval(); + this.fence = _storageSize(); + Engine.assume(this.fence >= 0); + } + + return this.fence; + } + + protected void _checkForModification() { + if (_parentModCount() != expectedModCount) + throw new ConcurrentModificationException(); + } + + public abstract int characteristics(); + + public long estimateSize() { + return getExactSizeIfKnown(); + } + + public abstract void forEachRemaining(Consumer userAction); + + public long getExactSizeIfKnown() { + return _getFence() - this.index; + } + + public abstract boolean tryAdvance(Consumer userAction); + + public AbstractSpliteratorImpl trySplit() { + int hi = _getFence(); + int lo = this.index; + int mid = (lo + hi) >>> 1; + if (lo >= mid) + return null; + + this.index = mid; + return _create(lo, mid); + } +} diff --git a/approximations/src/main/java/generated/java/util/ArrayList.java b/approximations/src/main/java/generated/java/util/ArrayList.java deleted file mode 100644 index 3d20bbd6..00000000 --- a/approximations/src/main/java/generated/java/util/ArrayList.java +++ /dev/null @@ -1,1119 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/ArrayList.lsl:21 -// - java/util/ArrayList.main.lsl:18 -// -package generated.java.util; - -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; -import java.lang.Cloneable; -import java.lang.Comparable; -import java.lang.IllegalArgumentException; -import java.lang.IndexOutOfBoundsException; -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.Collection; -import java.util.Comparator; -import java.util.ConcurrentModificationException; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; -import java.util.RandomAccess; -import java.util.Spliterator; -import java.util.function.Consumer; -import java.util.function.IntFunction; -import java.util.function.Predicate; -import java.util.function.UnaryOperator; -import java.util.stream.Stream; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import org.usvm.api.SymbolicList; -import runtime.LibSLRuntime; -import stub.java.util.stream.StreamLSL; - -/** - * ArrayListAutomaton for ArrayList ~> java.util.ArrayList - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(java.util.ArrayList.class) -public class ArrayList implements LibSLRuntime.Automaton, List, RandomAccess, Cloneable, Serializable { - private static final long serialVersionUID = 8683452581122892189L; - - static { - Engine.assume(true); - } - - private byte __$lsl_state = __$lsl_States.Allocated; - - public SymbolicList storage; - - public transient int modCount; - - @LibSLRuntime.AutomatonConstructor - public ArrayList(Void __$lsl_token, final byte p0, final SymbolicList p1, - final int p2) { - this.__$lsl_state = p0; - this.storage = p1; - this.modCount = p2; - } - - @LibSLRuntime.AutomatonConstructor - public ArrayList(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Allocated, null, 0); - } - - /** - * [CONSTRUCTOR] ArrayListAutomaton::(ArrayList) -> void - * Source: java/util/ArrayList.main.lsl:536 - */ - public ArrayList() { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - this.storage = Engine.makeSymbolicList(); - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [CONSTRUCTOR] ArrayListAutomaton::(ArrayList, Collection) -> void - * Source: java/util/ArrayList.main.lsl:542 - */ - public ArrayList(Collection c) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - if (c == null) { - throw new NullPointerException(); - } - this.storage = Engine.makeSymbolicList(); - _addAllElements(0, c); - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [CONSTRUCTOR] ArrayListAutomaton::(ArrayList, int) -> void - * Source: java/util/ArrayList.main.lsl:553 - */ - public ArrayList(int initialCapacity) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - if (initialCapacity < 0) { - throw new IllegalArgumentException(); - } - this.storage = Engine.makeSymbolicList(); - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [SUBROUTINE] ArrayListAutomaton::_checkValidIndex(int, int) -> void - * Source: java/util/ArrayList.main.lsl:86 - */ - public void _checkValidIndex(int index, int length) { - /* body */ { - if ((index < 0) || (length <= index)) { - throw new IndexOutOfBoundsException(); - } - } - } - - /** - * [SUBROUTINE] ArrayListAutomaton::_rangeCheckForAdd(int) -> void - * Source: java/util/ArrayList.main.lsl:98 - */ - public void _rangeCheckForAdd(int index) { - /* body */ { - if ((index > this.storage.size()) || (index < 0)) { - throw new IndexOutOfBoundsException(); - } - } - } - - /** - * [SUBROUTINE] ArrayListAutomaton::_addAllElements(int, Collection) -> boolean - * Source: java/util/ArrayList.main.lsl:110 - */ - public boolean _addAllElements(int index, Collection c) { - boolean result = false; - /* body */ { - final int oldLength = this.storage.size(); - if ((c != null && c.getClass() == java.util.ArrayList.class)) { - final SymbolicList otherStorage = ((ArrayList) ((Object) c)).storage; - final int otherLength = otherStorage.size(); - Engine.assume(otherStorage != null); - Engine.assume(otherLength >= 0); - int i = 0; - for (i = 0; i < otherLength; i += 1) { - final Object item = otherStorage.get(i); - this.storage.insert(index, item); - index += 1; - } - ; - } else { - final Iterator iter = c.iterator(); - while (iter.hasNext()) { - final Object item = iter.next(); - this.storage.insert(index, item); - index += 1; - } - ; - } - result = oldLength != this.storage.size(); - if (result) { - this.modCount += 1; - } - } - return result; - } - - /** - * [SUBROUTINE] ArrayListAutomaton::_subListRangeCheck(int, int, int) -> void - * Source: java/util/ArrayList.main.lsl:160 - */ - public void _subListRangeCheck(int fromIndex, int toIndex, int size) { - /* body */ { - if (fromIndex < 0) { - throw new IndexOutOfBoundsException(); - } - if (toIndex > size) { - throw new IndexOutOfBoundsException(); - } - if (fromIndex > toIndex) { - throw new IllegalArgumentException(); - } - } - } - - /** - * [SUBROUTINE] ArrayListAutomaton::_checkForComodification(int) -> void - * Source: java/util/ArrayList.main.lsl:184 - */ - public void _checkForComodification(int expectedModCount) { - /* body */ { - if (this.modCount != expectedModCount) { - throw new ConcurrentModificationException(); - } - } - } - - /** - * [SUBROUTINE] ArrayListAutomaton::_deleteElement(int) -> Object - * Source: java/util/ArrayList.main.lsl:191 - */ - public Object _deleteElement(int index) { - Object result = null; - /* body */ { - _checkValidIndex(index, this.storage.size()); - result = this.storage.get(index); - this.storage.remove(index); - this.modCount += 1; - } - return result; - } - - /** - * [SUBROUTINE] ArrayListAutomaton::_addElement(int, Object) -> void - * Source: java/util/ArrayList.main.lsl:202 - */ - public void _addElement(int index, Object element) { - /* body */ { - _rangeCheckForAdd(index); - this.storage.insert(index, element); - this.modCount += 1; - } - } - - /** - * [SUBROUTINE] ArrayListAutomaton::_setElement(int, Object) -> Object - * Source: java/util/ArrayList.main.lsl:212 - */ - private Object _setElement(int index, Object element) { - Object result = null; - /* body */ { - _checkValidIndex(index, this.storage.size()); - result = this.storage.get(index); - this.storage.set(index, element); - } - return result; - } - - /** - * [SUBROUTINE] ArrayListAutomaton::_replaceAllRange(UnaryOperator, int, int) -> void - * Source: java/util/ArrayList.main.lsl:227 - */ - public void _replaceAllRange(UnaryOperator op, int i, int end) { - /* body */ { - final int expectedModCount = this.modCount; - while ((this.modCount == expectedModCount) && (i < end)) { - final Object oldItem = this.storage.get(i); - final Object newItem = op.apply(oldItem); - this.storage.set(i, newItem); - i += 1; - } - ; - _checkForComodification(expectedModCount); - } - } - - /** - * [SUBROUTINE] ArrayListAutomaton::_removeIf(Predicate, int, int) -> boolean - * Source: java/util/ArrayList.main.lsl:249 - */ - public boolean _removeIf(Predicate filter, int start, int end) { - boolean result = false; - /* body */ { - if (filter == null) { - throw new NullPointerException(); - } - final int oldLength = this.storage.size(); - final int expectedModCount = this.modCount; - Engine.assume(start <= end); - int i = 0; - for (i = end - 1; i > start; i += -1) { - final Object item = this.storage.get(i); - if (filter.test(item)) { - this.storage.remove(i); - } - } - ; - _checkForComodification(expectedModCount); - result = oldLength != this.storage.size(); - } - return result; - } - - /** - * [SUBROUTINE] ArrayListAutomaton::_equalsRange(List, int, int) -> boolean - * Source: java/util/ArrayList.main.lsl:278 - */ - public boolean _equalsRange(List other, int from, int to) { - boolean result = false; - /* body */ { - result = true; - int i = from; - SymbolicList otherStorage = null; - if ((other != null && other.getClass() == java.util.ArrayList.class)) { - otherStorage = ((ArrayList) ((Object) other)).storage; - result = to == otherStorage.size(); - if (result) { - while (result && (i < to)) { - final Object a = otherStorage.get(i); - final Object b = this.storage.get(i); - result = LibSLRuntime.equals(a, b); - i += 1; - } - ; - } - } else { - if ((other != null && other.getClass() == stub.java.util.ArrayList_SubList.class)) { - final ArrayList otherRoot = ((ArrayList_SubList) ((Object) other)).root; - otherStorage = ((ArrayList) ((Object) otherRoot)).storage; - result = to == ((ArrayList_SubList) ((Object) other)).length; - if (result) { - while (result && (i < to)) { - final Object a = otherStorage.get(i); - final Object b = this.storage.get(i); - result = LibSLRuntime.equals(a, b); - i += 1; - } - ; - } - } else { - final Iterator iter = other.iterator(); - while (result && (i < to) && iter.hasNext()) { - final Object a = iter.next(); - final Object b = this.storage.get(i); - result = LibSLRuntime.equals(a, b); - i += 1; - } - ; - result &= !iter.hasNext(); - } - } - } - return result; - } - - /** - * [SUBROUTINE] ArrayListAutomaton::_makeStream(boolean) -> Stream - * Source: java/util/ArrayList.main.lsl:343 - */ - private Stream _makeStream(boolean parallel) { - Stream result = null; - /* body */ { - final int count = this.storage.size(); - final Object[] items = new Object[count]; - int i = 0; - for (i = 0; i < count; i += 1) { - items[i] = this.storage.get(i); - } - ; - result = (StreamLSL) ((Object) new generated.java.util.stream.StreamLSL((Void) null, - /* state = */ generated.java.util.stream.StreamLSL.__$lsl_States.Initialized, - /* storage = */ items, - /* length = */ count, - /* closeHandlers = */ Engine.makeSymbolicList(), - /* isParallel = */ parallel, - /* linkedOrConsumed = */ false - )); - } - return result; - } - - /** - * [SUBROUTINE] ArrayListAutomaton::_batchRemove(Collection, boolean, int, int) -> boolean - * Source: java/util/ArrayList.main.lsl:370 - */ - public boolean _batchRemove(Collection c, boolean complement, int start, int end) { - boolean result = false; - /* body */ { - if (c == null) { - throw new NullPointerException(); - } - final int oldLength = this.storage.size(); - if ((oldLength == 0) || (start >= end)) { - result = false; - } else { - final int otherLength = c.size(); - if (otherLength == 0) { - if (complement) { - result = true; - this.storage = Engine.makeSymbolicList(); - this.modCount += 1; - } else { - result = false; - } - } else { - Engine.assume(otherLength > 0); - int i = 0; - start -= 1; - end -= 1; - if ((c != null && c.getClass() == java.util.ArrayList.class)) { - final SymbolicList otherStorage = ((ArrayList) ((Object) c)).storage; - Engine.assume(otherStorage != null); - for (i = end; i > start; i += -1) { - final Object item = this.storage.get(i); - if ((LibSLRuntime.ListActions.find(otherStorage, item, 0, this.storage.size()) == -1) == complement) { - _deleteElement(i); - } - } - ; - } else { - for (i = end; i > start; i += -1) { - final Object item = this.storage.get(i); - if (c.contains(item) != complement) { - _deleteElement(i); - } - } - ; - } - result = oldLength != this.storage.size(); - } - } - } - return result; - } - - /** - * [SUBROUTINE] ArrayListAutomaton::_do_sort(int, int, Comparator) -> void - * Source: java/util/ArrayList.main.lsl:443 - */ - public void _do_sort(int start, int end, Comparator c) { - /* body */ { - if (start < end) { - final int expectedModCount = this.modCount; - Engine.assume(start >= 0); - Engine.assume(end > 0); - final int outerLimit = end - 1; - int innerLimit = 0; - int i = 0; - int j = 0; - if (c == null) { - for (i = start; i < outerLimit; i += 1) { - innerLimit = (end - i) - 1; - for (j = start; j < innerLimit; j += 1) { - final int idxA = j; - final int idxB = j + 1; - final Object a = this.storage.get(idxA); - final Object b = this.storage.get(idxB); - if (((Comparable) a).compareTo(b) > 0) { - this.storage.set(idxA, b); - this.storage.set(idxB, a); - } - } - ; - } - ; - } else { - for (i = start; i < outerLimit; i += 1) { - innerLimit = (end - i) - 1; - for (j = start; j < innerLimit; j += 1) { - final int idxA = j; - final int idxB = j + 1; - final Object a = this.storage.get(idxA); - final Object b = this.storage.get(idxB); - if (c.compare(a, b) > 0) { - this.storage.set(idxA, b); - this.storage.set(idxB, a); - } - } - ; - } - ; - } - _checkForComodification(expectedModCount); - } - this.modCount += 1; - } - } - - /** - * [FUNCTION] ArrayListAutomaton::add(ArrayList, Object) -> boolean - * Source: java/util/ArrayList.main.lsl:566 - */ - public boolean add(Object e) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - this.storage.insert(this.storage.size(), e); - this.modCount += 1; - result = true; - } - return result; - } - - /** - * [FUNCTION] ArrayListAutomaton::add(ArrayList, int, Object) -> void - * Source: java/util/ArrayList.main.lsl:576 - */ - public void add(int index, Object element) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - _addElement(index, element); - } - } - - /** - * [FUNCTION] ArrayListAutomaton::addAll(ArrayList, Collection) -> boolean - * Source: java/util/ArrayList.main.lsl:582 - */ - public boolean addAll(Collection c) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = _addAllElements(this.storage.size(), c); - } - return result; - } - - /** - * [FUNCTION] ArrayListAutomaton::addAll(ArrayList, int, Collection) -> boolean - * Source: java/util/ArrayList.main.lsl:588 - */ - public boolean addAll(int index, Collection c) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - _rangeCheckForAdd(index); - result = _addAllElements(index, c); - } - return result; - } - - /** - * [FUNCTION] ArrayListAutomaton::clear(ArrayList) -> void - * Source: java/util/ArrayList.main.lsl:595 - */ - public void clear() { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - this.storage = Engine.makeSymbolicList(); - this.modCount += 1; - } - } - - /** - * [FUNCTION] ArrayListAutomaton::clone(ArrayList) -> Object - * Source: java/util/ArrayList.main.lsl:602 - */ - public Object clone() { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final SymbolicList storageCopy = Engine.makeSymbolicList(); - this.storage.copy(storageCopy, 0, 0, this.storage.size()); - result = (java.util.ArrayList) ((Object) new ArrayList((Void) null, - /* state = */ ArrayList.__$lsl_States.Initialized, - /* storage = */ storageCopy, - /* modCount = */ 0 - )); - } - return result; - } - - /** - * [FUNCTION] ArrayListAutomaton::contains(ArrayList, Object) -> boolean - * Source: java/util/ArrayList.main.lsl:613 - */ - public boolean contains(Object o) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = LibSLRuntime.ListActions.find(this.storage, o, 0, this.storage.size()) != -1; - } - return result; - } - - /** - * [FUNCTION] ArrayListAutomaton::containsAll(ArrayList, Collection) -> boolean - * Source: java/util/ArrayList.main.lsl:620 - */ - public boolean containsAll(Collection c) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = true; - if ((c != null && c.getClass() == java.util.ArrayList.class)) { - final SymbolicList otherStorage = ((ArrayList) ((Object) c)).storage; - Engine.assume(otherStorage != null); - final int otherLength = otherStorage.size(); - Engine.assume(otherLength >= 0); - int i = 0; - while (result && (i < otherLength)) { - final Object item = otherStorage.get(i); - result = LibSLRuntime.ListActions.find(this.storage, item, 0, this.storage.size()) != -1; - i += 1; - } - ; - } else { - final Iterator iter = c.iterator(); - while (result && iter.hasNext()) { - final Object item = iter.next(); - result = LibSLRuntime.ListActions.find(this.storage, item, 0, this.storage.size()) != -1; - } - ; - } - } - return result; - } - - /** - * [FUNCTION] ArrayListAutomaton::ensureCapacity(ArrayList, int) -> void - * Source: java/util/ArrayList.main.lsl:663 - */ - public void ensureCapacity(int minCapacity) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - this.modCount += 1; - } - } - - /** - * [FUNCTION] ArrayListAutomaton::equals(ArrayList, Object) -> boolean - * Source: java/util/ArrayList.main.lsl:670 - */ - public boolean equals(Object other) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (other == this) { - result = true; - } else { - if ((other != null && other.getClass() == java.util.ArrayList.class)) { - final int expectedModCount = this.modCount; - final int otherExpectedModCount = ((ArrayList) ((Object) other)).modCount; - final SymbolicList otherStorage = ((ArrayList) ((Object) other)).storage; - if (this.storage.size() == otherStorage.size()) { - result = LibSLRuntime.equals(this.storage, otherStorage); - } else { - result = false; - } - ((ArrayList) ((Object) other))._checkForComodification(otherExpectedModCount); - _checkForComodification(expectedModCount); - } else { - result = false; - } - } - } - return result; - } - - /** - * [FUNCTION] ArrayListAutomaton::forEach(ArrayList, Consumer) -> void - * Source: java/util/ArrayList.main.lsl:700 - */ - public void forEach(Consumer _action) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (_action == null) { - throw new NullPointerException(); - } - final int expectedModCount = this.modCount; - int i = 0; - while ((this.modCount == expectedModCount) && (i < this.storage.size())) { - final Object item = this.storage.get(i); - _action.accept(item); - i += 1; - } - ; - _checkForComodification(expectedModCount); - } - } - - /** - * [FUNCTION] ArrayListAutomaton::get(ArrayList, int) -> Object - * Source: java/util/ArrayList.main.lsl:725 - */ - public Object get(int index) { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - _checkValidIndex(index, this.storage.size()); - result = this.storage.get(index); - } - return result; - } - - /** - * [FUNCTION] ArrayListAutomaton::hashCode(ArrayList) -> int - * Source: java/util/ArrayList.main.lsl:733 - */ - public int hashCode() { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = LibSLRuntime.hashCode(this.storage); - } - return result; - } - - /** - * [FUNCTION] ArrayListAutomaton::indexOf(ArrayList, Object) -> int - * Source: java/util/ArrayList.main.lsl:739 - */ - public int indexOf(Object o) { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = LibSLRuntime.ListActions.find(this.storage, o, 0, this.storage.size()); - } - return result; - } - - /** - * [FUNCTION] ArrayListAutomaton::isEmpty(ArrayList) -> boolean - * Source: java/util/ArrayList.main.lsl:745 - */ - public boolean isEmpty() { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.storage.size() == 0; - } - return result; - } - - /** - * [FUNCTION] ArrayListAutomaton::iterator(ArrayList) -> Iterator - * Source: java/util/ArrayList.main.lsl:751 - */ - public Iterator iterator() { - Iterator result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = (stub.java.util.ArrayList_ListItr) ((Object) new ArrayList_ListItr((Void) null, - /* state = */ ArrayList_ListItr.__$lsl_States.Initialized, - /* parent = */ this, - /* cursor = */ 0, - /* expectedModCount = */ this.modCount, - /* lastRet = */ -1 - )); - } - return result; - } - - /** - * [FUNCTION] ArrayListAutomaton::lastIndexOf(ArrayList, Object) -> int - * Source: java/util/ArrayList.main.lsl:761 - */ - public int lastIndexOf(Object o) { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = -1; - final int size = this.storage.size(); - if (size != 0) { - Engine.assume(size > 0); - final SymbolicList items = this.storage; - int i = 0; - for (i = size - 1; i > -1; i += -1) { - final Object e = items.get(i); - if (LibSLRuntime.equals(o, e)) { - result = i; - break; - } - } - ; - } - } - return result; - } - - /** - * [FUNCTION] ArrayListAutomaton::listIterator(ArrayList) -> ListIterator - * Source: java/util/ArrayList.main.lsl:792 - */ - public ListIterator listIterator() { - ListIterator result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = (stub.java.util.ArrayList_ListItr) ((Object) new ArrayList_ListItr((Void) null, - /* state = */ ArrayList_ListItr.__$lsl_States.Initialized, - /* parent = */ this, - /* cursor = */ 0, - /* expectedModCount = */ this.modCount, - /* lastRet = */ -1 - )); - } - return result; - } - - /** - * [FUNCTION] ArrayListAutomaton::listIterator(ArrayList, int) -> ListIterator - * Source: java/util/ArrayList.main.lsl:802 - */ - public ListIterator listIterator(int index) { - ListIterator result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - _rangeCheckForAdd(index); - result = (stub.java.util.ArrayList_ListItr) ((Object) new ArrayList_ListItr((Void) null, - /* state = */ ArrayList_ListItr.__$lsl_States.Initialized, - /* parent = */ this, - /* cursor = */ index, - /* expectedModCount = */ this.modCount, - /* lastRet = */ -1 - )); - } - return result; - } - - /** - * [FUNCTION] ArrayListAutomaton::parallelStream(ArrayList) -> Stream - * Source: java/util/ArrayList.main.lsl:815 - */ - public Stream parallelStream() { - Stream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = _makeStream(true); - } - return result; - } - - /** - * [FUNCTION] ArrayListAutomaton::remove(ArrayList, Object) -> boolean - * Source: java/util/ArrayList.main.lsl:821 - */ - public boolean remove(Object o) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final int index = LibSLRuntime.ListActions.find(this.storage, o, 0, this.storage.size()); - result = index != -1; - if (result) { - _deleteElement(index); - } - } - return result; - } - - /** - * [FUNCTION] ArrayListAutomaton::remove(ArrayList, int) -> Object - * Source: java/util/ArrayList.main.lsl:830 - */ - public Object remove(int index) { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = _deleteElement(index); - } - return result; - } - - /** - * [FUNCTION] ArrayListAutomaton::removeAll(ArrayList, Collection) -> boolean - * Source: java/util/ArrayList.main.lsl:836 - */ - public boolean removeAll(Collection c) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = _batchRemove(c, false, 0, this.storage.size()); - } - return result; - } - - /** - * [FUNCTION] ArrayListAutomaton::removeIf(ArrayList, Predicate) -> boolean - * Source: java/util/ArrayList.main.lsl:842 - */ - public boolean removeIf(Predicate filter) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = _removeIf(filter, 0, this.storage.size()); - } - return result; - } - - /** - * [FUNCTION] ArrayListAutomaton::replaceAll(ArrayList, UnaryOperator) -> void - * Source: java/util/ArrayList.main.lsl:848 - */ - public void replaceAll(UnaryOperator op) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (op == null) { - throw new NullPointerException(); - } - _replaceAllRange(op, 0, this.storage.size()); - this.modCount += 1; - } - } - - /** - * [FUNCTION] ArrayListAutomaton::retainAll(ArrayList, Collection) -> boolean - * Source: java/util/ArrayList.main.lsl:858 - */ - public boolean retainAll(Collection c) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = _batchRemove(c, true, 0, this.storage.size()); - } - return result; - } - - /** - * [FUNCTION] ArrayListAutomaton::set(ArrayList, int, Object) -> Object - * Source: java/util/ArrayList.main.lsl:864 - */ - public Object set(int index, Object element) { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = _setElement(index, element); - } - return result; - } - - /** - * [FUNCTION] ArrayListAutomaton::size(ArrayList) -> int - * Source: java/util/ArrayList.main.lsl:870 - */ - public int size() { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.storage.size(); - } - return result; - } - - /** - * [FUNCTION] ArrayListAutomaton::sort(ArrayList, Comparator) -> void - * Source: java/util/ArrayList.main.lsl:876 - */ - public void sort(Comparator c) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - _do_sort(0, this.storage.size(), c); - } - } - - /** - * [FUNCTION] ArrayListAutomaton::spliterator(ArrayList) -> Spliterator - * Source: java/util/ArrayList.main.lsl:882 - */ - public Spliterator spliterator() { - Spliterator result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = (stub.java.util.ArrayList_Spliterator) ((Object) new ArrayList_Spliterator((Void) null, - /* state = */ ArrayList_Spliterator.__$lsl_States.Initialized, - /* parent = */ this, - /* index = */ 0, - /* fence = */ -1, - /* expectedModCount = */ 0 - )); - } - return result; - } - - /** - * [FUNCTION] ArrayListAutomaton::stream(ArrayList) -> Stream - * Source: java/util/ArrayList.main.lsl:891 - */ - public Stream stream() { - Stream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = _makeStream(false); - } - return result; - } - - /** - * [FUNCTION] ArrayListAutomaton::subList(ArrayList, int, int) -> List - * Source: java/util/ArrayList.main.lsl:897 - */ - public List subList(int fromIndex, int toIndex) { - List result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - _subListRangeCheck(fromIndex, toIndex, this.storage.size()); - result = (stub.java.util.ArrayList_SubList) ((Object) new ArrayList_SubList((Void) null, - /* state = */ ArrayList_SubList.__$lsl_States.Initialized, - /* root = */ this, - /* parentList = */ null, - /* offset = */ fromIndex, - /* length = */ toIndex - fromIndex, - /* modCount = */ this.modCount - )); - } - return result; - } - - /** - * [FUNCTION] ArrayListAutomaton::toArray(ArrayList) -> array - * Source: java/util/ArrayList.main.lsl:911 - */ - public Object[] toArray() { - Object[] result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final int len = this.storage.size(); - result = new Object[len]; - int i = 0; - for (i = 0; i < len; i += 1) { - result[i] = this.storage.get(i); - } - ; - } - return result; - } - - /** - * [FUNCTION] ArrayListAutomaton::toArray(ArrayList, IntFunction) -> array - * Source: java/util/ArrayList.main.lsl:931 - */ - public Object[] toArray(IntFunction generator) { - Object[] result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final Object[] a = ((Object[]) generator.apply(0)); - final int aLen = a.length; - final int len = this.storage.size(); - result = new Object[len]; - int i = 0; - for (i = 0; i < len; i += 1) { - result[i] = this.storage.get(i); - } - ; - } - return result; - } - - /** - * [FUNCTION] ArrayListAutomaton::toArray(ArrayList, array) -> array - * Source: java/util/ArrayList.main.lsl:949 - */ - public Object[] toArray(Object[] a) { - Object[] result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final int aLen = a.length; - final int len = this.storage.size(); - if (aLen < len) { - a = new Object[len]; - } - result = a; - int i = 0; - for (i = 0; i < len; i += 1) { - result[i] = this.storage.get(i); - } - ; - if (aLen > len) { - result[len] = null; - } - } - return result; - } - - /** - * [FUNCTION] ArrayListAutomaton::toString(ArrayList) -> String - * Source: java/util/ArrayList.main.lsl:972 - */ - public String toString() { - String result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = LibSLRuntime.toString(this.storage); - } - return result; - } - - /** - * [FUNCTION] ArrayListAutomaton::trimToSize(ArrayList) -> void - * Source: java/util/ArrayList.main.lsl:978 - */ - public void trimToSize() { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - this.modCount += 1; - } - } - - /** - * [FUNCTION] ArrayListAutomaton::writeObject(ArrayList, ObjectOutputStream) -> void - * Source: java/util/ArrayList.main.lsl:987 - */ - private void writeObject(ObjectOutputStream s) throws java.io.IOException { - /* body */ { - LibSLRuntime.not_implemented(/* no serialization support yet */); - } - } - - /** - * [FUNCTION] ArrayListAutomaton::readObject(ArrayList, ObjectInputStream) -> void - * Source: java/util/ArrayList.main.lsl:995 - */ - private void readObject(ObjectInputStream s) throws java.io.IOException, - java.lang.ClassNotFoundException { - /* body */ { - LibSLRuntime.not_implemented(/* no serialization support yet */); - } - } - - public static final class __$lsl_States { - public static final byte Allocated = (byte) 0; - - public static final byte Initialized = (byte) 1; - } - - @Approximate(ArrayList.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/ArrayList_ListItr.java b/approximations/src/main/java/generated/java/util/ArrayList_ListItr.java deleted file mode 100644 index f0c7655c..00000000 --- a/approximations/src/main/java/generated/java/util/ArrayList_ListItr.java +++ /dev/null @@ -1,264 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/ArrayList.lsl:36 -// - java/util/ArrayList.ListIterator.lsl:16 -// -package generated.java.util; - -import java.lang.IllegalStateException; -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.ConcurrentModificationException; -import java.util.ListIterator; -import java.util.NoSuchElementException; -import java.util.function.Consumer; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import org.usvm.api.SymbolicList; -import runtime.LibSLRuntime; - -/** - * ArrayList_ListIteratorAutomaton for ArrayList_ListIterator ~> java.util.ArrayList_ListItr - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(stub.java.util.ArrayList_ListItr.class) -public final class ArrayList_ListItr implements LibSLRuntime.Automaton, ListIterator { - static { - Engine.assume(true); - } - - public ArrayList parent; - - public int cursor; - - public int expectedModCount; - - public int lastRet; - - @LibSLRuntime.AutomatonConstructor - public ArrayList_ListItr(Void __$lsl_token, final byte p0, final ArrayList p1, final int p2, - final int p3, final int p4) { - this.parent = p1; - this.cursor = p2; - this.expectedModCount = p3; - this.lastRet = p4; - } - - @LibSLRuntime.AutomatonConstructor - public ArrayList_ListItr(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Initialized, null, 0, 0, -1); - } - - /** - * [SUBROUTINE] ArrayList_ListIteratorAutomaton::_checkForComodification() -> void - * Source: java/util/ArrayList.ListIterator.lsl:55 - */ - private void _checkForComodification() { - /* body */ { - final int modCount = ((ArrayList) ((Object) this.parent)).modCount; - if (modCount != this.expectedModCount) { - throw new ConcurrentModificationException(); - } - } - } - - /** - * [FUNCTION] ArrayList_ListIteratorAutomaton::hasPrevious(ArrayList_ListIterator) -> boolean - * Source: java/util/ArrayList.ListIterator.lsl:65 - */ - public boolean hasPrevious() { - boolean result = false; - /* body */ { - result = this.cursor != 0; - } - return result; - } - - /** - * [FUNCTION] ArrayList_ListIteratorAutomaton::nextIndex(ArrayList_ListIterator) -> int - * Source: java/util/ArrayList.ListIterator.lsl:71 - */ - public int nextIndex() { - int result = 0; - /* body */ { - result = this.cursor; - } - return result; - } - - /** - * [FUNCTION] ArrayList_ListIteratorAutomaton::previousIndex(ArrayList_ListIterator) -> int - * Source: java/util/ArrayList.ListIterator.lsl:77 - */ - public int previousIndex() { - int result = 0; - /* body */ { - result = this.cursor - 1; - } - return result; - } - - /** - * [FUNCTION] ArrayList_ListIteratorAutomaton::hasNext(ArrayList_ListIterator) -> boolean - * Source: java/util/ArrayList.ListIterator.lsl:83 - */ - public boolean hasNext() { - boolean result = false; - /* body */ { - Engine.assume(this.parent != null); - result = this.cursor != ((ArrayList) ((Object) this.parent)).storage.size(); - } - return result; - } - - /** - * [FUNCTION] ArrayList_ListIteratorAutomaton::next(ArrayList_ListIterator) -> Object - * Source: java/util/ArrayList.ListIterator.lsl:92 - */ - public Object next() { - Object result = null; - /* body */ { - Engine.assume(this.parent != null); - _checkForComodification(); - final SymbolicList parentStorage = ((ArrayList) ((Object) this.parent)).storage; - final int i = this.cursor; - if (i >= parentStorage.size()) { - throw new NoSuchElementException(); - } - this.cursor = i + 1; - this.lastRet = i; - result = parentStorage.get(i); - } - return result; - } - - /** - * [FUNCTION] ArrayList_ListIteratorAutomaton::previous(ArrayList_ListIterator) -> Object - * Source: java/util/ArrayList.ListIterator.lsl:112 - */ - public Object previous() { - Object result = null; - /* body */ { - Engine.assume(this.parent != null); - _checkForComodification(); - final SymbolicList parentStorage = ((ArrayList) ((Object) this.parent)).storage; - final int i = this.cursor - 1; - if (i < 0) { - throw new NoSuchElementException(); - } - if (i >= parentStorage.size()) { - throw new ConcurrentModificationException(); - } - this.cursor = i; - this.lastRet = i; - result = parentStorage.get(i); - } - return result; - } - - /** - * [FUNCTION] ArrayList_ListIteratorAutomaton::remove(ArrayList_ListIterator) -> void - * Source: java/util/ArrayList.ListIterator.lsl:136 - */ - public void remove() { - /* body */ { - Engine.assume(this.parent != null); - if (this.lastRet < 0) { - throw new IllegalStateException(); - } - _checkForComodification(); - final SymbolicList pStorage = ((ArrayList) ((Object) this.parent)).storage; - if (this.lastRet >= pStorage.size()) { - throw new ConcurrentModificationException(); - } else { - ((ArrayList) ((Object) this.parent)).modCount += 1; - pStorage.remove(this.lastRet); - } - this.cursor = this.lastRet; - this.lastRet = -1; - this.expectedModCount = ((ArrayList) ((Object) this.parent)).modCount; - } - } - - /** - * [FUNCTION] ArrayList_ListIteratorAutomaton::set(ArrayList_ListIterator, Object) -> void - * Source: java/util/ArrayList.ListIterator.lsl:164 - */ - public void set(Object e) { - /* body */ { - Engine.assume(this.parent != null); - if (this.lastRet < 0) { - throw new IllegalStateException(); - } - _checkForComodification(); - final SymbolicList pStorage = ((ArrayList) ((Object) this.parent)).storage; - if (this.lastRet >= pStorage.size()) { - throw new ConcurrentModificationException(); - } else { - pStorage.set(this.lastRet, e); - } - } - } - - /** - * [FUNCTION] ArrayList_ListIteratorAutomaton::add(ArrayList_ListIterator, Object) -> void - * Source: java/util/ArrayList.ListIterator.lsl:182 - */ - public void add(Object e) { - /* body */ { - Engine.assume(this.parent != null); - _checkForComodification(); - final int i = this.cursor; - final SymbolicList pStorage = ((ArrayList) ((Object) this.parent)).storage; - if (this.lastRet > pStorage.size()) { - throw new ConcurrentModificationException(); - } else { - ((ArrayList) ((Object) this.parent)).modCount += 1; - pStorage.insert(i, e); - } - this.cursor = i + 1; - this.lastRet = -1; - this.expectedModCount = ((ArrayList) ((Object) this.parent)).modCount; - } - } - - /** - * [FUNCTION] ArrayList_ListIteratorAutomaton::forEachRemaining(ArrayList_ListIterator, Consumer) -> void - * Source: java/util/ArrayList.ListIterator.lsl:209 - */ - public void forEachRemaining(Consumer userAction) { - /* body */ { - Engine.assume(this.parent != null); - if (userAction == null) { - throw new NullPointerException(); - } - int i = this.cursor; - final SymbolicList es = ((ArrayList) ((Object) this.parent)).storage; - final int size = es.size(); - if (i < size) { - while ((i < size) && (((ArrayList) ((Object) this.parent)).modCount == this.expectedModCount)) { - final Object item = es.get(i); - userAction.accept(item); - i += 1; - } - ; - this.cursor = i; - this.lastRet = i - 1; - _checkForComodification(); - } - } - } - - public static final class __$lsl_States { - public static final byte Initialized = (byte) 0; - } - - @Approximate(ArrayList_ListItr.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/ArrayList_Spliterator.java b/approximations/src/main/java/generated/java/util/ArrayList_Spliterator.java deleted file mode 100644 index 31ada83c..00000000 --- a/approximations/src/main/java/generated/java/util/ArrayList_Spliterator.java +++ /dev/null @@ -1,231 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/ArrayList.lsl:45 -// - java/util/ArrayList.Spliterator.lsl:16 -// -package generated.java.util; - -import generated.runtime.LibSLGlobals; -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.ConcurrentModificationException; -import java.util.Spliterator; -import java.util.function.Consumer; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import org.usvm.api.SymbolicList; -import runtime.LibSLRuntime; - -/** - * ArrayList_SpliteratorAutomaton for ArrayList_Spliterator ~> java.util.ArrayList_Spliterator - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(stub.java.util.ArrayList_Spliterator.class) -public final class ArrayList_Spliterator implements LibSLRuntime.Automaton, Spliterator { - static { - Engine.assume(true); - } - - private byte __$lsl_state = __$lsl_States.Allocated; - - public ArrayList parent; - - public int index; - - public int fence; - - public int expectedModCount; - - @LibSLRuntime.AutomatonConstructor - public ArrayList_Spliterator(Void __$lsl_token, final byte p0, final ArrayList p1, final int p2, - final int p3, final int p4) { - this.__$lsl_state = p0; - this.parent = p1; - this.index = p2; - this.fence = p3; - this.expectedModCount = p4; - } - - @LibSLRuntime.AutomatonConstructor - public ArrayList_Spliterator(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Allocated, null, 0, -1, 0); - } - - /** - * [CONSTRUCTOR] ArrayList_SpliteratorAutomaton::(ArrayList_Spliterator, ArrayList, int, int, int) -> void - * Source: java/util/ArrayList.Spliterator.lsl:81 - */ - private ArrayList_Spliterator(ArrayList _this, int origin, int fence, int expectedModCount) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - LibSLRuntime.not_implemented(/* inaccessible constructor */); - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [SUBROUTINE] ArrayList_SpliteratorAutomaton::_getFence() -> int - * Source: java/util/ArrayList.Spliterator.lsl:65 - */ - private int _getFence() { - int result = 0; - /* body */ { - if (this.fence == -1) { - Engine.assume(this.parent != null); - this.expectedModCount = ((ArrayList) ((Object) this.parent)).modCount; - this.fence = ((ArrayList) ((Object) this.parent)).storage.size(); - } - result = this.fence; - } - return result; - } - - /** - * [FUNCTION] ArrayList_SpliteratorAutomaton::characteristics(ArrayList_Spliterator) -> int - * Source: java/util/ArrayList.Spliterator.lsl:95 - */ - public int characteristics() { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = LibSLGlobals.SPLITERATOR_ORDERED | LibSLGlobals.SPLITERATOR_SIZED | LibSLGlobals.SPLITERATOR_SUBSIZED; - } - return result; - } - - /** - * [FUNCTION] ArrayList_SpliteratorAutomaton::estimateSize(ArrayList_Spliterator) -> long - * Source: java/util/ArrayList.Spliterator.lsl:101 - */ - public long estimateSize() { - long result = 0L; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = _getFence() - this.index; - } - return result; - } - - /** - * [FUNCTION] ArrayList_SpliteratorAutomaton::forEachRemaining(ArrayList_Spliterator, Consumer) -> void - * Source: java/util/ArrayList.Spliterator.lsl:107 - */ - public void forEachRemaining(Consumer _action) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (_action == null) { - throw new NullPointerException(); - } - Engine.assume(this.parent != null); - final SymbolicList a = ((ArrayList) ((Object) this.parent)).storage; - if (a == null) { - throw new ConcurrentModificationException(); - } - int hi = this.fence; - int mc = this.expectedModCount; - if (hi == -1) { - hi = a.size(); - mc = ((ArrayList) ((Object) this.parent)).modCount; - } - int i = this.index; - this.index = hi; - if ((i < 0) || (hi > a.size())) { - throw new ConcurrentModificationException(); - } - for (i = i; i < hi; i += 1) { - final Object item = a.get(i); - _action.accept(item); - } - ; - if (mc != ((ArrayList) ((Object) this.parent)).modCount) { - throw new ConcurrentModificationException(); - } - } - } - - /** - * [FUNCTION] ArrayList_SpliteratorAutomaton::getExactSizeIfKnown(ArrayList_Spliterator) -> long - * Source: java/util/ArrayList.Spliterator.lsl:154 - */ - public long getExactSizeIfKnown() { - long result = 0L; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = _getFence() - this.index; - } - return result; - } - - /** - * [FUNCTION] ArrayList_SpliteratorAutomaton::tryAdvance(ArrayList_Spliterator, Consumer) -> boolean - * Source: java/util/ArrayList.Spliterator.lsl:167 - */ - public boolean tryAdvance(Consumer _action) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (_action == null) { - throw new NullPointerException(); - } - final int hi = _getFence(); - final int i = this.index; - if (i < hi) { - Engine.assume(this.parent != null); - this.index = i + 1; - final SymbolicList parentStorage = ((ArrayList) ((Object) this.parent)).storage; - final Object item = parentStorage.get(i); - _action.accept(item); - if (((ArrayList) ((Object) this.parent)).modCount != this.expectedModCount) { - throw new ConcurrentModificationException(); - } - result = true; - } else { - result = false; - } - } - return result; - } - - /** - * [FUNCTION] ArrayList_SpliteratorAutomaton::trySplit(ArrayList_Spliterator) -> Spliterator - * Source: java/util/ArrayList.Spliterator.lsl:197 - */ - public Spliterator trySplit() { - Spliterator result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final int hi = _getFence(); - final int lo = this.index; - final int mid = (lo + hi) >>> 1; - if (lo >= mid) { - result = null; - } else { - result = (stub.java.util.ArrayList_Spliterator) ((Object) new ArrayList_Spliterator((Void) null, - /* state = */ ArrayList_Spliterator.__$lsl_States.Initialized, - /* parent = */ this.parent, - /* index = */ lo, - /* fence = */ mid, - /* expectedModCount = */ this.expectedModCount - )); - } - this.index = mid; - } - return result; - } - - public static final class __$lsl_States { - public static final byte Allocated = (byte) 0; - - public static final byte Initialized = (byte) 1; - } - - @Approximate(ArrayList_Spliterator.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/ArrayList_SubList$ListIterator.java b/approximations/src/main/java/generated/java/util/ArrayList_SubList$ListIterator.java deleted file mode 100644 index 315f37c4..00000000 --- a/approximations/src/main/java/generated/java/util/ArrayList_SubList$ListIterator.java +++ /dev/null @@ -1,277 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/ArrayList.lsl:75 -// - java/util/ArrayList.SubList.ListIterator.lsl:16 -// -package generated.java.util; - -import java.lang.IllegalStateException; -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.ConcurrentModificationException; -import java.util.ListIterator; -import java.util.NoSuchElementException; -import java.util.function.Consumer; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import org.usvm.api.SymbolicList; -import runtime.LibSLRuntime; - -/** - * ArrayList_SubList_ListIteratorAutomaton for ArrayList_SubList_ListIterator ~> java.util.ArrayList_SubList$ListIterator - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(stub.java.util.ArrayList_SubList$ListIterator.class) -public final class ArrayList_SubList$ListIterator implements LibSLRuntime.Automaton, ListIterator { - static { - Engine.assume(true); - } - - public ArrayList root; - - public ArrayList_SubList sublist; - - public int cursor; - - public int expectedModCount; - - public int offset; - - public int size; - - public int lastRet; - - @LibSLRuntime.AutomatonConstructor - public ArrayList_SubList$ListIterator(Void __$lsl_token, final byte p0, final ArrayList p1, - final ArrayList_SubList p2, final int p3, final int p4, final int p5, final int p6, - final int p7) { - this.root = p1; - this.sublist = p2; - this.cursor = p3; - this.expectedModCount = p4; - this.offset = p5; - this.size = p6; - this.lastRet = p7; - } - - @LibSLRuntime.AutomatonConstructor - public ArrayList_SubList$ListIterator(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Initialized, null, null, 0, 0, 0, 0, -1); - } - - /** - * [SUBROUTINE] ArrayList_SubList_ListIteratorAutomaton::_checkForComodification() -> void - * Source: java/util/ArrayList.SubList.ListIterator.lsl:58 - */ - private void _checkForComodification() { - /* body */ { - final int modCount = ((ArrayList) ((Object) this.root)).modCount; - if (modCount != this.expectedModCount) { - throw new ConcurrentModificationException(); - } - } - } - - /** - * [FUNCTION] ArrayList_SubList_ListIteratorAutomaton::hasPrevious(ArrayList_SubList_ListIterator) -> boolean - * Source: java/util/ArrayList.SubList.ListIterator.lsl:68 - */ - public boolean hasPrevious() { - boolean result = false; - /* body */ { - result = this.cursor != 0; - } - return result; - } - - /** - * [FUNCTION] ArrayList_SubList_ListIteratorAutomaton::nextIndex(ArrayList_SubList_ListIterator) -> int - * Source: java/util/ArrayList.SubList.ListIterator.lsl:74 - */ - public int nextIndex() { - int result = 0; - /* body */ { - result = this.cursor; - } - return result; - } - - /** - * [FUNCTION] ArrayList_SubList_ListIteratorAutomaton::previousIndex(ArrayList_SubList_ListIterator) -> int - * Source: java/util/ArrayList.SubList.ListIterator.lsl:80 - */ - public int previousIndex() { - int result = 0; - /* body */ { - result = this.cursor - 1; - } - return result; - } - - /** - * [FUNCTION] ArrayList_SubList_ListIteratorAutomaton::hasNext(ArrayList_SubList_ListIterator) -> boolean - * Source: java/util/ArrayList.SubList.ListIterator.lsl:86 - */ - public boolean hasNext() { - boolean result = false; - /* body */ { - result = this.cursor != this.size; - } - return result; - } - - /** - * [FUNCTION] ArrayList_SubList_ListIteratorAutomaton::next(ArrayList_SubList_ListIterator) -> Object - * Source: java/util/ArrayList.SubList.ListIterator.lsl:92 - */ - public Object next() { - Object result = null; - /* body */ { - Engine.assume(this.root != null); - _checkForComodification(); - final SymbolicList rootStorage = ((ArrayList) ((Object) this.root)).storage; - final int i = this.offset + this.cursor; - if (i >= rootStorage.size()) { - throw new NoSuchElementException(); - } - this.lastRet = this.cursor; - this.cursor += 1; - result = rootStorage.get(i); - } - return result; - } - - /** - * [FUNCTION] ArrayList_SubList_ListIteratorAutomaton::previous(ArrayList_SubList_ListIterator) -> Object - * Source: java/util/ArrayList.SubList.ListIterator.lsl:112 - */ - public Object previous() { - Object result = null; - /* body */ { - Engine.assume(this.root != null); - _checkForComodification(); - final int i = (this.offset + this.cursor) - 1; - if (i < this.offset) { - throw new NoSuchElementException(); - } - final SymbolicList rootStorage = ((ArrayList) ((Object) this.root)).storage; - if (i >= rootStorage.size()) { - throw new ConcurrentModificationException(); - } - this.cursor -= 1; - this.lastRet = this.cursor; - result = rootStorage.get(i); - } - return result; - } - - /** - * [FUNCTION] ArrayList_SubList_ListIteratorAutomaton::remove(ArrayList_SubList_ListIterator) -> void - * Source: java/util/ArrayList.SubList.ListIterator.lsl:135 - */ - public void remove() { - /* body */ { - Engine.assume(this.root != null); - if (this.lastRet < 0) { - throw new IllegalStateException(); - } - _checkForComodification(); - if (this.lastRet >= this.size) { - throw new ConcurrentModificationException(); - } else { - ((ArrayList) ((Object) this.root))._deleteElement(this.offset + this.lastRet); - ((ArrayList_SubList) ((Object) this.sublist))._updateSizeAndModCount(-1); - this.expectedModCount = ((ArrayList) ((Object) this.root)).modCount; - this.size -= 1; - } - this.cursor = this.lastRet; - this.lastRet = -1; - } - } - - /** - * [FUNCTION] ArrayList_SubList_ListIteratorAutomaton::set(ArrayList_SubList_ListIterator, Object) -> void - * Source: java/util/ArrayList.SubList.ListIterator.lsl:163 - */ - public void set(Object e) { - /* body */ { - Engine.assume(this.root != null); - if (this.lastRet < 0) { - throw new IllegalStateException(); - } - _checkForComodification(); - final SymbolicList rootStorage = ((ArrayList) ((Object) this.root)).storage; - final int index = this.offset + this.lastRet; - if (index >= rootStorage.size()) { - throw new ConcurrentModificationException(); - } else { - rootStorage.set(index, e); - } - } - } - - /** - * [FUNCTION] ArrayList_SubList_ListIteratorAutomaton::add(ArrayList_SubList_ListIterator, Object) -> void - * Source: java/util/ArrayList.SubList.ListIterator.lsl:183 - */ - public void add(Object e) { - /* body */ { - Engine.assume(this.root != null); - _checkForComodification(); - final int i = this.offset + this.cursor; - if ((this.offset + this.lastRet) > ((ArrayList) ((Object) this.root)).storage.size()) { - throw new ConcurrentModificationException(); - } else { - ((ArrayList) ((Object) this.root))._addElement(i, e); - ((ArrayList_SubList) ((Object) this.sublist))._updateSizeAndModCount(1); - this.expectedModCount = ((ArrayList) ((Object) this.root)).modCount; - this.size += 1; - } - this.cursor += 1; - this.lastRet = -1; - } - } - - /** - * [FUNCTION] ArrayList_SubList_ListIteratorAutomaton::forEachRemaining(ArrayList_SubList_ListIterator, Consumer) -> void - * Source: java/util/ArrayList.SubList.ListIterator.lsl:210 - */ - public void forEachRemaining(Consumer userAction) { - /* body */ { - Engine.assume(this.root != null); - if (userAction == null) { - throw new NullPointerException(); - } - int i = this.cursor; - if (i < this.size) { - i += this.offset; - final SymbolicList es = ((ArrayList) ((Object) this.root)).storage; - if (i >= es.size()) { - throw new ConcurrentModificationException(); - } - final int end = this.offset + this.size; - for (i = i; i < end; i += 1) { - final Object item = es.get(i); - userAction.accept(item); - } - ; - this.cursor = i - this.offset; - this.lastRet = this.cursor - 1; - _checkForComodification(); - } - } - } - - public static final class __$lsl_States { - public static final byte Initialized = (byte) 0; - } - - @Approximate(ArrayList_SubList$ListIterator.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/ArrayList_SubList$Spliterator.java b/approximations/src/main/java/generated/java/util/ArrayList_SubList$Spliterator.java deleted file mode 100644 index 8ea78534..00000000 --- a/approximations/src/main/java/generated/java/util/ArrayList_SubList$Spliterator.java +++ /dev/null @@ -1,212 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/ArrayList.lsl:65 -// - java/util/ArrayList.SubList.Spliterator.lsl:16 -// -package generated.java.util; - -import generated.runtime.LibSLGlobals; -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.ConcurrentModificationException; -import java.util.Spliterator; -import java.util.function.Consumer; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import org.usvm.api.SymbolicList; -import runtime.LibSLRuntime; - -/** - * ArrayList_SubList_SpliteratorAutomaton for ArrayList_SubList_Spliterator ~> java.util.ArrayList_SubList$Spliterator - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(stub.java.util.ArrayList_SubList$Spliterator.class) -public final class ArrayList_SubList$Spliterator implements LibSLRuntime.Automaton, Spliterator { - static { - Engine.assume(true); - } - - public ArrayList root; - - public ArrayList_SubList parent; - - public int index; - - public int fence; - - public int expectedModCount; - - @LibSLRuntime.AutomatonConstructor - public ArrayList_SubList$Spliterator(Void __$lsl_token, final byte p0, final ArrayList p1, - final ArrayList_SubList p2, final int p3, final int p4, final int p5) { - this.root = p1; - this.parent = p2; - this.index = p3; - this.fence = p4; - this.expectedModCount = p5; - } - - @LibSLRuntime.AutomatonConstructor - public ArrayList_SubList$Spliterator(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Initialized, null, null, 0, -1, 0); - } - - /** - * [SUBROUTINE] ArrayList_SubList_SpliteratorAutomaton::_getFence() -> int - * Source: java/util/ArrayList.SubList.Spliterator.lsl:60 - */ - private int _getFence() { - int result = 0; - /* body */ { - if (this.fence == -1) { - Engine.assume(this.parent != null); - this.expectedModCount = ((ArrayList_SubList) ((Object) this.parent)).modCount; - this.fence = ((ArrayList_SubList) ((Object) this.parent)).length; - } - result = this.fence; - } - return result; - } - - /** - * [FUNCTION] ArrayList_SubList_SpliteratorAutomaton::characteristics(ArrayList_SubList_Spliterator) -> int - * Source: java/util/ArrayList.SubList.Spliterator.lsl:80 - */ - public int characteristics() { - int result = 0; - /* body */ { - result = LibSLGlobals.SPLITERATOR_ORDERED | LibSLGlobals.SPLITERATOR_SIZED | LibSLGlobals.SPLITERATOR_SUBSIZED; - } - return result; - } - - /** - * [FUNCTION] ArrayList_SubList_SpliteratorAutomaton::estimateSize(ArrayList_SubList_Spliterator) -> long - * Source: java/util/ArrayList.SubList.Spliterator.lsl:86 - */ - public long estimateSize() { - long result = 0L; - /* body */ { - result = _getFence() - this.index; - } - return result; - } - - /** - * [FUNCTION] ArrayList_SubList_SpliteratorAutomaton::forEachRemaining(ArrayList_SubList_Spliterator, Consumer) -> void - * Source: java/util/ArrayList.SubList.Spliterator.lsl:92 - */ - public void forEachRemaining(Consumer _action) { - /* body */ { - if (_action == null) { - throw new NullPointerException(); - } - Engine.assume(this.root != null); - Engine.assume(this.parent != null); - final SymbolicList a = ((ArrayList) ((Object) this.root)).storage; - if (a == null) { - throw new ConcurrentModificationException(); - } - int hi = this.fence; - int mc = this.expectedModCount; - if (hi == -1) { - hi = ((ArrayList_SubList) ((Object) this.parent)).length; - mc = ((ArrayList_SubList) ((Object) this.parent)).modCount; - } - int i = this.index; - this.index = hi; - if ((i < 0) || (hi > ((ArrayList_SubList) ((Object) this.parent)).length)) { - throw new ConcurrentModificationException(); - } - for (i = i; i < hi; i += 1) { - final Object item = a.get(i); - _action.accept(item); - } - ; - if (mc != ((ArrayList_SubList) ((Object) this.parent)).modCount) { - throw new ConcurrentModificationException(); - } - } - } - - /** - * [FUNCTION] ArrayList_SubList_SpliteratorAutomaton::getExactSizeIfKnown(ArrayList_SubList_Spliterator) -> long - * Source: java/util/ArrayList.SubList.Spliterator.lsl:141 - */ - public long getExactSizeIfKnown() { - long result = 0L; - /* body */ { - result = _getFence() - this.index; - } - return result; - } - - /** - * [FUNCTION] ArrayList_SubList_SpliteratorAutomaton::tryAdvance(ArrayList_SubList_Spliterator, Consumer) -> boolean - * Source: java/util/ArrayList.SubList.Spliterator.lsl:154 - */ - public boolean tryAdvance(Consumer _action) { - boolean result = false; - /* body */ { - if (_action == null) { - throw new NullPointerException(); - } - final int hi = _getFence(); - final int i = this.index; - if (i < hi) { - Engine.assume(this.root != null); - this.index = i + 1; - final SymbolicList rootStorage = ((ArrayList) ((Object) this.root)).storage; - final Object item = rootStorage.get(i); - _action.accept(item); - if (((ArrayList) ((Object) this.root)).modCount != this.expectedModCount) { - throw new ConcurrentModificationException(); - } - result = true; - } else { - result = false; - } - } - return result; - } - - /** - * [FUNCTION] ArrayList_SubList_SpliteratorAutomaton::trySplit(ArrayList_SubList_Spliterator) -> Spliterator - * Source: java/util/ArrayList.SubList.Spliterator.lsl:184 - */ - public Spliterator trySplit() { - Spliterator result = null; - /* body */ { - final int hi = _getFence(); - final int lo = this.index; - final int mid = (lo + hi) >>> 1; - if (lo >= mid) { - result = null; - } else { - result = (stub.java.util.ArrayList_SubList$Spliterator) ((Object) new ArrayList_SubList$Spliterator((Void) null, - /* state = */ ArrayList_SubList$Spliterator.__$lsl_States.Initialized, - /* root = */ this.root, - /* parent = */ this.parent, - /* index = */ lo, - /* fence = */ mid, - /* expectedModCount = */ this.expectedModCount - )); - } - this.index = mid; - } - return result; - } - - public static final class __$lsl_States { - public static final byte Initialized = (byte) 0; - } - - @Approximate(ArrayList_SubList$Spliterator.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/ArrayList_SubList.java b/approximations/src/main/java/generated/java/util/ArrayList_SubList.java deleted file mode 100644 index fdeadbf2..00000000 --- a/approximations/src/main/java/generated/java/util/ArrayList_SubList.java +++ /dev/null @@ -1,908 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/ArrayList.lsl:54 -// - java/util/ArrayList.SubList.lsl:16 -// -package generated.java.util; - -import java.lang.Object; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.Collection; -import java.util.Comparator; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; -import java.util.RandomAccess; -import java.util.Spliterator; -import java.util.function.Consumer; -import java.util.function.IntFunction; -import java.util.function.Predicate; -import java.util.function.UnaryOperator; -import java.util.stream.Stream; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import org.usvm.api.SymbolicList; -import runtime.LibSLRuntime; -import stub.java.util.stream.StreamLSL; - -/** - * ArrayList_SubListAutomaton for ArrayList_SubList ~> java.util.ArrayList_SubList - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(stub.java.util.ArrayList_SubList.class) -public final class ArrayList_SubList implements LibSLRuntime.Automaton, List, RandomAccess { - static { - Engine.assume(true); - } - - private byte __$lsl_state = __$lsl_States.Allocated; - - public ArrayList root; - - public ArrayList_SubList parentList; - - public int offset; - - public int length; - - public int modCount; - - @LibSLRuntime.AutomatonConstructor - public ArrayList_SubList(Void __$lsl_token, final byte p0, final ArrayList p1, - final ArrayList_SubList p2, final int p3, final int p4, final int p5) { - this.__$lsl_state = p0; - this.root = p1; - this.parentList = p2; - this.offset = p3; - this.length = p4; - this.modCount = p5; - } - - @LibSLRuntime.AutomatonConstructor - public ArrayList_SubList(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Allocated, null, null, 0, 0, 0); - } - - /** - * [CONSTRUCTOR] ArrayList_SubListAutomaton::(ArrayList_SubList, ArrayList, int, int) -> void - * Source: java/util/ArrayList.SubList.lsl:211 - */ - public ArrayList_SubList(ArrayList root, int fromIndex, int toIndex) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - LibSLRuntime.not_implemented(/* inaccessible constructor */); - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [CONSTRUCTOR] ArrayList_SubListAutomaton::(ArrayList_SubList, ArrayList_SubList, int, int) -> void - * Source: java/util/ArrayList.SubList.lsl:218 - */ - private ArrayList_SubList(ArrayList_SubList parent, int fromIndex, int toIndex) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - LibSLRuntime.not_implemented(/* inaccessible constructor */); - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [SUBROUTINE] ArrayList_SubListAutomaton::_addAllElements(int, Collection) -> boolean - * Source: java/util/ArrayList.SubList.lsl:91 - */ - private boolean _addAllElements(int index, Collection c) { - boolean result = false; - /* body */ { - Engine.assume(this.root != null); - final int effectiveIndex = this.offset + index; - ((ArrayList) ((Object) this.root))._rangeCheckForAdd(effectiveIndex); - final int collectionSize = c.size(); - if (collectionSize == 0) { - result = false; - } else { - result = true; - ((ArrayList) ((Object) this.root))._checkForComodification(this.modCount); - ((ArrayList) ((Object) this.root))._addAllElements(effectiveIndex, c); - _updateSizeAndModCount(collectionSize); - } - } - return result; - } - - /** - * [SUBROUTINE] ArrayList_SubListAutomaton::_updateSizeAndModCount(int) -> void - * Source: java/util/ArrayList.SubList.lsl:114 - */ - public void _updateSizeAndModCount(int sizeChange) { - /* body */ { - Engine.assume(this.root != null); - this.length += sizeChange; - this.modCount = ((ArrayList) ((Object) this.root)).modCount; - ArrayList_SubList aList = this.parentList; - while (aList != null) { - ((ArrayList_SubList) ((Object) aList)).length += sizeChange; - ((ArrayList_SubList) ((Object) aList)).modCount = this.modCount; - aList = ((ArrayList_SubList) ((Object) aList)).parentList; - } - ; - } - } - - /** - * [SUBROUTINE] ArrayList_SubListAutomaton::_indexOfElement(Object) -> int - * Source: java/util/ArrayList.SubList.lsl:139 - */ - private int _indexOfElement(Object o) { - int result = 0; - /* body */ { - Engine.assume(this.root != null); - ((ArrayList) ((Object) this.root))._checkForComodification(this.modCount); - final SymbolicList parentStorage = ((ArrayList) ((Object) this.root)).storage; - final int index = LibSLRuntime.ListActions.find(parentStorage, o, this.offset, this.offset + this.length); - if (index != -1) { - result = index - this.offset; - } else { - result = -1; - } - } - return result; - } - - /** - * [SUBROUTINE] ArrayList_SubListAutomaton::_makeStream(boolean) -> Stream - * Source: java/util/ArrayList.SubList.lsl:154 - */ - private Stream _makeStream(boolean parallel) { - Stream result = null; - /* body */ { - Engine.assume(this.root != null); - ((ArrayList) ((Object) this.root))._checkForComodification(this.modCount); - final SymbolicList parentStorage = ((ArrayList) ((Object) this.root)).storage; - final int count = this.length; - final Object[] items = new Object[count]; - int i = 0; - for (i = 0; i < count; i += 1) { - items[i] = parentStorage.get(this.offset + i); - } - ; - result = (StreamLSL) ((Object) new generated.java.util.stream.StreamLSL((Void) null, - /* state = */ generated.java.util.stream.StreamLSL.__$lsl_States.Initialized, - /* storage = */ items, - /* length = */ count, - /* closeHandlers = */ Engine.makeSymbolicList(), - /* isParallel = */ parallel, - /* linkedOrConsumed = */ false - )); - } - return result; - } - - /** - * [SUBROUTINE] ArrayList_SubListAutomaton::_batchRemove(Collection, boolean) -> boolean - * Source: java/util/ArrayList.SubList.lsl:186 - */ - private boolean _batchRemove(Collection c, boolean complement) { - boolean result = false; - /* body */ { - Engine.assume(this.root != null); - ((ArrayList) ((Object) this.root))._checkForComodification(this.modCount); - if (this.length != 0) { - final int oldRootLength = ((ArrayList) ((Object) this.root)).storage.size(); - result = ((ArrayList) ((Object) this.root))._batchRemove(c, complement, this.offset, this.offset + this.length); - if (result) { - final int newRootLength = ((ArrayList) ((Object) this.root)).storage.size(); - _updateSizeAndModCount(newRootLength - oldRootLength); - } - } else { - result = false; - } - } - return result; - } - - /** - * [FUNCTION] ArrayList_SubListAutomaton::add(ArrayList_SubList, Object) -> boolean - * Source: java/util/ArrayList.SubList.lsl:230 - */ - public boolean add(Object e) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(this.root != null); - ((ArrayList) ((Object) this.root))._checkForComodification(this.modCount); - final int effectiveIndex = this.offset + this.length; - ((ArrayList) ((Object) this.root))._addElement(effectiveIndex, e); - _updateSizeAndModCount(1); - } - return result; - } - - /** - * [FUNCTION] ArrayList_SubListAutomaton::add(ArrayList_SubList, int, Object) -> void - * Source: java/util/ArrayList.SubList.lsl:243 - */ - public void add(int index, Object element) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(this.root != null); - ((ArrayList) ((Object) this.root))._checkForComodification(this.modCount); - final int effectiveIndex = this.offset + index; - ((ArrayList) ((Object) this.root))._addElement(effectiveIndex, element); - _updateSizeAndModCount(1); - } - } - - /** - * [FUNCTION] ArrayList_SubListAutomaton::addAll(ArrayList_SubList, Collection) -> boolean - * Source: java/util/ArrayList.SubList.lsl:256 - */ - public boolean addAll(Collection c) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - _addAllElements(this.length, c); - } - return result; - } - - /** - * [FUNCTION] ArrayList_SubListAutomaton::addAll(ArrayList_SubList, int, Collection) -> boolean - * Source: java/util/ArrayList.SubList.lsl:262 - */ - public boolean addAll(int index, Collection c) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - _addAllElements(index, c); - } - return result; - } - - /** - * [FUNCTION] ArrayList_SubListAutomaton::clear(ArrayList_SubList) -> void - * Source: java/util/ArrayList.SubList.lsl:269 - */ - public void clear() { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(this.root != null); - ((ArrayList) ((Object) this.root))._checkForComodification(this.modCount); - final int size = this.length; - if (size != 0) { - Engine.assume(size > 0); - final int end = this.offset - 1; - final int start = end + size; - final SymbolicList rootStorage = ((ArrayList) ((Object) this.root)).storage; - int i = 0; - for (i = start; i > end; i += -1) { - rootStorage.remove(i); - } - ; - ((ArrayList) ((Object) this.root)).modCount += 1; - _updateSizeAndModCount(-size); - } - } - } - - /** - * [FUNCTION] ArrayList_SubListAutomaton::contains(ArrayList_SubList, Object) -> boolean - * Source: java/util/ArrayList.SubList.lsl:301 - */ - public boolean contains(Object o) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = _indexOfElement(o) != -1; - } - return result; - } - - /** - * [FUNCTION] ArrayList_SubListAutomaton::containsAll(ArrayList_SubList, Collection) -> boolean - * Source: java/util/ArrayList.SubList.lsl:308 - */ - public boolean containsAll(Collection c) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = true; - if (!c.isEmpty()) { - Engine.assume(this.root != null); - final SymbolicList rootStorage = ((ArrayList) ((Object) this.root)).storage; - final int end = this.offset + this.length; - if ((c != null && c.getClass() == stub.java.util.ArrayList_SubList.class)) { - final ArrayList otherRoot = ((ArrayList_SubList) ((Object) c)).root; - Engine.assume(otherRoot != null); - final SymbolicList otherStorage = ((ArrayList) ((Object) otherRoot)).storage; - final int otherOffset = ((ArrayList_SubList) ((Object) c)).offset; - final int otherEnd = otherOffset + ((ArrayList_SubList) ((Object) c)).length; - Engine.assume(otherStorage != null); - Engine.assume(otherOffset >= 0); - Engine.assume(otherEnd >= 0); - int i = otherOffset; - while (result && (i < otherEnd)) { - final Object item = otherStorage.get(i); - result = LibSLRuntime.ListActions.find(rootStorage, item, this.offset, end) != -1; - i += 1; - } - ; - } else { - final Iterator iter = c.iterator(); - while (result && iter.hasNext()) { - final Object item = iter.next(); - result = LibSLRuntime.ListActions.find(rootStorage, item, this.offset, end) != -1; - } - ; - } - } - } - return result; - } - - /** - * [FUNCTION] ArrayList_SubListAutomaton::equals(ArrayList_SubList, Object) -> boolean - * Source: java/util/ArrayList.SubList.lsl:364 - */ - public boolean equals(Object o) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (o == this) { - result = true; - } else { - result = (o != null && o.getClass() == stub.java.util.ArrayList_SubList.class); - if (result) { - Engine.assume(this.root != null); - final int otherLength = ((ArrayList_SubList) ((Object) o)).length; - Engine.assume(otherLength >= 0); - result = this.length == otherLength; - if (result) { - result = ((ArrayList) ((Object) this.root))._equalsRange(((List) o), this.offset, this.offset + this.length); - ((ArrayList) ((Object) this.root))._checkForComodification(this.modCount); - } - } - } - } - return result; - } - - /** - * [FUNCTION] ArrayList_SubListAutomaton::forEach(ArrayList_SubList, Consumer) -> void - * Source: java/util/ArrayList.SubList.lsl:392 - */ - public void forEach(Consumer _action) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.length != 0) { - Engine.assume(this.length > 0); - Engine.assume(this.root != null); - final SymbolicList rootStorage = ((ArrayList) ((Object) this.root)).storage; - final int expectedModCount = ((ArrayList) ((Object) this.root)).modCount; - this.modCount = expectedModCount; - int i = this.offset; - final int end = this.offset + this.length; - while ((i < end) && (((ArrayList) ((Object) this.root)).modCount == expectedModCount)) { - final Object item = rootStorage.get(i); - _action.accept(item); - i += 1; - } - ; - ((ArrayList) ((Object) this.root))._checkForComodification(expectedModCount); - } - } - } - - /** - * [FUNCTION] ArrayList_SubListAutomaton::get(ArrayList_SubList, int) -> Object - * Source: java/util/ArrayList.SubList.lsl:424 - */ - public Object get(int index) { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(this.root != null); - ((ArrayList) ((Object) this.root))._checkValidIndex(index, this.length); - ((ArrayList) ((Object) this.root))._checkForComodification(this.modCount); - final int effectiveIndex = this.offset + index; - result = ((ArrayList) ((Object) this.root)).storage.get(effectiveIndex); - } - return result; - } - - /** - * [FUNCTION] ArrayList_SubListAutomaton::hashCode(ArrayList_SubList) -> int - * Source: java/util/ArrayList.SubList.lsl:436 - */ - public int hashCode() { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = 1; - if (this.length != 0) { - Engine.assume(this.length > 0); - Engine.assume(this.root != null); - final SymbolicList rootStorage = ((ArrayList) ((Object) this.root)).storage; - int i = this.offset; - final int end = this.offset + this.length; - for (i = i; i < end; i += 1) { - final Object item = rootStorage.get(i); - result = (31 * result) + LibSLRuntime.hashCode(item); - } - ; - ((ArrayList) ((Object) this.root))._checkForComodification(this.modCount); - } - } - return result; - } - - /** - * [FUNCTION] ArrayList_SubListAutomaton::indexOf(ArrayList_SubList, Object) -> int - * Source: java/util/ArrayList.SubList.lsl:464 - */ - public int indexOf(Object o) { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = _indexOfElement(o); - } - return result; - } - - /** - * [FUNCTION] ArrayList_SubListAutomaton::isEmpty(ArrayList_SubList) -> boolean - * Source: java/util/ArrayList.SubList.lsl:471 - */ - public boolean isEmpty() { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.length == 0; - } - return result; - } - - /** - * [FUNCTION] ArrayList_SubListAutomaton::iterator(ArrayList_SubList) -> Iterator - * Source: java/util/ArrayList.SubList.lsl:477 - */ - public Iterator iterator() { - Iterator result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = (stub.java.util.ArrayList_SubList$ListIterator) ((Object) new ArrayList_SubList$ListIterator((Void) null, - /* state = */ ArrayList_SubList$ListIterator.__$lsl_States.Initialized, - /* root = */ this.root, - /* sublist = */ this, - /* cursor = */ 0, - /* expectedModCount = */ this.modCount, - /* offset = */ this.offset, - /* size = */ this.length, - /* lastRet = */ -1 - )); - } - return result; - } - - /** - * [FUNCTION] ArrayList_SubListAutomaton::lastIndexOf(ArrayList_SubList, Object) -> int - * Source: java/util/ArrayList.SubList.lsl:490 - */ - public int lastIndexOf(Object o) { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(this.root != null); - ((ArrayList) ((Object) this.root))._checkForComodification(this.modCount); - if (this.length == 0) { - result = -1; - } else { - Engine.assume(this.length > 0); - final int end = this.offset + this.length; - final SymbolicList rootStorage = ((ArrayList) ((Object) this.root)).storage; - result = LibSLRuntime.ListActions.find(rootStorage, o, this.offset, end); - if (result != -1) { - final int nextIndex = result + 1; - if (nextIndex < end) { - final int rightIndex = LibSLRuntime.ListActions.find(rootStorage, o, nextIndex, end); - Engine.assume(rightIndex == -1); - } - result -= this.offset; - } - } - } - return result; - } - - /** - * [FUNCTION] ArrayList_SubListAutomaton::listIterator(ArrayList_SubList) -> ListIterator - * Source: java/util/ArrayList.SubList.lsl:524 - */ - public ListIterator listIterator() { - ListIterator result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = (stub.java.util.ArrayList_SubList$ListIterator) ((Object) new ArrayList_SubList$ListIterator((Void) null, - /* state = */ ArrayList_SubList$ListIterator.__$lsl_States.Initialized, - /* root = */ this.root, - /* sublist = */ this, - /* cursor = */ 0, - /* expectedModCount = */ this.modCount, - /* offset = */ this.offset, - /* size = */ this.length, - /* lastRet = */ -1 - )); - } - return result; - } - - /** - * [FUNCTION] ArrayList_SubListAutomaton::listIterator(ArrayList_SubList, int) -> ListIterator - * Source: java/util/ArrayList.SubList.lsl:537 - */ - public ListIterator listIterator(int index) { - ListIterator result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = (stub.java.util.ArrayList_SubList$ListIterator) ((Object) new ArrayList_SubList$ListIterator((Void) null, - /* state = */ ArrayList_SubList$ListIterator.__$lsl_States.Initialized, - /* root = */ this.root, - /* sublist = */ this, - /* cursor = */ index, - /* expectedModCount = */ this.modCount, - /* offset = */ this.offset, - /* size = */ this.length, - /* lastRet = */ -1 - )); - } - return result; - } - - /** - * [FUNCTION] ArrayList_SubListAutomaton::parallelStream(ArrayList_SubList) -> Stream - * Source: java/util/ArrayList.SubList.lsl:551 - */ - public Stream parallelStream() { - Stream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = _makeStream(true); - } - return result; - } - - /** - * [FUNCTION] ArrayList_SubListAutomaton::remove(ArrayList_SubList, Object) -> boolean - * Source: java/util/ArrayList.SubList.lsl:558 - */ - public boolean remove(Object o) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(this.root != null); - final int end = this.offset + this.length; - final SymbolicList rootStorage = ((ArrayList) ((Object) this.root)).storage; - final int index = LibSLRuntime.ListActions.find(rootStorage, o, this.offset, end); - result = index != -1; - if (result) { - ((ArrayList) ((Object) this.root))._checkForComodification(this.modCount); - ((ArrayList) ((Object) this.root))._deleteElement(index); - _updateSizeAndModCount(-1); - } - } - return result; - } - - /** - * [FUNCTION] ArrayList_SubListAutomaton::remove(ArrayList_SubList, int) -> Object - * Source: java/util/ArrayList.SubList.lsl:578 - */ - public Object remove(int index) { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(this.root != null); - ((ArrayList) ((Object) this.root))._checkValidIndex(index, this.length); - ((ArrayList) ((Object) this.root))._checkForComodification(this.modCount); - final int effectiveIndex = this.offset + index; - result = ((ArrayList) ((Object) this.root))._deleteElement(effectiveIndex); - _updateSizeAndModCount(-1); - } - return result; - } - - /** - * [FUNCTION] ArrayList_SubListAutomaton::removeAll(ArrayList_SubList, Collection) -> boolean - * Source: java/util/ArrayList.SubList.lsl:592 - */ - public boolean removeAll(Collection c) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - _batchRemove(c, false); - } - return result; - } - - /** - * [FUNCTION] ArrayList_SubListAutomaton::removeIf(ArrayList_SubList, Predicate) -> boolean - * Source: java/util/ArrayList.SubList.lsl:598 - */ - public boolean removeIf(Predicate filter) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(this.root != null); - ((ArrayList) ((Object) this.root))._checkForComodification(this.modCount); - final int size = this.length; - if (size != 0) { - final int oldRootLength = ((ArrayList) ((Object) this.root)).storage.size(); - result = ((ArrayList) ((Object) this.root))._removeIf(filter, this.offset, this.offset + this.length); - if (result) { - final int newRootLength = ((ArrayList) ((Object) this.root)).storage.size(); - _updateSizeAndModCount(newRootLength - oldRootLength); - } - } else { - result = false; - } - } - return result; - } - - /** - * [FUNCTION] ArrayList_SubListAutomaton::replaceAll(ArrayList_SubList, UnaryOperator) -> void - * Source: java/util/ArrayList.SubList.lsl:622 - */ - public void replaceAll(UnaryOperator operator) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(this.root != null); - ((ArrayList) ((Object) this.root))._replaceAllRange(operator, this.offset, this.offset + this.length); - } - } - - /** - * [FUNCTION] ArrayList_SubListAutomaton::retainAll(ArrayList_SubList, Collection) -> boolean - * Source: java/util/ArrayList.SubList.lsl:629 - */ - public boolean retainAll(Collection c) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - _batchRemove(c, true); - } - return result; - } - - /** - * [FUNCTION] ArrayList_SubListAutomaton::set(ArrayList_SubList, int, Object) -> Object - * Source: java/util/ArrayList.SubList.lsl:635 - */ - public Object set(int index, Object element) { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(this.root != null); - ((ArrayList) ((Object) this.root))._checkValidIndex(index, this.length); - ((ArrayList) ((Object) this.root))._checkForComodification(this.modCount); - final SymbolicList parentStorage = ((ArrayList) ((Object) this.root)).storage; - final int effectiveIndex = this.offset + index; - result = parentStorage.get(effectiveIndex); - parentStorage.set(effectiveIndex, element); - } - return result; - } - - /** - * [FUNCTION] ArrayList_SubListAutomaton::size(ArrayList_SubList) -> int - * Source: java/util/ArrayList.SubList.lsl:649 - */ - public int size() { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(this.root != null); - ((ArrayList) ((Object) this.root))._checkForComodification(this.modCount); - result = this.length; - } - return result; - } - - /** - * [FUNCTION] ArrayList_SubListAutomaton::sort(ArrayList_SubList, Comparator) -> void - * Source: java/util/ArrayList.SubList.lsl:659 - */ - public void sort(Comparator c) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(this.root != null); - ((ArrayList) ((Object) this.root))._do_sort(this.offset, this.offset + this.length, c); - this.modCount = ((ArrayList) ((Object) this.root)).modCount; - } - } - - /** - * [FUNCTION] ArrayList_SubListAutomaton::spliterator(ArrayList_SubList) -> Spliterator - * Source: java/util/ArrayList.SubList.lsl:667 - */ - public Spliterator spliterator() { - Spliterator result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = (stub.java.util.ArrayList_SubList$Spliterator) ((Object) new ArrayList_SubList$Spliterator((Void) null, - /* state = */ ArrayList_SubList$Spliterator.__$lsl_States.Initialized, - /* root = */ this.root, - /* parent = */ this, - /* index = */ 0, - /* fence = */ -1, - /* expectedModCount = */ 0 - )); - } - return result; - } - - /** - * [FUNCTION] ArrayList_SubListAutomaton::stream(ArrayList_SubList) -> Stream - * Source: java/util/ArrayList.SubList.lsl:677 - */ - public Stream stream() { - Stream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = _makeStream(false); - } - return result; - } - - /** - * [FUNCTION] ArrayList_SubListAutomaton::subList(ArrayList_SubList, int, int) -> List - * Source: java/util/ArrayList.SubList.lsl:683 - */ - public List subList(int fromIndex, int toIndex) { - List result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(this.root != null); - ((ArrayList) ((Object) this.root))._subListRangeCheck(fromIndex, toIndex, this.length); - result = (stub.java.util.ArrayList_SubList) ((Object) new ArrayList_SubList((Void) null, - /* state = */ ArrayList_SubList.__$lsl_States.Initialized, - /* root = */ this.root, - /* parentList = */ this, - /* offset = */ this.offset + fromIndex, - /* length = */ toIndex - fromIndex, - /* modCount = */ this.modCount - )); - } - return result; - } - - /** - * [FUNCTION] ArrayList_SubListAutomaton::toArray(ArrayList_SubList) -> array - * Source: java/util/ArrayList.SubList.lsl:699 - */ - public Object[] toArray() { - Object[] result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(this.root != null); - ((ArrayList) ((Object) this.root))._checkForComodification(this.modCount); - result = new Object[this.length]; - final SymbolicList rootStorage = ((ArrayList) ((Object) this.root)).storage; - final int end = this.offset + this.length; - int i = 0; - int j = 0; - for (i = this.offset; i < end; i += 1) { - result[j] = rootStorage.get(i); - j += 1; - } - ; - } - return result; - } - - /** - * [FUNCTION] ArrayList_SubListAutomaton::toArray(ArrayList_SubList, IntFunction) -> array - * Source: java/util/ArrayList.SubList.lsl:724 - */ - public Object[] toArray(IntFunction generator) { - Object[] result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final Object[] a = ((Object[]) generator.apply(0)); - final int aSize = a.length; - Engine.assume(this.root != null); - ((ArrayList) ((Object) this.root))._checkForComodification(this.modCount); - result = new Object[this.length]; - final SymbolicList rootStorage = ((ArrayList) ((Object) this.root)).storage; - final int end = this.offset + this.length; - int i = 0; - int j = 0; - for (i = this.offset; i < end; i += 1) { - result[j] = rootStorage.get(i); - j += 1; - } - ; - } - return result; - } - - /** - * [FUNCTION] ArrayList_SubListAutomaton::toArray(ArrayList_SubList, array) -> array - * Source: java/util/ArrayList.SubList.lsl:746 - */ - public Object[] toArray(Object[] a) { - Object[] result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(this.root != null); - ((ArrayList) ((Object) this.root))._checkForComodification(this.modCount); - final int aSize = a.length; - if (aSize < this.length) { - a = new Object[this.length]; - } - result = a; - final SymbolicList rootStorage = ((ArrayList) ((Object) this.root)).storage; - final int end = this.offset + this.length; - int i = 0; - int j = 0; - for (i = this.offset; i < end; i += 1) { - result[j] = rootStorage.get(i); - j += 1; - } - ; - if (aSize > this.length) { - result[aSize] = null; - } - } - return result; - } - - /** - * [FUNCTION] ArrayList_SubListAutomaton::toString(ArrayList_SubList) -> String - * Source: java/util/ArrayList.SubList.lsl:773 - */ - public String toString() { - String result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.length == 0) { - result = "[]"; - } else { - result = "["; - Engine.assume(this.root != null); - final SymbolicList rootStorage = ((ArrayList) ((Object) this.root)).storage; - int i = this.offset; - final int end = this.offset + this.length; - int counter = this.length; - for (i = i; i < end; i += 1) { - final Object item = rootStorage.get(i); - result = result.concat(LibSLRuntime.toString(item)); - counter -= 1; - if (counter != 0) { - result = result.concat(", "); - } - } - ; - result = result.concat("]"); - } - } - return result; - } - - public static final class __$lsl_States { - public static final byte Allocated = (byte) 0; - - public static final byte Initialized = (byte) 1; - } - - @Approximate(ArrayList_SubList.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/HashMap.java b/approximations/src/main/java/generated/java/util/HashMap.java deleted file mode 100644 index 62f04b2e..00000000 --- a/approximations/src/main/java/generated/java/util/HashMap.java +++ /dev/null @@ -1,862 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/HashMap.lsl:22 -// - java/util/HashMap.main.lsl:25 -// -package generated.java.util; - -import java.io.Serializable; -import java.lang.ClassCastException; -import java.lang.Cloneable; -import java.lang.IllegalArgumentException; -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.Collection; -import java.util.ConcurrentModificationException; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; -import java.util.function.BiConsumer; -import java.util.function.BiFunction; -import java.util.function.Function; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; - -/** - * HashMapAutomaton for HashMap ~> java.util.HashMap - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(java.util.HashMap.class) -public class HashMap implements LibSLRuntime.Automaton, Map, Cloneable, Serializable { - private static final long serialVersionUID = 362498820763181265L; - - static { - Engine.assume(true); - } - - private byte __$lsl_state = __$lsl_States.Allocated; - - public LibSLRuntime.Map> storage; - - public transient int modCount; - - @LibSLRuntime.AutomatonConstructor - public HashMap(Void __$lsl_token, final byte p0, - final LibSLRuntime.Map> p1, final int p2) { - this.__$lsl_state = p0; - this.storage = p1; - this.modCount = p2; - } - - @LibSLRuntime.AutomatonConstructor - public HashMap(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Allocated, null, 0); - } - - /** - * [CONSTRUCTOR] HashMapAutomaton::(HashMap) -> void - * Source: java/util/HashMap.main.lsl:153 - */ - public HashMap() { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - this.storage = new LibSLRuntime.Map<>(new LibSLRuntime.HashMapContainer<>()); - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [CONSTRUCTOR] HashMapAutomaton::(HashMap, Map) -> void - * Source: java/util/HashMap.main.lsl:159 - */ - public HashMap(Map m) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - this.storage = new LibSLRuntime.Map<>(new LibSLRuntime.HashMapContainer<>()); - final Set> entrySet = ((Set>) m.entrySet()); - final Iterator> iter = entrySet.iterator(); - while (iter.hasNext()) { - final Map.Entry oEntry = iter.next(); - final Object key = oEntry.getKey(); - final Object value = oEntry.getValue(); - Map.Entry entry = null; - if (this.storage.hasKey(key)) { - entry = this.storage.get(key); - ((AbstractMap_SimpleEntry) ((Object) entry)).value = value; - } else { - entry = (stub.java.util.AbstractMap_SimpleEntry) ((Object) new AbstractMap_SimpleEntry((Void) null, - /* state = */ AbstractMap_SimpleEntry.__$lsl_States.Initialized, - /* key = */ key, - /* value = */ value - )); - this.storage.set(key, entry); - } - this.modCount += 1; - } - ; - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [CONSTRUCTOR] HashMapAutomaton::(HashMap, int) -> void - * Source: java/util/HashMap.main.lsl:167 - */ - public HashMap(int initialCapacity) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - if (initialCapacity < 0) { - throw new IllegalArgumentException(); - } - this.storage = new LibSLRuntime.Map<>(new LibSLRuntime.HashMapContainer<>()); - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [CONSTRUCTOR] HashMapAutomaton::(HashMap, int, float) -> void - * Source: java/util/HashMap.main.lsl:179 - */ - public HashMap(int initialCapacity, float loadFactor) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - if (initialCapacity < 0) { - throw new IllegalArgumentException(); - } - if ((loadFactor <= 0) || (loadFactor != loadFactor)) { - throw new IllegalArgumentException(); - } - this.storage = new LibSLRuntime.Map<>(new LibSLRuntime.HashMapContainer<>()); - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [SUBROUTINE] HashMapAutomaton::_checkForComodification(int) -> void - * Source: java/util/HashMap.main.lsl:130 - */ - public void _checkForComodification(int expectedModCount) { - /* body */ { - if (this.modCount != expectedModCount) { - throw new ConcurrentModificationException(); - } - } - } - - /** - * [FUNCTION] HashMapAutomaton::clear(HashMap) -> void - * Source: java/util/HashMap.main.lsl:199 - */ - public void clear() { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - this.modCount += 1; - this.storage = new LibSLRuntime.Map<>(new LibSLRuntime.HashMapContainer<>()); - } - } - - /** - * [FUNCTION] HashMapAutomaton::clone(HashMap) -> Object - * Source: java/util/HashMap.main.lsl:206 - */ - public Object clone() { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final LibSLRuntime.Map> otherStorage = new LibSLRuntime.Map<>(new LibSLRuntime.HashMapContainer<>()); - result = (java.util.HashMap) ((Object) new HashMap((Void) null, - /* state = */ HashMap.__$lsl_States.Initialized, - /* storage = */ otherStorage, - /* modCount = */ 0 - )); - final int size = this.storage.size(); - if (size != 0) { - final LibSLRuntime.Map> unseen = this.storage.duplicate(); - int c = 0; - for (c = size; c > 0; c += -1) { - final Object key = unseen.anyKey(); - final Map.Entry entry = unseen.get(key); - final Object value = ((AbstractMap_SimpleEntry) ((Object) entry)).value; - final Map.Entry otherEntry = (stub.java.util.AbstractMap_SimpleEntry) ((Object) new AbstractMap_SimpleEntry((Void) null, - /* state = */ AbstractMap_SimpleEntry.__$lsl_States.Initialized, - /* key = */ key, - /* value = */ value - )); - otherStorage.set(key, otherEntry); - unseen.remove(key); - } - ; - } - } - return result; - } - - /** - * [FUNCTION] HashMapAutomaton::compute(HashMap, Object, BiFunction) -> Object - * Source: java/util/HashMap.main.lsl:244 - */ - public Object compute(Object key, BiFunction remappingFunction) { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (remappingFunction == null) { - throw new NullPointerException(); - } - Object oldValue = null; - Map.Entry entry = null; - if (this.storage.hasKey(key)) { - entry = this.storage.get(key); - oldValue = ((AbstractMap_SimpleEntry) ((Object) entry)).value; - } - final int expectedModCount = this.modCount; - final Object newValue = remappingFunction.apply(key, oldValue); - _checkForComodification(expectedModCount); - if (newValue == null) { - this.storage.remove(key); - } else { - if (entry != null) { - ((AbstractMap_SimpleEntry) ((Object) entry)).value = newValue; - } else { - entry = (stub.java.util.AbstractMap_SimpleEntry) ((Object) new AbstractMap_SimpleEntry((Void) null, - /* state = */ AbstractMap_SimpleEntry.__$lsl_States.Initialized, - /* key = */ key, - /* value = */ newValue - )); - this.storage.set(key, entry); - } - } - result = newValue; - } - return result; - } - - /** - * [FUNCTION] HashMapAutomaton::computeIfAbsent(HashMap, Object, Function) -> Object - * Source: java/util/HashMap.main.lsl:287 - */ - public Object computeIfAbsent(Object key, Function mappingFunction) { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (mappingFunction == null) { - throw new NullPointerException(); - } - Object oldValue = null; - Map.Entry entry = null; - if (this.storage.hasKey(key)) { - entry = this.storage.get(key); - oldValue = ((AbstractMap_SimpleEntry) ((Object) entry)).value; - } - if (oldValue != null) { - result = oldValue; - } else { - final int expectedModCount = this.modCount; - final Object newValue = mappingFunction.apply(key); - _checkForComodification(expectedModCount); - if (newValue != null) { - if (entry != null) { - ((AbstractMap_SimpleEntry) ((Object) entry)).value = newValue; - } else { - entry = (stub.java.util.AbstractMap_SimpleEntry) ((Object) new AbstractMap_SimpleEntry((Void) null, - /* state = */ AbstractMap_SimpleEntry.__$lsl_States.Initialized, - /* key = */ key, - /* value = */ newValue - )); - this.storage.set(key, entry); - } - } - result = newValue; - } - } - return result; - } - - /** - * [FUNCTION] HashMapAutomaton::computeIfPresent(HashMap, Object, BiFunction) -> Object - * Source: java/util/HashMap.main.lsl:331 - */ - public Object computeIfPresent(Object key, BiFunction remappingFunction) { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (remappingFunction == null) { - throw new NullPointerException(); - } - Object oldValue = null; - Map.Entry entry = null; - if (this.storage.hasKey(key)) { - entry = this.storage.get(key); - oldValue = ((AbstractMap_SimpleEntry) ((Object) entry)).value; - } - if (oldValue == null) { - result = oldValue; - } else { - final int expectedModCount = this.modCount; - final Object newValue = remappingFunction.apply(key, oldValue); - _checkForComodification(expectedModCount); - if (newValue == null) { - this.storage.remove(key); - } else { - if (entry != null) { - ((AbstractMap_SimpleEntry) ((Object) entry)).value = newValue; - } else { - entry = (stub.java.util.AbstractMap_SimpleEntry) ((Object) new AbstractMap_SimpleEntry((Void) null, - /* state = */ AbstractMap_SimpleEntry.__$lsl_States.Initialized, - /* key = */ key, - /* value = */ newValue - )); - this.storage.set(key, entry); - } - } - result = newValue; - } - } - return result; - } - - /** - * [FUNCTION] HashMapAutomaton::containsKey(HashMap, Object) -> boolean - * Source: java/util/HashMap.main.lsl:378 - */ - public boolean containsKey(Object key) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.storage.size() == 0) { - result = false; - } else { - result = this.storage.hasKey(key); - } - } - return result; - } - - /** - * [FUNCTION] HashMapAutomaton::containsValue(HashMap, Object) -> boolean - * Source: java/util/HashMap.main.lsl:387 - */ - public boolean containsValue(Object value) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = false; - int storageSize = this.storage.size(); - if (storageSize != 0) { - final LibSLRuntime.Map> unseen = this.storage.duplicate(); - while ((result != true) && (storageSize != 0)) { - final Object curKey = unseen.anyKey(); - final Map.Entry entry = this.storage.get(curKey); - final Object curValue = ((AbstractMap_SimpleEntry) ((Object) entry)).value; - if (LibSLRuntime.equals(curValue, value)) { - result = true; - } - unseen.remove(curKey); - storageSize -= 1; - } - ; - } - } - return result; - } - - /** - * [FUNCTION] HashMapAutomaton::entrySet(HashMap) -> Set - * Source: java/util/HashMap.main.lsl:416 - */ - public Set entrySet() { - Set result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = (stub.java.util.HashMap_EntrySet) ((Object) new HashMap_EntrySet((Void) null, - /* state = */ HashMap_EntrySet.__$lsl_States.Initialized, - /* storageRef = */ this.storage, - /* parent = */ this - )); - } - return result; - } - - /** - * [FUNCTION] HashMapAutomaton::equals(HashMap, Object) -> boolean - * Source: java/util/HashMap.main.lsl:426 - */ - public boolean equals(Object other) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (other == this) { - result = true; - } else { - result = false; - if ((other instanceof Map)) { - final Map m = ((Map) other); - int thisLength = this.storage.size(); - if (thisLength == m.size()) { - try { - result = true; - final LibSLRuntime.Map> unseen = this.storage.duplicate(); - while (result && (thisLength != 0)) { - final Object key = unseen.anyKey(); - final Map.Entry entry = this.storage.get(key); - final Object value = ((AbstractMap_SimpleEntry) ((Object) entry)).value; - if (value == null) { - if (m.get(key) != null) { - result = false; - } else { - if (!m.containsKey(key)) { - result = false; - } - } - } else { - result = LibSLRuntime.equals(value, m.get(key)); - } - unseen.remove(key); - thisLength -= 1; - } - ; - } catch (ClassCastException __$lsl_exception) { - result = false; - } catch (NullPointerException __$lsl_exception) { - result = false; - } - ; - } - } - } - } - return result; - } - - /** - * [FUNCTION] HashMapAutomaton::forEach(HashMap, BiConsumer) -> void - * Source: java/util/HashMap.main.lsl:494 - */ - public void forEach(BiConsumer userAction) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (userAction == null) { - throw new NullPointerException(); - } - final int storageSize = this.storage.size(); - if (storageSize > 0) { - final int expectedModCount = this.modCount; - final LibSLRuntime.Map> unseen = this.storage.duplicate(); - int i = 0; - for (i = 0; i < storageSize; i += 1) { - final Object curKey = unseen.anyKey(); - final Map.Entry entry = this.storage.get(curKey); - final Object curValue = ((AbstractMap_SimpleEntry) ((Object) entry)).value; - userAction.accept(curKey, curValue); - unseen.remove(curKey); - } - ; - _checkForComodification(expectedModCount); - } - } - } - - /** - * [FUNCTION] HashMapAutomaton::get(HashMap, Object) -> Object - * Source: java/util/HashMap.main.lsl:529 - */ - public Object get(Object key) { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final Object defaultValue = null; - if (this.storage.hasKey(key)) { - final Map.Entry entry = this.storage.get(key); - result = ((AbstractMap_SimpleEntry) ((Object) entry)).value; - } else { - result = defaultValue; - } - } - return result; - } - - /** - * [FUNCTION] HashMapAutomaton::getOrDefault(HashMap, Object, Object) -> Object - * Source: java/util/HashMap.main.lsl:536 - */ - public Object getOrDefault(Object key, Object defaultValue) { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.storage.hasKey(key)) { - final Map.Entry entry = this.storage.get(key); - result = ((AbstractMap_SimpleEntry) ((Object) entry)).value; - } else { - result = defaultValue; - } - } - return result; - } - - /** - * [FUNCTION] HashMapAutomaton::hashCode(HashMap) -> int - * Source: java/util/HashMap.main.lsl:543 - */ - public int hashCode() { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = LibSLRuntime.hashCode(this.storage); - } - return result; - } - - /** - * [FUNCTION] HashMapAutomaton::isEmpty(HashMap) -> boolean - * Source: java/util/HashMap.main.lsl:549 - */ - public boolean isEmpty() { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.storage.size() == 0; - } - return result; - } - - /** - * [FUNCTION] HashMapAutomaton::keySet(HashMap) -> Set - * Source: java/util/HashMap.main.lsl:555 - */ - public Set keySet() { - Set result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = (stub.java.util.HashMap_KeySet) ((Object) new HashMap_KeySet((Void) null, - /* state = */ HashMap_KeySet.__$lsl_States.Initialized, - /* storageRef = */ this.storage, - /* parent = */ this - )); - } - return result; - } - - /** - * [FUNCTION] HashMapAutomaton::merge(HashMap, Object, Object, BiFunction) -> Object - * Source: java/util/HashMap.main.lsl:564 - */ - public Object merge(Object key, Object value, BiFunction remappingFunction) { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (value == null) { - throw new NullPointerException(); - } - if (remappingFunction == null) { - throw new NullPointerException(); - } - Map.Entry entry = null; - if (this.storage.hasKey(key)) { - entry = this.storage.get(key); - final Object oldValue = ((AbstractMap_SimpleEntry) ((Object) entry)).value; - if (oldValue == null) { - result = value; - } else { - final int expectedModCount = this.modCount; - result = remappingFunction.apply(oldValue, value); - _checkForComodification(expectedModCount); - } - if (result == null) { - this.storage.remove(key); - } else { - ((AbstractMap_SimpleEntry) ((Object) entry)).value = result; - } - } else { - entry = (stub.java.util.AbstractMap_SimpleEntry) ((Object) new AbstractMap_SimpleEntry((Void) null, - /* state = */ AbstractMap_SimpleEntry.__$lsl_States.Initialized, - /* key = */ key, - /* value = */ value - )); - this.storage.set(key, entry); - this.modCount += 1; - result = value; - } - } - return result; - } - - /** - * [FUNCTION] HashMapAutomaton::put(HashMap, Object, Object) -> Object - * Source: java/util/HashMap.main.lsl:607 - */ - public Object put(Object key, Object value) { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = null; - Map.Entry entry = null; - if (this.storage.hasKey(key)) { - entry = this.storage.get(key); - result = ((AbstractMap_SimpleEntry) ((Object) entry)).value; - ((AbstractMap_SimpleEntry) ((Object) entry)).value = value; - } else { - entry = (stub.java.util.AbstractMap_SimpleEntry) ((Object) new AbstractMap_SimpleEntry((Void) null, - /* state = */ AbstractMap_SimpleEntry.__$lsl_States.Initialized, - /* key = */ key, - /* value = */ value - )); - this.storage.set(key, entry); - } - this.modCount += 1; - } - return result; - } - - /** - * [FUNCTION] HashMapAutomaton::putAll(HashMap, Map) -> void - * Source: java/util/HashMap.main.lsl:633 - */ - public void putAll(Map m) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (m == null) { - throw new NullPointerException(); - } - final Set> entrySet = ((Set>) m.entrySet()); - final Iterator> iter = entrySet.iterator(); - while (iter.hasNext()) { - final Map.Entry oEntry = iter.next(); - final Object key = oEntry.getKey(); - final Object value = oEntry.getValue(); - Map.Entry entry = null; - if (this.storage.hasKey(key)) { - entry = this.storage.get(key); - ((AbstractMap_SimpleEntry) ((Object) entry)).value = value; - } else { - entry = (stub.java.util.AbstractMap_SimpleEntry) ((Object) new AbstractMap_SimpleEntry((Void) null, - /* state = */ AbstractMap_SimpleEntry.__$lsl_States.Initialized, - /* key = */ key, - /* value = */ value - )); - this.storage.set(key, entry); - } - this.modCount += 1; - } - ; - } - } - - /** - * [FUNCTION] HashMapAutomaton::putIfAbsent(HashMap, Object, Object) -> Object - * Source: java/util/HashMap.main.lsl:642 - */ - public Object putIfAbsent(Object key, Object value) { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Map.Entry entry = null; - if (this.storage.hasKey(key)) { - entry = this.storage.get(key); - result = ((AbstractMap_SimpleEntry) ((Object) entry)).value; - } else { - result = null; - entry = (stub.java.util.AbstractMap_SimpleEntry) ((Object) new AbstractMap_SimpleEntry((Void) null, - /* state = */ AbstractMap_SimpleEntry.__$lsl_States.Initialized, - /* key = */ key, - /* value = */ value - )); - this.storage.set(key, entry); - this.modCount += 1; - } - } - return result; - } - - /** - * [FUNCTION] HashMapAutomaton::remove(HashMap, Object) -> Object - * Source: java/util/HashMap.main.lsl:664 - */ - public Object remove(Object key) { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.storage.hasKey(key)) { - final Map.Entry entry = this.storage.get(key); - result = ((AbstractMap_SimpleEntry) ((Object) entry)).value; - this.storage.remove(key); - this.modCount += 1; - } else { - result = null; - } - } - return result; - } - - /** - * [FUNCTION] HashMapAutomaton::remove(HashMap, Object, Object) -> boolean - * Source: java/util/HashMap.main.lsl:682 - */ - public boolean remove(Object key, Object value) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.storage.hasKey(key)) { - final Map.Entry entry = this.storage.get(key); - final Object curValue = ((AbstractMap_SimpleEntry) ((Object) entry)).value; - if (LibSLRuntime.equals(curValue, value)) { - this.storage.remove(key); - this.modCount += 1; - result = true; - } - } else { - result = false; - } - } - return result; - } - - /** - * [FUNCTION] HashMapAutomaton::replace(HashMap, Object, Object) -> Object - * Source: java/util/HashMap.main.lsl:703 - */ - public Object replace(Object key, Object value) { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.storage.hasKey(key)) { - final Map.Entry entry = this.storage.get(key); - result = ((AbstractMap_SimpleEntry) ((Object) entry)).value; - ((AbstractMap_SimpleEntry) ((Object) entry)).value = value; - } else { - result = null; - } - } - return result; - } - - /** - * [FUNCTION] HashMapAutomaton::replace(HashMap, Object, Object, Object) -> boolean - * Source: java/util/HashMap.main.lsl:719 - */ - public boolean replace(Object key, Object oldValue, Object newValue) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = false; - if (this.storage.hasKey(key)) { - final Map.Entry entry = this.storage.get(key); - final Object curValue = ((AbstractMap_SimpleEntry) ((Object) entry)).value; - if (LibSLRuntime.equals(curValue, oldValue)) { - ((AbstractMap_SimpleEntry) ((Object) entry)).value = newValue; - result = true; - } - } - } - return result; - } - - /** - * [FUNCTION] HashMapAutomaton::replaceAll(HashMap, BiFunction) -> void - * Source: java/util/HashMap.main.lsl:737 - */ - public void replaceAll(BiFunction function) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (function == null) { - throw new NullPointerException(); - } - final int size = this.storage.size(); - if (size > 0) { - final int expectedModCount = this.modCount; - final LibSLRuntime.Map> unseen = this.storage.duplicate(); - int i = 0; - for (i = 0; i < size; i += 1) { - final Object key = unseen.anyKey(); - final Map.Entry entry = this.storage.get(key); - ((AbstractMap_SimpleEntry) ((Object) entry)).value = function.apply(key, ((AbstractMap_SimpleEntry) ((Object) entry)).value); - unseen.remove(key); - } - ; - _checkForComodification(expectedModCount); - } - } - } - - /** - * [FUNCTION] HashMapAutomaton::size(HashMap) -> int - * Source: java/util/HashMap.main.lsl:773 - */ - public int size() { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.storage.size(); - } - return result; - } - - /** - * [FUNCTION] HashMapAutomaton::toString(HashMap) -> String - * Source: java/util/HashMap.main.lsl:780 - */ - public String toString() { - String result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - int count = this.storage.size(); - if (count == 0) { - result = "{}"; - } else { - result = "{"; - final LibSLRuntime.Map> unseen = this.storage.duplicate(); - count = unseen.size(); - Engine.assume(count > 0); - while (count != 0) { - final Object key = unseen.anyKey(); - final Map.Entry entry = unseen.get(key); - unseen.remove(key); - result = result.concat(LibSLRuntime.toString(entry)); - count -= 1; - if (count != 0) { - result = result.concat(", "); - } - } - ; - result = result.concat("}"); - } - } - return result; - } - - /** - * [FUNCTION] HashMapAutomaton::values(HashMap) -> Collection - * Source: java/util/HashMap.main.lsl:818 - */ - public Collection values() { - Collection result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = (stub.java.util.HashMap_Values) ((Object) new HashMap_Values((Void) null, - /* state = */ HashMap_Values.__$lsl_States.Initialized, - /* storageRef = */ this.storage, - /* parent = */ this - )); - } - return result; - } - - public static final class __$lsl_States { - public static final byte Allocated = (byte) 0; - - public static final byte Initialized = (byte) 1; - } - - @Approximate(HashMap.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/HashMap_EntryIterator.java b/approximations/src/main/java/generated/java/util/HashMap_EntryIterator.java deleted file mode 100644 index 995a086a..00000000 --- a/approximations/src/main/java/generated/java/util/HashMap_EntryIterator.java +++ /dev/null @@ -1,152 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/HashMap.lsl:99 -// - java/util/HashMap.EntryIterator.lsl:20 -// -package generated.java.util; - -import java.lang.IllegalStateException; -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.ConcurrentModificationException; -import java.util.Iterator; -import java.util.Map; -import java.util.NoSuchElementException; -import java.util.function.Consumer; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; - -/** - * HashMap_EntryIteratorAutomaton for HashMap_EntryIterator ~> java.util.HashMap_EntryIterator - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(stub.java.util.HashMap_EntryIterator.class) -public final class HashMap_EntryIterator implements LibSLRuntime.Automaton, Iterator { - static { - Engine.assume(true); - } - - public HashMap parent; - - public LibSLRuntime.Map> unseen; - - public int expectedModCount; - - public Object currentKey; - - @LibSLRuntime.AutomatonConstructor - public HashMap_EntryIterator(Void __$lsl_token, final byte p0, final HashMap p1, - final LibSLRuntime.Map> p2, final int p3, - final Object p4) { - this.parent = p1; - this.unseen = p2; - this.expectedModCount = p3; - this.currentKey = p4; - } - - @LibSLRuntime.AutomatonConstructor - public HashMap_EntryIterator(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Initialized, null, null, 0, null); - } - - /** - * [SUBROUTINE] HashMap_EntryIteratorAutomaton::_checkForComodification() -> void - * Source: java/util/HashMap.EntryIterator.lsl:53 - */ - private void _checkForComodification() { - /* body */ { - final int modCount = ((HashMap) ((Object) this.parent)).modCount; - if (modCount != this.expectedModCount) { - throw new ConcurrentModificationException(); - } - } - } - - /** - * [FUNCTION] HashMap_EntryIteratorAutomaton::forEachRemaining(HashMap_EntryIterator, Consumer) -> void - * Source: java/util/HashMap.EntryIterator.lsl:68 - */ - public void forEachRemaining(Consumer userAction) { - /* body */ { - if (userAction == null) { - throw new NullPointerException(); - } - int size = this.unseen.size(); - if (size != 0) { - while ((size != 0) && (((HashMap) ((Object) this.parent)).modCount == this.expectedModCount)) { - _checkForComodification(); - final Object curKey = this.unseen.anyKey(); - userAction.accept(this.unseen.get(curKey)); - this.unseen.remove(curKey); - size -= 1; - } - ; - } - } - } - - /** - * [FUNCTION] HashMap_EntryIteratorAutomaton::hasNext(HashMap_EntryIterator) -> boolean - * Source: java/util/HashMap.EntryIterator.lsl:96 - */ - public final boolean hasNext() { - boolean result = false; - /* body */ { - result = this.unseen.size() != 0; - } - return result; - } - - /** - * [FUNCTION] HashMap_EntryIteratorAutomaton::next(HashMap_EntryIterator) -> Map_Entry - * Source: java/util/HashMap.EntryIterator.lsl:102 - */ - public final Map.Entry next() { - Map.Entry result = null; - /* body */ { - _checkForComodification(); - if (this.unseen.size() == 0) { - throw new NoSuchElementException(); - } - final Object curKey = this.unseen.anyKey(); - result = this.unseen.get(curKey); - this.unseen.remove(curKey); - this.currentKey = curKey; - } - return result; - } - - /** - * [FUNCTION] HashMap_EntryIteratorAutomaton::remove(HashMap_EntryIterator) -> void - * Source: java/util/HashMap.EntryIterator.lsl:119 - */ - public final void remove() { - /* body */ { - Engine.assume(this.parent != null); - final Object key = this.currentKey; - if (key == null) { - throw new IllegalStateException(); - } - _checkForComodification(); - ((HashMap) ((Object) this.parent)).storage.remove(key); - ((HashMap) ((Object) this.parent)).modCount += 1; - this.unseen.remove(key); - this.expectedModCount = ((HashMap) ((Object) this.parent)).modCount; - this.currentKey = null; - } - } - - public static final class __$lsl_States { - public static final byte Initialized = (byte) 0; - } - - @Approximate(HashMap_EntryIterator.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/HashMap_EntrySet.java b/approximations/src/main/java/generated/java/util/HashMap_EntrySet.java deleted file mode 100644 index 227dc08f..00000000 --- a/approximations/src/main/java/generated/java/util/HashMap_EntrySet.java +++ /dev/null @@ -1,600 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/HashMap.lsl:90 -// - java/util/HashMap.EntrySet.lsl:27 -// -package generated.java.util; - -import java.lang.ClassCastException; -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.lang.UnsupportedOperationException; -import java.lang.Void; -import java.util.Collection; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; -import java.util.Spliterator; -import java.util.function.Consumer; -import java.util.function.IntFunction; -import java.util.function.Predicate; -import java.util.stream.Stream; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; -import stub.java.util.stream.StreamLSL; - -/** - * HashMap_EntrySetAutomaton for HashMap_EntrySet ~> java.util.HashMap_EntrySet - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(stub.java.util.HashMap_EntrySet.class) -public final class HashMap_EntrySet implements LibSLRuntime.Automaton { - static { - Engine.assume(true); - } - - public LibSLRuntime.Map> storageRef; - - public HashMap parent; - - @LibSLRuntime.AutomatonConstructor - public HashMap_EntrySet(Void __$lsl_token, final byte p0, - final LibSLRuntime.Map> p1, final HashMap p2) { - this.storageRef = p1; - this.parent = p2; - } - - @LibSLRuntime.AutomatonConstructor - public HashMap_EntrySet(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Initialized, null, null); - } - - /** - * [SUBROUTINE] HashMap_EntrySetAutomaton::_mapToEntryArray() -> array> - * Source: java/util/HashMap.EntrySet.lsl:80 - */ - private Map.Entry[] _mapToEntryArray() { - Map.Entry[] result = null; - /* body */ { - final int storageSize = this.storageRef.size(); - result = new Map.Entry[storageSize]; - if (storageSize != 0) { - final LibSLRuntime.Map> unseen = this.storageRef.duplicate(); - int i = 0; - for (i = 0; i < storageSize; i += 1) { - final Object curKey = unseen.anyKey(); - result[i] = this.storageRef.get(curKey); - unseen.remove(curKey); - } - ; - } - } - return result; - } - - /** - * [FUNCTION] HashMap_EntrySetAutomaton::add(HashMap_EntrySet, Object) -> boolean - * Source: java/util/HashMap.EntrySet.lsl:115 - */ - public boolean add(Object e) { - boolean result = false; - /* body */ { - if (true) { - throw new UnsupportedOperationException(); - } - } - return result; - } - - /** - * [FUNCTION] HashMap_EntrySetAutomaton::addAll(HashMap_EntrySet, Collection) -> boolean - * Source: java/util/HashMap.EntrySet.lsl:123 - */ - public boolean addAll(Collection c) { - boolean result = false; - /* body */ { - if (true) { - throw new UnsupportedOperationException(); - } - } - return result; - } - - /** - * [FUNCTION] HashMap_EntrySetAutomaton::clear(HashMap_EntrySet) -> void - * Source: java/util/HashMap.EntrySet.lsl:130 - */ - public final void clear() { - /* body */ { - ((HashMap) ((Object) this.parent)).modCount += 1; - final LibSLRuntime.Map> newStorage = new LibSLRuntime.Map<>(new LibSLRuntime.HashMapContainer<>()); - this.storageRef = newStorage; - ((HashMap) ((Object) this.parent)).storage = newStorage; - } - } - - /** - * [FUNCTION] HashMap_EntrySetAutomaton::contains(HashMap_EntrySet, Object) -> boolean - * Source: java/util/HashMap.EntrySet.lsl:141 - */ - public final boolean contains(Object o) { - boolean result = false; - /* body */ { - result = false; - if ((o instanceof Map.Entry)) { - final Map.Entry oEntry = ((Map.Entry) o); - final Object key = oEntry.getKey(); - if (this.storageRef.hasKey(key)) { - final Map.Entry entry = this.storageRef.get(key); - result = LibSLRuntime.equals(entry, oEntry); - } - } - } - return result; - } - - /** - * [FUNCTION] HashMap_EntrySetAutomaton::containsAll(HashMap_EntrySet, Collection) -> boolean - * Source: java/util/HashMap.EntrySet.lsl:160 - */ - public boolean containsAll(Collection c) { - boolean result = false; - /* body */ { - result = true; - final Iterator> iter = ((Iterator>) c.iterator()); - while (result && iter.hasNext()) { - final Map.Entry oEntry = iter.next(); - final Object key = oEntry.getKey(); - if (this.storageRef.hasKey(key)) { - final Map.Entry entry = this.storageRef.get(key); - result = LibSLRuntime.equals(entry, oEntry); - } else { - result = false; - } - } - ; - } - return result; - } - - /** - * [FUNCTION] HashMap_EntrySetAutomaton::equals(HashMap_EntrySet, Object) -> boolean - * Source: java/util/HashMap.EntrySet.lsl:191 - */ - public boolean equals(Object other) { - boolean result = false; - /* body */ { - if (other == this) { - result = true; - } else { - result = false; - if ((other instanceof Set)) { - final Collection c = ((Collection) other); - if (this.storageRef.size() == c.size()) { - try { - result = true; - final Iterator> iter = ((Iterator>) c.iterator()); - while (result && iter.hasNext()) { - final Map.Entry oEntry = iter.next(); - final Object key = oEntry.getKey(); - if (this.storageRef.hasKey(key)) { - final Map.Entry entry = this.storageRef.get(key); - result = LibSLRuntime.equals(entry, oEntry); - } else { - result = false; - } - } - ; - } catch (ClassCastException __$lsl_exception) { - result = false; - } catch (NullPointerException __$lsl_exception) { - result = false; - } - ; - } - } - } - } - return result; - } - - /** - * [FUNCTION] HashMap_EntrySetAutomaton::forEach(HashMap_EntrySet, Consumer) -> void - * Source: java/util/HashMap.EntrySet.lsl:236 - */ - public final void forEach(Consumer userAction) { - /* body */ { - if (userAction == null) { - throw new NullPointerException(); - } - final int size = this.storageRef.size(); - if (size > 0) { - final int expectedModCount = ((HashMap) ((Object) this.parent)).modCount; - final LibSLRuntime.Map> unseen = this.storageRef.duplicate(); - int i = 0; - for (i = 0; i < size; i += 1) { - final Object key = unseen.anyKey(); - final Map.Entry entry = this.storageRef.get(key); - userAction.accept(entry); - unseen.remove(key); - } - ; - ((HashMap) ((Object) this.parent))._checkForComodification(expectedModCount); - } - } - } - - /** - * [FUNCTION] HashMap_EntrySetAutomaton::hashCode(HashMap_EntrySet) -> int - * Source: java/util/HashMap.EntrySet.lsl:270 - */ - public int hashCode() { - int result = 0; - /* body */ { - result = LibSLRuntime.hashCode(this.storageRef); - } - return result; - } - - /** - * [FUNCTION] HashMap_EntrySetAutomaton::isEmpty(HashMap_EntrySet) -> boolean - * Source: java/util/HashMap.EntrySet.lsl:277 - */ - public boolean isEmpty() { - boolean result = false; - /* body */ { - result = this.storageRef.size() == 0; - } - return result; - } - - /** - * [FUNCTION] HashMap_EntrySetAutomaton::iterator(HashMap_EntrySet) -> Iterator - * Source: java/util/HashMap.EntrySet.lsl:283 - */ - public final Iterator iterator() { - Iterator result = null; - /* body */ { - result = (stub.java.util.HashMap_EntryIterator) ((Object) new HashMap_EntryIterator((Void) null, - /* state = */ HashMap_EntryIterator.__$lsl_States.Initialized, - /* parent = */ this.parent, - /* unseen = */ this.storageRef.duplicate(), - /* expectedModCount = */ ((HashMap) ((Object) this.parent)).modCount, - /* currentKey = */ null - )); - } - return result; - } - - /** - * [FUNCTION] HashMap_EntrySetAutomaton::parallelStream(HashMap_EntrySet) -> Stream - * Source: java/util/HashMap.EntrySet.lsl:294 - */ - public Stream parallelStream() { - Stream result = null; - /* body */ { - final Object[] items = _mapToEntryArray(); - result = (StreamLSL) ((Object) new generated.java.util.stream.StreamLSL((Void) null, - /* state = */ generated.java.util.stream.StreamLSL.__$lsl_States.Initialized, - /* storage = */ items, - /* length = */ items.length, - /* closeHandlers = */ Engine.makeSymbolicList(), - /* isParallel = */ true, - /* linkedOrConsumed = */ false - )); - } - return result; - } - - /** - * [FUNCTION] HashMap_EntrySetAutomaton::remove(HashMap_EntrySet, Object) -> boolean - * Source: java/util/HashMap.EntrySet.lsl:307 - */ - public final boolean remove(Object o) { - boolean result = false; - /* body */ { - result = false; - if ((o instanceof Map.Entry)) { - final Map.Entry oEntry = ((Map.Entry) o); - final Object key = oEntry.getKey(); - if (this.storageRef.hasKey(key)) { - final Map.Entry entry = this.storageRef.get(key); - if (LibSLRuntime.equals(entry, oEntry)) { - this.storageRef.remove(key); - ((HashMap) ((Object) this.parent)).modCount += 1; - result = true; - } - } - } - } - return result; - } - - /** - * [FUNCTION] HashMap_EntrySetAutomaton::removeAll(HashMap_EntrySet, Collection) -> boolean - * Source: java/util/HashMap.EntrySet.lsl:332 - */ - public boolean removeAll(Collection c) { - boolean result = false; - /* body */ { - if (c == null) { - throw new NullPointerException(); - } - result = false; - final int startStorageSize = this.storageRef.size(); - final int cSize = c.size(); - if ((startStorageSize != 0) && (cSize != 0)) { - if (startStorageSize > cSize) { - final Iterator> iter = ((Iterator>) c.iterator()); - while (iter.hasNext()) { - final Map.Entry entry = iter.next(); - final Object curKey = ((AbstractMap_SimpleEntry) ((Object) entry)).key; - if (this.storageRef.hasKey(curKey)) { - if (LibSLRuntime.equals(entry, this.storageRef.get(curKey))) { - this.storageRef.remove(curKey); - ((HashMap) ((Object) this.parent)).modCount += 1; - } - } - } - ; - } else { - final LibSLRuntime.Map> unseen = this.storageRef.duplicate(); - int i = 0; - for (i = 0; i < startStorageSize; i += 1) { - final Object curKey = unseen.anyKey(); - final Map.Entry entry = this.storageRef.get(curKey); - if (c.contains(entry)) { - this.storageRef.remove(curKey); - ((HashMap) ((Object) this.parent)).modCount += 1; - } - unseen.remove(curKey); - } - ; - } - final int resultStorageSize = this.storageRef.size(); - result = startStorageSize != resultStorageSize; - } - } - return result; - } - - /** - * [FUNCTION] HashMap_EntrySetAutomaton::removeIf(HashMap_EntrySet, Predicate) -> boolean - * Source: java/util/HashMap.EntrySet.lsl:396 - */ - public boolean removeIf(Predicate filter) { - boolean result = false; - /* body */ { - if (filter == null) { - throw new NullPointerException(); - } - result = false; - final int startStorageSize = this.storageRef.size(); - if (startStorageSize != 0) { - final LibSLRuntime.Map> unseen = this.storageRef.duplicate(); - int i = 0; - for (i = 0; i < startStorageSize; i += 1) { - final Object curKey = unseen.anyKey(); - final Map.Entry entry = unseen.get(curKey); - if (filter.test(entry)) { - this.storageRef.remove(curKey); - ((HashMap) ((Object) this.parent)).modCount += 1; - } - unseen.remove(curKey); - } - ; - final int resultStorageSize = this.storageRef.size(); - result = startStorageSize != resultStorageSize; - } - } - return result; - } - - /** - * [FUNCTION] HashMap_EntrySetAutomaton::retainAll(HashMap_EntrySet, Collection) -> boolean - * Source: java/util/HashMap.EntrySet.lsl:433 - */ - public boolean retainAll(Collection c) { - boolean result = false; - /* body */ { - if (c == null) { - throw new NullPointerException(); - } - result = false; - final int startStorageSize = this.storageRef.size(); - final int cSize = c.size(); - if ((startStorageSize != 0) && (cSize != 0)) { - final LibSLRuntime.Map> unseen = this.storageRef.duplicate(); - int i = 0; - for (i = 0; i < startStorageSize; i += 1) { - final Object curKey = unseen.anyKey(); - final Map.Entry entry = unseen.get(curKey); - if (!c.contains(entry)) { - this.storageRef.remove(curKey); - ((HashMap) ((Object) this.parent)).modCount += 1; - } - } - ; - final int resultStorageSize = this.storageRef.size(); - result = startStorageSize != resultStorageSize; - } - } - return result; - } - - /** - * [FUNCTION] HashMap_EntrySetAutomaton::size(HashMap_EntrySet) -> int - * Source: java/util/HashMap.EntrySet.lsl:469 - */ - public final int size() { - int result = 0; - /* body */ { - result = this.storageRef.size(); - } - return result; - } - - /** - * [FUNCTION] HashMap_EntrySetAutomaton::spliterator(HashMap_EntrySet) -> Spliterator - * Source: java/util/HashMap.EntrySet.lsl:475 - */ - public final Spliterator spliterator() { - Spliterator result = null; - /* body */ { - result = (stub.java.util.HashMap_EntrySpliterator) ((Object) new HashMap_EntrySpliterator((Void) null, - /* state = */ HashMap_EntrySpliterator.__$lsl_States.Initialized, - /* parent = */ this.parent, - /* entryStorage = */ _mapToEntryArray(), - /* index = */ 0, - /* fence = */ -1, - /* est = */ 0, - /* expectedModCount = */ 0 - )); - } - return result; - } - - /** - * [FUNCTION] HashMap_EntrySetAutomaton::stream(HashMap_EntrySet) -> Stream - * Source: java/util/HashMap.EntrySet.lsl:485 - */ - public Stream stream() { - Stream result = null; - /* body */ { - final Object[] items = _mapToEntryArray(); - result = (StreamLSL) ((Object) new generated.java.util.stream.StreamLSL((Void) null, - /* state = */ generated.java.util.stream.StreamLSL.__$lsl_States.Initialized, - /* storage = */ items, - /* length = */ items.length, - /* closeHandlers = */ Engine.makeSymbolicList(), - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - return result; - } - - /** - * [FUNCTION] HashMap_EntrySetAutomaton::toArray(HashMap_EntrySet) -> array - * Source: java/util/HashMap.EntrySet.lsl:498 - */ - public Object[] toArray() { - Object[] result = null; - /* body */ { - final int len = this.storageRef.size(); - result = new Object[len]; - if (len != 0) { - final LibSLRuntime.Map> unseen = this.storageRef.duplicate(); - int i = 0; - for (i = 0; i < len; i += 1) { - final Object key = unseen.anyKey(); - result[i] = unseen.get(key); - unseen.remove(key); - } - ; - } - } - return result; - } - - /** - * [FUNCTION] HashMap_EntrySetAutomaton::toArray(HashMap_EntrySet, IntFunction) -> array - * Source: java/util/HashMap.EntrySet.lsl:526 - */ - public Object[] toArray(IntFunction generator) { - Object[] result = null; - /* body */ { - final Object[] a = ((Object[]) generator.apply(0)); - final int aLen = a.length; - final int len = this.storageRef.size(); - result = new Object[len]; - if (len != 0) { - final LibSLRuntime.Map> unseen = this.storageRef.duplicate(); - int i = 0; - for (i = 0; i < len; i += 1) { - final Object key = unseen.anyKey(); - result[i] = unseen.get(key); - unseen.remove(key); - } - ; - } - } - return result; - } - - /** - * [FUNCTION] HashMap_EntrySetAutomaton::toArray(HashMap_EntrySet, array) -> array - * Source: java/util/HashMap.EntrySet.lsl:548 - */ - public Object[] toArray(Object[] a) { - Object[] result = null; - /* body */ { - final int aLen = a.length; - final int len = this.storageRef.size(); - if (aLen < len) { - a = new Object[len]; - } - result = a; - if (len != 0) { - final LibSLRuntime.Map> unseen = this.storageRef.duplicate(); - int i = 0; - for (i = 0; i < len; i += 1) { - final Object key = unseen.anyKey(); - result[i] = unseen.get(key); - unseen.remove(key); - } - ; - if (aLen > len) { - result[len] = null; - } - } - } - return result; - } - - /** - * [FUNCTION] HashMap_EntrySetAutomaton::toString(HashMap_EntrySet) -> String - * Source: java/util/HashMap.EntrySet.lsl:574 - */ - public String toString() { - String result = null; - /* body */ { - final int size = this.storageRef.size(); - if (size == 0) { - result = "[]"; - } else { - result = "["; - final int lastIndex = size - 1; - final LibSLRuntime.Map> unseen = this.storageRef.duplicate(); - int i = 0; - for (i = 0; i < size; i += 1) { - final Object key = unseen.anyKey(); - final Map.Entry entry = unseen.get(key); - final Object value = ((AbstractMap_SimpleEntry) ((Object) entry)).value; - result = result.concat(LibSLRuntime.toString(key).concat("=").concat(LibSLRuntime.toString(value))); - if (i != lastIndex) { - result = result.concat(", "); - } - unseen.remove(key); - } - ; - result = result.concat("]"); - } - } - return result; - } - - public static final class __$lsl_States { - public static final byte Initialized = (byte) 0; - } - - @Approximate(HashMap_EntrySet.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/HashMap_EntrySpliterator.java b/approximations/src/main/java/generated/java/util/HashMap_EntrySpliterator.java deleted file mode 100644 index aff56770..00000000 --- a/approximations/src/main/java/generated/java/util/HashMap_EntrySpliterator.java +++ /dev/null @@ -1,220 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/HashMap.lsl:108 -// - java/util/HashMap.EntrySpliterator.lsl:21 -// -package generated.java.util; - -import generated.runtime.LibSLGlobals; -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.ConcurrentModificationException; -import java.util.Map; -import java.util.Spliterator; -import java.util.function.Consumer; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; - -/** - * HashMap_EntrySpliteratorAutomaton for HashMap_EntrySpliterator ~> java.util.HashMap_EntrySpliterator - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(stub.java.util.HashMap_EntrySpliterator.class) -public final class HashMap_EntrySpliterator implements LibSLRuntime.Automaton, Spliterator { - static { - Engine.assume(true); - } - - public HashMap parent; - - public Map.Entry[] entryStorage; - - public int index; - - public int fence; - - public int est; - - public int expectedModCount; - - @LibSLRuntime.AutomatonConstructor - public HashMap_EntrySpliterator(Void __$lsl_token, final byte p0, final HashMap p1, - final Map.Entry[] p2, final int p3, final int p4, final int p5, - final int p6) { - this.parent = p1; - this.entryStorage = p2; - this.index = p3; - this.fence = p4; - this.est = p5; - this.expectedModCount = p6; - } - - @LibSLRuntime.AutomatonConstructor - public HashMap_EntrySpliterator(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Initialized, null, null, 0, -1, 0, 0); - } - - /** - * [SUBROUTINE] HashMap_EntrySpliteratorAutomaton::_getFence() -> int - * Source: java/util/HashMap.EntrySpliterator.lsl:54 - */ - private int _getFence() { - int result = 0; - /* body */ { - Engine.assume(this.parent != null); - if (this.fence < 0) { - final int storageSize = this.entryStorage.length; - this.est = storageSize; - this.fence = storageSize; - this.expectedModCount = ((HashMap) ((Object) this.parent)).modCount; - } - result = this.fence; - } - return result; - } - - /** - * [FUNCTION] HashMap_EntrySpliteratorAutomaton::characteristics(HashMap_EntrySpliterator) -> int - * Source: java/util/HashMap.EntrySpliterator.lsl:88 - */ - public int characteristics() { - int result = 0; - /* body */ { - if ((this.fence < 0) || (this.est == this.entryStorage.length)) { - result = LibSLGlobals.SPLITERATOR_SIZED | LibSLGlobals.SPLITERATOR_DISTINCT; - } else { - result = LibSLGlobals.SPLITERATOR_DISTINCT; - } - } - return result; - } - - /** - * [FUNCTION] HashMap_EntrySpliteratorAutomaton::estimateSize(HashMap_EntrySpliterator) -> long - * Source: java/util/HashMap.EntrySpliterator.lsl:98 - */ - public final long estimateSize() { - long result = 0L; - /* body */ { - _getFence(); - result = ((long) this.est); - } - return result; - } - - /** - * [FUNCTION] HashMap_EntrySpliteratorAutomaton::forEachRemaining(HashMap_EntrySpliterator, Consumer) -> void - * Source: java/util/HashMap.EntrySpliterator.lsl:105 - */ - public void forEachRemaining(Consumer userAction) { - /* body */ { - if (userAction == null) { - throw new NullPointerException(); - } - int hi = this.fence; - int mc = this.expectedModCount; - int i = this.index; - final int storageSize = this.entryStorage.length; - if (hi < 0) { - mc = ((HashMap) ((Object) this.parent)).modCount; - this.expectedModCount = mc; - this.fence = storageSize; - hi = storageSize; - } - this.index = hi; - if ((storageSize > 0) && (storageSize >= hi) && (i >= 0) && (i < this.index)) { - while (i < hi) { - Map.Entry entry = entryStorage[i]; - userAction.accept(entry); - i += 1; - } - ; - if (((HashMap) ((Object) this.parent)).modCount != mc) { - throw new ConcurrentModificationException(); - } - } - } - } - - /** - * [FUNCTION] HashMap_EntrySpliteratorAutomaton::getExactSizeIfKnown(HashMap_EntrySpliterator) -> long - * Source: java/util/HashMap.EntrySpliterator.lsl:154 - */ - public long getExactSizeIfKnown() { - long result = 0L; - /* body */ { - result = _getFence() - this.index; - } - return result; - } - - /** - * [FUNCTION] HashMap_EntrySpliteratorAutomaton::tryAdvance(HashMap_EntrySpliterator, Consumer) -> boolean - * Source: java/util/HashMap.EntrySpliterator.lsl:167 - */ - public boolean tryAdvance(Consumer userAction) { - boolean result = false; - /* body */ { - if (userAction == null) { - throw new NullPointerException(); - } - int hi = _getFence(); - int i = this.index; - if (i < hi) { - this.index = i + 1; - userAction.accept(entryStorage[i]); - if (this.expectedModCount != ((HashMap) ((Object) this.parent)).modCount) { - throw new ConcurrentModificationException(); - } - result = true; - } else { - result = false; - } - } - return result; - } - - /** - * [FUNCTION] HashMap_EntrySpliteratorAutomaton::trySplit(HashMap_EntrySpliterator) -> Spliterator - * Source: java/util/HashMap.EntrySpliterator.lsl:192 - */ - public Spliterator trySplit() { - Spliterator result = null; - /* body */ { - Engine.assume(this.parent != null); - final int hi = _getFence(); - final int lo = this.index; - int mid = (hi + lo) >>> 1; - if (lo >= mid) { - result = null; - } else { - this.est = this.est >>> 1; - this.index = mid; - result = (stub.java.util.HashMap_EntrySpliterator) ((Object) new HashMap_EntrySpliterator((Void) null, - /* state = */ HashMap_EntrySpliterator.__$lsl_States.Initialized, - /* parent = */ this.parent, - /* entryStorage = */ this.entryStorage, - /* index = */ lo, - /* fence = */ mid, - /* est = */ this.est, - /* expectedModCount = */ this.expectedModCount - )); - } - } - return result; - } - - public static final class __$lsl_States { - public static final byte Initialized = (byte) 0; - } - - @Approximate(HashMap_EntrySpliterator.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/HashMap_KeyIterator.java b/approximations/src/main/java/generated/java/util/HashMap_KeyIterator.java deleted file mode 100644 index 152c4e54..00000000 --- a/approximations/src/main/java/generated/java/util/HashMap_KeyIterator.java +++ /dev/null @@ -1,144 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/HashMap.lsl:72 -// - java/util/HashMap.KeyIterator.lsl:20 -// -package generated.java.util; - -import java.lang.IllegalStateException; -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.ConcurrentModificationException; -import java.util.Iterator; -import java.util.Map; -import java.util.NoSuchElementException; -import java.util.function.Consumer; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; - -/** - * HashMap_KeyIteratorAutomaton for HashMap_KeyIterator ~> java.util.HashMap_KeyIterator - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(stub.java.util.HashMap_KeyIterator.class) -public final class HashMap_KeyIterator implements LibSLRuntime.Automaton, Iterator { - static { - Engine.assume(true); - } - - public HashMap parent; - - public LibSLRuntime.Map> unseen; - - public int expectedModCount; - - public Object currentKey; - - @LibSLRuntime.AutomatonConstructor - public HashMap_KeyIterator(Void __$lsl_token, final byte p0, final HashMap p1, - final LibSLRuntime.Map> p2, final int p3, - final Object p4) { - this.parent = p1; - this.unseen = p2; - this.expectedModCount = p3; - this.currentKey = p4; - } - - @LibSLRuntime.AutomatonConstructor - public HashMap_KeyIterator(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Initialized, null, null, 0, null); - } - - /** - * [FUNCTION] HashMap_KeyIteratorAutomaton::forEachRemaining(HashMap_KeyIterator, Consumer) -> void - * Source: java/util/HashMap.KeyIterator.lsl:67 - */ - public void forEachRemaining(Consumer userAction) { - /* body */ { - if (userAction == null) { - throw new NullPointerException(); - } - int size = this.unseen.size(); - if (size != 0) { - while ((size != 0) && (((HashMap) ((Object) this.parent)).modCount == this.expectedModCount)) { - if (((HashMap) ((Object) this.parent)).modCount != this.expectedModCount) { - throw new ConcurrentModificationException(); - } - final Object key = this.unseen.anyKey(); - userAction.accept(key); - this.unseen.remove(key); - size -= 1; - } - ; - } - } - } - - /** - * [FUNCTION] HashMap_KeyIteratorAutomaton::hasNext(HashMap_KeyIterator) -> boolean - * Source: java/util/HashMap.KeyIterator.lsl:96 - */ - public final boolean hasNext() { - boolean result = false; - /* body */ { - result = this.unseen.size() != 0; - } - return result; - } - - /** - * [FUNCTION] HashMap_KeyIteratorAutomaton::next(HashMap_KeyIterator) -> Object - * Source: java/util/HashMap.KeyIterator.lsl:102 - */ - public final Object next() { - Object result = null; - /* body */ { - if (((HashMap) ((Object) this.parent)).modCount != this.expectedModCount) { - throw new ConcurrentModificationException(); - } - if (this.unseen.size() == 0) { - throw new NoSuchElementException(); - } - result = this.unseen.anyKey(); - this.unseen.remove(result); - this.currentKey = result; - } - return result; - } - - /** - * [FUNCTION] HashMap_KeyIteratorAutomaton::remove(HashMap_KeyIterator) -> void - * Source: java/util/HashMap.KeyIterator.lsl:117 - */ - public final void remove() { - /* body */ { - Engine.assume(this.parent != null); - final Object key = this.currentKey; - if (key == null) { - throw new IllegalStateException(); - } - if (((HashMap) ((Object) this.parent)).modCount != this.expectedModCount) { - throw new ConcurrentModificationException(); - } - this.unseen.remove(key); - ((HashMap) ((Object) this.parent)).storage.remove(key); - ((HashMap) ((Object) this.parent)).modCount += 1; - this.expectedModCount = ((HashMap) ((Object) this.parent)).modCount; - this.currentKey = null; - } - } - - public static final class __$lsl_States { - public static final byte Initialized = (byte) 0; - } - - @Approximate(HashMap_KeyIterator.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/HashMap_KeySet.java b/approximations/src/main/java/generated/java/util/HashMap_KeySet.java deleted file mode 100644 index d919ba8f..00000000 --- a/approximations/src/main/java/generated/java/util/HashMap_KeySet.java +++ /dev/null @@ -1,612 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/HashMap.lsl:63 -// - java/util/HashMap.KeySet.lsl:27 -// -package generated.java.util; - -import java.lang.ClassCastException; -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.lang.UnsupportedOperationException; -import java.lang.Void; -import java.util.Collection; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; -import java.util.Spliterator; -import java.util.function.Consumer; -import java.util.function.IntFunction; -import java.util.function.Predicate; -import java.util.stream.Stream; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; -import stub.java.util.stream.StreamLSL; - -/** - * HashMap_KeySetAutomaton for HashMap_KeySet ~> java.util.HashMap_KeySet - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(stub.java.util.HashMap_KeySet.class) -public final class HashMap_KeySet implements LibSLRuntime.Automaton { - static { - Engine.assume(true); - } - - private byte __$lsl_state = __$lsl_States.Allocated; - - public LibSLRuntime.Map> storageRef; - - public HashMap parent; - - @LibSLRuntime.AutomatonConstructor - public HashMap_KeySet(Void __$lsl_token, final byte p0, - final LibSLRuntime.Map> p1, final HashMap p2) { - this.__$lsl_state = p0; - this.storageRef = p1; - this.parent = p2; - } - - @LibSLRuntime.AutomatonConstructor - public HashMap_KeySet(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Allocated, null, null); - } - - /** - * [CONSTRUCTOR] HashMap_KeySetAutomaton::(HashMap_KeySet, HashMap) -> void - * Source: java/util/HashMap.KeySet.lsl:134 - */ - private HashMap_KeySet(HashMap _this) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - LibSLRuntime.error("Private constructor call"); - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [SUBROUTINE] HashMap_KeySetAutomaton::_mapToKeysArray() -> array - * Source: java/util/HashMap.KeySet.lsl:86 - */ - private Object[] _mapToKeysArray() { - Object[] result = null; - /* body */ { - final int storageSize = this.storageRef.size(); - result = new Object[storageSize]; - final LibSLRuntime.Map> unseen = this.storageRef.duplicate(); - int i = 0; - for (i = 0; i < storageSize; i += 1) { - final Object curKey = unseen.anyKey(); - result[i] = curKey; - unseen.remove(curKey); - } - ; - } - return result; - } - - /** - * [FUNCTION] HashMap_KeySetAutomaton::add(HashMap_KeySet, Object) -> boolean - * Source: java/util/HashMap.KeySet.lsl:145 - */ - public boolean add(Object e) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (true) { - throw new UnsupportedOperationException(); - } - } - return result; - } - - /** - * [FUNCTION] HashMap_KeySetAutomaton::addAll(HashMap_KeySet, Collection) -> boolean - * Source: java/util/HashMap.KeySet.lsl:153 - */ - public boolean addAll(Collection c) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (true) { - throw new UnsupportedOperationException(); - } - } - return result; - } - - /** - * [FUNCTION] HashMap_KeySetAutomaton::clear(HashMap_KeySet) -> void - * Source: java/util/HashMap.KeySet.lsl:160 - */ - public final void clear() { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - ((HashMap) ((Object) this.parent)).modCount += 1; - final LibSLRuntime.Map> newStorage = new LibSLRuntime.Map<>(new LibSLRuntime.HashMapContainer<>()); - this.storageRef = newStorage; - ((HashMap) ((Object) this.parent)).storage = newStorage; - } - } - - /** - * [FUNCTION] HashMap_KeySetAutomaton::contains(HashMap_KeySet, Object) -> boolean - * Source: java/util/HashMap.KeySet.lsl:170 - */ - public final boolean contains(Object key) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.storageRef.size() == 0) { - result = false; - } else { - result = this.storageRef.hasKey(key); - } - } - return result; - } - - /** - * [FUNCTION] HashMap_KeySetAutomaton::containsAll(HashMap_KeySet, Collection) -> boolean - * Source: java/util/HashMap.KeySet.lsl:180 - */ - public boolean containsAll(Collection c) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = true; - final Iterator iter = c.iterator(); - while (result && iter.hasNext()) { - final Object item = iter.next(); - result = this.storageRef.hasKey(item); - } - ; - } - return result; - } - - /** - * [FUNCTION] HashMap_KeySetAutomaton::equals(HashMap_KeySet, Object) -> boolean - * Source: java/util/HashMap.KeySet.lsl:193 - */ - public boolean equals(Object other) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (other == this) { - result = true; - } else { - if ((other instanceof Set)) { - final Collection c = ((Collection) other); - final int cLength = c.size(); - final int thisLength = this.storageRef.size(); - if (thisLength == cLength) { - try { - result = true; - final Iterator iter = c.iterator(); - while (result && iter.hasNext()) { - final Object item = iter.next(); - result = this.storageRef.hasKey(item); - } - ; - } catch (ClassCastException __$lsl_exception) { - result = false; - } catch (NullPointerException __$lsl_exception) { - result = false; - } - ; - } else { - result = false; - } - } else { - result = false; - } - } - } - return result; - } - - /** - * [FUNCTION] HashMap_KeySetAutomaton::forEach(HashMap_KeySet, Consumer) -> void - * Source: java/util/HashMap.KeySet.lsl:230 - */ - public final void forEach(Consumer userAction) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (userAction == null) { - throw new NullPointerException(); - } - final int storageSize = this.storageRef.size(); - if (storageSize > 0) { - final LibSLRuntime.Map> unseen = this.storageRef.duplicate(); - final int expectedModCount = ((HashMap) ((Object) this.parent)).modCount; - int i = 0; - for (i = 0; i < storageSize; i += 1) { - final Object curKey = unseen.anyKey(); - userAction.accept(curKey); - unseen.remove(curKey); - } - ; - ((HashMap) ((Object) this.parent))._checkForComodification(expectedModCount); - } - } - } - - /** - * [FUNCTION] HashMap_KeySetAutomaton::hashCode(HashMap_KeySet) -> int - * Source: java/util/HashMap.KeySet.lsl:259 - */ - public int hashCode() { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = LibSLRuntime.hashCode(this.storageRef); - } - return result; - } - - /** - * [FUNCTION] HashMap_KeySetAutomaton::isEmpty(HashMap_KeySet) -> boolean - * Source: java/util/HashMap.KeySet.lsl:266 - */ - public boolean isEmpty() { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.storageRef.size() == 0; - } - return result; - } - - /** - * [FUNCTION] HashMap_KeySetAutomaton::iterator(HashMap_KeySet) -> Iterator - * Source: java/util/HashMap.KeySet.lsl:272 - */ - public final Iterator iterator() { - Iterator result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = (stub.java.util.HashMap_KeyIterator) ((Object) new HashMap_KeyIterator((Void) null, - /* state = */ HashMap_KeyIterator.__$lsl_States.Initialized, - /* parent = */ this.parent, - /* unseen = */ this.storageRef.duplicate(), - /* expectedModCount = */ ((HashMap) ((Object) this.parent)).modCount, - /* currentKey = */ null - )); - } - return result; - } - - /** - * [FUNCTION] HashMap_KeySetAutomaton::parallelStream(HashMap_KeySet) -> Stream - * Source: java/util/HashMap.KeySet.lsl:283 - */ - public Stream parallelStream() { - Stream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final Object[] items = _mapToKeysArray(); - result = (StreamLSL) ((Object) new generated.java.util.stream.StreamLSL((Void) null, - /* state = */ generated.java.util.stream.StreamLSL.__$lsl_States.Initialized, - /* storage = */ _mapToKeysArray(), - /* length = */ items.length, - /* closeHandlers = */ Engine.makeSymbolicList(), - /* isParallel = */ true, - /* linkedOrConsumed = */ false - )); - } - return result; - } - - /** - * [FUNCTION] HashMap_KeySetAutomaton::remove(HashMap_KeySet, Object) -> boolean - * Source: java/util/HashMap.KeySet.lsl:296 - */ - public final boolean remove(Object key) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = false; - if (this.storageRef.hasKey(key)) { - this.storageRef.remove(key); - ((HashMap) ((Object) this.parent)).modCount += 1; - result = true; - } - } - return result; - } - - /** - * [FUNCTION] HashMap_KeySetAutomaton::removeAll(HashMap_KeySet, Collection) -> boolean - * Source: java/util/HashMap.KeySet.lsl:309 - */ - public boolean removeAll(Collection c) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (c == null) { - throw new NullPointerException(); - } - result = false; - final int startStorageSize = this.storageRef.size(); - final int cSize = c.size(); - if ((startStorageSize != 0) && (cSize != 0)) { - if (startStorageSize > cSize) { - final Iterator iter = c.iterator(); - while (iter.hasNext()) { - final Object oKey = iter.next(); - if (this.storageRef.hasKey(oKey)) { - this.storageRef.remove(oKey); - ((HashMap) ((Object) this.parent)).modCount += 1; - } - } - ; - } else { - final LibSLRuntime.Map> unseen = this.storageRef.duplicate(); - int i = 0; - for (i = 0; i < startStorageSize; i += 1) { - final Object curKey = unseen.anyKey(); - if (c.contains(curKey)) { - this.storageRef.remove(curKey); - ((HashMap) ((Object) this.parent)).modCount += 1; - } - unseen.remove(curKey); - } - ; - } - final int resultStorageSize = this.storageRef.size(); - result = startStorageSize != resultStorageSize; - } - } - return result; - } - - /** - * [FUNCTION] HashMap_KeySetAutomaton::removeIf(HashMap_KeySet, Predicate) -> boolean - * Source: java/util/HashMap.KeySet.lsl:368 - */ - public boolean removeIf(Predicate filter) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (filter == null) { - throw new NullPointerException(); - } - result = false; - final int startStorageSize = this.storageRef.size(); - if (startStorageSize != 0) { - final LibSLRuntime.Map> unseen = this.storageRef.duplicate(); - int i = 0; - for (i = 0; i < startStorageSize; i += 1) { - final Object curKey = unseen.anyKey(); - if (filter.test(curKey)) { - this.storageRef.remove(curKey); - ((HashMap) ((Object) this.parent)).modCount += 1; - } - unseen.remove(curKey); - } - ; - final int resultStorageSize = this.storageRef.size(); - result = startStorageSize != resultStorageSize; - } - } - return result; - } - - /** - * [FUNCTION] HashMap_KeySetAutomaton::retainAll(HashMap_KeySet, Collection) -> boolean - * Source: java/util/HashMap.KeySet.lsl:404 - */ - public boolean retainAll(Collection c) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (c == null) { - throw new NullPointerException(); - } - result = false; - final int startStorageSize = this.storageRef.size(); - final int cSize = c.size(); - if ((startStorageSize != 0) && (cSize != 0)) { - final LibSLRuntime.Map> unseen = this.storageRef.duplicate(); - int i = 0; - for (i = 0; i < startStorageSize; i += 1) { - final Object curKey = unseen.anyKey(); - if (!c.contains(curKey)) { - this.storageRef.remove(curKey); - ((HashMap) ((Object) this.parent)).modCount += 1; - } - unseen.remove(curKey); - } - ; - final int resultStorageSize = this.storageRef.size(); - result = startStorageSize != resultStorageSize; - } - } - return result; - } - - /** - * [FUNCTION] HashMap_KeySetAutomaton::size(HashMap_KeySet) -> int - * Source: java/util/HashMap.KeySet.lsl:440 - */ - public final int size() { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.storageRef.size(); - } - return result; - } - - /** - * [FUNCTION] HashMap_KeySetAutomaton::spliterator(HashMap_KeySet) -> Spliterator - * Source: java/util/HashMap.KeySet.lsl:446 - */ - public final Spliterator spliterator() { - Spliterator result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = (stub.java.util.HashMap_KeySpliterator) ((Object) new HashMap_KeySpliterator((Void) null, - /* state = */ HashMap_KeySpliterator.__$lsl_States.Initialized, - /* keysStorage = */ _mapToKeysArray(), - /* parent = */ this.parent, - /* index = */ 0, - /* fence = */ -1, - /* est = */ 0, - /* expectedModCount = */ 0 - )); - } - return result; - } - - /** - * [FUNCTION] HashMap_KeySetAutomaton::stream(HashMap_KeySet) -> Stream - * Source: java/util/HashMap.KeySet.lsl:456 - */ - public Stream stream() { - Stream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final Object[] items = _mapToKeysArray(); - result = (StreamLSL) ((Object) new generated.java.util.stream.StreamLSL((Void) null, - /* state = */ generated.java.util.stream.StreamLSL.__$lsl_States.Initialized, - /* storage = */ items, - /* length = */ items.length, - /* closeHandlers = */ Engine.makeSymbolicList(), - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - return result; - } - - /** - * [FUNCTION] HashMap_KeySetAutomaton::toArray(HashMap_KeySet) -> array - * Source: java/util/HashMap.KeySet.lsl:470 - */ - public Object[] toArray() { - Object[] result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final int len = this.storageRef.size(); - result = new Object[len]; - if (len != 0) { - final LibSLRuntime.Map> unseen = this.storageRef.duplicate(); - int i = 0; - for (i = 0; i < len; i += 1) { - final Object curKey = unseen.anyKey(); - result[i] = curKey; - unseen.remove(curKey); - } - ; - } - } - return result; - } - - /** - * [FUNCTION] HashMap_KeySetAutomaton::toArray(HashMap_KeySet, IntFunction) -> array - * Source: java/util/HashMap.KeySet.lsl:496 - */ - public Object[] toArray(IntFunction generator) { - Object[] result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final Object[] a = ((Object[]) generator.apply(0)); - final int aLen = a.length; - final int len = this.storageRef.size(); - result = new Object[len]; - if (len != 0) { - final LibSLRuntime.Map> unseen = this.storageRef.duplicate(); - int i = 0; - for (i = 0; i < len; i += 1) { - final Object curKey = unseen.anyKey(); - result[i] = curKey; - unseen.remove(curKey); - } - ; - } - } - return result; - } - - /** - * [FUNCTION] HashMap_KeySetAutomaton::toArray(HashMap_KeySet, array) -> array - * Source: java/util/HashMap.KeySet.lsl:518 - */ - public Object[] toArray(Object[] a) { - Object[] result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final int aLen = a.length; - final int len = this.storageRef.size(); - if (aLen < len) { - a = new Object[len]; - } - result = a; - if (len != 0) { - final LibSLRuntime.Map> unseen = this.storageRef.duplicate(); - int i = 0; - for (i = 0; i < len; i += 1) { - final Object curKey = unseen.anyKey(); - result[i] = curKey; - unseen.remove(curKey); - } - ; - if (aLen > len) { - result[len] = null; - } - } - } - return result; - } - - /** - * [FUNCTION] HashMap_KeySetAutomaton::toString(HashMap_KeySet) -> String - * Source: java/util/HashMap.KeySet.lsl:544 - */ - public String toString() { - String result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final int size = this.storageRef.size(); - if (size == 0) { - result = "[]"; - } else { - result = "["; - final int lastIndex = size - 1; - final LibSLRuntime.Map> unseen = this.storageRef.duplicate(); - int i = 0; - for (i = 0; i < size; i += 1) { - final Object key = unseen.anyKey(); - result = result.concat(LibSLRuntime.toString(key)); - if (i != lastIndex) { - result = result.concat(", "); - } - unseen.remove(key); - } - ; - result = result.concat("]"); - } - } - return result; - } - - public static final class __$lsl_States { - public static final byte Allocated = (byte) 0; - - public static final byte Initialized = (byte) 1; - } - - @Approximate(HashMap_KeySet.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/HashMap_KeySpliterator.java b/approximations/src/main/java/generated/java/util/HashMap_KeySpliterator.java deleted file mode 100644 index 9ea2bf7e..00000000 --- a/approximations/src/main/java/generated/java/util/HashMap_KeySpliterator.java +++ /dev/null @@ -1,219 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/HashMap.lsl:81 -// - java/util/HashMap.KeySpliterator.lsl:21 -// -package generated.java.util; - -import generated.runtime.LibSLGlobals; -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.ConcurrentModificationException; -import java.util.Spliterator; -import java.util.function.Consumer; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; - -/** - * HashMap_KeySpliteratorAutomaton for HashMap_KeySpliterator ~> java.util.HashMap_KeySpliterator - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(stub.java.util.HashMap_KeySpliterator.class) -public final class HashMap_KeySpliterator implements LibSLRuntime.Automaton, Spliterator { - static { - Engine.assume(true); - } - - public Object[] keysStorage; - - public HashMap parent; - - public int index; - - public int fence; - - public int est; - - public int expectedModCount; - - @LibSLRuntime.AutomatonConstructor - public HashMap_KeySpliterator(Void __$lsl_token, final byte p0, final Object[] p1, - final HashMap p2, final int p3, final int p4, final int p5, final int p6) { - this.keysStorage = p1; - this.parent = p2; - this.index = p3; - this.fence = p4; - this.est = p5; - this.expectedModCount = p6; - } - - @LibSLRuntime.AutomatonConstructor - public HashMap_KeySpliterator(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Initialized, null, null, 0, -1, 0, 0); - } - - /** - * [SUBROUTINE] HashMap_KeySpliteratorAutomaton::_getFence() -> int - * Source: java/util/HashMap.KeySpliterator.lsl:54 - */ - private int _getFence() { - int result = 0; - /* body */ { - Engine.assume(this.parent != null); - if (this.fence < 0) { - final int storageSize = this.keysStorage.length; - this.est = storageSize; - this.fence = storageSize; - this.expectedModCount = ((HashMap) ((Object) this.parent)).modCount; - } - result = this.fence; - } - return result; - } - - /** - * [FUNCTION] HashMap_KeySpliteratorAutomaton::characteristics(HashMap_KeySpliterator) -> int - * Source: java/util/HashMap.KeySpliterator.lsl:88 - */ - public int characteristics() { - int result = 0; - /* body */ { - if ((this.fence < 0) || (this.est == this.keysStorage.length)) { - result = LibSLGlobals.SPLITERATOR_SIZED | LibSLGlobals.SPLITERATOR_DISTINCT; - } else { - result = LibSLGlobals.SPLITERATOR_DISTINCT; - } - } - return result; - } - - /** - * [FUNCTION] HashMap_KeySpliteratorAutomaton::estimateSize(HashMap_KeySpliterator) -> long - * Source: java/util/HashMap.KeySpliterator.lsl:98 - */ - public final long estimateSize() { - long result = 0L; - /* body */ { - _getFence(); - result = ((long) this.est); - } - return result; - } - - /** - * [FUNCTION] HashMap_KeySpliteratorAutomaton::forEachRemaining(HashMap_KeySpliterator, Consumer) -> void - * Source: java/util/HashMap.KeySpliterator.lsl:105 - */ - public void forEachRemaining(Consumer userAction) { - /* body */ { - if (userAction == null) { - throw new NullPointerException(); - } - int hi = this.fence; - int mc = this.expectedModCount; - int i = this.index; - final int storageSize = this.keysStorage.length; - if (hi < 0) { - this.expectedModCount = ((HashMap) ((Object) this.parent)).modCount; - mc = this.expectedModCount; - this.fence = storageSize; - hi = storageSize; - } - this.index = hi; - if ((storageSize > 0) && (storageSize >= hi) && (i >= 0) && (i < this.index)) { - while (i < hi) { - Object curKey = keysStorage[i]; - userAction.accept(curKey); - i += 1; - } - ; - final int modCount = ((HashMap) ((Object) this.parent)).modCount; - if (modCount != mc) { - throw new ConcurrentModificationException(); - } - } - } - } - - /** - * [FUNCTION] HashMap_KeySpliteratorAutomaton::getExactSizeIfKnown(HashMap_KeySpliterator) -> long - * Source: java/util/HashMap.KeySpliterator.lsl:155 - */ - public long getExactSizeIfKnown() { - long result = 0L; - /* body */ { - result = _getFence() - this.index; - } - return result; - } - - /** - * [FUNCTION] HashMap_KeySpliteratorAutomaton::tryAdvance(HashMap_KeySpliterator, Consumer) -> boolean - * Source: java/util/HashMap.KeySpliterator.lsl:168 - */ - public boolean tryAdvance(Consumer userAction) { - boolean result = false; - /* body */ { - if (userAction == null) { - throw new NullPointerException(); - } - int hi = _getFence(); - int i = this.index; - if (i < hi) { - this.index = i + 1; - userAction.accept(keysStorage[i]); - if (this.expectedModCount != ((HashMap) ((Object) this.parent)).modCount) { - throw new ConcurrentModificationException(); - } - result = true; - } else { - result = false; - } - } - return result; - } - - /** - * [FUNCTION] HashMap_KeySpliteratorAutomaton::trySplit(HashMap_KeySpliterator) -> Spliterator - * Source: java/util/HashMap.KeySpliterator.lsl:193 - */ - public Spliterator trySplit() { - Spliterator result = null; - /* body */ { - Engine.assume(this.parent != null); - final int hi = _getFence(); - final int lo = this.index; - int mid = (hi + lo) >>> 1; - if (lo >= mid) { - result = null; - } else { - this.est = this.est >>> 1; - this.index = mid; - result = (stub.java.util.HashMap_KeySpliterator) ((Object) new HashMap_KeySpliterator((Void) null, - /* state = */ HashMap_KeySpliterator.__$lsl_States.Initialized, - /* keysStorage = */ this.keysStorage, - /* parent = */ this.parent, - /* index = */ lo, - /* fence = */ mid, - /* est = */ this.est, - /* expectedModCount = */ this.expectedModCount - )); - } - } - return result; - } - - public static final class __$lsl_States { - public static final byte Initialized = (byte) 0; - } - - @Approximate(HashMap_KeySpliterator.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/HashMap_ValueIterator.java b/approximations/src/main/java/generated/java/util/HashMap_ValueIterator.java deleted file mode 100644 index ad052654..00000000 --- a/approximations/src/main/java/generated/java/util/HashMap_ValueIterator.java +++ /dev/null @@ -1,147 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/HashMap.lsl:45 -// - java/util/HashMap.ValueIterator.lsl:20 -// -package generated.java.util; - -import java.lang.IllegalStateException; -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.ConcurrentModificationException; -import java.util.Iterator; -import java.util.Map; -import java.util.NoSuchElementException; -import java.util.function.Consumer; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; - -/** - * HashMap_ValueIteratorAutomaton for HashMap_ValueIterator ~> java.util.HashMap_ValueIterator - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(stub.java.util.HashMap_ValueIterator.class) -public class HashMap_ValueIterator implements LibSLRuntime.Automaton, Iterator { - static { - Engine.assume(true); - } - - public HashMap parent; - - public LibSLRuntime.Map> unseen; - - public int expectedModCount; - - public Object currentKey; - - @LibSLRuntime.AutomatonConstructor - public HashMap_ValueIterator(Void __$lsl_token, final byte p0, final HashMap p1, - final LibSLRuntime.Map> p2, final int p3, - final Object p4) { - this.parent = p1; - this.unseen = p2; - this.expectedModCount = p3; - this.currentKey = p4; - } - - @LibSLRuntime.AutomatonConstructor - public HashMap_ValueIterator(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Initialized, null, null, 0, null); - } - - /** - * [FUNCTION] HashMap_ValueIteratorAutomaton::forEachRemaining(HashMap_ValueIterator, Consumer) -> void - * Source: java/util/HashMap.ValueIterator.lsl:67 - */ - public void forEachRemaining(Consumer userAction) { - /* body */ { - if (userAction == null) { - throw new NullPointerException(); - } - int size = this.unseen.size(); - if (size != 0) { - while ((size != 0) && (((HashMap) ((Object) this.parent)).modCount == this.expectedModCount)) { - if (((HashMap) ((Object) this.parent)).modCount != this.expectedModCount) { - throw new ConcurrentModificationException(); - } - final Object key = this.unseen.anyKey(); - final Map.Entry entry = this.unseen.get(key); - userAction.accept(((AbstractMap_SimpleEntry) ((Object) entry)).value); - this.unseen.remove(key); - size -= 1; - } - ; - } - } - } - - /** - * [FUNCTION] HashMap_ValueIteratorAutomaton::hasNext(HashMap_ValueIterator) -> boolean - * Source: java/util/HashMap.ValueIterator.lsl:99 - */ - public final boolean hasNext() { - boolean result = false; - /* body */ { - result = this.unseen.size() != 0; - } - return result; - } - - /** - * [FUNCTION] HashMap_ValueIteratorAutomaton::next(HashMap_ValueIterator) -> Object - * Source: java/util/HashMap.ValueIterator.lsl:105 - */ - public final Object next() { - Object result = null; - /* body */ { - if (((HashMap) ((Object) this.parent)).modCount != this.expectedModCount) { - throw new ConcurrentModificationException(); - } - if (this.unseen.size() == 0) { - throw new NoSuchElementException(); - } - final Object key = this.unseen.anyKey(); - final Map.Entry entry = this.unseen.get(key); - result = ((AbstractMap_SimpleEntry) ((Object) entry)).value; - this.unseen.remove(key); - this.currentKey = key; - } - return result; - } - - /** - * [FUNCTION] HashMap_ValueIteratorAutomaton::remove(HashMap_ValueIterator) -> void - * Source: java/util/HashMap.ValueIterator.lsl:123 - */ - public final void remove() { - /* body */ { - Engine.assume(this.parent != null); - final Object key = this.currentKey; - if (this.currentKey == null) { - throw new IllegalStateException(); - } - if (((HashMap) ((Object) this.parent)).modCount != this.expectedModCount) { - throw new ConcurrentModificationException(); - } - this.unseen.remove(key); - ((HashMap) ((Object) this.parent)).storage.remove(key); - ((HashMap) ((Object) this.parent)).modCount += 1; - this.expectedModCount = ((HashMap) ((Object) this.parent)).modCount; - this.currentKey = null; - } - } - - public static final class __$lsl_States { - public static final byte Initialized = (byte) 0; - } - - @Approximate(HashMap_ValueIterator.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/HashMap_ValueSpliterator.java b/approximations/src/main/java/generated/java/util/HashMap_ValueSpliterator.java deleted file mode 100644 index d7e22912..00000000 --- a/approximations/src/main/java/generated/java/util/HashMap_ValueSpliterator.java +++ /dev/null @@ -1,218 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/HashMap.lsl:54 -// - java/util/HashMap.ValueSpliterator.lsl:21 -// -package generated.java.util; - -import generated.runtime.LibSLGlobals; -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.ConcurrentModificationException; -import java.util.Spliterator; -import java.util.function.Consumer; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; - -/** - * HashMap_ValueSpliteratorAutomaton for HashMap_ValueSpliterator ~> java.util.HashMap_ValueSpliterator - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(stub.java.util.HashMap_ValueSpliterator.class) -public final class HashMap_ValueSpliterator implements LibSLRuntime.Automaton, Spliterator { - static { - Engine.assume(true); - } - - public Object[] valuesStorage; - - public HashMap parent; - - public int index; - - public int fence; - - public int est; - - public int expectedModCount; - - @LibSLRuntime.AutomatonConstructor - public HashMap_ValueSpliterator(Void __$lsl_token, final byte p0, final Object[] p1, - final HashMap p2, final int p3, final int p4, final int p5, final int p6) { - this.valuesStorage = p1; - this.parent = p2; - this.index = p3; - this.fence = p4; - this.est = p5; - this.expectedModCount = p6; - } - - @LibSLRuntime.AutomatonConstructor - public HashMap_ValueSpliterator(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Initialized, null, null, 0, -1, 0, 0); - } - - /** - * [SUBROUTINE] HashMap_ValueSpliteratorAutomaton::_getFence() -> int - * Source: java/util/HashMap.ValueSpliterator.lsl:55 - */ - private int _getFence() { - int result = 0; - /* body */ { - Engine.assume(this.parent != null); - if (this.fence < 0) { - final int storageSize = this.valuesStorage.length; - this.est = storageSize; - this.fence = storageSize; - this.expectedModCount = ((HashMap) ((Object) this.parent)).modCount; - } - result = this.fence; - } - return result; - } - - /** - * [FUNCTION] HashMap_ValueSpliteratorAutomaton::characteristics(HashMap_ValueSpliterator) -> int - * Source: java/util/HashMap.ValueSpliterator.lsl:89 - */ - public int characteristics() { - int result = 0; - /* body */ { - if ((this.fence < 0) || (this.est == this.valuesStorage.length)) { - result = LibSLGlobals.SPLITERATOR_SIZED; - } else { - result = 0; - } - } - return result; - } - - /** - * [FUNCTION] HashMap_ValueSpliteratorAutomaton::estimateSize(HashMap_ValueSpliterator) -> long - * Source: java/util/HashMap.ValueSpliterator.lsl:99 - */ - public final long estimateSize() { - long result = 0L; - /* body */ { - _getFence(); - result = ((long) this.est); - } - return result; - } - - /** - * [FUNCTION] HashMap_ValueSpliteratorAutomaton::forEachRemaining(HashMap_ValueSpliterator, Consumer) -> void - * Source: java/util/HashMap.ValueSpliterator.lsl:106 - */ - public void forEachRemaining(Consumer userAction) { - /* body */ { - if (userAction == null) { - throw new NullPointerException(); - } - int hi = this.fence; - int mc = this.expectedModCount; - int i = this.index; - final int storageSize = this.valuesStorage.length; - if (hi < 0) { - mc = ((HashMap) ((Object) this.parent)).modCount; - this.expectedModCount = mc; - this.fence = storageSize; - hi = storageSize; - } - this.index = hi; - if ((storageSize > 0) && (storageSize >= hi) && (i >= 0) && (i < this.index)) { - while (i < hi) { - userAction.accept(valuesStorage[i]); - i += 1; - } - ; - final int modCount = ((HashMap) ((Object) this.parent)).modCount; - if (modCount != mc) { - throw new ConcurrentModificationException(); - } - } - } - } - - /** - * [FUNCTION] HashMap_ValueSpliteratorAutomaton::getExactSizeIfKnown(HashMap_ValueSpliterator) -> long - * Source: java/util/HashMap.ValueSpliterator.lsl:156 - */ - public long getExactSizeIfKnown() { - long result = 0L; - /* body */ { - result = _getFence() - this.index; - } - return result; - } - - /** - * [FUNCTION] HashMap_ValueSpliteratorAutomaton::tryAdvance(HashMap_ValueSpliterator, Consumer) -> boolean - * Source: java/util/HashMap.ValueSpliterator.lsl:169 - */ - public boolean tryAdvance(Consumer userAction) { - boolean result = false; - /* body */ { - if (userAction == null) { - throw new NullPointerException(); - } - int hi = _getFence(); - int i = this.index; - if (i < hi) { - this.index = i + 1; - userAction.accept(valuesStorage[i]); - if (((HashMap) ((Object) this.parent)).modCount != this.expectedModCount) { - throw new ConcurrentModificationException(); - } - result = true; - } else { - result = false; - } - } - return result; - } - - /** - * [FUNCTION] HashMap_ValueSpliteratorAutomaton::trySplit(HashMap_ValueSpliterator) -> Spliterator - * Source: java/util/HashMap.ValueSpliterator.lsl:194 - */ - public Spliterator trySplit() { - Spliterator result = null; - /* body */ { - Engine.assume(this.parent != null); - final int hi = _getFence(); - final int lo = this.index; - int mid = (hi + lo) >>> 1; - if (lo >= mid) { - result = null; - } else { - this.est = this.est >>> 1; - this.index = mid; - result = (stub.java.util.HashMap_ValueSpliterator) ((Object) new HashMap_ValueSpliterator((Void) null, - /* state = */ HashMap_ValueSpliterator.__$lsl_States.Initialized, - /* valuesStorage = */ this.valuesStorage, - /* parent = */ this.parent, - /* index = */ lo, - /* fence = */ mid, - /* est = */ this.est, - /* expectedModCount = */ this.expectedModCount - )); - } - } - return result; - } - - public static final class __$lsl_States { - public static final byte Initialized = (byte) 0; - } - - @Approximate(HashMap_ValueSpliterator.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/HashMap_Values.java b/approximations/src/main/java/generated/java/util/HashMap_Values.java deleted file mode 100644 index d18dac15..00000000 --- a/approximations/src/main/java/generated/java/util/HashMap_Values.java +++ /dev/null @@ -1,581 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/HashMap.lsl:36 -// - java/util/HashMap.Values.lsl:25 -// -package generated.java.util; - -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.lang.UnsupportedOperationException; -import java.lang.Void; -import java.util.Collection; -import java.util.Iterator; -import java.util.Map; -import java.util.Spliterator; -import java.util.function.Consumer; -import java.util.function.IntFunction; -import java.util.function.Predicate; -import java.util.stream.Stream; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; -import stub.java.util.stream.StreamLSL; - -/** - * HashMap_ValuesAutomaton for HashMap_Values ~> java.util.HashMap_Values - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(stub.java.util.HashMap_Values.class) -public class HashMap_Values implements LibSLRuntime.Automaton { - static { - Engine.assume(true); - } - - public LibSLRuntime.Map> storageRef; - - public HashMap parent; - - @LibSLRuntime.AutomatonConstructor - public HashMap_Values(Void __$lsl_token, final byte p0, - final LibSLRuntime.Map> p1, final HashMap p2) { - this.storageRef = p1; - this.parent = p2; - } - - @LibSLRuntime.AutomatonConstructor - public HashMap_Values(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Initialized, null, null); - } - - /** - * [SUBROUTINE] HashMap_ValuesAutomaton::_mapToValuesArray() -> array - * Source: java/util/HashMap.Values.lsl:76 - */ - private Object[] _mapToValuesArray() { - Object[] result = null; - /* body */ { - final int size = this.storageRef.size(); - result = new Object[size]; - if (size != 0) { - final LibSLRuntime.Map> unseen = this.storageRef.duplicate(); - int i = 0; - for (i = 0; i < size; i += 1) { - final Object curKey = unseen.anyKey(); - final Map.Entry entry = unseen.get(curKey); - result[i] = ((AbstractMap_SimpleEntry) ((Object) entry)).value; - unseen.remove(curKey); - } - ; - } - } - return result; - } - - /** - * [FUNCTION] HashMap_ValuesAutomaton::add(HashMap_Values, Object) -> boolean - * Source: java/util/HashMap.Values.lsl:113 - */ - public boolean add(Object e) { - boolean result = false; - /* body */ { - if (true) { - throw new UnsupportedOperationException(); - } - } - return result; - } - - /** - * [FUNCTION] HashMap_ValuesAutomaton::addAll(HashMap_Values, Collection) -> boolean - * Source: java/util/HashMap.Values.lsl:121 - */ - public boolean addAll(Collection c) { - boolean result = false; - /* body */ { - if (true) { - throw new UnsupportedOperationException(); - } - } - return result; - } - - /** - * [FUNCTION] HashMap_ValuesAutomaton::clear(HashMap_Values) -> void - * Source: java/util/HashMap.Values.lsl:128 - */ - public final void clear() { - /* body */ { - ((HashMap) ((Object) this.parent)).modCount += 1; - final LibSLRuntime.Map> newStorage = new LibSLRuntime.Map<>(new LibSLRuntime.HashMapContainer<>()); - ((HashMap) ((Object) this.parent)).storage = newStorage; - this.storageRef = newStorage; - } - } - - /** - * [FUNCTION] HashMap_ValuesAutomaton::contains(HashMap_Values, Object) -> boolean - * Source: java/util/HashMap.Values.lsl:138 - */ - public final boolean contains(Object value) { - boolean result = false; - /* body */ { - result = false; - int size = this.storageRef.size(); - if (size != 0) { - final LibSLRuntime.Map> unseen = this.storageRef.duplicate(); - while ((result != true) && (size != 0)) { - final Object key = unseen.anyKey(); - final Map.Entry entry = unseen.get(key); - final Object curValue = ((AbstractMap_SimpleEntry) ((Object) entry)).value; - if (LibSLRuntime.equals(curValue, value)) { - result = true; - } - unseen.remove(key); - size -= 1; - } - ; - } - } - return result; - } - - /** - * [FUNCTION] HashMap_ValuesAutomaton::containsAll(HashMap_Values, Collection) -> boolean - * Source: java/util/HashMap.Values.lsl:170 - */ - public boolean containsAll(Collection c) { - boolean result = false; - /* body */ { - result = true; - final int thisSize = this.storageRef.size(); - if ((thisSize != 0) && (c != this)) { - Engine.assume(thisSize > 0); - final int otherSize = c.size(); - if (otherSize > 0) { - int i = 0; - final Object[] thisValues = new Object[thisSize]; - final LibSLRuntime.Map> unseen = this.storageRef.duplicate(); - for (i = 0; i < thisSize; i += 1) { - final Object key = unseen.anyKey(); - final Map.Entry entry = unseen.get(key); - thisValues[i] = ((AbstractMap_SimpleEntry) ((Object) entry)).value; - unseen.remove(key); - } - ; - final Iterator iter = c.iterator(); - while (result && iter.hasNext()) { - final Object value = iter.next(); - result = false; - i = 0; - while ((!result) && (i != thisSize)) { - result = LibSLRuntime.equals(thisValues[i], value); - i += 1; - } - ; - } - ; - } - } - } - return result; - } - - /** - * [FUNCTION] HashMap_ValuesAutomaton::forEach(HashMap_Values, Consumer) -> void - * Source: java/util/HashMap.Values.lsl:268 - */ - public final void forEach(Consumer userAction) { - /* body */ { - if (userAction == null) { - throw new NullPointerException(); - } - final int size = this.storageRef.size(); - if (size > 0) { - final int expectedModCount = ((HashMap) ((Object) this.parent)).modCount; - final LibSLRuntime.Map> unseen = this.storageRef.duplicate(); - int i = 0; - for (i = 0; i < size; i += 1) { - final Object key = unseen.anyKey(); - final Map.Entry entry = unseen.get(key); - userAction.accept(((AbstractMap_SimpleEntry) ((Object) entry)).value); - unseen.remove(key); - } - ; - ((HashMap) ((Object) this.parent))._checkForComodification(expectedModCount); - } - } - } - - /** - * [FUNCTION] HashMap_ValuesAutomaton::isEmpty(HashMap_Values) -> boolean - * Source: java/util/HashMap.Values.lsl:304 - */ - public boolean isEmpty() { - boolean result = false; - /* body */ { - result = this.storageRef.size() == 0; - } - return result; - } - - /** - * [FUNCTION] HashMap_ValuesAutomaton::iterator(HashMap_Values) -> Iterator - * Source: java/util/HashMap.Values.lsl:310 - */ - public final Iterator iterator() { - Iterator result = null; - /* body */ { - result = (stub.java.util.HashMap_ValueIterator) ((Object) new HashMap_ValueIterator((Void) null, - /* state = */ HashMap_ValueIterator.__$lsl_States.Initialized, - /* parent = */ this.parent, - /* unseen = */ this.storageRef.duplicate(), - /* expectedModCount = */ ((HashMap) ((Object) this.parent)).modCount, - /* currentKey = */ null - )); - } - return result; - } - - /** - * [FUNCTION] HashMap_ValuesAutomaton::parallelStream(HashMap_Values) -> Stream - * Source: java/util/HashMap.Values.lsl:321 - */ - public Stream parallelStream() { - Stream result = null; - /* body */ { - final Object[] items = _mapToValuesArray(); - result = (StreamLSL) ((Object) new generated.java.util.stream.StreamLSL((Void) null, - /* state = */ generated.java.util.stream.StreamLSL.__$lsl_States.Initialized, - /* storage = */ items, - /* length = */ items.length, - /* closeHandlers = */ Engine.makeSymbolicList(), - /* isParallel = */ true, - /* linkedOrConsumed = */ false - )); - } - return result; - } - - /** - * [FUNCTION] HashMap_ValuesAutomaton::remove(HashMap_Values, Object) -> boolean - * Source: java/util/HashMap.Values.lsl:335 - */ - public boolean remove(Object value) { - boolean result = false; - /* body */ { - result = false; - final LibSLRuntime.Map> unseen = this.storageRef.duplicate(); - int thisSize = this.storageRef.size(); - int i = 0; - if (value == null) { - while ((result != true) && (thisSize != 0)) { - final Object curKey = unseen.anyKey(); - final Map.Entry entry = unseen.get(curKey); - final Object curValue = ((AbstractMap_SimpleEntry) ((Object) entry)).value; - if (curValue == null) { - this.storageRef.remove(curKey); - result = true; - ((HashMap) ((Object) this.parent)).modCount += 1; - } - unseen.remove(curKey); - thisSize -= 1; - } - ; - } else { - while ((result != true) && (thisSize != 0)) { - final Object curKey = unseen.anyKey(); - final Map.Entry entry = unseen.get(curKey); - final Object curValue = ((AbstractMap_SimpleEntry) ((Object) entry)).value; - if (LibSLRuntime.equals(value, curValue)) { - this.storageRef.remove(curKey); - result = true; - ((HashMap) ((Object) this.parent)).modCount += 1; - } - unseen.remove(curKey); - thisSize -= 1; - } - ; - } - } - return result; - } - - /** - * [FUNCTION] HashMap_ValuesAutomaton::removeAll(HashMap_Values, Collection) -> boolean - * Source: java/util/HashMap.Values.lsl:392 - */ - public boolean removeAll(Collection c) { - boolean result = false; - /* body */ { - if (c == null) { - throw new NullPointerException(); - } - result = false; - final int startStorageSize = this.storageRef.size(); - final int cSize = c.size(); - if ((startStorageSize != 0) && (cSize != 0)) { - final LibSLRuntime.Map> unseen = this.storageRef.duplicate(); - int i = 0; - for (i = 0; i < startStorageSize; i += 1) { - final Object curKey = unseen.anyKey(); - final Map.Entry entry = unseen.get(curKey); - final Object curValue = ((AbstractMap_SimpleEntry) ((Object) entry)).value; - if (c.contains(curValue)) { - this.storageRef.remove(curKey); - ((HashMap) ((Object) this.parent)).modCount += 1; - } - unseen.remove(curKey); - } - ; - final int resultStorageSize = this.storageRef.size(); - result = startStorageSize != resultStorageSize; - } - } - return result; - } - - /** - * [FUNCTION] HashMap_ValuesAutomaton::removeIf(HashMap_Values, Predicate) -> boolean - * Source: java/util/HashMap.Values.lsl:431 - */ - public boolean removeIf(Predicate filter) { - boolean result = false; - /* body */ { - if (filter == null) { - throw new NullPointerException(); - } - result = false; - final int startStorageSize = this.storageRef.size(); - if (startStorageSize != 0) { - final LibSLRuntime.Map> unseen = this.storageRef.duplicate(); - int i = 0; - for (i = 0; i < startStorageSize; i += 1) { - final Object curKey = unseen.anyKey(); - final Map.Entry entry = unseen.get(curKey); - final Object curValue = ((AbstractMap_SimpleEntry) ((Object) entry)).value; - if (filter.test(curValue)) { - this.storageRef.remove(curKey); - ((HashMap) ((Object) this.parent)).modCount += 1; - } - unseen.remove(curKey); - } - ; - final int resultStorageSize = this.storageRef.size(); - result = startStorageSize != resultStorageSize; - } - } - return result; - } - - /** - * [FUNCTION] HashMap_ValuesAutomaton::retainAll(HashMap_Values, Collection) -> boolean - * Source: java/util/HashMap.Values.lsl:469 - */ - public boolean retainAll(Collection c) { - boolean result = false; - /* body */ { - if (c == null) { - throw new NullPointerException(); - } - result = false; - final int startStorageSize = this.storageRef.size(); - final int cSize = c.size(); - if ((startStorageSize != 0) && (cSize != 0)) { - final LibSLRuntime.Map> unseen = this.storageRef.duplicate(); - int i = 0; - for (i = 0; i < startStorageSize; i += 1) { - final Object curKey = unseen.anyKey(); - final Map.Entry entry = unseen.get(curKey); - final Object curValue = ((AbstractMap_SimpleEntry) ((Object) entry)).value; - if (!c.contains(curValue)) { - this.storageRef.remove(curKey); - ((HashMap) ((Object) this.parent)).modCount += 1; - } - unseen.remove(curKey); - } - ; - final int resultStorageSize = this.storageRef.size(); - result = startStorageSize != resultStorageSize; - } - } - return result; - } - - /** - * [FUNCTION] HashMap_ValuesAutomaton::size(HashMap_Values) -> int - * Source: java/util/HashMap.Values.lsl:507 - */ - public final int size() { - int result = 0; - /* body */ { - result = this.storageRef.size(); - } - return result; - } - - /** - * [FUNCTION] HashMap_ValuesAutomaton::spliterator(HashMap_Values) -> Spliterator - * Source: java/util/HashMap.Values.lsl:513 - */ - public final Spliterator spliterator() { - Spliterator result = null; - /* body */ { - result = (stub.java.util.HashMap_ValueSpliterator) ((Object) new HashMap_ValueSpliterator((Void) null, - /* state = */ HashMap_ValueSpliterator.__$lsl_States.Initialized, - /* valuesStorage = */ _mapToValuesArray(), - /* parent = */ this.parent, - /* index = */ 0, - /* fence = */ -1, - /* est = */ 0, - /* expectedModCount = */ 0 - )); - } - return result; - } - - /** - * [FUNCTION] HashMap_ValuesAutomaton::stream(HashMap_Values) -> Stream - * Source: java/util/HashMap.Values.lsl:523 - */ - public Stream stream() { - Stream result = null; - /* body */ { - final Object[] items = _mapToValuesArray(); - result = (StreamLSL) ((Object) new generated.java.util.stream.StreamLSL((Void) null, - /* state = */ generated.java.util.stream.StreamLSL.__$lsl_States.Initialized, - /* storage = */ items, - /* length = */ items.length, - /* closeHandlers = */ Engine.makeSymbolicList(), - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - return result; - } - - /** - * [FUNCTION] HashMap_ValuesAutomaton::toArray(HashMap_Values) -> array - * Source: java/util/HashMap.Values.lsl:536 - */ - public Object[] toArray() { - Object[] result = null; - /* body */ { - final int len = this.storageRef.size(); - result = new Object[len]; - if (len != 0) { - final LibSLRuntime.Map> unseen = this.storageRef.duplicate(); - int i = 0; - for (i = 0; i < len; i += 1) { - final Object key = unseen.anyKey(); - final Map.Entry entry = unseen.get(key); - result[i] = ((AbstractMap_SimpleEntry) ((Object) entry)).value; - unseen.remove(key); - } - ; - } - } - return result; - } - - /** - * [FUNCTION] HashMap_ValuesAutomaton::toArray(HashMap_Values, IntFunction) -> array - * Source: java/util/HashMap.Values.lsl:565 - */ - public Object[] toArray(IntFunction generator) { - Object[] result = null; - /* body */ { - final Object[] a = ((Object[]) generator.apply(0)); - final int aLen = a.length; - final int len = this.storageRef.size(); - result = new Object[len]; - if (len != 0) { - final LibSLRuntime.Map> unseen = this.storageRef.duplicate(); - int i = 0; - for (i = 0; i < len; i += 1) { - final Object key = unseen.anyKey(); - final Map.Entry entry = unseen.get(key); - result[i] = ((AbstractMap_SimpleEntry) ((Object) entry)).value; - unseen.remove(key); - } - ; - } - } - return result; - } - - /** - * [FUNCTION] HashMap_ValuesAutomaton::toArray(HashMap_Values, array) -> array - * Source: java/util/HashMap.Values.lsl:587 - */ - public Object[] toArray(Object[] a) { - Object[] result = null; - /* body */ { - final int aLen = a.length; - final int len = this.storageRef.size(); - if (aLen < len) { - a = new Object[len]; - } - result = a; - if (len != 0) { - final LibSLRuntime.Map> unseen = this.storageRef.duplicate(); - int i = 0; - for (i = 0; i < len; i += 1) { - final Object key = unseen.anyKey(); - final Map.Entry entry = unseen.get(key); - result[i] = ((AbstractMap_SimpleEntry) ((Object) entry)).value; - unseen.remove(key); - } - ; - if (aLen > len) { - result[len] = null; - } - } - } - return result; - } - - /** - * [FUNCTION] HashMap_ValuesAutomaton::toString(HashMap_Values) -> String - * Source: java/util/HashMap.Values.lsl:613 - */ - public String toString() { - String result = null; - /* body */ { - final int size = this.storageRef.size(); - if (size == 0) { - result = "[]"; - } else { - result = "["; - final int lastIndex = size - 1; - final LibSLRuntime.Map> unseen = this.storageRef.duplicate(); - int i = 0; - for (i = 0; i < size; i += 1) { - final Object key = unseen.anyKey(); - final Map.Entry entry = unseen.get(key); - result = result.concat(LibSLRuntime.toString(((AbstractMap_SimpleEntry) ((Object) entry)).value)); - if (i != lastIndex) { - result = result.concat(", "); - } - unseen.remove(key); - } - ; - result = result.concat("]"); - } - } - return result; - } - - public static final class __$lsl_States { - public static final byte Initialized = (byte) 0; - } - - @Approximate(HashMap_Values.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/HashSet.java b/approximations/src/main/java/generated/java/util/HashSet.java deleted file mode 100644 index 57bf4777..00000000 --- a/approximations/src/main/java/generated/java/util/HashSet.java +++ /dev/null @@ -1,759 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/HashSet.lsl:20 -// - java/util/HashSet.main.lsl:25 -// -package generated.java.util; - -import generated.runtime.LibSLGlobals; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; -import java.lang.Cloneable; -import java.lang.IllegalArgumentException; -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.Collection; -import java.util.ConcurrentModificationException; -import java.util.Iterator; -import java.util.Set; -import java.util.Spliterator; -import java.util.function.Consumer; -import java.util.function.IntFunction; -import java.util.function.Predicate; -import java.util.stream.Stream; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; -import stub.java.util.stream.StreamLSL; - -/** - * HashSetAutomaton for HashSet ~> java.util.HashSet - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(java.util.HashSet.class) -public class HashSet implements LibSLRuntime.Automaton, Set, Cloneable, Serializable { - private static final long serialVersionUID = -5024744406713321676L; - - static { - Engine.assume(true); - } - - private byte __$lsl_state = __$lsl_States.Allocated; - - public LibSLRuntime.Map storage; - - public transient int modCount; - - @LibSLRuntime.AutomatonConstructor - public HashSet(Void __$lsl_token, final byte p0, final LibSLRuntime.Map p1, - final int p2) { - this.__$lsl_state = p0; - this.storage = p1; - this.modCount = p2; - } - - @LibSLRuntime.AutomatonConstructor - public HashSet(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Allocated, null, 0); - } - - /** - * [CONSTRUCTOR] HashSetAutomaton::(HashSet) -> void - * Source: java/util/HashSet.main.lsl:157 - */ - public HashSet() { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - this.storage = new LibSLRuntime.Map<>(new LibSLRuntime.HashMapContainer<>()); - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [CONSTRUCTOR] HashSetAutomaton::(HashSet, Collection) -> void - * Source: java/util/HashSet.main.lsl:163 - */ - public HashSet(Collection c) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - this.storage = new LibSLRuntime.Map<>(new LibSLRuntime.HashMapContainer<>()); - _addAllElements(c); - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [CONSTRUCTOR] HashSetAutomaton::(HashSet, int) -> void - * Source: java/util/HashSet.main.lsl:170 - */ - public HashSet(int initialCapacity) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - if (initialCapacity < 0) { - throw new IllegalArgumentException(); - } - this.storage = new LibSLRuntime.Map<>(new LibSLRuntime.HashMapContainer<>()); - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [CONSTRUCTOR] HashSetAutomaton::(HashSet, int, float) -> void - * Source: java/util/HashSet.main.lsl:182 - */ - public HashSet(int initialCapacity, float loadFactor) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - if (initialCapacity < 0) { - throw new IllegalArgumentException(); - } - if ((loadFactor <= 0) || (loadFactor != loadFactor)) { - throw new IllegalArgumentException(); - } - this.storage = new LibSLRuntime.Map<>(new LibSLRuntime.HashMapContainer<>()); - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [CONSTRUCTOR] HashSetAutomaton::(HashSet, int, float, boolean) -> void - * Source: java/util/HashSet.main.lsl:200 - */ - private HashSet(int initialCapacity, float loadFactor, boolean dummy) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - LibSLRuntime.error("Private constructor call"); - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [SUBROUTINE] HashSetAutomaton::_checkForComodification(int) -> void - * Source: java/util/HashSet.main.lsl:79 - */ - public void _checkForComodification(int expectedModCount) { - /* body */ { - if (this.modCount != expectedModCount) { - throw new ConcurrentModificationException(); - } - } - } - - /** - * [SUBROUTINE] HashSetAutomaton::_addAllElements(Collection) -> boolean - * Source: java/util/HashSet.main.lsl:86 - */ - private boolean _addAllElements(Collection c) { - boolean result = false; - /* body */ { - final int lengthBeforeAdd = this.storage.size(); - final Iterator iter = c.iterator(); - while (iter.hasNext()) { - final Object key = iter.next(); - if (!this.storage.hasKey(key)) { - this.storage.set(key, LibSLGlobals.SOMETHING); - } - } - ; - if (lengthBeforeAdd != this.storage.size()) { - this.modCount += 1; - result = true; - } else { - result = false; - } - } - return result; - } - - /** - * [SUBROUTINE] HashSetAutomaton::_makeStream(boolean) -> Stream - * Source: java/util/HashSet.main.lsl:123 - */ - private Stream _makeStream(boolean parallel) { - Stream result = null; - /* body */ { - final LibSLRuntime.Map unseen = this.storage.duplicate(); - final int count = unseen.size(); - final Object[] items = new Object[count]; - int i = 0; - for (i = 0; i < count; i += 1) { - final Object key = unseen.anyKey(); - unseen.remove(key); - items[i] = key; - } - ; - result = (StreamLSL) ((Object) new generated.java.util.stream.StreamLSL((Void) null, - /* state = */ generated.java.util.stream.StreamLSL.__$lsl_States.Initialized, - /* storage = */ items, - /* length = */ count, - /* closeHandlers = */ Engine.makeSymbolicList(), - /* isParallel = */ parallel, - /* linkedOrConsumed = */ false - )); - } - return result; - } - - /** - * [FUNCTION] HashSetAutomaton::add(HashSet, Object) -> boolean - * Source: java/util/HashSet.main.lsl:208 - */ - public boolean add(Object obj) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final boolean hasKey = this.storage.hasKey(obj); - if (hasKey) { - result = false; - } else { - this.storage.set(obj, LibSLGlobals.SOMETHING); - result = true; - } - this.modCount += 1; - } - return result; - } - - /** - * [FUNCTION] HashSetAutomaton::clear(HashSet) -> void - * Source: java/util/HashSet.main.lsl:226 - */ - public void clear() { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - this.storage = new LibSLRuntime.Map<>(new LibSLRuntime.HashMapContainer<>()); - this.modCount += 1; - } - } - - /** - * [FUNCTION] HashSetAutomaton::clone(HashSet) -> Object - * Source: java/util/HashSet.main.lsl:233 - */ - public Object clone() { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = (java.util.HashSet) ((Object) new HashSet((Void) null, - /* state = */ HashSet.__$lsl_States.Initialized, - /* storage = */ this.storage.duplicate(), - /* modCount = */ 0 - )); - } - return result; - } - - /** - * [FUNCTION] HashSetAutomaton::contains(HashSet, Object) -> boolean - * Source: java/util/HashSet.main.lsl:241 - */ - public boolean contains(Object obj) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.storage.size() == 0) { - result = false; - } else { - result = this.storage.hasKey(obj); - } - } - return result; - } - - /** - * [FUNCTION] HashSetAutomaton::isEmpty(HashSet) -> boolean - * Source: java/util/HashSet.main.lsl:250 - */ - public boolean isEmpty() { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.storage.size() == 0; - } - return result; - } - - /** - * [FUNCTION] HashSetAutomaton::iterator(HashSet) -> Iterator - * Source: java/util/HashSet.main.lsl:256 - */ - public Iterator iterator() { - Iterator result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final LibSLRuntime.Map unseenKeys = this.storage.duplicate(); - result = (stub.java.util.HashSet_KeyIterator) ((Object) new HashSet_KeyIterator((Void) null, - /* state = */ HashSet_KeyIterator.__$lsl_States.Initialized, - /* expectedModCount = */ this.modCount, - /* unseenKeys = */ unseenKeys, - /* parent = */ this, - /* index = */ 0, - /* currentKey = */ 0, - /* nextWasCalled = */ false - )); - } - return result; - } - - /** - * [FUNCTION] HashSetAutomaton::remove(HashSet, Object) -> boolean - * Source: java/util/HashSet.main.lsl:267 - */ - public boolean remove(Object obj) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.storage.hasKey(obj)) { - this.storage.remove(obj); - this.modCount += 1; - result = true; - } else { - result = false; - } - } - return result; - } - - /** - * [FUNCTION] HashSetAutomaton::size(HashSet) -> int - * Source: java/util/HashSet.main.lsl:282 - */ - public int size() { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.storage.size(); - } - return result; - } - - /** - * [FUNCTION] HashSetAutomaton::spliterator(HashSet) -> Spliterator - * Source: java/util/HashSet.main.lsl:288 - */ - public Spliterator spliterator() { - Spliterator result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final Object[] keysStorageArray = new Object[this.storage.size()]; - final LibSLRuntime.Map unseenKeys = this.storage.duplicate(); - int i = 0; - for (i = 0; i < this.storage.size(); i += 1) { - final Object key = unseenKeys.anyKey(); - unseenKeys.remove(key); - keysStorageArray[i] = key; - } - ; - result = (stub.java.util.HashSet_KeySpliterator) ((Object) new HashSet_KeySpliterator((Void) null, - /* state = */ HashSet_KeySpliterator.__$lsl_States.Initialized, - /* keysStorage = */ keysStorageArray, - /* index = */ 0, - /* fence = */ -1, - /* est = */ 0, - /* expectedModCount = */ this.modCount, - /* parent = */ this - )); - } - return result; - } - - /** - * [FUNCTION] HashSetAutomaton::equals(HashSet, Object) -> boolean - * Source: java/util/HashSet.main.lsl:320 - */ - public boolean equals(Object other) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (other == this) { - result = true; - } else { - if ((other != null && other.getClass() == java.util.HashSet.class)) { - final int expectedModCount = this.modCount; - final int otherExpectedModCount = ((HashSet) ((Object) other)).modCount; - final LibSLRuntime.Map otherStorage = ((HashSet) ((Object) other)).storage; - if (this.storage.size() == otherStorage.size()) { - result = LibSLRuntime.equals(this.storage, otherStorage); - } else { - result = false; - } - ((HashSet) ((Object) other))._checkForComodification(otherExpectedModCount); - _checkForComodification(expectedModCount); - } else { - result = false; - } - } - } - return result; - } - - /** - * [FUNCTION] HashSetAutomaton::hashCode(HashSet) -> int - * Source: java/util/HashSet.main.lsl:351 - */ - public int hashCode() { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = LibSLRuntime.hashCode(this.storage); - } - return result; - } - - /** - * [FUNCTION] HashSetAutomaton::removeAll(HashSet, Collection) -> boolean - * Source: java/util/HashSet.main.lsl:357 - */ - public boolean removeAll(Collection c) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (c == null) { - throw new NullPointerException(); - } - final int expectedModCount = this.modCount; - final int otherSize = c.size(); - final Iterator iter = c.iterator(); - final int lengthBeforeRemoving = this.storage.size(); - int i = 0; - if (this.storage.size() > otherSize) { - while (iter.hasNext()) { - final Object key = iter.next(); - if (this.storage.hasKey(key)) { - this.storage.remove(key); - } - } - ; - } else { - final LibSLRuntime.Map unseenKeys = this.storage.duplicate(); - while (i < lengthBeforeRemoving) { - final Object key = unseenKeys.anyKey(); - unseenKeys.remove(key); - if (c.contains(key)) { - this.storage.remove(key); - } - i += 1; - } - ; - } - _checkForComodification(expectedModCount); - this.modCount += 1; - result = lengthBeforeRemoving != this.storage.size(); - } - return result; - } - - /** - * [FUNCTION] HashSetAutomaton::toArray(HashSet) -> array - * Source: java/util/HashSet.main.lsl:413 - */ - public Object[] toArray() { - Object[] result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final int len = this.storage.size(); - result = new Object[len]; - final int expectedModCount = this.modCount; - final LibSLRuntime.Map unseenKeys = this.storage.duplicate(); - int i = 0; - for (i = 0; i < len; i += 1) { - final Object key = unseenKeys.anyKey(); - unseenKeys.remove(key); - result[i] = key; - } - ; - _checkForComodification(expectedModCount); - } - return result; - } - - /** - * [FUNCTION] HashSetAutomaton::toArray(HashSet, array) -> array - * Source: java/util/HashSet.main.lsl:439 - */ - public Object[] toArray(Object[] a) { - Object[] result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final int expectedModCount = this.modCount; - final int aLen = a.length; - final int len = this.storage.size(); - final LibSLRuntime.Map unseenKeys = this.storage.duplicate(); - int i = 0; - if (aLen < len) { - a = new Object[len]; - } - result = a; - for (i = 0; i < len; i += 1) { - final Object key = unseenKeys.anyKey(); - unseenKeys.remove(key); - result[i] = key; - } - ; - if (aLen > len) { - result[len] = null; - } - _checkForComodification(expectedModCount); - } - return result; - } - - /** - * [FUNCTION] HashSetAutomaton::toArray(HashSet, IntFunction) -> array - * Source: java/util/HashSet.main.lsl:464 - */ - public Object[] toArray(IntFunction generator) { - Object[] result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (generator == null) { - throw new NullPointerException(); - } - final int len = this.storage.size(); - result = ((Object[]) generator.apply(0)); - final int expectedModCount = this.modCount; - final LibSLRuntime.Map unseenKeys = this.storage.duplicate(); - int i = 0; - for (i = 0; i < len; i += 1) { - final Object key = unseenKeys.anyKey(); - unseenKeys.remove(key); - result[i] = key; - } - ; - _checkForComodification(expectedModCount); - } - return result; - } - - /** - * [FUNCTION] HashSetAutomaton::containsAll(HashSet, Collection) -> boolean - * Source: java/util/HashSet.main.lsl:484 - */ - public boolean containsAll(Collection c) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final int otherSize = c.size(); - final Iterator iter = c.iterator(); - boolean isContainsAll = true; - while (iter.hasNext()) { - final Object key = iter.next(); - final boolean isKeyExist = this.storage.hasKey(key); - if (!isKeyExist) { - isContainsAll = false; - break; - } - } - ; - result = isContainsAll; - } - return result; - } - - /** - * [FUNCTION] HashSetAutomaton::addAll(HashSet, Collection) -> boolean - * Source: java/util/HashSet.main.lsl:512 - */ - public boolean addAll(Collection c) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = _addAllElements(c); - } - return result; - } - - /** - * [FUNCTION] HashSetAutomaton::retainAll(HashSet, Collection) -> boolean - * Source: java/util/HashSet.main.lsl:518 - */ - public boolean retainAll(Collection c) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (c == null) { - throw new NullPointerException(); - } - final int lengthBeforeAdd = this.storage.size(); - final LibSLRuntime.Map unseenKeys = this.storage.duplicate(); - int i = 0; - while (i < lengthBeforeAdd) { - final Object key = unseenKeys.anyKey(); - unseenKeys.remove(key); - if (!c.contains(key)) { - this.storage.remove(key); - } - i += 1; - } - ; - if (lengthBeforeAdd != this.storage.size()) { - this.modCount += 1; - result = true; - } else { - result = false; - } - } - return result; - } - - /** - * [FUNCTION] HashSetAutomaton::removeIf(HashSet, Predicate) -> boolean - * Source: java/util/HashSet.main.lsl:556 - */ - public boolean removeIf(Predicate filter) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (filter == null) { - throw new NullPointerException(); - } - final int lengthBeforeAdd = this.storage.size(); - final int expectedModCount = this.modCount; - int i = 0; - final LibSLRuntime.Map unseenKeys = this.storage.duplicate(); - while (i < lengthBeforeAdd) { - final Object key = unseenKeys.anyKey(); - unseenKeys.remove(key); - if (filter.test(key)) { - this.storage.remove(key); - } - i += 1; - } - ; - _checkForComodification(expectedModCount); - if (lengthBeforeAdd != this.storage.size()) { - this.modCount += 1; - result = true; - } else { - result = false; - } - } - return result; - } - - /** - * [FUNCTION] HashSetAutomaton::forEach(HashSet, Consumer) -> void - * Source: java/util/HashSet.main.lsl:596 - */ - public void forEach(Consumer userAction) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (userAction == null) { - throw new NullPointerException(); - } - int i = 0; - final int count = this.storage.size(); - final int expectedModCount = this.modCount; - final LibSLRuntime.Map unseenKeys = this.storage.duplicate(); - while (i < count) { - final Object key = unseenKeys.anyKey(); - unseenKeys.remove(key); - userAction.accept(key); - i += 1; - } - ; - _checkForComodification(expectedModCount); - } - } - - /** - * [FUNCTION] HashSetAutomaton::stream(HashSet) -> Stream - * Source: java/util/HashSet.main.lsl:627 - */ - public Stream stream() { - Stream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = _makeStream(false); - } - return result; - } - - /** - * [FUNCTION] HashSetAutomaton::parallelStream(HashSet) -> Stream - * Source: java/util/HashSet.main.lsl:634 - */ - public Stream parallelStream() { - Stream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = _makeStream(true); - } - return result; - } - - /** - * [FUNCTION] HashSetAutomaton::writeObject(HashSet, ObjectOutputStream) -> void - * Source: java/util/HashSet.main.lsl:642 - */ - private void writeObject(ObjectOutputStream s) throws java.io.IOException { - /* body */ { - LibSLRuntime.not_implemented(/* no serialization support yet */); - } - } - - /** - * [FUNCTION] HashSetAutomaton::readObject(HashSet, ObjectInputStream) -> void - * Source: java/util/HashSet.main.lsl:649 - */ - private void readObject(ObjectInputStream s) throws java.io.IOException, - java.lang.ClassNotFoundException { - /* body */ { - LibSLRuntime.not_implemented(/* no serialization support yet */); - } - } - - /** - * [FUNCTION] HashSetAutomaton::toString(HashSet) -> String - * Source: java/util/HashSet.main.lsl:657 - */ - public String toString() { - String result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final LibSLRuntime.Map items = this.storage; - int count = items.size(); - if (count == 0) { - result = "[]"; - } else { - Engine.assume(count > 0); - result = "["; - final LibSLRuntime.Map unseen = items.duplicate(); - while (count != 0) { - final Object key = unseen.anyKey(); - unseen.remove(key); - result = result.concat(LibSLRuntime.toString(key)); - if (count > 1) { - result = result.concat(", "); - } - count -= 1; - } - ; - result = result.concat("]"); - } - } - return result; - } - - public static final class __$lsl_States { - public static final byte Allocated = (byte) 0; - - public static final byte Initialized = (byte) 1; - } - - @Approximate(HashSet.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/HashSet_KeyIterator.java b/approximations/src/main/java/generated/java/util/HashSet_KeyIterator.java deleted file mode 100644 index e6f762f4..00000000 --- a/approximations/src/main/java/generated/java/util/HashSet_KeyIterator.java +++ /dev/null @@ -1,193 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/HashSet.lsl:41 -// - java/util/HashSet.KeyIterator.lsl:19 -// -package generated.java.util; - -import java.lang.IllegalStateException; -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.ConcurrentModificationException; -import java.util.Iterator; -import java.util.NoSuchElementException; -import java.util.function.Consumer; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; - -/** - * HashSet_KeyIteratorAutomaton for HashSet_KeyIterator ~> java.util.HashSet_KeyIterator - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(stub.java.util.HashSet_KeyIterator.class) -public final class HashSet_KeyIterator implements LibSLRuntime.Automaton, Iterator { - static { - Engine.assume(true); - } - - private byte __$lsl_state = __$lsl_States.Allocated; - - public int expectedModCount; - - public LibSLRuntime.Map unseenKeys; - - public HashSet parent; - - public int index; - - public Object currentKey; - - public boolean nextWasCalled; - - @LibSLRuntime.AutomatonConstructor - public HashSet_KeyIterator(Void __$lsl_token, final byte p0, final int p1, - final LibSLRuntime.Map p2, final HashSet p3, final int p4, - final Object p5, final boolean p6) { - this.__$lsl_state = p0; - this.expectedModCount = p1; - this.unseenKeys = p2; - this.parent = p3; - this.index = p4; - this.currentKey = p5; - this.nextWasCalled = p6; - } - - @LibSLRuntime.AutomatonConstructor - public HashSet_KeyIterator(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Allocated, 0, null, null, 0, 0, false); - } - - /** - * [CONSTRUCTOR] HashSet_KeyIteratorAutomaton::(HashSet_KeyIterator, HashMap) -> void - * Source: java/util/HashSet.KeyIterator.lsl:66 - */ - private HashSet_KeyIterator(HashMap source) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - LibSLRuntime.error("Private constructor call"); - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [SUBROUTINE] HashSet_KeyIteratorAutomaton::_checkForComodification() -> void - * Source: java/util/HashSet.KeyIterator.lsl:56 - */ - private void _checkForComodification() { - /* body */ { - final int modCount = ((HashSet) ((Object) this.parent)).modCount; - if (this.expectedModCount != modCount) { - throw new ConcurrentModificationException(); - } - } - } - - /** - * [FUNCTION] HashSet_KeyIteratorAutomaton::hasNext(HashSet_KeyIterator) -> boolean - * Source: java/util/HashSet.KeyIterator.lsl:74 - */ - public boolean hasNext() { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(this.parent != null); - final LibSLRuntime.Map parentStorage = ((HashSet) ((Object) this.parent)).storage; - final int length = parentStorage.size(); - result = this.index < length; - } - return result; - } - - /** - * [FUNCTION] HashSet_KeyIteratorAutomaton::next(HashSet_KeyIterator) -> Object - * Source: java/util/HashSet.KeyIterator.lsl:84 - */ - public final Object next() { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(this.parent != null); - _checkForComodification(); - final LibSLRuntime.Map parentStorage = ((HashSet) ((Object) this.parent)).storage; - final int length = parentStorage.size(); - final boolean atValidPosition = this.index < length; - if (!atValidPosition) { - throw new NoSuchElementException(); - } - final Object key = this.unseenKeys.anyKey(); - this.unseenKeys.remove(key); - this.currentKey = key; - result = key; - this.index += 1; - this.nextWasCalled = true; - } - return result; - } - - /** - * [FUNCTION] HashSet_KeyIteratorAutomaton::remove(HashSet_KeyIterator) -> void - * Source: java/util/HashSet.KeyIterator.lsl:106 - */ - public void remove() { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(this.parent != null); - final LibSLRuntime.Map parentStorage = ((HashSet) ((Object) this.parent)).storage; - final int length = parentStorage.size(); - final boolean atValidPosition = this.index < length; - if (!atValidPosition || !this.nextWasCalled) { - throw new IllegalStateException(); - } - this.nextWasCalled = false; - _checkForComodification(); - parentStorage.remove(this.currentKey); - this.expectedModCount = ((HashSet) ((Object) this.parent)).modCount; - } - } - - /** - * [FUNCTION] HashSet_KeyIteratorAutomaton::forEachRemaining(HashSet_KeyIterator, Consumer) -> void - * Source: java/util/HashSet.KeyIterator.lsl:126 - */ - public void forEachRemaining(Consumer userAction) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(this.parent != null); - if (userAction == null) { - throw new NullPointerException(); - } - final LibSLRuntime.Map parentStorage = ((HashSet) ((Object) this.parent)).storage; - final int length = parentStorage.size(); - int i = this.index; - while (i < length) { - _checkForComodification(); - final Object key = this.unseenKeys.anyKey(); - this.unseenKeys.remove(key); - Engine.assume(key != this.currentKey); - this.currentKey = key; - userAction.accept(key); - i += 1; - } - ; - this.index = i; - this.nextWasCalled = true; - } - } - - public static final class __$lsl_States { - public static final byte Allocated = (byte) 0; - - public static final byte Initialized = (byte) 1; - } - - @Approximate(HashSet_KeyIterator.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/HashSet_KeySpliterator.java b/approximations/src/main/java/generated/java/util/HashSet_KeySpliterator.java deleted file mode 100644 index ea7cc2ba..00000000 --- a/approximations/src/main/java/generated/java/util/HashSet_KeySpliterator.java +++ /dev/null @@ -1,255 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/HashSet.lsl:32 -// - java/util/HashSet.Spliterator.lsl:19 -// -package generated.java.util; - -import generated.runtime.LibSLGlobals; -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.ConcurrentModificationException; -import java.util.Spliterator; -import java.util.function.Consumer; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; - -/** - * HashSet_KeySpliteratorAutomaton for HashSet_KeySpliterator ~> java.util.HashSet_KeySpliterator - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(stub.java.util.HashSet_KeySpliterator.class) -public final class HashSet_KeySpliterator implements LibSLRuntime.Automaton, Spliterator { - static { - Engine.assume(true); - } - - private byte __$lsl_state = __$lsl_States.Allocated; - - public Object[] keysStorage; - - public int index; - - public int fence; - - public int est; - - public int expectedModCount; - - public HashSet parent; - - @LibSLRuntime.AutomatonConstructor - public HashSet_KeySpliterator(Void __$lsl_token, final byte p0, final Object[] p1, final int p2, - final int p3, final int p4, final int p5, final HashSet p6) { - this.__$lsl_state = p0; - this.keysStorage = p1; - this.index = p2; - this.fence = p3; - this.est = p4; - this.expectedModCount = p5; - this.parent = p6; - } - - @LibSLRuntime.AutomatonConstructor - public HashSet_KeySpliterator(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Allocated, null, 0, 0, 0, 0, null); - } - - /** - * [CONSTRUCTOR] HashSet_KeySpliteratorAutomaton::(HashSet_KeySpliterator, HashMap, int, int, int, int) -> void - * Source: java/util/HashSet.Spliterator.lsl:89 - */ - private HashSet_KeySpliterator(HashMap source, int origin, int fence, int est, - int expectedModCount) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - this.index = origin; - fence = fence; - est = est; - expectedModCount = expectedModCount; - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [SUBROUTINE] HashSet_KeySpliteratorAutomaton::_getFence() -> int - * Source: java/util/HashSet.Spliterator.lsl:54 - */ - private int _getFence() { - int result = 0; - /* body */ { - Engine.assume(this.parent != null); - int hi = this.fence; - if (hi < 0) { - final LibSLRuntime.Map parentStorage = ((HashSet) ((Object) this.parent)).storage; - this.est = parentStorage.size(); - this.expectedModCount = ((HashSet) ((Object) this.parent)).modCount; - this.fence = this.est; - hi = this.fence; - } - result = hi; - } - return result; - } - - /** - * [SUBROUTINE] HashSet_KeySpliteratorAutomaton::_checkForComodification() -> void - * Source: java/util/HashSet.Spliterator.lsl:79 - */ - private void _checkForComodification() { - /* body */ { - final int modCount = ((HashSet) ((Object) this.parent)).modCount; - if (this.expectedModCount != modCount) { - throw new ConcurrentModificationException(); - } - } - } - - /** - * [FUNCTION] HashSet_KeySpliteratorAutomaton::estimateSize(HashSet_KeySpliterator) -> long - * Source: java/util/HashSet.Spliterator.lsl:101 - */ - public long estimateSize() { - long result = 0L; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - _getFence(); - result = ((long) this.est); - } - return result; - } - - /** - * [FUNCTION] HashSet_KeySpliteratorAutomaton::characteristics(HashSet_KeySpliterator) -> int - * Source: java/util/HashSet.Spliterator.lsl:108 - */ - public int characteristics() { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(this.parent != null); - result = 0; - final LibSLRuntime.Map parentStorage = ((HashSet) ((Object) this.parent)).storage; - final int length = parentStorage.size(); - if ((this.fence < 0) || (this.est == length)) { - result = LibSLGlobals.SPLITERATOR_SIZED; - } - result |= LibSLGlobals.SPLITERATOR_DISTINCT; - } - return result; - } - - /** - * [FUNCTION] HashSet_KeySpliteratorAutomaton::forEachRemaining(HashSet_KeySpliterator, Consumer) -> void - * Source: java/util/HashSet.Spliterator.lsl:122 - */ - public void forEachRemaining(Consumer userAction) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(this.parent != null); - if (userAction == null) { - throw new NullPointerException(); - } - int hi = this.fence; - int mc = this.expectedModCount; - int i = this.index; - final LibSLRuntime.Map parentStorage = ((HashSet) ((Object) this.parent)).storage; - final int length = parentStorage.size(); - if (hi < 0) { - this.expectedModCount = ((HashSet) ((Object) this.parent)).modCount; - mc = this.expectedModCount; - this.fence = length; - hi = this.fence; - } - this.index = hi; - if ((length > 0) && (length >= hi) && (i >= 0) && (i < this.index)) { - final Object[] storage = this.keysStorage; - Engine.assume(storage != null); - while (i < hi) { - final Object key = storage[i]; - userAction.accept(key); - i += 1; - } - ; - final int modCount = ((HashSet) ((Object) this.parent)).modCount; - if (modCount != mc) { - throw new ConcurrentModificationException(); - } - } - } - } - - /** - * [FUNCTION] HashSet_KeySpliteratorAutomaton::tryAdvance(HashSet_KeySpliterator, Consumer) -> boolean - * Source: java/util/HashSet.Spliterator.lsl:173 - */ - public boolean tryAdvance(Consumer userAction) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(this.parent != null); - if (userAction == null) { - throw new NullPointerException(); - } - int hi = _getFence(); - int i = this.index; - if (i < hi) { - final Object key = keysStorage[i]; - userAction.accept(key); - this.index += 1; - _checkForComodification(); - result = true; - } - result = false; - } - return result; - } - - /** - * [FUNCTION] HashSet_KeySpliteratorAutomaton::trySplit(HashSet_KeySpliterator) -> Spliterator - * Source: java/util/HashSet.Spliterator.lsl:197 - */ - public Spliterator trySplit() { - Spliterator result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(this.parent != null); - final int hi = _getFence(); - final int lo = this.index; - int mid = (hi + lo) >>> 1; - if (lo >= mid) { - result = null; - } else { - this.est = this.est >>> 1; - this.index = mid; - result = (stub.java.util.HashSet_KeySpliterator) ((Object) new HashSet_KeySpliterator((Void) null, - /* state = */ HashSet_KeySpliterator.__$lsl_States.Initialized, - /* keysStorage = */ this.keysStorage, - /* index = */ lo, - /* fence = */ mid, - /* est = */ this.est, - /* expectedModCount = */ this.expectedModCount, - /* parent = */ this.parent - )); - } - } - return result; - } - - public static final class __$lsl_States { - public static final byte Allocated = (byte) 0; - - public static final byte Initialized = (byte) 1; - } - - @Approximate(HashSet_KeySpliterator.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/LinkedHashSet.java b/approximations/src/main/java/generated/java/util/LinkedHashSet.java deleted file mode 100644 index 95b5075d..00000000 --- a/approximations/src/main/java/generated/java/util/LinkedHashSet.java +++ /dev/null @@ -1,745 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/LinkedHashSet.lsl:20 -// - java/util/LinkedHashSet.main.lsl:25 -// -package generated.java.util; - -import generated.runtime.LibSLGlobals; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; -import java.lang.Cloneable; -import java.lang.IllegalArgumentException; -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.Collection; -import java.util.ConcurrentModificationException; -import java.util.Iterator; -import java.util.Set; -import java.util.Spliterator; -import java.util.function.Consumer; -import java.util.function.IntFunction; -import java.util.function.Predicate; -import java.util.stream.Stream; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; -import stub.java.util.stream.StreamLSL; - -/** - * LinkedHashSetAutomaton for LinkedHashSet ~> java.util.LinkedHashSet - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(java.util.LinkedHashSet.class) -public class LinkedHashSet implements LibSLRuntime.Automaton, Set, Cloneable, Serializable { - private static final long serialVersionUID = -2851667679971038690L; - - static { - Engine.assume(true); - } - - private byte __$lsl_state = __$lsl_States.Allocated; - - public LibSLRuntime.Map storage; - - public transient int modCount; - - @LibSLRuntime.AutomatonConstructor - public LinkedHashSet(Void __$lsl_token, final byte p0, - final LibSLRuntime.Map p1, final int p2) { - this.__$lsl_state = p0; - this.storage = p1; - this.modCount = p2; - } - - @LibSLRuntime.AutomatonConstructor - public LinkedHashSet(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Allocated, null, 0); - } - - /** - * [CONSTRUCTOR] LinkedHashSetAutomaton::(LinkedHashSet) -> void - * Source: java/util/LinkedHashSet.main.lsl:156 - */ - public LinkedHashSet() { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - this.storage = new LibSLRuntime.Map<>(new LibSLRuntime.HashMapContainer<>()); - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [CONSTRUCTOR] LinkedHashSetAutomaton::(LinkedHashSet, Collection) -> void - * Source: java/util/LinkedHashSet.main.lsl:162 - */ - public LinkedHashSet(Collection c) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - this.storage = new LibSLRuntime.Map<>(new LibSLRuntime.HashMapContainer<>()); - _addAllElements(c); - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [CONSTRUCTOR] LinkedHashSetAutomaton::(LinkedHashSet, int) -> void - * Source: java/util/LinkedHashSet.main.lsl:169 - */ - public LinkedHashSet(int initialCapacity) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - if (initialCapacity < 0) { - throw new IllegalArgumentException(); - } - this.storage = new LibSLRuntime.Map<>(new LibSLRuntime.HashMapContainer<>()); - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [CONSTRUCTOR] LinkedHashSetAutomaton::(LinkedHashSet, int, float) -> void - * Source: java/util/LinkedHashSet.main.lsl:181 - */ - public LinkedHashSet(int initialCapacity, float loadFactor) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - if (initialCapacity < 0) { - throw new IllegalArgumentException(); - } - if ((loadFactor <= 0) || (loadFactor != loadFactor)) { - throw new IllegalArgumentException(); - } - this.storage = new LibSLRuntime.Map<>(new LibSLRuntime.HashMapContainer<>()); - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [SUBROUTINE] LinkedHashSetAutomaton::_checkForComodification(int) -> void - * Source: java/util/LinkedHashSet.main.lsl:78 - */ - public void _checkForComodification(int expectedModCount) { - /* body */ { - if (this.modCount != expectedModCount) { - throw new ConcurrentModificationException(); - } - } - } - - /** - * [SUBROUTINE] LinkedHashSetAutomaton::_addAllElements(Collection) -> boolean - * Source: java/util/LinkedHashSet.main.lsl:85 - */ - private boolean _addAllElements(Collection c) { - boolean result = false; - /* body */ { - final int lengthBeforeAdd = this.storage.size(); - final Iterator iter = c.iterator(); - while (iter.hasNext()) { - final Object key = iter.next(); - if (!this.storage.hasKey(key)) { - this.storage.set(key, LibSLGlobals.SOMETHING); - } - } - ; - if (lengthBeforeAdd != this.storage.size()) { - this.modCount += 1; - result = true; - } else { - result = false; - } - } - return result; - } - - /** - * [SUBROUTINE] LinkedHashSetAutomaton::_makeStream(boolean) -> Stream - * Source: java/util/LinkedHashSet.main.lsl:122 - */ - private Stream _makeStream(boolean parallel) { - Stream result = null; - /* body */ { - final LibSLRuntime.Map unseen = this.storage.duplicate(); - final int count = unseen.size(); - final Object[] items = new Object[count]; - int i = 0; - for (i = 0; i < count; i += 1) { - final Object key = unseen.anyKey(); - unseen.remove(key); - items[i] = key; - } - ; - result = (StreamLSL) ((Object) new generated.java.util.stream.StreamLSL((Void) null, - /* state = */ generated.java.util.stream.StreamLSL.__$lsl_States.Initialized, - /* storage = */ items, - /* length = */ count, - /* closeHandlers = */ Engine.makeSymbolicList(), - /* isParallel = */ parallel, - /* linkedOrConsumed = */ false - )); - } - return result; - } - - /** - * [FUNCTION] LinkedHashSetAutomaton::add(LinkedHashSet, Object) -> boolean - * Source: java/util/LinkedHashSet.main.lsl:201 - */ - public boolean add(Object obj) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final boolean hasKey = this.storage.hasKey(obj); - if (hasKey) { - result = false; - } else { - this.storage.set(obj, LibSLGlobals.SOMETHING); - result = true; - } - this.modCount += 1; - } - return result; - } - - /** - * [FUNCTION] LinkedHashSetAutomaton::clear(LinkedHashSet) -> void - * Source: java/util/LinkedHashSet.main.lsl:219 - */ - public void clear() { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - this.storage = new LibSLRuntime.Map<>(new LibSLRuntime.HashMapContainer<>()); - this.modCount += 1; - } - } - - /** - * [FUNCTION] LinkedHashSetAutomaton::clone(LinkedHashSet) -> Object - * Source: java/util/LinkedHashSet.main.lsl:226 - */ - public Object clone() { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = (java.util.LinkedHashSet) ((Object) new LinkedHashSet((Void) null, - /* state = */ LinkedHashSet.__$lsl_States.Initialized, - /* storage = */ this.storage.duplicate(), - /* modCount = */ 0 - )); - } - return result; - } - - /** - * [FUNCTION] LinkedHashSetAutomaton::contains(LinkedHashSet, Object) -> boolean - * Source: java/util/LinkedHashSet.main.lsl:234 - */ - public boolean contains(Object obj) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.storage.size() == 0) { - result = false; - } else { - result = this.storage.hasKey(obj); - } - } - return result; - } - - /** - * [FUNCTION] LinkedHashSetAutomaton::isEmpty(LinkedHashSet) -> boolean - * Source: java/util/LinkedHashSet.main.lsl:243 - */ - public boolean isEmpty() { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.storage.size() == 0; - } - return result; - } - - /** - * [FUNCTION] LinkedHashSetAutomaton::iterator(LinkedHashSet) -> Iterator - * Source: java/util/LinkedHashSet.main.lsl:249 - */ - public Iterator iterator() { - Iterator result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final LibSLRuntime.Map unseenKeys = this.storage.duplicate(); - result = (stub.java.util.LinkedHashSet_KeyIterator) ((Object) new LinkedHashSet_KeyIterator((Void) null, - /* state = */ LinkedHashSet_KeyIterator.__$lsl_States.Initialized, - /* expectedModCount = */ this.modCount, - /* unseenKeys = */ unseenKeys, - /* parent = */ this, - /* index = */ 0, - /* currentKey = */ 0, - /* nextWasCalled = */ false - )); - } - return result; - } - - /** - * [FUNCTION] LinkedHashSetAutomaton::remove(LinkedHashSet, Object) -> boolean - * Source: java/util/LinkedHashSet.main.lsl:260 - */ - public boolean remove(Object obj) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.storage.hasKey(obj)) { - this.storage.remove(obj); - this.modCount += 1; - result = true; - } else { - result = false; - } - } - return result; - } - - /** - * [FUNCTION] LinkedHashSetAutomaton::size(LinkedHashSet) -> int - * Source: java/util/LinkedHashSet.main.lsl:275 - */ - public int size() { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.storage.size(); - } - return result; - } - - /** - * [FUNCTION] LinkedHashSetAutomaton::spliterator(LinkedHashSet) -> Spliterator - * Source: java/util/LinkedHashSet.main.lsl:281 - */ - public Spliterator spliterator() { - Spliterator result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final Object[] keysStorageArray = new Object[this.storage.size()]; - final LibSLRuntime.Map unseenKeys = this.storage.duplicate(); - int i = 0; - for (i = 0; i < this.storage.size(); i += 1) { - final Object key = unseenKeys.anyKey(); - unseenKeys.remove(key); - keysStorageArray[i] = key; - } - ; - result = (stub.java.util.LinkedHashSet_KeySpliterator) ((Object) new LinkedHashSet_KeySpliterator((Void) null, - /* state = */ LinkedHashSet_KeySpliterator.__$lsl_States.Initialized, - /* keysStorage = */ keysStorageArray, - /* index = */ 0, - /* fence = */ -1, - /* est = */ 0, - /* expectedModCount = */ this.modCount, - /* parent = */ this - )); - } - return result; - } - - /** - * [FUNCTION] LinkedHashSetAutomaton::equals(LinkedHashSet, Object) -> boolean - * Source: java/util/LinkedHashSet.main.lsl:312 - */ - public boolean equals(Object other) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (other == this) { - result = true; - } else { - if ((other != null && other.getClass() == java.util.LinkedHashSet.class)) { - final int expectedModCount = this.modCount; - final int otherExpectedModCount = ((LinkedHashSet) ((Object) other)).modCount; - final LibSLRuntime.Map otherStorage = ((LinkedHashSet) ((Object) other)).storage; - if (this.storage.size() == otherStorage.size()) { - result = LibSLRuntime.equals(this.storage, otherStorage); - } else { - result = false; - } - ((LinkedHashSet) ((Object) other))._checkForComodification(otherExpectedModCount); - _checkForComodification(expectedModCount); - } else { - result = false; - } - } - } - return result; - } - - /** - * [FUNCTION] LinkedHashSetAutomaton::hashCode(LinkedHashSet) -> int - * Source: java/util/LinkedHashSet.main.lsl:343 - */ - public int hashCode() { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = LibSLRuntime.hashCode(this.storage); - } - return result; - } - - /** - * [FUNCTION] LinkedHashSetAutomaton::removeAll(LinkedHashSet, Collection) -> boolean - * Source: java/util/LinkedHashSet.main.lsl:349 - */ - public boolean removeAll(Collection c) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (c == null) { - throw new NullPointerException(); - } - final int expectedModCount = this.modCount; - final int otherSize = c.size(); - final Iterator iter = c.iterator(); - final int lengthBeforeRemoving = this.storage.size(); - int i = 0; - if (this.storage.size() > otherSize) { - while (iter.hasNext()) { - final Object key = iter.next(); - if (this.storage.hasKey(key)) { - this.storage.remove(key); - } - } - ; - } else { - final LibSLRuntime.Map unseenKeys = this.storage.duplicate(); - while (i < lengthBeforeRemoving) { - final Object key = unseenKeys.anyKey(); - unseenKeys.remove(key); - if (c.contains(key)) { - this.storage.remove(key); - } - i += 1; - } - ; - } - _checkForComodification(expectedModCount); - this.modCount += 1; - result = lengthBeforeRemoving != this.storage.size(); - } - return result; - } - - /** - * [FUNCTION] LinkedHashSetAutomaton::toArray(LinkedHashSet) -> array - * Source: java/util/LinkedHashSet.main.lsl:404 - */ - public Object[] toArray() { - Object[] result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final int len = this.storage.size(); - result = new Object[len]; - final int expectedModCount = this.modCount; - final LibSLRuntime.Map unseenKeys = this.storage.duplicate(); - int i = 0; - for (i = 0; i < len; i += 1) { - final Object key = unseenKeys.anyKey(); - unseenKeys.remove(key); - result[i] = key; - } - ; - _checkForComodification(expectedModCount); - } - return result; - } - - /** - * [FUNCTION] LinkedHashSetAutomaton::toArray(LinkedHashSet, array) -> array - * Source: java/util/LinkedHashSet.main.lsl:430 - */ - public Object[] toArray(Object[] a) { - Object[] result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final int expectedModCount = this.modCount; - final int aLen = a.length; - final int len = this.storage.size(); - final LibSLRuntime.Map unseenKeys = this.storage.duplicate(); - int i = 0; - if (aLen < len) { - a = new Object[len]; - } - result = a; - for (i = 0; i < len; i += 1) { - final Object key = unseenKeys.anyKey(); - unseenKeys.remove(key); - result[i] = key; - } - ; - if (aLen > len) { - result[len] = null; - } - _checkForComodification(expectedModCount); - } - return result; - } - - /** - * [FUNCTION] LinkedHashSetAutomaton::toArray(LinkedHashSet, IntFunction) -> array - * Source: java/util/LinkedHashSet.main.lsl:455 - */ - public Object[] toArray(IntFunction generator) { - Object[] result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (generator == null) { - throw new NullPointerException(); - } - final int len = this.storage.size(); - result = ((Object[]) generator.apply(0)); - final int expectedModCount = this.modCount; - final LibSLRuntime.Map unseenKeys = this.storage.duplicate(); - int i = 0; - for (i = 0; i < len; i += 1) { - final Object key = unseenKeys.anyKey(); - unseenKeys.remove(key); - result[i] = key; - } - ; - _checkForComodification(expectedModCount); - } - return result; - } - - /** - * [FUNCTION] LinkedHashSetAutomaton::containsAll(LinkedHashSet, Collection) -> boolean - * Source: java/util/LinkedHashSet.main.lsl:475 - */ - public boolean containsAll(Collection c) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final int otherSize = c.size(); - final Iterator iter = c.iterator(); - boolean isContainsAll = true; - while (iter.hasNext()) { - final Object key = iter.next(); - final boolean isKeyExist = this.storage.hasKey(key); - if (!isKeyExist) { - isContainsAll = false; - break; - } - } - ; - result = isContainsAll; - } - return result; - } - - /** - * [FUNCTION] LinkedHashSetAutomaton::addAll(LinkedHashSet, Collection) -> boolean - * Source: java/util/LinkedHashSet.main.lsl:503 - */ - public boolean addAll(Collection c) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = _addAllElements(c); - } - return result; - } - - /** - * [FUNCTION] LinkedHashSetAutomaton::retainAll(LinkedHashSet, Collection) -> boolean - * Source: java/util/LinkedHashSet.main.lsl:509 - */ - public boolean retainAll(Collection c) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (c == null) { - throw new NullPointerException(); - } - final int lengthBeforeAdd = this.storage.size(); - final LibSLRuntime.Map unseenKeys = this.storage.duplicate(); - int i = 0; - while (i < lengthBeforeAdd) { - final Object key = unseenKeys.anyKey(); - unseenKeys.remove(key); - if (!c.contains(key)) { - this.storage.remove(key); - } - i += 1; - } - ; - if (lengthBeforeAdd != this.storage.size()) { - this.modCount += 1; - result = true; - } else { - result = false; - } - } - return result; - } - - /** - * [FUNCTION] LinkedHashSetAutomaton::removeIf(LinkedHashSet, Predicate) -> boolean - * Source: java/util/LinkedHashSet.main.lsl:547 - */ - public boolean removeIf(Predicate filter) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (filter == null) { - throw new NullPointerException(); - } - final int lengthBeforeAdd = this.storage.size(); - final int expectedModCount = this.modCount; - int i = 0; - final LibSLRuntime.Map unseenKeys = this.storage.duplicate(); - while (i < lengthBeforeAdd) { - final Object key = unseenKeys.anyKey(); - unseenKeys.remove(key); - if (filter.test(key)) { - this.storage.remove(key); - } - i += 1; - } - ; - _checkForComodification(expectedModCount); - if (lengthBeforeAdd != this.storage.size()) { - this.modCount += 1; - result = true; - } else { - result = false; - } - } - return result; - } - - /** - * [FUNCTION] LinkedHashSetAutomaton::forEach(LinkedHashSet, Consumer) -> void - * Source: java/util/LinkedHashSet.main.lsl:587 - */ - public void forEach(Consumer userAction) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (userAction == null) { - throw new NullPointerException(); - } - int i = 0; - final int expectedModCount = this.modCount; - final LibSLRuntime.Map unseenKeys = this.storage.duplicate(); - while (i < this.storage.size()) { - final Object key = unseenKeys.anyKey(); - unseenKeys.remove(key); - userAction.accept(key); - i += 1; - } - ; - _checkForComodification(expectedModCount); - } - } - - /** - * [FUNCTION] LinkedHashSetAutomaton::stream(LinkedHashSet) -> Stream - * Source: java/util/LinkedHashSet.main.lsl:617 - */ - public Stream stream() { - Stream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = _makeStream(false); - } - return result; - } - - /** - * [FUNCTION] LinkedHashSetAutomaton::parallelStream(LinkedHashSet) -> Stream - * Source: java/util/LinkedHashSet.main.lsl:624 - */ - public Stream parallelStream() { - Stream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = _makeStream(true); - } - return result; - } - - /** - * [FUNCTION] LinkedHashSetAutomaton::writeObject(LinkedHashSet, ObjectOutputStream) -> void - * Source: java/util/LinkedHashSet.main.lsl:632 - */ - private void writeObject(ObjectOutputStream s) throws java.io.IOException { - /* body */ { - LibSLRuntime.not_implemented(/* no serialization support yet */); - } - } - - /** - * [FUNCTION] LinkedHashSetAutomaton::readObject(LinkedHashSet, ObjectInputStream) -> void - * Source: java/util/LinkedHashSet.main.lsl:639 - */ - private void readObject(ObjectInputStream s) throws java.io.IOException, - java.lang.ClassNotFoundException { - /* body */ { - LibSLRuntime.not_implemented(/* no serialization support yet */); - } - } - - /** - * [FUNCTION] LinkedHashSetAutomaton::toString(LinkedHashSet) -> String - * Source: java/util/LinkedHashSet.main.lsl:647 - */ - public String toString() { - String result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final LibSLRuntime.Map items = this.storage; - int count = items.size(); - if (count == 0) { - result = "[]"; - } else { - Engine.assume(count > 0); - result = "["; - final LibSLRuntime.Map unseen = items.duplicate(); - while (count != 0) { - final Object key = unseen.anyKey(); - unseen.remove(key); - result = result.concat(LibSLRuntime.toString(key)); - if (count > 1) { - result = result.concat(", "); - } - count -= 1; - } - ; - result = result.concat("]"); - } - } - return result; - } - - public static final class __$lsl_States { - public static final byte Allocated = (byte) 0; - - public static final byte Initialized = (byte) 1; - } - - @Approximate(LinkedHashSet.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/LinkedHashSet_KeyIterator.java b/approximations/src/main/java/generated/java/util/LinkedHashSet_KeyIterator.java deleted file mode 100644 index 60200543..00000000 --- a/approximations/src/main/java/generated/java/util/LinkedHashSet_KeyIterator.java +++ /dev/null @@ -1,190 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/LinkedHashSet.lsl:39 -// - java/util/LinkedHashSet.KeyIterator.lsl:19 -// -package generated.java.util; - -import java.lang.IllegalStateException; -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.ConcurrentModificationException; -import java.util.Iterator; -import java.util.NoSuchElementException; -import java.util.function.Consumer; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; - -/** - * LinkedHashSet_KeyIteratorAutomaton for LinkedHashSet_KeyIterator ~> java.util.LinkedHashSet_KeyIterator - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(stub.java.util.LinkedHashSet_KeyIterator.class) -public final class LinkedHashSet_KeyIterator implements LibSLRuntime.Automaton, Iterator { - static { - Engine.assume(true); - } - - private byte __$lsl_state = __$lsl_States.Allocated; - - public int expectedModCount; - - public LibSLRuntime.Map unseenKeys; - - public LinkedHashSet parent; - - public int index; - - public Object currentKey; - - public boolean nextWasCalled; - - @LibSLRuntime.AutomatonConstructor - public LinkedHashSet_KeyIterator(Void __$lsl_token, final byte p0, final int p1, - final LibSLRuntime.Map p2, final LinkedHashSet p3, final int p4, - final Object p5, final boolean p6) { - this.__$lsl_state = p0; - this.expectedModCount = p1; - this.unseenKeys = p2; - this.parent = p3; - this.index = p4; - this.currentKey = p5; - this.nextWasCalled = p6; - } - - @LibSLRuntime.AutomatonConstructor - public LinkedHashSet_KeyIterator(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Allocated, 0, null, null, 0, 0, false); - } - - /** - * [CONSTRUCTOR] LinkedHashSet_KeyIteratorAutomaton::(LinkedHashSet_KeyIterator, HashMap) -> void - * Source: java/util/LinkedHashSet.KeyIterator.lsl:65 - */ - private LinkedHashSet_KeyIterator(HashMap source) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - LibSLRuntime.error("Private constructor call"); - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [SUBROUTINE] LinkedHashSet_KeyIteratorAutomaton::_checkForComodification() -> void - * Source: java/util/LinkedHashSet.KeyIterator.lsl:55 - */ - private void _checkForComodification() { - /* body */ { - final int modCount = ((LinkedHashSet) ((Object) this.parent)).modCount; - if (this.expectedModCount != modCount) { - throw new ConcurrentModificationException(); - } - } - } - - /** - * [FUNCTION] LinkedHashSet_KeyIteratorAutomaton::hasNext(LinkedHashSet_KeyIterator) -> boolean - * Source: java/util/LinkedHashSet.KeyIterator.lsl:73 - */ - public boolean hasNext() { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(this.parent != null); - final LibSLRuntime.Map parentStorage = ((LinkedHashSet) ((Object) this.parent)).storage; - result = this.index < parentStorage.size(); - } - return result; - } - - /** - * [FUNCTION] LinkedHashSet_KeyIteratorAutomaton::next(LinkedHashSet_KeyIterator) -> Object - * Source: java/util/LinkedHashSet.KeyIterator.lsl:83 - */ - public final Object next() { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(this.parent != null); - _checkForComodification(); - final LibSLRuntime.Map parentStorage = ((LinkedHashSet) ((Object) this.parent)).storage; - final boolean atValidPosition = this.index < parentStorage.size(); - if (!atValidPosition) { - throw new NoSuchElementException(); - } - final Object key = this.unseenKeys.anyKey(); - this.unseenKeys.remove(key); - this.currentKey = key; - result = key; - this.index += 1; - this.nextWasCalled = true; - } - return result; - } - - /** - * [FUNCTION] LinkedHashSet_KeyIteratorAutomaton::remove(LinkedHashSet_KeyIterator) -> void - * Source: java/util/LinkedHashSet.KeyIterator.lsl:105 - */ - public void remove() { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(this.parent != null); - final LibSLRuntime.Map parentStorage = ((LinkedHashSet) ((Object) this.parent)).storage; - final boolean atValidPosition = this.index < parentStorage.size(); - if (!atValidPosition || !this.nextWasCalled) { - throw new IllegalStateException(); - } - this.nextWasCalled = false; - _checkForComodification(); - parentStorage.remove(this.currentKey); - this.expectedModCount = ((LinkedHashSet) ((Object) this.parent)).modCount; - } - } - - /** - * [FUNCTION] LinkedHashSet_KeyIteratorAutomaton::forEachRemaining(LinkedHashSet_KeyIterator, Consumer) -> void - * Source: java/util/LinkedHashSet.KeyIterator.lsl:125 - */ - public void forEachRemaining(Consumer userAction) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(this.parent != null); - if (userAction == null) { - throw new NullPointerException(); - } - final LibSLRuntime.Map parentStorage = ((LinkedHashSet) ((Object) this.parent)).storage; - final int length = parentStorage.size(); - int i = this.index; - while (i < length) { - _checkForComodification(); - final Object key = this.unseenKeys.anyKey(); - this.unseenKeys.remove(key); - Engine.assume(key != this.currentKey); - this.currentKey = key; - userAction.accept(key); - i += 1; - } - ; - this.index = i; - this.nextWasCalled = true; - } - } - - public static final class __$lsl_States { - public static final byte Allocated = (byte) 0; - - public static final byte Initialized = (byte) 1; - } - - @Approximate(LinkedHashSet_KeyIterator.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/LinkedHashSet_KeySpliterator.java b/approximations/src/main/java/generated/java/util/LinkedHashSet_KeySpliterator.java deleted file mode 100644 index 96985a89..00000000 --- a/approximations/src/main/java/generated/java/util/LinkedHashSet_KeySpliterator.java +++ /dev/null @@ -1,254 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/LinkedHashSet.lsl:31 -// - java/util/LinkedHashSet.Spliterator.lsl:19 -// -package generated.java.util; - -import generated.runtime.LibSLGlobals; -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.ConcurrentModificationException; -import java.util.Spliterator; -import java.util.function.Consumer; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; - -/** - * LinkedHashSet_KeySpliteratorAutomaton for LinkedHashSet_KeySpliterator ~> java.util.LinkedHashSet_KeySpliterator - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(stub.java.util.LinkedHashSet_KeySpliterator.class) -public final class LinkedHashSet_KeySpliterator implements LibSLRuntime.Automaton, Spliterator { - static { - Engine.assume(true); - } - - private byte __$lsl_state = __$lsl_States.Allocated; - - public Object[] keysStorage; - - public int index; - - public int fence; - - public int est; - - public int expectedModCount; - - public LinkedHashSet parent; - - @LibSLRuntime.AutomatonConstructor - public LinkedHashSet_KeySpliterator(Void __$lsl_token, final byte p0, final Object[] p1, - final int p2, final int p3, final int p4, final int p5, final LinkedHashSet p6) { - this.__$lsl_state = p0; - this.keysStorage = p1; - this.index = p2; - this.fence = p3; - this.est = p4; - this.expectedModCount = p5; - this.parent = p6; - } - - @LibSLRuntime.AutomatonConstructor - public LinkedHashSet_KeySpliterator(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Allocated, null, 0, 0, 0, 0, null); - } - - /** - * [CONSTRUCTOR] LinkedHashSet_KeySpliteratorAutomaton::(LinkedHashSet_KeySpliterator, HashMap, int, int, int, int) -> void - * Source: java/util/LinkedHashSet.Spliterator.lsl:89 - */ - private LinkedHashSet_KeySpliterator(HashMap source, int origin, int fence, int est, - int expectedModCount) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - this.index = origin; - fence = fence; - est = est; - expectedModCount = expectedModCount; - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [SUBROUTINE] LinkedHashSet_KeySpliteratorAutomaton::_getFence() -> int - * Source: java/util/LinkedHashSet.Spliterator.lsl:54 - */ - private int _getFence() { - int result = 0; - /* body */ { - Engine.assume(this.parent != null); - int hi = this.fence; - if (hi < 0) { - final LibSLRuntime.Map parentStorage = ((LinkedHashSet) ((Object) this.parent)).storage; - this.est = parentStorage.size(); - this.expectedModCount = ((LinkedHashSet) ((Object) this.parent)).modCount; - this.fence = this.est; - hi = this.fence; - } - result = hi; - } - return result; - } - - /** - * [SUBROUTINE] LinkedHashSet_KeySpliteratorAutomaton::_checkForComodification() -> void - * Source: java/util/LinkedHashSet.Spliterator.lsl:79 - */ - private void _checkForComodification() { - /* body */ { - final int modCount = ((LinkedHashSet) ((Object) this.parent)).modCount; - if (this.expectedModCount != modCount) { - throw new ConcurrentModificationException(); - } - } - } - - /** - * [FUNCTION] LinkedHashSet_KeySpliteratorAutomaton::estimateSize(LinkedHashSet_KeySpliterator) -> long - * Source: java/util/LinkedHashSet.Spliterator.lsl:100 - */ - public long estimateSize() { - long result = 0L; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - _getFence(); - result = ((long) this.est); - } - return result; - } - - /** - * [FUNCTION] LinkedHashSet_KeySpliteratorAutomaton::characteristics(LinkedHashSet_KeySpliterator) -> int - * Source: java/util/LinkedHashSet.Spliterator.lsl:107 - */ - public int characteristics() { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(this.parent != null); - final LibSLRuntime.Map parentStorage = ((LinkedHashSet) ((Object) this.parent)).storage; - result = 0; - if ((this.fence < 0) || (this.est == parentStorage.size())) { - result = LibSLGlobals.SPLITERATOR_SIZED; - } - result |= LibSLGlobals.SPLITERATOR_DISTINCT; - } - return result; - } - - /** - * [FUNCTION] LinkedHashSet_KeySpliteratorAutomaton::forEachRemaining(LinkedHashSet_KeySpliterator, Consumer) -> void - * Source: java/util/LinkedHashSet.Spliterator.lsl:121 - */ - public void forEachRemaining(Consumer userAction) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(this.parent != null); - if (userAction == null) { - throw new NullPointerException(); - } - int hi = this.fence; - int mc = this.expectedModCount; - int i = this.index; - final LibSLRuntime.Map parentStorage = ((LinkedHashSet) ((Object) this.parent)).storage; - final int length = parentStorage.size(); - if (hi < 0) { - this.expectedModCount = ((LinkedHashSet) ((Object) this.parent)).modCount; - mc = this.expectedModCount; - this.fence = length; - hi = this.fence; - } - this.index = hi; - if ((length > 0) && (length >= hi) && (i >= 0) && (i < this.index)) { - final Object[] storage = this.keysStorage; - Engine.assume(storage != null); - while (i < hi) { - final Object key = storage[i]; - userAction.accept(key); - i += 1; - } - ; - final int modCount = ((LinkedHashSet) ((Object) this.parent)).modCount; - if (modCount != mc) { - throw new ConcurrentModificationException(); - } - } - } - } - - /** - * [FUNCTION] LinkedHashSet_KeySpliteratorAutomaton::tryAdvance(LinkedHashSet_KeySpliterator, Consumer) -> boolean - * Source: java/util/LinkedHashSet.Spliterator.lsl:168 - */ - public boolean tryAdvance(Consumer userAction) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(this.parent != null); - if (userAction == null) { - throw new NullPointerException(); - } - int hi = _getFence(); - int i = this.index; - if (i < hi) { - final Object key = keysStorage[i]; - userAction.accept(key); - this.index += 1; - _checkForComodification(); - result = true; - } - result = false; - } - return result; - } - - /** - * [FUNCTION] LinkedHashSet_KeySpliteratorAutomaton::trySplit(LinkedHashSet_KeySpliterator) -> Spliterator - * Source: java/util/LinkedHashSet.Spliterator.lsl:192 - */ - public Spliterator trySplit() { - Spliterator result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(this.parent != null); - final int hi = _getFence(); - final int lo = this.index; - int mid = (hi + lo) >>> 1; - if (lo >= mid) { - result = null; - } else { - this.est = this.est >>> 1; - this.index = mid; - result = (stub.java.util.LinkedHashSet_KeySpliterator) ((Object) new LinkedHashSet_KeySpliterator((Void) null, - /* state = */ LinkedHashSet_KeySpliterator.__$lsl_States.Initialized, - /* keysStorage = */ this.keysStorage, - /* index = */ lo, - /* fence = */ mid, - /* est = */ this.est, - /* expectedModCount = */ this.expectedModCount, - /* parent = */ this.parent - )); - } - } - return result; - } - - public static final class __$lsl_States { - public static final byte Allocated = (byte) 0; - - public static final byte Initialized = (byte) 1; - } - - @Approximate(LinkedHashSet_KeySpliterator.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/LinkedList.java b/approximations/src/main/java/generated/java/util/LinkedList.java deleted file mode 100644 index 44c22137..00000000 --- a/approximations/src/main/java/generated/java/util/LinkedList.java +++ /dev/null @@ -1,1425 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/LinkedList.lsl:19 -// - java/util/LinkedList.main.lsl:18 -// -package generated.java.util; - -import java.io.Serializable; -import java.lang.Cloneable; -import java.lang.Comparable; -import java.lang.IllegalArgumentException; -import java.lang.IndexOutOfBoundsException; -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.Collection; -import java.util.Comparator; -import java.util.ConcurrentModificationException; -import java.util.Deque; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; -import java.util.NoSuchElementException; -import java.util.Spliterator; -import java.util.function.Consumer; -import java.util.function.IntFunction; -import java.util.function.Predicate; -import java.util.function.UnaryOperator; -import java.util.stream.Stream; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import org.usvm.api.SymbolicList; -import runtime.LibSLRuntime; -import stub.java.util.stream.StreamLSL; - -/** - * LinkedListAutomaton for LinkedList ~> java.util.LinkedList - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(java.util.LinkedList.class) -public class LinkedList implements LibSLRuntime.Automaton, List, Deque, Cloneable, Serializable { - private static final long serialVersionUID = 876323262645176354L; - - static { - Engine.assume(true); - } - - private byte __$lsl_state = __$lsl_States.Allocated; - - public SymbolicList storage; - - public transient int modCount; - - @LibSLRuntime.AutomatonConstructor - public LinkedList(Void __$lsl_token, final byte p0, final SymbolicList p1, - final int p2) { - this.__$lsl_state = p0; - this.storage = p1; - this.modCount = p2; - } - - @LibSLRuntime.AutomatonConstructor - public LinkedList(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Allocated, null, 0); - } - - /** - * [CONSTRUCTOR] LinkedListAutomaton::(LinkedList) -> void - * Source: java/util/LinkedList.main.lsl:566 - */ - public LinkedList() { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - this.storage = Engine.makeSymbolicList(); - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [CONSTRUCTOR] LinkedListAutomaton::(LinkedList, Collection) -> void - * Source: java/util/LinkedList.main.lsl:572 - */ - public LinkedList(Collection c) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - if (c == null) { - throw new NullPointerException(); - } - this.storage = Engine.makeSymbolicList(); - _addAllElements(this.storage.size(), c); - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [SUBROUTINE] LinkedListAutomaton::_checkForComodification(int) -> void - * Source: java/util/LinkedList.main.lsl:109 - */ - public void _checkForComodification(int expectedModCount) { - /* body */ { - if (this.modCount != expectedModCount) { - throw new ConcurrentModificationException(); - } - } - } - - /** - * [SUBROUTINE] LinkedListAutomaton::_subListRangeCheck(int, int, int) -> void - * Source: java/util/LinkedList.main.lsl:117 - */ - public void _subListRangeCheck(int fromIndex, int toIndex, int size) { - /* body */ { - if (fromIndex < 0) { - throw new IndexOutOfBoundsException(); - } - if (toIndex > size) { - throw new IndexOutOfBoundsException(); - } - if (fromIndex > toIndex) { - throw new IllegalArgumentException(); - } - } - } - - /** - * [SUBROUTINE] LinkedListAutomaton::_unlinkAny(int) -> Object - * Source: java/util/LinkedList.main.lsl:141 - */ - public Object _unlinkAny(int index) { - Object result = null; - /* body */ { - result = this.storage.get(index); - this.storage.remove(index); - this.modCount += 1; - } - return result; - } - - /** - * [SUBROUTINE] LinkedListAutomaton::_linkAny(int, Object) -> void - * Source: java/util/LinkedList.main.lsl:149 - */ - public void _linkAny(int index, Object e) { - /* body */ { - this.storage.insert(index, e); - this.modCount += 1; - } - } - - /** - * [SUBROUTINE] LinkedListAutomaton::_checkElementIndex(int, int) -> void - * Source: java/util/LinkedList.main.lsl:156 - */ - public void _checkElementIndex(int index, int size) { - /* body */ { - if (!_isValidIndex(index, size)) { - throw new IndexOutOfBoundsException(); - } - } - } - - /** - * [SUBROUTINE] LinkedListAutomaton::_isValidIndex(int, int) -> boolean - * Source: java/util/LinkedList.main.lsl:168 - */ - private boolean _isValidIndex(int index, int size) { - boolean result = false; - /* body */ { - result = (0 <= index) && (index < size); - } - return result; - } - - /** - * [SUBROUTINE] LinkedListAutomaton::_isPositionIndex(int) -> boolean - * Source: java/util/LinkedList.main.lsl:174 - */ - private boolean _isPositionIndex(int index) { - boolean result = false; - /* body */ { - result = (0 <= index) && (index <= this.storage.size()); - } - return result; - } - - /** - * [SUBROUTINE] LinkedListAutomaton::_checkPositionIndex(int) -> void - * Source: java/util/LinkedList.main.lsl:180 - */ - public void _checkPositionIndex(int index) { - /* body */ { - if (!_isPositionIndex(index)) { - throw new IndexOutOfBoundsException(); - } - } - } - - /** - * [SUBROUTINE] LinkedListAutomaton::_unlinkFirst() -> Object - * Source: java/util/LinkedList.main.lsl:192 - */ - private Object _unlinkFirst() { - Object result = null; - /* body */ { - if (this.storage.size() == 0) { - throw new NoSuchElementException(); - } - result = _unlinkAny(0); - } - return result; - } - - /** - * [SUBROUTINE] LinkedListAutomaton::_unlinkByFirstEqualsObject(Object) -> boolean - * Source: java/util/LinkedList.main.lsl:201 - */ - private boolean _unlinkByFirstEqualsObject(Object o) { - boolean result = false; - /* body */ { - final int index = LibSLRuntime.ListActions.find(this.storage, o, 0, this.storage.size()); - result = index != -1; - if (result) { - this.storage.remove(index); - this.modCount += 1; - } - } - return result; - } - - /** - * [SUBROUTINE] LinkedListAutomaton::_addAllElements(int, Collection) -> boolean - * Source: java/util/LinkedList.main.lsl:213 - */ - public boolean _addAllElements(int index, Collection c) { - boolean result = false; - /* body */ { - _checkPositionIndex(index); - final Iterator iter = c.iterator(); - result = iter.hasNext(); - while (iter.hasNext()) { - final Object item = iter.next(); - this.storage.insert(index, item); - index += 1; - } - ; - this.modCount += 1; - } - return result; - } - - /** - * [SUBROUTINE] LinkedListAutomaton::_getFirstElement() -> Object - * Source: java/util/LinkedList.main.lsl:238 - */ - private Object _getFirstElement() { - Object result = null; - /* body */ { - if (this.storage.size() == 0) { - throw new NoSuchElementException(); - } - result = this.storage.get(0); - } - return result; - } - - /** - * [SUBROUTINE] LinkedListAutomaton::_replaceAllRange(UnaryOperator, int, int) -> void - * Source: java/util/LinkedList.main.lsl:247 - */ - public void _replaceAllRange(UnaryOperator op, int i, int end) { - /* body */ { - final int expectedModCount = this.modCount; - while ((this.modCount == expectedModCount) && (i < end)) { - final Object oldItem = this.storage.get(i); - final Object newItem = op.apply(oldItem); - this.storage.set(i, newItem); - i += 1; - } - ; - _checkForComodification(expectedModCount); - } - } - - /** - * [SUBROUTINE] LinkedListAutomaton::_removeIf(Predicate, int, int) -> boolean - * Source: java/util/LinkedList.main.lsl:269 - */ - public boolean _removeIf(Predicate filter, int start, int end) { - boolean result = false; - /* body */ { - if (filter == null) { - throw new NullPointerException(); - } - final int oldSize = this.storage.size(); - final int expectedModCount = this.modCount; - Engine.assume(start <= end); - int i = 0; - for (i = end - 1; i > start; i += -1) { - final Object item = this.storage.get(i); - if (filter.test(item)) { - this.storage.remove(i); - } - } - ; - _checkForComodification(expectedModCount); - result = oldSize != this.storage.size(); - } - return result; - } - - /** - * [SUBROUTINE] LinkedListAutomaton::_equalsRange(List, int, int) -> boolean - * Source: java/util/LinkedList.main.lsl:299 - */ - public boolean _equalsRange(List other, int from, int to) { - boolean result = false; - /* body */ { - result = true; - int i = from; - int otherLength = 0; - SymbolicList otherStorage = null; - if ((other != null && other.getClass() == java.util.LinkedList.class)) { - otherStorage = ((LinkedList) ((Object) other)).storage; - otherLength = otherStorage.size(); - result = to == otherLength; - if (result) { - while (result && (i < to)) { - final Object a = otherStorage.get(i); - final Object b = this.storage.get(i); - result = LibSLRuntime.equals(a, b); - i += 1; - } - ; - } - } else { - final Iterator iter = other.iterator(); - while (result && (i < to) && iter.hasNext()) { - final Object a = iter.next(); - final Object b = this.storage.get(i); - result = LibSLRuntime.equals(a, b); - i += 1; - } - ; - result &= !iter.hasNext(); - } - } - return result; - } - - /** - * [SUBROUTINE] LinkedListAutomaton::_makeStream(boolean) -> Stream - * Source: java/util/LinkedList.main.lsl:374 - */ - private Stream _makeStream(boolean parallel) { - Stream result = null; - /* body */ { - final int count = this.storage.size(); - final Object[] items = new Object[count]; - int i = 0; - for (i = 0; i < count; i += 1) { - items[i] = this.storage.get(i); - } - ; - result = (StreamLSL) ((Object) new generated.java.util.stream.StreamLSL((Void) null, - /* state = */ generated.java.util.stream.StreamLSL.__$lsl_States.Initialized, - /* storage = */ items, - /* length = */ count, - /* closeHandlers = */ Engine.makeSymbolicList(), - /* isParallel = */ parallel, - /* linkedOrConsumed = */ false - )); - } - return result; - } - - /** - * [SUBROUTINE] LinkedListAutomaton::_batchRemove(Collection, boolean, int, int) -> boolean - * Source: java/util/LinkedList.main.lsl:401 - */ - public boolean _batchRemove(Collection c, boolean complement, int start, int end) { - boolean result = false; - /* body */ { - if (c == null) { - throw new NullPointerException(); - } - final int oldSize = this.storage.size(); - if ((oldSize == 0) || (start >= end)) { - result = false; - } else { - final int otherLength = c.size(); - if (otherLength == 0) { - if (complement) { - result = true; - this.storage = Engine.makeSymbolicList(); - this.modCount += 1; - } else { - result = false; - } - } else { - Engine.assume(otherLength > 0); - int i = 0; - start -= 1; - end -= 1; - if ((c != null && c.getClass() == java.util.LinkedList.class)) { - final SymbolicList otherStorage = ((LinkedList) ((Object) c)).storage; - Engine.assume(otherStorage != null); - for (i = end; i > start; i += -1) { - final Object item = this.storage.get(i); - if ((LibSLRuntime.ListActions.find(otherStorage, item, 0, this.storage.size()) == -1) == complement) { - _unlinkAny(i); - } - } - ; - } else { - for (i = end; i > start; i += -1) { - final Object item = this.storage.get(i); - if (c.contains(item) != complement) { - _unlinkAny(i); - } - } - ; - } - result = oldSize != this.storage.size(); - } - } - } - return result; - } - - /** - * [SUBROUTINE] LinkedListAutomaton::_do_sort(int, int, Comparator) -> void - * Source: java/util/LinkedList.main.lsl:473 - */ - public void _do_sort(int start, int end, Comparator c) { - /* body */ { - if (start < end) { - final int expectedModCount = this.modCount; - Engine.assume(start >= 0); - Engine.assume(end > 0); - final int outerLimit = end - 1; - int innerLimit = 0; - int i = 0; - int j = 0; - if (c == null) { - for (i = start; i < outerLimit; i += 1) { - innerLimit = (end - i) - 1; - for (j = start; j < innerLimit; j += 1) { - final int idxA = j; - final int idxB = j + 1; - final Object a = this.storage.get(idxA); - final Object b = this.storage.get(idxB); - if (((Comparable) a).compareTo(b) > 0) { - this.storage.set(idxA, b); - this.storage.set(idxB, a); - } - } - ; - } - ; - } else { - for (i = start; i < outerLimit; i += 1) { - innerLimit = (end - i) - 1; - for (j = start; j < innerLimit; j += 1) { - final int idxA = j; - final int idxB = j + 1; - final Object a = this.storage.get(idxA); - final Object b = this.storage.get(idxB); - if (c.compare(a, b) > 0) { - this.storage.set(idxA, b); - this.storage.set(idxB, a); - } - } - ; - } - ; - } - _checkForComodification(expectedModCount); - } - this.modCount += 1; - } - } - - /** - * [FUNCTION] LinkedListAutomaton::add(LinkedList, Object) -> boolean - * Source: java/util/LinkedList.main.lsl:585 - */ - public boolean add(Object e) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - _linkAny(this.storage.size(), e); - result = true; - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::add(LinkedList, int, Object) -> void - * Source: java/util/LinkedList.main.lsl:592 - */ - public void add(int index, Object element) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - _checkPositionIndex(index); - _linkAny(index, element); - } - } - - /** - * [FUNCTION] LinkedListAutomaton::addAll(LinkedList, Collection) -> boolean - * Source: java/util/LinkedList.main.lsl:599 - */ - public boolean addAll(Collection c) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = _addAllElements(this.storage.size(), c); - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::addAll(LinkedList, int, Collection) -> boolean - * Source: java/util/LinkedList.main.lsl:605 - */ - public boolean addAll(int index, Collection c) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = _addAllElements(index, c); - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::addFirst(LinkedList, Object) -> void - * Source: java/util/LinkedList.main.lsl:611 - */ - public void addFirst(Object e) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - _linkAny(0, e); - } - } - - /** - * [FUNCTION] LinkedListAutomaton::addLast(LinkedList, Object) -> void - * Source: java/util/LinkedList.main.lsl:617 - */ - public void addLast(Object e) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - _linkAny(this.storage.size(), e); - } - } - - /** - * [FUNCTION] LinkedListAutomaton::clear(LinkedList) -> void - * Source: java/util/LinkedList.main.lsl:623 - */ - public void clear() { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - this.storage = Engine.makeSymbolicList(); - this.modCount += 1; - } - } - - /** - * [FUNCTION] LinkedListAutomaton::clone(LinkedList) -> Object - * Source: java/util/LinkedList.main.lsl:630 - */ - public Object clone() { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final SymbolicList storageCopy = Engine.makeSymbolicList(); - this.storage.copy(storageCopy, 0, 0, this.storage.size()); - result = (java.util.LinkedList) ((Object) new LinkedList((Void) null, - /* state = */ LinkedList.__$lsl_States.Initialized, - /* storage = */ storageCopy, - /* modCount = */ 0 - )); - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::contains(LinkedList, Object) -> boolean - * Source: java/util/LinkedList.main.lsl:641 - */ - public boolean contains(Object o) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = LibSLRuntime.ListActions.find(this.storage, o, 0, this.storage.size()) != -1; - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::containsAll(LinkedList, Collection) -> boolean - * Source: java/util/LinkedList.main.lsl:648 - */ - public boolean containsAll(Collection c) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = true; - if ((c != null && c.getClass() == java.util.LinkedList.class)) { - final SymbolicList otherStorage = ((LinkedList) ((Object) c)).storage; - final int otherSize = otherStorage.size(); - Engine.assume(otherStorage != null); - Engine.assume(otherSize >= 0); - int i = 0; - while (result && (i < otherSize)) { - final Object item = otherStorage.get(i); - result = LibSLRuntime.ListActions.find(this.storage, item, 0, this.storage.size()) != -1; - i += 1; - } - ; - } else { - final Iterator iter = c.iterator(); - while (result && iter.hasNext()) { - final Object item = iter.next(); - result = LibSLRuntime.ListActions.find(this.storage, item, 0, this.storage.size()) != -1; - } - ; - } - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::descendingIterator(LinkedList) -> Iterator - * Source: java/util/LinkedList.main.lsl:691 - */ - public Iterator descendingIterator() { - Iterator result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = (stub.java.util.LinkedList_DescendingIterator) ((Object) new LinkedList_DescendingIterator((Void) null, - /* state = */ LinkedList_DescendingIterator.__$lsl_States.Initialized, - /* parent = */ this, - /* cursor = */ this.storage.size(), - /* expectedModCount = */ this.modCount, - /* lastRet = */ -1 - )); - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::element(LinkedList) -> Object - * Source: java/util/LinkedList.main.lsl:701 - */ - public Object element() { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = _getFirstElement(); - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::equals(LinkedList, Object) -> boolean - * Source: java/util/LinkedList.main.lsl:708 - */ - public boolean equals(Object o) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this == o) { - result = true; - } else { - if ((o != null && o.getClass() == java.util.LinkedList.class)) { - final int expectedModCount = this.modCount; - final int otherExpectedModCount = ((LinkedList) ((Object) o)).modCount; - final SymbolicList otherStorage = ((LinkedList) ((Object) o)).storage; - if (this.storage.size() == otherStorage.size()) { - result = LibSLRuntime.equals(this.storage, otherStorage); - } else { - result = false; - } - ((LinkedList) ((Object) o))._checkForComodification(otherExpectedModCount); - _checkForComodification(expectedModCount); - } else { - result = false; - } - } - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::forEach(LinkedList, Consumer) -> void - * Source: java/util/LinkedList.main.lsl:744 - */ - public void forEach(Consumer _action) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (_action == null) { - throw new NullPointerException(); - } - final int expectedModCount = this.modCount; - int i = 0; - while ((this.modCount == expectedModCount) && (i < this.storage.size())) { - final Object item = this.storage.get(i); - _action.accept(item); - i += 1; - } - ; - _checkForComodification(expectedModCount); - } - } - - /** - * [FUNCTION] LinkedListAutomaton::get(LinkedList, int) -> Object - * Source: java/util/LinkedList.main.lsl:769 - */ - public Object get(int index) { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - _checkElementIndex(index, this.storage.size()); - result = this.storage.get(index); - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::getFirst(LinkedList) -> Object - * Source: java/util/LinkedList.main.lsl:776 - */ - public Object getFirst() { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = _getFirstElement(); - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::getLast(LinkedList) -> Object - * Source: java/util/LinkedList.main.lsl:782 - */ - public Object getLast() { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.storage.size() == 0) { - throw new NoSuchElementException(); - } - result = this.storage.get(this.storage.size() - 1); - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::hashCode(LinkedList) -> int - * Source: java/util/LinkedList.main.lsl:792 - */ - public int hashCode() { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = LibSLRuntime.hashCode(this.storage); - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::indexOf(LinkedList, Object) -> int - * Source: java/util/LinkedList.main.lsl:798 - */ - public int indexOf(Object o) { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = LibSLRuntime.ListActions.find(this.storage, o, 0, this.storage.size()); - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::isEmpty(LinkedList) -> boolean - * Source: java/util/LinkedList.main.lsl:805 - */ - public boolean isEmpty() { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.storage.size() == 0; - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::iterator(LinkedList) -> Iterator - * Source: java/util/LinkedList.main.lsl:812 - */ - public Iterator iterator() { - Iterator result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = (stub.java.util.LinkedList_ListItr) ((Object) new LinkedList_ListItr((Void) null, - /* state = */ LinkedList_ListItr.__$lsl_States.Initialized, - /* parent = */ this, - /* cursor = */ 0, - /* expectedModCount = */ this.modCount, - /* lastRet = */ -1 - )); - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::lastIndexOf(LinkedList, Object) -> int - * Source: java/util/LinkedList.main.lsl:822 - */ - public int lastIndexOf(Object o) { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = -1; - final int size = this.storage.size(); - if (size != 0) { - Engine.assume(size > 0); - final SymbolicList items = this.storage; - int i = 0; - for (i = size - 1; i > -1; i += -1) { - final Object e = items.get(i); - if (LibSLRuntime.equals(o, e)) { - result = i; - break; - } - } - ; - } - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::listIterator(LinkedList) -> ListIterator - * Source: java/util/LinkedList.main.lsl:854 - */ - public ListIterator listIterator() { - ListIterator result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = (stub.java.util.LinkedList_ListItr) ((Object) new LinkedList_ListItr((Void) null, - /* state = */ LinkedList_ListItr.__$lsl_States.Initialized, - /* parent = */ this, - /* cursor = */ 0, - /* expectedModCount = */ this.modCount, - /* lastRet = */ -1 - )); - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::listIterator(LinkedList, int) -> ListIterator - * Source: java/util/LinkedList.main.lsl:864 - */ - public ListIterator listIterator(int index) { - ListIterator result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - _checkPositionIndex(index); - result = (stub.java.util.LinkedList_ListItr) ((Object) new LinkedList_ListItr((Void) null, - /* state = */ LinkedList_ListItr.__$lsl_States.Initialized, - /* parent = */ this, - /* cursor = */ index, - /* expectedModCount = */ this.modCount, - /* lastRet = */ -1 - )); - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::offer(LinkedList, Object) -> boolean - * Source: java/util/LinkedList.main.lsl:876 - */ - public boolean offer(Object e) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - _linkAny(this.storage.size(), e); - result = true; - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::offerFirst(LinkedList, Object) -> boolean - * Source: java/util/LinkedList.main.lsl:883 - */ - public boolean offerFirst(Object e) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - _linkAny(0, e); - result = true; - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::offerLast(LinkedList, Object) -> boolean - * Source: java/util/LinkedList.main.lsl:890 - */ - public boolean offerLast(Object e) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - _linkAny(this.storage.size(), e); - result = true; - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::parallelStream(LinkedList) -> Stream - * Source: java/util/LinkedList.main.lsl:898 - */ - public Stream parallelStream() { - Stream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = _makeStream(true); - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::peek(LinkedList) -> Object - * Source: java/util/LinkedList.main.lsl:904 - */ - public Object peek() { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.storage.size() == 0) { - result = null; - } else { - result = this.storage.get(0); - } - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::peekFirst(LinkedList) -> Object - * Source: java/util/LinkedList.main.lsl:913 - */ - public Object peekFirst() { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.storage.size() == 0) { - result = null; - } else { - result = this.storage.get(0); - } - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::peekLast(LinkedList) -> Object - * Source: java/util/LinkedList.main.lsl:922 - */ - public Object peekLast() { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.storage.size() == 0) { - result = null; - } else { - result = this.storage.get(this.storage.size() - 1); - } - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::poll(LinkedList) -> Object - * Source: java/util/LinkedList.main.lsl:931 - */ - public Object poll() { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.storage.size() == 0) { - result = null; - } else { - result = _unlinkAny(0); - } - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::pollFirst(LinkedList) -> Object - * Source: java/util/LinkedList.main.lsl:940 - */ - public Object pollFirst() { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.storage.size() == 0) { - result = null; - } else { - result = _unlinkAny(0); - } - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::pollLast(LinkedList) -> Object - * Source: java/util/LinkedList.main.lsl:949 - */ - public Object pollLast() { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.storage.size() == 0) { - result = null; - } else { - result = _unlinkAny(this.storage.size() - 1); - } - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::pop(LinkedList) -> Object - * Source: java/util/LinkedList.main.lsl:958 - */ - public Object pop() { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = _unlinkFirst(); - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::push(LinkedList, Object) -> void - * Source: java/util/LinkedList.main.lsl:964 - */ - public void push(Object e) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - _linkAny(0, e); - } - } - - /** - * [FUNCTION] LinkedListAutomaton::remove(LinkedList) -> Object - * Source: java/util/LinkedList.main.lsl:970 - */ - public Object remove() { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = _unlinkFirst(); - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::remove(LinkedList, Object) -> boolean - * Source: java/util/LinkedList.main.lsl:976 - */ - public boolean remove(Object o) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = _unlinkByFirstEqualsObject(o); - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::remove(LinkedList, int) -> Object - * Source: java/util/LinkedList.main.lsl:982 - */ - public Object remove(int index) { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - _checkElementIndex(index, this.storage.size()); - result = _unlinkAny(index); - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::removeAll(LinkedList, Collection) -> boolean - * Source: java/util/LinkedList.main.lsl:990 - */ - public boolean removeAll(Collection c) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = _batchRemove(c, false, 0, this.storage.size()); - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::removeFirst(LinkedList) -> Object - * Source: java/util/LinkedList.main.lsl:996 - */ - public Object removeFirst() { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = _unlinkFirst(); - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::removeFirstOccurrence(LinkedList, Object) -> boolean - * Source: java/util/LinkedList.main.lsl:1002 - */ - public boolean removeFirstOccurrence(Object o) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = _unlinkByFirstEqualsObject(o); - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::removeIf(LinkedList, Predicate) -> boolean - * Source: java/util/LinkedList.main.lsl:1009 - */ - public boolean removeIf(Predicate filter) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = _removeIf(filter, 0, this.storage.size()); - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::removeLast(LinkedList) -> Object - * Source: java/util/LinkedList.main.lsl:1015 - */ - public Object removeLast() { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.storage.size() == 0) { - throw new NoSuchElementException(); - } - result = _unlinkAny(this.storage.size() - 1); - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::removeLastOccurrence(LinkedList, Object) -> boolean - * Source: java/util/LinkedList.main.lsl:1024 - */ - public boolean removeLastOccurrence(Object o) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final int size = this.storage.size(); - if (size == 0) { - result = false; - } else { - Engine.assume(size > 0); - int index = size - 1; - for (index = index; index > -1; index += -1) { - final Object item = this.storage.get(index); - if (LibSLRuntime.equals(item, o)) { - break; - } - } - ; - result = index != -1; - if (result) { - this.storage.remove(index); - this.modCount += 1; - } - } - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::replaceAll(LinkedList, UnaryOperator) -> void - * Source: java/util/LinkedList.main.lsl:1061 - */ - public void replaceAll(UnaryOperator op) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (op == null) { - throw new NullPointerException(); - } - _replaceAllRange(op, 0, this.storage.size()); - this.modCount += 1; - } - } - - /** - * [FUNCTION] LinkedListAutomaton::retainAll(LinkedList, Collection) -> boolean - * Source: java/util/LinkedList.main.lsl:1072 - */ - public boolean retainAll(Collection c) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = _batchRemove(c, true, 0, this.storage.size()); - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::set(LinkedList, int, Object) -> Object - * Source: java/util/LinkedList.main.lsl:1078 - */ - public Object set(int index, Object element) { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - _checkElementIndex(index, this.storage.size()); - result = this.storage.get(index); - this.storage.set(index, element); - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::size(LinkedList) -> int - * Source: java/util/LinkedList.main.lsl:1086 - */ - public int size() { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.storage.size(); - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::sort(LinkedList, Comparator) -> void - * Source: java/util/LinkedList.main.lsl:1093 - */ - public void sort(Comparator c) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - _do_sort(0, this.storage.size(), c); - } - } - - /** - * [FUNCTION] LinkedListAutomaton::spliterator(LinkedList) -> Spliterator - * Source: java/util/LinkedList.main.lsl:1099 - */ - public Spliterator spliterator() { - Spliterator result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = (stub.java.util.LinkedList_Spliterator) ((Object) new LinkedList_Spliterator((Void) null, - /* state = */ LinkedList_Spliterator.__$lsl_States.Initialized, - /* parent = */ this, - /* index = */ 0, - /* fence = */ -1, - /* expectedModCount = */ 0 - )); - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::stream(LinkedList) -> Stream - * Source: java/util/LinkedList.main.lsl:1108 - */ - public Stream stream() { - Stream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = _makeStream(false); - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::subList(LinkedList, int, int) -> List - * Source: java/util/LinkedList.main.lsl:1115 - */ - public List subList(int fromIndex, int toIndex) { - List result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - _subListRangeCheck(fromIndex, toIndex, this.storage.size()); - result = (stub.java.util.LinkedList_SubList) ((Object) new LinkedList_SubList((Void) null, - /* state = */ LinkedList_SubList.__$lsl_States.Initialized, - /* root = */ this, - /* parentList = */ null, - /* offset = */ fromIndex, - /* length = */ toIndex - fromIndex, - /* modCount = */ this.modCount - )); - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::toArray(LinkedList) -> array - * Source: java/util/LinkedList.main.lsl:1129 - */ - public Object[] toArray() { - Object[] result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final int len = this.storage.size(); - result = new Object[len]; - int i = 0; - for (i = 0; i < len; i += 1) { - result[i] = this.storage.get(i); - } - ; - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::toArray(LinkedList, IntFunction) -> array - * Source: java/util/LinkedList.main.lsl:1149 - */ - public Object[] toArray(IntFunction generator) { - Object[] result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final Object[] a = ((Object[]) generator.apply(0)); - final int aLen = a.length; - final int len = this.storage.size(); - result = new Object[len]; - int i = 0; - for (i = 0; i < len; i += 1) { - result[i] = this.storage.get(i); - } - ; - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::toArray(LinkedList, array) -> array - * Source: java/util/LinkedList.main.lsl:1167 - */ - public Object[] toArray(Object[] a) { - Object[] result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final int aLen = a.length; - final int len = this.storage.size(); - int i = 0; - if (aLen < len) { - result = new Object[len]; - for (i = 0; i < len; i += 1) { - result[i] = this.storage.get(i); - } - ; - } else { - result = a; - for (i = 0; i < len; i += 1) { - result[i] = this.storage.get(i); - } - ; - if (aLen > len) { - result[len] = null; - } - } - } - return result; - } - - /** - * [FUNCTION] LinkedListAutomaton::toString(LinkedList) -> String - * Source: java/util/LinkedList.main.lsl:1199 - */ - public String toString() { - String result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = LibSLRuntime.toString(this.storage); - } - return result; - } - - public static final class __$lsl_States { - public static final byte Allocated = (byte) 0; - - public static final byte Initialized = (byte) 1; - } - - @Approximate(LinkedList.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/LinkedList_DescendingIterator.java b/approximations/src/main/java/generated/java/util/LinkedList_DescendingIterator.java deleted file mode 100644 index 2a418da2..00000000 --- a/approximations/src/main/java/generated/java/util/LinkedList_DescendingIterator.java +++ /dev/null @@ -1,158 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/LinkedList.lsl:43 -// - java/util/LinkedList.DescendingIterator.lsl:18 -// -package generated.java.util; - -import java.lang.IllegalStateException; -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.ConcurrentModificationException; -import java.util.Iterator; -import java.util.NoSuchElementException; -import java.util.function.Consumer; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import org.usvm.api.SymbolicList; -import runtime.LibSLRuntime; - -/** - * LinkedList_DescendingIteratorAutomaton for LinkedList_DescendingIterator ~> java.util.LinkedList_DescendingIterator - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(stub.java.util.LinkedList_DescendingIterator.class) -public final class LinkedList_DescendingIterator implements LibSLRuntime.Automaton, Iterator { - static { - Engine.assume(true); - } - - public LinkedList parent; - - public int cursor; - - public int expectedModCount; - - public int lastRet; - - @LibSLRuntime.AutomatonConstructor - public LinkedList_DescendingIterator(Void __$lsl_token, final byte p0, final LinkedList p1, - final int p2, final int p3, final int p4) { - this.parent = p1; - this.cursor = p2; - this.expectedModCount = p3; - this.lastRet = p4; - } - - @LibSLRuntime.AutomatonConstructor - public LinkedList_DescendingIterator(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Initialized, null, 0, 0, -1); - } - - /** - * [FUNCTION] LinkedList_DescendingIteratorAutomaton::hasNext(LinkedList_DescendingIterator) -> boolean - * Source: java/util/LinkedList.DescendingIterator.lsl:60 - */ - public boolean hasNext() { - boolean result = false; - /* body */ { - Engine.assume(this.parent != null); - result = this.cursor != 0; - } - return result; - } - - /** - * [FUNCTION] LinkedList_DescendingIteratorAutomaton::next(LinkedList_DescendingIterator) -> Object - * Source: java/util/LinkedList.DescendingIterator.lsl:69 - */ - public Object next() { - Object result = null; - /* body */ { - Engine.assume(this.parent != null); - if (((LinkedList) ((Object) this.parent)).modCount != this.expectedModCount) { - throw new ConcurrentModificationException(); - } - final SymbolicList parentStorage = ((LinkedList) ((Object) this.parent)).storage; - final int i = this.cursor - 1; - if (i < 0) { - throw new NoSuchElementException(); - } - if (i >= parentStorage.size()) { - throw new ConcurrentModificationException(); - } - this.cursor = i; - this.lastRet = i; - result = parentStorage.get(i); - } - return result; - } - - /** - * [FUNCTION] LinkedList_DescendingIteratorAutomaton::remove(LinkedList_DescendingIterator) -> void - * Source: java/util/LinkedList.DescendingIterator.lsl:93 - */ - public void remove() { - /* body */ { - Engine.assume(this.parent != null); - if (this.lastRet < 0) { - throw new IllegalStateException(); - } - if (((LinkedList) ((Object) this.parent)).modCount != this.expectedModCount) { - throw new ConcurrentModificationException(); - } - final SymbolicList pStorage = ((LinkedList) ((Object) this.parent)).storage; - if (this.lastRet >= pStorage.size()) { - throw new ConcurrentModificationException(); - } else { - ((LinkedList) ((Object) this.parent)).modCount += 1; - pStorage.remove(this.lastRet); - } - this.cursor = this.lastRet; - this.lastRet = -1; - this.expectedModCount = ((LinkedList) ((Object) this.parent)).modCount; - } - } - - /** - * [FUNCTION] LinkedList_DescendingIteratorAutomaton::forEachRemaining(LinkedList_DescendingIterator, Consumer) -> void - * Source: java/util/LinkedList.DescendingIterator.lsl:121 - */ - public void forEachRemaining(Consumer userAction) { - /* body */ { - Engine.assume(this.parent != null); - if (userAction == null) { - throw new NullPointerException(); - } - int i = this.cursor; - final SymbolicList es = ((LinkedList) ((Object) this.parent)).storage; - final int size = es.size(); - if (i < size) { - while ((i < size) && (((LinkedList) ((Object) this.parent)).modCount == this.expectedModCount)) { - final Object item = es.get(i); - userAction.accept(item); - i += 1; - } - ; - this.cursor = i; - this.lastRet = i - 1; - if (((LinkedList) ((Object) this.parent)).modCount != this.expectedModCount) { - throw new ConcurrentModificationException(); - } - } - } - } - - public static final class __$lsl_States { - public static final byte Initialized = (byte) 0; - } - - @Approximate(LinkedList_DescendingIterator.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/LinkedList_ListItr.java b/approximations/src/main/java/generated/java/util/LinkedList_ListItr.java deleted file mode 100644 index 6a42b636..00000000 --- a/approximations/src/main/java/generated/java/util/LinkedList_ListItr.java +++ /dev/null @@ -1,264 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/LinkedList.lsl:34 -// - java/util/LinkedList.ListIterator.lsl:16 -// -package generated.java.util; - -import java.lang.IllegalStateException; -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.ConcurrentModificationException; -import java.util.ListIterator; -import java.util.NoSuchElementException; -import java.util.function.Consumer; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import org.usvm.api.SymbolicList; -import runtime.LibSLRuntime; - -/** - * LinkedList_ListIteratorAutomaton for LinkedList_ListIterator ~> java.util.LinkedList_ListItr - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(stub.java.util.LinkedList_ListItr.class) -public final class LinkedList_ListItr implements LibSLRuntime.Automaton, ListIterator { - static { - Engine.assume(true); - } - - public LinkedList parent; - - public int cursor; - - public int expectedModCount; - - public int lastRet; - - @LibSLRuntime.AutomatonConstructor - public LinkedList_ListItr(Void __$lsl_token, final byte p0, final LinkedList p1, final int p2, - final int p3, final int p4) { - this.parent = p1; - this.cursor = p2; - this.expectedModCount = p3; - this.lastRet = p4; - } - - @LibSLRuntime.AutomatonConstructor - public LinkedList_ListItr(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Initialized, null, 0, 0, -1); - } - - /** - * [SUBROUTINE] LinkedList_ListIteratorAutomaton::_checkForComodification() -> void - * Source: java/util/LinkedList.ListIterator.lsl:55 - */ - private void _checkForComodification() { - /* body */ { - final int modCount = ((LinkedList) ((Object) this.parent)).modCount; - if (modCount != this.expectedModCount) { - throw new ConcurrentModificationException(); - } - } - } - - /** - * [FUNCTION] LinkedList_ListIteratorAutomaton::hasPrevious(LinkedList_ListIterator) -> boolean - * Source: java/util/LinkedList.ListIterator.lsl:65 - */ - public boolean hasPrevious() { - boolean result = false; - /* body */ { - result = this.cursor != 0; - } - return result; - } - - /** - * [FUNCTION] LinkedList_ListIteratorAutomaton::nextIndex(LinkedList_ListIterator) -> int - * Source: java/util/LinkedList.ListIterator.lsl:71 - */ - public int nextIndex() { - int result = 0; - /* body */ { - result = this.cursor; - } - return result; - } - - /** - * [FUNCTION] LinkedList_ListIteratorAutomaton::previousIndex(LinkedList_ListIterator) -> int - * Source: java/util/LinkedList.ListIterator.lsl:77 - */ - public int previousIndex() { - int result = 0; - /* body */ { - result = this.cursor - 1; - } - return result; - } - - /** - * [FUNCTION] LinkedList_ListIteratorAutomaton::hasNext(LinkedList_ListIterator) -> boolean - * Source: java/util/LinkedList.ListIterator.lsl:83 - */ - public boolean hasNext() { - boolean result = false; - /* body */ { - Engine.assume(this.parent != null); - result = this.cursor != ((LinkedList) ((Object) this.parent)).storage.size(); - } - return result; - } - - /** - * [FUNCTION] LinkedList_ListIteratorAutomaton::next(LinkedList_ListIterator) -> Object - * Source: java/util/LinkedList.ListIterator.lsl:92 - */ - public Object next() { - Object result = null; - /* body */ { - Engine.assume(this.parent != null); - _checkForComodification(); - final SymbolicList parentStorage = ((LinkedList) ((Object) this.parent)).storage; - final int i = this.cursor; - if (i >= parentStorage.size()) { - throw new NoSuchElementException(); - } - this.cursor = i + 1; - this.lastRet = i; - result = parentStorage.get(i); - } - return result; - } - - /** - * [FUNCTION] LinkedList_ListIteratorAutomaton::previous(LinkedList_ListIterator) -> Object - * Source: java/util/LinkedList.ListIterator.lsl:112 - */ - public Object previous() { - Object result = null; - /* body */ { - Engine.assume(this.parent != null); - _checkForComodification(); - final SymbolicList parentStorage = ((LinkedList) ((Object) this.parent)).storage; - final int i = this.cursor - 1; - if (i < 0) { - throw new NoSuchElementException(); - } - if (i >= parentStorage.size()) { - throw new ConcurrentModificationException(); - } - this.cursor = i; - this.lastRet = i; - result = parentStorage.get(i); - } - return result; - } - - /** - * [FUNCTION] LinkedList_ListIteratorAutomaton::remove(LinkedList_ListIterator) -> void - * Source: java/util/LinkedList.ListIterator.lsl:136 - */ - public void remove() { - /* body */ { - Engine.assume(this.parent != null); - if (this.lastRet < 0) { - throw new IllegalStateException(); - } - _checkForComodification(); - final SymbolicList pStorage = ((LinkedList) ((Object) this.parent)).storage; - if (this.lastRet >= pStorage.size()) { - throw new ConcurrentModificationException(); - } else { - ((LinkedList) ((Object) this.parent)).modCount += 1; - pStorage.remove(this.lastRet); - } - this.cursor = this.lastRet; - this.lastRet = -1; - this.expectedModCount = ((LinkedList) ((Object) this.parent)).modCount; - } - } - - /** - * [FUNCTION] LinkedList_ListIteratorAutomaton::set(LinkedList_ListIterator, Object) -> void - * Source: java/util/LinkedList.ListIterator.lsl:164 - */ - public void set(Object e) { - /* body */ { - Engine.assume(this.parent != null); - if (this.lastRet < 0) { - throw new IllegalStateException(); - } - _checkForComodification(); - final SymbolicList pStorage = ((LinkedList) ((Object) this.parent)).storage; - if (this.lastRet >= pStorage.size()) { - throw new ConcurrentModificationException(); - } else { - pStorage.set(this.lastRet, e); - } - } - } - - /** - * [FUNCTION] LinkedList_ListIteratorAutomaton::add(LinkedList_ListIterator, Object) -> void - * Source: java/util/LinkedList.ListIterator.lsl:182 - */ - public void add(Object e) { - /* body */ { - Engine.assume(this.parent != null); - _checkForComodification(); - final int i = this.cursor; - final SymbolicList pStorage = ((LinkedList) ((Object) this.parent)).storage; - if (this.lastRet > pStorage.size()) { - throw new ConcurrentModificationException(); - } else { - ((LinkedList) ((Object) this.parent)).modCount += 1; - pStorage.insert(i, e); - } - this.cursor = i + 1; - this.lastRet = -1; - this.expectedModCount = ((LinkedList) ((Object) this.parent)).modCount; - } - } - - /** - * [FUNCTION] LinkedList_ListIteratorAutomaton::forEachRemaining(LinkedList_ListIterator, Consumer) -> void - * Source: java/util/LinkedList.ListIterator.lsl:209 - */ - public void forEachRemaining(Consumer userAction) { - /* body */ { - Engine.assume(this.parent != null); - if (userAction == null) { - throw new NullPointerException(); - } - int i = this.cursor; - final SymbolicList es = ((LinkedList) ((Object) this.parent)).storage; - final int size = es.size(); - if (i < size) { - while ((i < size) && (((LinkedList) ((Object) this.parent)).modCount == this.expectedModCount)) { - final Object item = es.get(i); - userAction.accept(item); - i += 1; - } - ; - this.cursor = i; - this.lastRet = i - 1; - _checkForComodification(); - } - } - } - - public static final class __$lsl_States { - public static final byte Initialized = (byte) 0; - } - - @Approximate(LinkedList_ListItr.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/LinkedList_Spliterator.java b/approximations/src/main/java/generated/java/util/LinkedList_Spliterator.java deleted file mode 100644 index f57dfe03..00000000 --- a/approximations/src/main/java/generated/java/util/LinkedList_Spliterator.java +++ /dev/null @@ -1,231 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/LinkedList.lsl:52 -// - java/util/LinkedList.Spliterator.lsl:16 -// -package generated.java.util; - -import generated.runtime.LibSLGlobals; -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.ConcurrentModificationException; -import java.util.Spliterator; -import java.util.function.Consumer; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import org.usvm.api.SymbolicList; -import runtime.LibSLRuntime; - -/** - * LinkedList_SpliteratorAutomaton for LinkedList_Spliterator ~> java.util.LinkedList_Spliterator - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(stub.java.util.LinkedList_Spliterator.class) -public final class LinkedList_Spliterator implements LibSLRuntime.Automaton, Spliterator { - static { - Engine.assume(true); - } - - private byte __$lsl_state = __$lsl_States.Allocated; - - public LinkedList parent; - - public int index; - - public int fence; - - public int expectedModCount; - - @LibSLRuntime.AutomatonConstructor - public LinkedList_Spliterator(Void __$lsl_token, final byte p0, final LinkedList p1, - final int p2, final int p3, final int p4) { - this.__$lsl_state = p0; - this.parent = p1; - this.index = p2; - this.fence = p3; - this.expectedModCount = p4; - } - - @LibSLRuntime.AutomatonConstructor - public LinkedList_Spliterator(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Allocated, null, 0, -1, 0); - } - - /** - * [CONSTRUCTOR] LinkedList_SpliteratorAutomaton::(LinkedList_Spliterator, LinkedList, int, int, int) -> void - * Source: java/util/LinkedList.Spliterator.lsl:81 - */ - private LinkedList_Spliterator(LinkedList _this, int origin, int fence, int expectedModCount) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - LibSLRuntime.not_implemented(/* inaccessible constructor */); - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [SUBROUTINE] LinkedList_SpliteratorAutomaton::_getFence() -> int - * Source: java/util/LinkedList.Spliterator.lsl:65 - */ - private int _getFence() { - int result = 0; - /* body */ { - if (this.fence == -1) { - Engine.assume(this.parent != null); - this.expectedModCount = ((LinkedList) ((Object) this.parent)).modCount; - this.fence = ((LinkedList) ((Object) this.parent)).storage.size(); - } - result = this.fence; - } - return result; - } - - /** - * [FUNCTION] LinkedList_SpliteratorAutomaton::characteristics(LinkedList_Spliterator) -> int - * Source: java/util/LinkedList.Spliterator.lsl:94 - */ - public int characteristics() { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = LibSLGlobals.SPLITERATOR_ORDERED | LibSLGlobals.SPLITERATOR_SIZED | LibSLGlobals.SPLITERATOR_SUBSIZED; - } - return result; - } - - /** - * [FUNCTION] LinkedList_SpliteratorAutomaton::estimateSize(LinkedList_Spliterator) -> long - * Source: java/util/LinkedList.Spliterator.lsl:100 - */ - public long estimateSize() { - long result = 0L; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = _getFence() - this.index; - } - return result; - } - - /** - * [FUNCTION] LinkedList_SpliteratorAutomaton::forEachRemaining(LinkedList_Spliterator, Consumer) -> void - * Source: java/util/LinkedList.Spliterator.lsl:106 - */ - public void forEachRemaining(Consumer _action) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (_action == null) { - throw new NullPointerException(); - } - Engine.assume(this.parent != null); - final SymbolicList a = ((LinkedList) ((Object) this.parent)).storage; - if (a == null) { - throw new ConcurrentModificationException(); - } - int hi = this.fence; - int mc = this.expectedModCount; - if (hi == -1) { - hi = a.size(); - mc = ((LinkedList) ((Object) this.parent)).modCount; - } - int i = this.index; - this.index = hi; - if ((i < 0) || (hi > a.size())) { - throw new ConcurrentModificationException(); - } - for (i = i; i < hi; i += 1) { - final Object item = a.get(i); - _action.accept(item); - } - ; - if (mc != ((LinkedList) ((Object) this.parent)).modCount) { - throw new ConcurrentModificationException(); - } - } - } - - /** - * [FUNCTION] LinkedList_SpliteratorAutomaton::getExactSizeIfKnown(LinkedList_Spliterator) -> long - * Source: java/util/LinkedList.Spliterator.lsl:153 - */ - public long getExactSizeIfKnown() { - long result = 0L; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = _getFence() - this.index; - } - return result; - } - - /** - * [FUNCTION] LinkedList_SpliteratorAutomaton::tryAdvance(LinkedList_Spliterator, Consumer) -> boolean - * Source: java/util/LinkedList.Spliterator.lsl:166 - */ - public boolean tryAdvance(Consumer _action) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (_action == null) { - throw new NullPointerException(); - } - final int hi = _getFence(); - final int i = this.index; - if (i < hi) { - Engine.assume(this.parent != null); - this.index = i + 1; - final SymbolicList parentStorage = ((LinkedList) ((Object) this.parent)).storage; - final Object item = parentStorage.get(i); - _action.accept(item); - if (((LinkedList) ((Object) this.parent)).modCount != this.expectedModCount) { - throw new ConcurrentModificationException(); - } - result = true; - } else { - result = false; - } - } - return result; - } - - /** - * [FUNCTION] LinkedList_SpliteratorAutomaton::trySplit(LinkedList_Spliterator) -> Spliterator - * Source: java/util/LinkedList.Spliterator.lsl:196 - */ - public Spliterator trySplit() { - Spliterator result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final int hi = _getFence(); - final int lo = this.index; - final int mid = (lo + hi) >>> 1; - if (lo >= mid) { - result = null; - } else { - result = (stub.java.util.LinkedList_Spliterator) ((Object) new LinkedList_Spliterator((Void) null, - /* state = */ LinkedList_Spliterator.__$lsl_States.Initialized, - /* parent = */ this.parent, - /* index = */ lo, - /* fence = */ mid, - /* expectedModCount = */ this.expectedModCount - )); - } - this.index = mid; - } - return result; - } - - public static final class __$lsl_States { - public static final byte Allocated = (byte) 0; - - public static final byte Initialized = (byte) 1; - } - - @Approximate(LinkedList_Spliterator.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/LinkedList_SubList$ListIterator.java b/approximations/src/main/java/generated/java/util/LinkedList_SubList$ListIterator.java deleted file mode 100644 index fb0bbd4f..00000000 --- a/approximations/src/main/java/generated/java/util/LinkedList_SubList$ListIterator.java +++ /dev/null @@ -1,277 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/LinkedList.lsl:82 -// - java/util/LinkedList.SubList.ListIterator.lsl:16 -// -package generated.java.util; - -import java.lang.IllegalStateException; -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.ConcurrentModificationException; -import java.util.ListIterator; -import java.util.NoSuchElementException; -import java.util.function.Consumer; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import org.usvm.api.SymbolicList; -import runtime.LibSLRuntime; - -/** - * LinkedList_SubList_ListIteratorAutomaton for LinkedList_SubList_ListIterator ~> java.util.LinkedList_SubList$ListIterator - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(stub.java.util.LinkedList_SubList$ListIterator.class) -public final class LinkedList_SubList$ListIterator implements LibSLRuntime.Automaton, ListIterator { - static { - Engine.assume(true); - } - - public LinkedList root; - - public LinkedList_SubList sublist; - - public int cursor; - - public int expectedModCount; - - public int offset; - - public int size; - - public int lastRet; - - @LibSLRuntime.AutomatonConstructor - public LinkedList_SubList$ListIterator(Void __$lsl_token, final byte p0, final LinkedList p1, - final LinkedList_SubList p2, final int p3, final int p4, final int p5, final int p6, - final int p7) { - this.root = p1; - this.sublist = p2; - this.cursor = p3; - this.expectedModCount = p4; - this.offset = p5; - this.size = p6; - this.lastRet = p7; - } - - @LibSLRuntime.AutomatonConstructor - public LinkedList_SubList$ListIterator(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Initialized, null, null, 0, 0, 0, 0, -1); - } - - /** - * [SUBROUTINE] LinkedList_SubList_ListIteratorAutomaton::_checkForComodification() -> void - * Source: java/util/LinkedList.SubList.ListIterator.lsl:58 - */ - private void _checkForComodification() { - /* body */ { - final int modCount = ((LinkedList) ((Object) this.root)).modCount; - if (modCount != this.expectedModCount) { - throw new ConcurrentModificationException(); - } - } - } - - /** - * [FUNCTION] LinkedList_SubList_ListIteratorAutomaton::hasPrevious(LinkedList_SubList_ListIterator) -> boolean - * Source: java/util/LinkedList.SubList.ListIterator.lsl:68 - */ - public boolean hasPrevious() { - boolean result = false; - /* body */ { - result = this.cursor != 0; - } - return result; - } - - /** - * [FUNCTION] LinkedList_SubList_ListIteratorAutomaton::nextIndex(LinkedList_SubList_ListIterator) -> int - * Source: java/util/LinkedList.SubList.ListIterator.lsl:74 - */ - public int nextIndex() { - int result = 0; - /* body */ { - result = this.cursor; - } - return result; - } - - /** - * [FUNCTION] LinkedList_SubList_ListIteratorAutomaton::previousIndex(LinkedList_SubList_ListIterator) -> int - * Source: java/util/LinkedList.SubList.ListIterator.lsl:80 - */ - public int previousIndex() { - int result = 0; - /* body */ { - result = this.cursor - 1; - } - return result; - } - - /** - * [FUNCTION] LinkedList_SubList_ListIteratorAutomaton::hasNext(LinkedList_SubList_ListIterator) -> boolean - * Source: java/util/LinkedList.SubList.ListIterator.lsl:86 - */ - public boolean hasNext() { - boolean result = false; - /* body */ { - result = this.cursor != this.size; - } - return result; - } - - /** - * [FUNCTION] LinkedList_SubList_ListIteratorAutomaton::next(LinkedList_SubList_ListIterator) -> Object - * Source: java/util/LinkedList.SubList.ListIterator.lsl:92 - */ - public Object next() { - Object result = null; - /* body */ { - Engine.assume(this.root != null); - _checkForComodification(); - final SymbolicList rootStorage = ((LinkedList) ((Object) this.root)).storage; - final int i = this.offset + this.cursor; - if (i >= rootStorage.size()) { - throw new NoSuchElementException(); - } - this.lastRet = this.cursor; - this.cursor += 1; - result = rootStorage.get(i); - } - return result; - } - - /** - * [FUNCTION] LinkedList_SubList_ListIteratorAutomaton::previous(LinkedList_SubList_ListIterator) -> Object - * Source: java/util/LinkedList.SubList.ListIterator.lsl:112 - */ - public Object previous() { - Object result = null; - /* body */ { - Engine.assume(this.root != null); - _checkForComodification(); - final int i = (this.offset + this.cursor) - 1; - if (i < this.offset) { - throw new NoSuchElementException(); - } - final SymbolicList rootStorage = ((LinkedList) ((Object) this.root)).storage; - if (i >= rootStorage.size()) { - throw new ConcurrentModificationException(); - } - this.cursor -= 1; - this.lastRet = this.cursor; - result = rootStorage.get(i); - } - return result; - } - - /** - * [FUNCTION] LinkedList_SubList_ListIteratorAutomaton::remove(LinkedList_SubList_ListIterator) -> void - * Source: java/util/LinkedList.SubList.ListIterator.lsl:135 - */ - public void remove() { - /* body */ { - Engine.assume(this.root != null); - if (this.lastRet < 0) { - throw new IllegalStateException(); - } - _checkForComodification(); - if (this.lastRet >= this.size) { - throw new ConcurrentModificationException(); - } else { - ((LinkedList) ((Object) this.root))._unlinkAny(this.offset + this.lastRet); - ((LinkedList_SubList) ((Object) this.sublist))._updateSizeAndModCount(-1); - this.expectedModCount = ((LinkedList) ((Object) this.root)).modCount; - this.size -= 1; - } - this.cursor = this.lastRet; - this.lastRet = -1; - } - } - - /** - * [FUNCTION] LinkedList_SubList_ListIteratorAutomaton::set(LinkedList_SubList_ListIterator, Object) -> void - * Source: java/util/LinkedList.SubList.ListIterator.lsl:163 - */ - public void set(Object e) { - /* body */ { - Engine.assume(this.root != null); - if (this.lastRet < 0) { - throw new IllegalStateException(); - } - _checkForComodification(); - final SymbolicList rootStorage = ((LinkedList) ((Object) this.root)).storage; - final int index = this.offset + this.lastRet; - if (index >= rootStorage.size()) { - throw new ConcurrentModificationException(); - } else { - rootStorage.set(index, e); - } - } - } - - /** - * [FUNCTION] LinkedList_SubList_ListIteratorAutomaton::add(LinkedList_SubList_ListIterator, Object) -> void - * Source: java/util/LinkedList.SubList.ListIterator.lsl:183 - */ - public void add(Object e) { - /* body */ { - Engine.assume(this.root != null); - _checkForComodification(); - final int i = this.offset + this.cursor; - if ((this.offset + this.lastRet) > ((LinkedList) ((Object) this.root)).storage.size()) { - throw new ConcurrentModificationException(); - } else { - ((LinkedList) ((Object) this.root))._linkAny(i, e); - ((LinkedList_SubList) ((Object) this.sublist))._updateSizeAndModCount(1); - this.expectedModCount = ((LinkedList) ((Object) this.root)).modCount; - this.size += 1; - } - this.cursor += 1; - this.lastRet = -1; - } - } - - /** - * [FUNCTION] LinkedList_SubList_ListIteratorAutomaton::forEachRemaining(LinkedList_SubList_ListIterator, Consumer) -> void - * Source: java/util/LinkedList.SubList.ListIterator.lsl:210 - */ - public void forEachRemaining(Consumer userAction) { - /* body */ { - Engine.assume(this.root != null); - if (userAction == null) { - throw new NullPointerException(); - } - int i = this.cursor; - if (i < this.size) { - i += this.offset; - final SymbolicList es = ((LinkedList) ((Object) this.root)).storage; - if (i >= es.size()) { - throw new ConcurrentModificationException(); - } - final int end = this.offset + this.size; - for (i = i; i < end; i += 1) { - final Object item = es.get(i); - userAction.accept(item); - } - ; - this.cursor = i - this.offset; - this.lastRet = this.cursor - 1; - _checkForComodification(); - } - } - } - - public static final class __$lsl_States { - public static final byte Initialized = (byte) 0; - } - - @Approximate(LinkedList_SubList$ListIterator.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/LinkedList_SubList$Spliterator.java b/approximations/src/main/java/generated/java/util/LinkedList_SubList$Spliterator.java deleted file mode 100644 index e39f0cb6..00000000 --- a/approximations/src/main/java/generated/java/util/LinkedList_SubList$Spliterator.java +++ /dev/null @@ -1,212 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/LinkedList.lsl:72 -// - java/util/LinkedList.SubList.Spliterator.lsl:16 -// -package generated.java.util; - -import generated.runtime.LibSLGlobals; -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.ConcurrentModificationException; -import java.util.Spliterator; -import java.util.function.Consumer; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import org.usvm.api.SymbolicList; -import runtime.LibSLRuntime; - -/** - * LinkedList_SubList_SpliteratorAutomaton for LinkedList_SubList_Spliterator ~> java.util.LinkedList_SubList$Spliterator - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(stub.java.util.LinkedList_SubList$Spliterator.class) -public final class LinkedList_SubList$Spliterator implements LibSLRuntime.Automaton, Spliterator { - static { - Engine.assume(true); - } - - public LinkedList root; - - public LinkedList_SubList parent; - - public int index; - - public int fence; - - public int expectedModCount; - - @LibSLRuntime.AutomatonConstructor - public LinkedList_SubList$Spliterator(Void __$lsl_token, final byte p0, final LinkedList p1, - final LinkedList_SubList p2, final int p3, final int p4, final int p5) { - this.root = p1; - this.parent = p2; - this.index = p3; - this.fence = p4; - this.expectedModCount = p5; - } - - @LibSLRuntime.AutomatonConstructor - public LinkedList_SubList$Spliterator(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Initialized, null, null, 0, -1, 0); - } - - /** - * [SUBROUTINE] LinkedList_SubList_SpliteratorAutomaton::_getFence() -> int - * Source: java/util/LinkedList.SubList.Spliterator.lsl:60 - */ - private int _getFence() { - int result = 0; - /* body */ { - if (this.fence == -1) { - Engine.assume(this.parent != null); - this.expectedModCount = ((LinkedList_SubList) ((Object) this.parent)).modCount; - this.fence = ((LinkedList_SubList) ((Object) this.parent)).length; - } - result = this.fence; - } - return result; - } - - /** - * [FUNCTION] LinkedList_SubList_SpliteratorAutomaton::characteristics(LinkedList_SubList_Spliterator) -> int - * Source: java/util/LinkedList.SubList.Spliterator.lsl:80 - */ - public int characteristics() { - int result = 0; - /* body */ { - result = LibSLGlobals.SPLITERATOR_ORDERED | LibSLGlobals.SPLITERATOR_SIZED | LibSLGlobals.SPLITERATOR_SUBSIZED; - } - return result; - } - - /** - * [FUNCTION] LinkedList_SubList_SpliteratorAutomaton::estimateSize(LinkedList_SubList_Spliterator) -> long - * Source: java/util/LinkedList.SubList.Spliterator.lsl:86 - */ - public long estimateSize() { - long result = 0L; - /* body */ { - result = _getFence() - this.index; - } - return result; - } - - /** - * [FUNCTION] LinkedList_SubList_SpliteratorAutomaton::forEachRemaining(LinkedList_SubList_Spliterator, Consumer) -> void - * Source: java/util/LinkedList.SubList.Spliterator.lsl:92 - */ - public void forEachRemaining(Consumer _action) { - /* body */ { - if (_action == null) { - throw new NullPointerException(); - } - Engine.assume(this.root != null); - Engine.assume(this.parent != null); - final SymbolicList a = ((LinkedList) ((Object) this.root)).storage; - if (a == null) { - throw new ConcurrentModificationException(); - } - int hi = this.fence; - int mc = this.expectedModCount; - if (hi == -1) { - hi = ((LinkedList_SubList) ((Object) this.parent)).length; - mc = ((LinkedList_SubList) ((Object) this.parent)).modCount; - } - int i = this.index; - this.index = hi; - if ((i < 0) || (hi > ((LinkedList_SubList) ((Object) this.parent)).length)) { - throw new ConcurrentModificationException(); - } - for (i = i; i < hi; i += 1) { - final Object item = a.get(i); - _action.accept(item); - } - ; - if (mc != ((LinkedList_SubList) ((Object) this.parent)).modCount) { - throw new ConcurrentModificationException(); - } - } - } - - /** - * [FUNCTION] LinkedList_SubList_SpliteratorAutomaton::getExactSizeIfKnown(LinkedList_SubList_Spliterator) -> long - * Source: java/util/LinkedList.SubList.Spliterator.lsl:141 - */ - public long getExactSizeIfKnown() { - long result = 0L; - /* body */ { - result = _getFence() - this.index; - } - return result; - } - - /** - * [FUNCTION] LinkedList_SubList_SpliteratorAutomaton::tryAdvance(LinkedList_SubList_Spliterator, Consumer) -> boolean - * Source: java/util/LinkedList.SubList.Spliterator.lsl:154 - */ - public boolean tryAdvance(Consumer _action) { - boolean result = false; - /* body */ { - if (_action == null) { - throw new NullPointerException(); - } - final int hi = _getFence(); - final int i = this.index; - if (i < hi) { - Engine.assume(this.root != null); - this.index = i + 1; - final SymbolicList rootStorage = ((LinkedList) ((Object) this.root)).storage; - final Object item = rootStorage.get(i); - _action.accept(item); - if (((LinkedList) ((Object) this.root)).modCount != this.expectedModCount) { - throw new ConcurrentModificationException(); - } - result = true; - } else { - result = false; - } - } - return result; - } - - /** - * [FUNCTION] LinkedList_SubList_SpliteratorAutomaton::trySplit(LinkedList_SubList_Spliterator) -> Spliterator - * Source: java/util/LinkedList.SubList.Spliterator.lsl:184 - */ - public Spliterator trySplit() { - Spliterator result = null; - /* body */ { - final int hi = _getFence(); - final int lo = this.index; - final int mid = (lo + hi) >>> 1; - if (lo >= mid) { - result = null; - } else { - result = (stub.java.util.LinkedList_SubList$Spliterator) ((Object) new LinkedList_SubList$Spliterator((Void) null, - /* state = */ LinkedList_SubList$Spliterator.__$lsl_States.Initialized, - /* root = */ this.root, - /* parent = */ this.parent, - /* index = */ lo, - /* fence = */ mid, - /* expectedModCount = */ this.expectedModCount - )); - } - this.index = mid; - } - return result; - } - - public static final class __$lsl_States { - public static final byte Initialized = (byte) 0; - } - - @Approximate(LinkedList_SubList$Spliterator.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/LinkedList_SubList.java b/approximations/src/main/java/generated/java/util/LinkedList_SubList.java deleted file mode 100644 index 62002017..00000000 --- a/approximations/src/main/java/generated/java/util/LinkedList_SubList.java +++ /dev/null @@ -1,908 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/LinkedList.lsl:61 -// - java/util/LinkedList.SubList.lsl:16 -// -package generated.java.util; - -import java.lang.Object; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.Collection; -import java.util.Comparator; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; -import java.util.RandomAccess; -import java.util.Spliterator; -import java.util.function.Consumer; -import java.util.function.IntFunction; -import java.util.function.Predicate; -import java.util.function.UnaryOperator; -import java.util.stream.Stream; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import org.usvm.api.SymbolicList; -import runtime.LibSLRuntime; -import stub.java.util.stream.StreamLSL; - -/** - * LinkedList_SubListAutomaton for LinkedList_SubList ~> java.util.LinkedList_SubList - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(stub.java.util.LinkedList_SubList.class) -public final class LinkedList_SubList implements LibSLRuntime.Automaton, List, RandomAccess { - static { - Engine.assume(true); - } - - private byte __$lsl_state = __$lsl_States.Allocated; - - public LinkedList root; - - public LinkedList_SubList parentList; - - public int offset; - - public int length; - - public int modCount; - - @LibSLRuntime.AutomatonConstructor - public LinkedList_SubList(Void __$lsl_token, final byte p0, final LinkedList p1, - final LinkedList_SubList p2, final int p3, final int p4, final int p5) { - this.__$lsl_state = p0; - this.root = p1; - this.parentList = p2; - this.offset = p3; - this.length = p4; - this.modCount = p5; - } - - @LibSLRuntime.AutomatonConstructor - public LinkedList_SubList(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Allocated, null, null, 0, 0, 0); - } - - /** - * [CONSTRUCTOR] LinkedList_SubListAutomaton::(LinkedList_SubList, LinkedList, int, int) -> void - * Source: java/util/LinkedList.SubList.lsl:211 - */ - public LinkedList_SubList(LinkedList root, int fromIndex, int toIndex) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - LibSLRuntime.not_implemented(/* inaccessible constructor */); - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [CONSTRUCTOR] LinkedList_SubListAutomaton::(LinkedList_SubList, LinkedList_SubList, int, int) -> void - * Source: java/util/LinkedList.SubList.lsl:218 - */ - private LinkedList_SubList(LinkedList_SubList parent, int fromIndex, int toIndex) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - LibSLRuntime.not_implemented(/* inaccessible constructor */); - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [SUBROUTINE] LinkedList_SubListAutomaton::_addAllElements(int, Collection) -> boolean - * Source: java/util/LinkedList.SubList.lsl:91 - */ - private boolean _addAllElements(int index, Collection c) { - boolean result = false; - /* body */ { - Engine.assume(this.root != null); - final int effectiveIndex = this.offset + index; - ((LinkedList) ((Object) this.root))._checkPositionIndex(effectiveIndex); - final int collectionSize = c.size(); - if (collectionSize == 0) { - result = false; - } else { - result = true; - ((LinkedList) ((Object) this.root))._checkForComodification(this.modCount); - ((LinkedList) ((Object) this.root))._addAllElements(effectiveIndex, c); - _updateSizeAndModCount(collectionSize); - } - } - return result; - } - - /** - * [SUBROUTINE] LinkedList_SubListAutomaton::_updateSizeAndModCount(int) -> void - * Source: java/util/LinkedList.SubList.lsl:114 - */ - public void _updateSizeAndModCount(int sizeChange) { - /* body */ { - Engine.assume(this.root != null); - this.length += sizeChange; - this.modCount = ((LinkedList) ((Object) this.root)).modCount; - LinkedList_SubList aList = this.parentList; - while (aList != null) { - ((LinkedList_SubList) ((Object) aList)).length += sizeChange; - ((LinkedList_SubList) ((Object) aList)).modCount = this.modCount; - aList = ((LinkedList_SubList) ((Object) aList)).parentList; - } - ; - } - } - - /** - * [SUBROUTINE] LinkedList_SubListAutomaton::_indexOfElement(Object) -> int - * Source: java/util/LinkedList.SubList.lsl:139 - */ - private int _indexOfElement(Object o) { - int result = 0; - /* body */ { - Engine.assume(this.root != null); - ((LinkedList) ((Object) this.root))._checkForComodification(this.modCount); - final SymbolicList parentStorage = ((LinkedList) ((Object) this.root)).storage; - final int index = LibSLRuntime.ListActions.find(parentStorage, o, this.offset, this.offset + this.length); - if (index != -1) { - result = index - this.offset; - } else { - result = -1; - } - } - return result; - } - - /** - * [SUBROUTINE] LinkedList_SubListAutomaton::_makeStream(boolean) -> Stream - * Source: java/util/LinkedList.SubList.lsl:154 - */ - private Stream _makeStream(boolean parallel) { - Stream result = null; - /* body */ { - Engine.assume(this.root != null); - ((LinkedList) ((Object) this.root))._checkForComodification(this.modCount); - final SymbolicList parentStorage = ((LinkedList) ((Object) this.root)).storage; - final int count = this.length; - final Object[] items = new Object[count]; - int i = 0; - for (i = 0; i < count; i += 1) { - items[i] = parentStorage.get(this.offset + i); - } - ; - result = (StreamLSL) ((Object) new generated.java.util.stream.StreamLSL((Void) null, - /* state = */ generated.java.util.stream.StreamLSL.__$lsl_States.Initialized, - /* storage = */ items, - /* length = */ count, - /* closeHandlers = */ Engine.makeSymbolicList(), - /* isParallel = */ parallel, - /* linkedOrConsumed = */ false - )); - } - return result; - } - - /** - * [SUBROUTINE] LinkedList_SubListAutomaton::_batchRemove(Collection, boolean) -> boolean - * Source: java/util/LinkedList.SubList.lsl:186 - */ - private boolean _batchRemove(Collection c, boolean complement) { - boolean result = false; - /* body */ { - Engine.assume(this.root != null); - ((LinkedList) ((Object) this.root))._checkForComodification(this.modCount); - if (this.length != 0) { - final int oldRootLength = ((LinkedList) ((Object) this.root)).storage.size(); - result = ((LinkedList) ((Object) this.root))._batchRemove(c, complement, this.offset, this.offset + this.length); - if (result) { - final int newRootLength = ((LinkedList) ((Object) this.root)).storage.size(); - _updateSizeAndModCount(newRootLength - oldRootLength); - } - } else { - result = false; - } - } - return result; - } - - /** - * [FUNCTION] LinkedList_SubListAutomaton::add(LinkedList_SubList, Object) -> boolean - * Source: java/util/LinkedList.SubList.lsl:230 - */ - public boolean add(Object e) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(this.root != null); - ((LinkedList) ((Object) this.root))._checkForComodification(this.modCount); - final int effectiveIndex = this.offset + this.length; - ((LinkedList) ((Object) this.root))._linkAny(effectiveIndex, e); - _updateSizeAndModCount(1); - } - return result; - } - - /** - * [FUNCTION] LinkedList_SubListAutomaton::add(LinkedList_SubList, int, Object) -> void - * Source: java/util/LinkedList.SubList.lsl:243 - */ - public void add(int index, Object element) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(this.root != null); - ((LinkedList) ((Object) this.root))._checkForComodification(this.modCount); - final int effectiveIndex = this.offset + index; - ((LinkedList) ((Object) this.root))._linkAny(effectiveIndex, element); - _updateSizeAndModCount(1); - } - } - - /** - * [FUNCTION] LinkedList_SubListAutomaton::addAll(LinkedList_SubList, Collection) -> boolean - * Source: java/util/LinkedList.SubList.lsl:256 - */ - public boolean addAll(Collection c) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - _addAllElements(this.length, c); - } - return result; - } - - /** - * [FUNCTION] LinkedList_SubListAutomaton::addAll(LinkedList_SubList, int, Collection) -> boolean - * Source: java/util/LinkedList.SubList.lsl:262 - */ - public boolean addAll(int index, Collection c) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - _addAllElements(index, c); - } - return result; - } - - /** - * [FUNCTION] LinkedList_SubListAutomaton::clear(LinkedList_SubList) -> void - * Source: java/util/LinkedList.SubList.lsl:269 - */ - public void clear() { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(this.root != null); - ((LinkedList) ((Object) this.root))._checkForComodification(this.modCount); - final int size = this.length; - if (size != 0) { - Engine.assume(size > 0); - final int end = this.offset - 1; - final int start = end + size; - final SymbolicList rootStorage = ((LinkedList) ((Object) this.root)).storage; - int i = 0; - for (i = start; i > end; i += -1) { - rootStorage.remove(i); - } - ; - ((LinkedList) ((Object) this.root)).modCount += 1; - _updateSizeAndModCount(-size); - } - } - } - - /** - * [FUNCTION] LinkedList_SubListAutomaton::contains(LinkedList_SubList, Object) -> boolean - * Source: java/util/LinkedList.SubList.lsl:301 - */ - public boolean contains(Object o) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = _indexOfElement(o) != -1; - } - return result; - } - - /** - * [FUNCTION] LinkedList_SubListAutomaton::containsAll(LinkedList_SubList, Collection) -> boolean - * Source: java/util/LinkedList.SubList.lsl:308 - */ - public boolean containsAll(Collection c) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = true; - if (!c.isEmpty()) { - Engine.assume(this.root != null); - final SymbolicList rootStorage = ((LinkedList) ((Object) this.root)).storage; - final int end = this.offset + this.length; - if ((c != null && c.getClass() == stub.java.util.LinkedList_SubList.class)) { - final LinkedList otherRoot = ((LinkedList_SubList) ((Object) c)).root; - Engine.assume(otherRoot != null); - final SymbolicList otherStorage = ((LinkedList) ((Object) otherRoot)).storage; - final int otherOffset = ((LinkedList_SubList) ((Object) c)).offset; - final int otherEnd = otherOffset + ((LinkedList_SubList) ((Object) c)).length; - Engine.assume(otherStorage != null); - Engine.assume(otherOffset >= 0); - Engine.assume(otherEnd >= 0); - int i = otherOffset; - while (result && (i < otherEnd)) { - final Object item = otherStorage.get(i); - result = LibSLRuntime.ListActions.find(rootStorage, item, this.offset, end) != -1; - i += 1; - } - ; - } else { - final Iterator iter = c.iterator(); - while (result && iter.hasNext()) { - final Object item = iter.next(); - result = LibSLRuntime.ListActions.find(rootStorage, item, this.offset, end) != -1; - } - ; - } - } - } - return result; - } - - /** - * [FUNCTION] LinkedList_SubListAutomaton::equals(LinkedList_SubList, Object) -> boolean - * Source: java/util/LinkedList.SubList.lsl:364 - */ - public boolean equals(Object o) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (o == this) { - result = true; - } else { - result = (o != null && o.getClass() == stub.java.util.LinkedList_SubList.class); - if (result) { - Engine.assume(this.root != null); - final int otherLength = ((LinkedList_SubList) ((Object) o)).length; - Engine.assume(otherLength >= 0); - result = this.length == otherLength; - if (result) { - result = ((LinkedList) ((Object) this.root))._equalsRange(((List) o), this.offset, this.offset + this.length); - ((LinkedList) ((Object) this.root))._checkForComodification(this.modCount); - } - } - } - } - return result; - } - - /** - * [FUNCTION] LinkedList_SubListAutomaton::forEach(LinkedList_SubList, Consumer) -> void - * Source: java/util/LinkedList.SubList.lsl:392 - */ - public void forEach(Consumer _action) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.length != 0) { - Engine.assume(this.length > 0); - Engine.assume(this.root != null); - final SymbolicList rootStorage = ((LinkedList) ((Object) this.root)).storage; - final int expectedModCount = ((LinkedList) ((Object) this.root)).modCount; - this.modCount = expectedModCount; - int i = this.offset; - final int end = this.offset + this.length; - while ((i < end) && (((LinkedList) ((Object) this.root)).modCount == expectedModCount)) { - final Object item = rootStorage.get(i); - _action.accept(item); - i += 1; - } - ; - ((LinkedList) ((Object) this.root))._checkForComodification(expectedModCount); - } - } - } - - /** - * [FUNCTION] LinkedList_SubListAutomaton::get(LinkedList_SubList, int) -> Object - * Source: java/util/LinkedList.SubList.lsl:424 - */ - public Object get(int index) { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(this.root != null); - ((LinkedList) ((Object) this.root))._checkElementIndex(index, this.length); - ((LinkedList) ((Object) this.root))._checkForComodification(this.modCount); - final int effectiveIndex = this.offset + index; - result = ((LinkedList) ((Object) this.root)).storage.get(effectiveIndex); - } - return result; - } - - /** - * [FUNCTION] LinkedList_SubListAutomaton::hashCode(LinkedList_SubList) -> int - * Source: java/util/LinkedList.SubList.lsl:436 - */ - public int hashCode() { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = 1; - if (this.length != 0) { - Engine.assume(this.length > 0); - Engine.assume(this.root != null); - final SymbolicList rootStorage = ((LinkedList) ((Object) this.root)).storage; - int i = this.offset; - final int end = this.offset + this.length; - for (i = i; i < end; i += 1) { - final Object item = rootStorage.get(i); - result = (31 * result) + LibSLRuntime.hashCode(item); - } - ; - ((LinkedList) ((Object) this.root))._checkForComodification(this.modCount); - } - } - return result; - } - - /** - * [FUNCTION] LinkedList_SubListAutomaton::indexOf(LinkedList_SubList, Object) -> int - * Source: java/util/LinkedList.SubList.lsl:464 - */ - public int indexOf(Object o) { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = _indexOfElement(o); - } - return result; - } - - /** - * [FUNCTION] LinkedList_SubListAutomaton::isEmpty(LinkedList_SubList) -> boolean - * Source: java/util/LinkedList.SubList.lsl:471 - */ - public boolean isEmpty() { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.length == 0; - } - return result; - } - - /** - * [FUNCTION] LinkedList_SubListAutomaton::iterator(LinkedList_SubList) -> Iterator - * Source: java/util/LinkedList.SubList.lsl:477 - */ - public Iterator iterator() { - Iterator result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = (stub.java.util.LinkedList_SubList$ListIterator) ((Object) new LinkedList_SubList$ListIterator((Void) null, - /* state = */ LinkedList_SubList$ListIterator.__$lsl_States.Initialized, - /* root = */ this.root, - /* sublist = */ this, - /* cursor = */ 0, - /* expectedModCount = */ this.modCount, - /* offset = */ this.offset, - /* size = */ this.length, - /* lastRet = */ -1 - )); - } - return result; - } - - /** - * [FUNCTION] LinkedList_SubListAutomaton::lastIndexOf(LinkedList_SubList, Object) -> int - * Source: java/util/LinkedList.SubList.lsl:490 - */ - public int lastIndexOf(Object o) { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(this.root != null); - ((LinkedList) ((Object) this.root))._checkForComodification(this.modCount); - if (this.length == 0) { - result = -1; - } else { - Engine.assume(this.length > 0); - final int end = this.offset + this.length; - final SymbolicList rootStorage = ((LinkedList) ((Object) this.root)).storage; - result = LibSLRuntime.ListActions.find(rootStorage, o, this.offset, end); - if (result != -1) { - final int nextIndex = result + 1; - if (nextIndex < end) { - final int rightIndex = LibSLRuntime.ListActions.find(rootStorage, o, nextIndex, end); - Engine.assume(rightIndex == -1); - } - result -= this.offset; - } - } - } - return result; - } - - /** - * [FUNCTION] LinkedList_SubListAutomaton::listIterator(LinkedList_SubList) -> ListIterator - * Source: java/util/LinkedList.SubList.lsl:524 - */ - public ListIterator listIterator() { - ListIterator result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = (stub.java.util.LinkedList_SubList$ListIterator) ((Object) new LinkedList_SubList$ListIterator((Void) null, - /* state = */ LinkedList_SubList$ListIterator.__$lsl_States.Initialized, - /* root = */ this.root, - /* sublist = */ this, - /* cursor = */ 0, - /* expectedModCount = */ this.modCount, - /* offset = */ this.offset, - /* size = */ this.length, - /* lastRet = */ -1 - )); - } - return result; - } - - /** - * [FUNCTION] LinkedList_SubListAutomaton::listIterator(LinkedList_SubList, int) -> ListIterator - * Source: java/util/LinkedList.SubList.lsl:537 - */ - public ListIterator listIterator(int index) { - ListIterator result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = (stub.java.util.LinkedList_SubList$ListIterator) ((Object) new LinkedList_SubList$ListIterator((Void) null, - /* state = */ LinkedList_SubList$ListIterator.__$lsl_States.Initialized, - /* root = */ this.root, - /* sublist = */ this, - /* cursor = */ index, - /* expectedModCount = */ this.modCount, - /* offset = */ this.offset, - /* size = */ this.length, - /* lastRet = */ -1 - )); - } - return result; - } - - /** - * [FUNCTION] LinkedList_SubListAutomaton::parallelStream(LinkedList_SubList) -> Stream - * Source: java/util/LinkedList.SubList.lsl:551 - */ - public Stream parallelStream() { - Stream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = _makeStream(true); - } - return result; - } - - /** - * [FUNCTION] LinkedList_SubListAutomaton::remove(LinkedList_SubList, Object) -> boolean - * Source: java/util/LinkedList.SubList.lsl:558 - */ - public boolean remove(Object o) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(this.root != null); - final int end = this.offset + this.length; - final SymbolicList rootStorage = ((LinkedList) ((Object) this.root)).storage; - final int index = LibSLRuntime.ListActions.find(rootStorage, o, this.offset, end); - result = index != -1; - if (result) { - ((LinkedList) ((Object) this.root))._checkForComodification(this.modCount); - ((LinkedList) ((Object) this.root))._unlinkAny(index); - _updateSizeAndModCount(-1); - } - } - return result; - } - - /** - * [FUNCTION] LinkedList_SubListAutomaton::remove(LinkedList_SubList, int) -> Object - * Source: java/util/LinkedList.SubList.lsl:578 - */ - public Object remove(int index) { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(this.root != null); - ((LinkedList) ((Object) this.root))._checkElementIndex(index, this.length); - ((LinkedList) ((Object) this.root))._checkForComodification(this.modCount); - final int effectiveIndex = this.offset + index; - result = ((LinkedList) ((Object) this.root))._unlinkAny(effectiveIndex); - _updateSizeAndModCount(-1); - } - return result; - } - - /** - * [FUNCTION] LinkedList_SubListAutomaton::removeAll(LinkedList_SubList, Collection) -> boolean - * Source: java/util/LinkedList.SubList.lsl:592 - */ - public boolean removeAll(Collection c) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - _batchRemove(c, false); - } - return result; - } - - /** - * [FUNCTION] LinkedList_SubListAutomaton::removeIf(LinkedList_SubList, Predicate) -> boolean - * Source: java/util/LinkedList.SubList.lsl:598 - */ - public boolean removeIf(Predicate filter) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(this.root != null); - ((LinkedList) ((Object) this.root))._checkForComodification(this.modCount); - final int size = this.length; - if (size != 0) { - final int oldRootLength = ((LinkedList) ((Object) this.root)).storage.size(); - result = ((LinkedList) ((Object) this.root))._removeIf(filter, this.offset, this.offset + this.length); - if (result) { - final int newRootLength = ((LinkedList) ((Object) this.root)).storage.size(); - _updateSizeAndModCount(newRootLength - oldRootLength); - } - } else { - result = false; - } - } - return result; - } - - /** - * [FUNCTION] LinkedList_SubListAutomaton::replaceAll(LinkedList_SubList, UnaryOperator) -> void - * Source: java/util/LinkedList.SubList.lsl:622 - */ - public void replaceAll(UnaryOperator operator) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(this.root != null); - ((LinkedList) ((Object) this.root))._replaceAllRange(operator, this.offset, this.offset + this.length); - } - } - - /** - * [FUNCTION] LinkedList_SubListAutomaton::retainAll(LinkedList_SubList, Collection) -> boolean - * Source: java/util/LinkedList.SubList.lsl:629 - */ - public boolean retainAll(Collection c) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - _batchRemove(c, true); - } - return result; - } - - /** - * [FUNCTION] LinkedList_SubListAutomaton::set(LinkedList_SubList, int, Object) -> Object - * Source: java/util/LinkedList.SubList.lsl:635 - */ - public Object set(int index, Object element) { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(this.root != null); - ((LinkedList) ((Object) this.root))._checkElementIndex(index, this.length); - ((LinkedList) ((Object) this.root))._checkForComodification(this.modCount); - final SymbolicList parentStorage = ((LinkedList) ((Object) this.root)).storage; - final int effectiveIndex = this.offset + index; - result = parentStorage.get(effectiveIndex); - parentStorage.set(effectiveIndex, element); - } - return result; - } - - /** - * [FUNCTION] LinkedList_SubListAutomaton::size(LinkedList_SubList) -> int - * Source: java/util/LinkedList.SubList.lsl:649 - */ - public int size() { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(this.root != null); - ((LinkedList) ((Object) this.root))._checkForComodification(this.modCount); - result = this.length; - } - return result; - } - - /** - * [FUNCTION] LinkedList_SubListAutomaton::sort(LinkedList_SubList, Comparator) -> void - * Source: java/util/LinkedList.SubList.lsl:659 - */ - public void sort(Comparator c) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(this.root != null); - ((LinkedList) ((Object) this.root))._do_sort(this.offset, this.offset + this.length, c); - this.modCount = ((LinkedList) ((Object) this.root)).modCount; - } - } - - /** - * [FUNCTION] LinkedList_SubListAutomaton::spliterator(LinkedList_SubList) -> Spliterator - * Source: java/util/LinkedList.SubList.lsl:667 - */ - public Spliterator spliterator() { - Spliterator result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = (stub.java.util.LinkedList_SubList$Spliterator) ((Object) new LinkedList_SubList$Spliterator((Void) null, - /* state = */ LinkedList_SubList$Spliterator.__$lsl_States.Initialized, - /* root = */ this.root, - /* parent = */ this, - /* index = */ 0, - /* fence = */ -1, - /* expectedModCount = */ 0 - )); - } - return result; - } - - /** - * [FUNCTION] LinkedList_SubListAutomaton::stream(LinkedList_SubList) -> Stream - * Source: java/util/LinkedList.SubList.lsl:677 - */ - public Stream stream() { - Stream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = _makeStream(false); - } - return result; - } - - /** - * [FUNCTION] LinkedList_SubListAutomaton::subList(LinkedList_SubList, int, int) -> List - * Source: java/util/LinkedList.SubList.lsl:683 - */ - public List subList(int fromIndex, int toIndex) { - List result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(this.root != null); - ((LinkedList) ((Object) this.root))._subListRangeCheck(fromIndex, toIndex, this.length); - result = (stub.java.util.LinkedList_SubList) ((Object) new LinkedList_SubList((Void) null, - /* state = */ LinkedList_SubList.__$lsl_States.Initialized, - /* root = */ this.root, - /* parentList = */ this, - /* offset = */ this.offset + fromIndex, - /* length = */ toIndex - fromIndex, - /* modCount = */ this.modCount - )); - } - return result; - } - - /** - * [FUNCTION] LinkedList_SubListAutomaton::toArray(LinkedList_SubList) -> array - * Source: java/util/LinkedList.SubList.lsl:699 - */ - public Object[] toArray() { - Object[] result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(this.root != null); - ((LinkedList) ((Object) this.root))._checkForComodification(this.modCount); - result = new Object[this.length]; - final SymbolicList rootStorage = ((LinkedList) ((Object) this.root)).storage; - final int end = this.offset + this.length; - int i = 0; - int j = 0; - for (i = this.offset; i < end; i += 1) { - result[j] = rootStorage.get(i); - j += 1; - } - ; - } - return result; - } - - /** - * [FUNCTION] LinkedList_SubListAutomaton::toArray(LinkedList_SubList, IntFunction) -> array - * Source: java/util/LinkedList.SubList.lsl:724 - */ - public Object[] toArray(IntFunction generator) { - Object[] result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final Object[] a = ((Object[]) generator.apply(0)); - final int aSize = a.length; - Engine.assume(this.root != null); - ((LinkedList) ((Object) this.root))._checkForComodification(this.modCount); - result = new Object[this.length]; - final SymbolicList rootStorage = ((LinkedList) ((Object) this.root)).storage; - final int end = this.offset + this.length; - int i = 0; - int j = 0; - for (i = this.offset; i < end; i += 1) { - result[j] = rootStorage.get(i); - j += 1; - } - ; - } - return result; - } - - /** - * [FUNCTION] LinkedList_SubListAutomaton::toArray(LinkedList_SubList, array) -> array - * Source: java/util/LinkedList.SubList.lsl:746 - */ - public Object[] toArray(Object[] a) { - Object[] result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(this.root != null); - ((LinkedList) ((Object) this.root))._checkForComodification(this.modCount); - final int aSize = a.length; - if (aSize < this.length) { - a = new Object[this.length]; - } - result = a; - final SymbolicList rootStorage = ((LinkedList) ((Object) this.root)).storage; - final int end = this.offset + this.length; - int i = 0; - int j = 0; - for (i = this.offset; i < end; i += 1) { - result[j] = rootStorage.get(i); - j += 1; - } - ; - if (aSize > this.length) { - result[aSize] = null; - } - } - return result; - } - - /** - * [FUNCTION] LinkedList_SubListAutomaton::toString(LinkedList_SubList) -> String - * Source: java/util/LinkedList.SubList.lsl:773 - */ - public String toString() { - String result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.length == 0) { - result = "[]"; - } else { - result = "["; - Engine.assume(this.root != null); - final SymbolicList rootStorage = ((LinkedList) ((Object) this.root)).storage; - int i = this.offset; - final int end = this.offset + this.length; - int counter = this.length; - for (i = i; i < end; i += 1) { - final Object item = rootStorage.get(i); - result = result.concat(LibSLRuntime.toString(item)); - counter -= 1; - if (counter != 0) { - result = result.concat(", "); - } - } - ; - result = result.concat("]"); - } - } - return result; - } - - public static final class __$lsl_States { - public static final byte Allocated = (byte) 0; - - public static final byte Initialized = (byte) 1; - } - - @Approximate(LinkedList_SubList.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/List.java b/approximations/src/main/java/generated/java/util/List.java deleted file mode 100644 index 86752101..00000000 --- a/approximations/src/main/java/generated/java/util/List.java +++ /dev/null @@ -1,333 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/List.lsl:25 -// - java/util/List.main.lsl:21 -// -package generated.java.util; - -import java.lang.Class; -import java.lang.Object; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.Collection; -import java.util.Iterator; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import org.usvm.api.SymbolicList; -import runtime.LibSLRuntime; - -/** - * ListAutomaton for LSLList ~> java.util.List - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(java.util.List.class) -public interface List extends LibSLRuntime.Automaton, java.util.List { - Class __$_lsl_INIT_INTERFACE_ListAutomaton_5013495c = Void.class; - - /** - * [FUNCTION] ListAutomaton::copyOf(Collection) -> List - * Source: java/util/List.main.lsl:62 - */ - static java.util.List copyOf(Collection coll) { - java.util.List result = null; - /* body */ { - final SymbolicList data = Engine.makeSymbolicList(); - int size = 0; - final Iterator iter = coll.iterator(); - while (iter.hasNext()) { - final Object item = iter.next(); - data.insert(size, item); - size += 1; - } - ; - result = (java.util.ArrayList) ((Object) new ArrayList((Void) null, - /* state = */ ArrayList.__$lsl_States.Initialized, - /* storage = */ data, - /* modCount = */ 0 - )); - } - return result; - } - - /** - * [FUNCTION] ListAutomaton::of() -> List - * Source: java/util/List.main.lsl:86 - */ - static java.util.List of() { - java.util.List result = null; - /* body */ { - result = (java.util.ArrayList) ((Object) new ArrayList((Void) null, - /* state = */ ArrayList.__$lsl_States.Initialized, - /* storage = */ Engine.makeSymbolicList(), - /* modCount = */ 0 - )); - } - return result; - } - - /** - * [FUNCTION] ListAutomaton::of(Object) -> List - * Source: java/util/List.main.lsl:94 - */ - static java.util.List of(Object e1) { - java.util.List result = null; - /* body */ { - final SymbolicList data = Engine.makeSymbolicList(); - data.insert(0, e1); - result = (java.util.ArrayList) ((Object) new ArrayList((Void) null, - /* state = */ ArrayList.__$lsl_States.Initialized, - /* storage = */ data, - /* modCount = */ 0 - )); - } - return result; - } - - /** - * [FUNCTION] ListAutomaton::of(Object, Object) -> List - * Source: java/util/List.main.lsl:106 - */ - static java.util.List of(Object e1, Object e2) { - java.util.List result = null; - /* body */ { - final SymbolicList data = Engine.makeSymbolicList(); - data.insert(0, e1); - data.insert(1, e2); - result = (java.util.ArrayList) ((Object) new ArrayList((Void) null, - /* state = */ ArrayList.__$lsl_States.Initialized, - /* storage = */ data, - /* modCount = */ 0 - )); - } - return result; - } - - /** - * [FUNCTION] ListAutomaton::of(Object, Object, Object) -> List - * Source: java/util/List.main.lsl:119 - */ - static java.util.List of(Object e1, Object e2, Object e3) { - java.util.List result = null; - /* body */ { - final SymbolicList data = Engine.makeSymbolicList(); - data.insert(0, e1); - data.insert(1, e2); - data.insert(2, e3); - result = (java.util.ArrayList) ((Object) new ArrayList((Void) null, - /* state = */ ArrayList.__$lsl_States.Initialized, - /* storage = */ data, - /* modCount = */ 0 - )); - } - return result; - } - - /** - * [FUNCTION] ListAutomaton::of(Object, Object, Object, Object) -> List - * Source: java/util/List.main.lsl:133 - */ - static java.util.List of(Object e1, Object e2, Object e3, Object e4) { - java.util.List result = null; - /* body */ { - final SymbolicList data = Engine.makeSymbolicList(); - data.insert(0, e1); - data.insert(1, e2); - data.insert(2, e3); - data.insert(3, e4); - result = (java.util.ArrayList) ((Object) new ArrayList((Void) null, - /* state = */ ArrayList.__$lsl_States.Initialized, - /* storage = */ data, - /* modCount = */ 0 - )); - } - return result; - } - - /** - * [FUNCTION] ListAutomaton::of(Object, Object, Object, Object, Object) -> List - * Source: java/util/List.main.lsl:148 - */ - static java.util.List of(Object e1, Object e2, Object e3, Object e4, Object e5) { - java.util.List result = null; - /* body */ { - final SymbolicList data = Engine.makeSymbolicList(); - data.insert(0, e1); - data.insert(1, e2); - data.insert(2, e3); - data.insert(3, e4); - data.insert(4, e5); - result = (java.util.ArrayList) ((Object) new ArrayList((Void) null, - /* state = */ ArrayList.__$lsl_States.Initialized, - /* storage = */ data, - /* modCount = */ 0 - )); - } - return result; - } - - /** - * [FUNCTION] ListAutomaton::of(Object, Object, Object, Object, Object, Object) -> List - * Source: java/util/List.main.lsl:164 - */ - static java.util.List of(Object e1, Object e2, Object e3, Object e4, Object e5, Object e6) { - java.util.List result = null; - /* body */ { - final SymbolicList data = Engine.makeSymbolicList(); - data.insert(0, e1); - data.insert(1, e2); - data.insert(2, e3); - data.insert(3, e4); - data.insert(4, e5); - data.insert(5, e6); - result = (java.util.ArrayList) ((Object) new ArrayList((Void) null, - /* state = */ ArrayList.__$lsl_States.Initialized, - /* storage = */ data, - /* modCount = */ 0 - )); - } - return result; - } - - /** - * [FUNCTION] ListAutomaton::of(Object, Object, Object, Object, Object, Object, Object) -> List - * Source: java/util/List.main.lsl:181 - */ - static java.util.List of(Object e1, Object e2, Object e3, Object e4, Object e5, Object e6, - Object e7) { - java.util.List result = null; - /* body */ { - final SymbolicList data = Engine.makeSymbolicList(); - data.insert(0, e1); - data.insert(1, e2); - data.insert(2, e3); - data.insert(3, e4); - data.insert(4, e5); - data.insert(5, e6); - data.insert(6, e7); - result = (java.util.ArrayList) ((Object) new ArrayList((Void) null, - /* state = */ ArrayList.__$lsl_States.Initialized, - /* storage = */ data, - /* modCount = */ 0 - )); - } - return result; - } - - /** - * [FUNCTION] ListAutomaton::of(Object, Object, Object, Object, Object, Object, Object, Object) -> List - * Source: java/util/List.main.lsl:199 - */ - static java.util.List of(Object e1, Object e2, Object e3, Object e4, Object e5, Object e6, - Object e7, Object e8) { - java.util.List result = null; - /* body */ { - final SymbolicList data = Engine.makeSymbolicList(); - data.insert(0, e1); - data.insert(1, e2); - data.insert(2, e3); - data.insert(3, e4); - data.insert(4, e5); - data.insert(5, e6); - data.insert(6, e7); - data.insert(7, e8); - result = (java.util.ArrayList) ((Object) new ArrayList((Void) null, - /* state = */ ArrayList.__$lsl_States.Initialized, - /* storage = */ data, - /* modCount = */ 0 - )); - } - return result; - } - - /** - * [FUNCTION] ListAutomaton::of(Object, Object, Object, Object, Object, Object, Object, Object, Object) -> List - * Source: java/util/List.main.lsl:218 - */ - static java.util.List of(Object e1, Object e2, Object e3, Object e4, Object e5, Object e6, - Object e7, Object e8, Object e9) { - java.util.List result = null; - /* body */ { - final SymbolicList data = Engine.makeSymbolicList(); - data.insert(0, e1); - data.insert(1, e2); - data.insert(2, e3); - data.insert(3, e4); - data.insert(4, e5); - data.insert(5, e6); - data.insert(6, e7); - data.insert(7, e8); - data.insert(8, e9); - result = (java.util.ArrayList) ((Object) new ArrayList((Void) null, - /* state = */ ArrayList.__$lsl_States.Initialized, - /* storage = */ data, - /* modCount = */ 0 - )); - } - return result; - } - - /** - * [FUNCTION] ListAutomaton::of(Object, Object, Object, Object, Object, Object, Object, Object, Object, Object) -> List - * Source: java/util/List.main.lsl:238 - */ - static java.util.List of(Object e1, Object e2, Object e3, Object e4, Object e5, Object e6, - Object e7, Object e8, Object e9, Object e10) { - java.util.List result = null; - /* body */ { - final SymbolicList data = Engine.makeSymbolicList(); - data.insert(0, e1); - data.insert(1, e2); - data.insert(2, e3); - data.insert(3, e4); - data.insert(4, e5); - data.insert(5, e6); - data.insert(6, e7); - data.insert(7, e8); - data.insert(8, e9); - data.insert(9, e10); - result = (java.util.ArrayList) ((Object) new ArrayList((Void) null, - /* state = */ ArrayList.__$lsl_States.Initialized, - /* storage = */ data, - /* modCount = */ 0 - )); - } - return result; - } - - /** - * [FUNCTION] ListAutomaton::of(array) -> List - * Source: java/util/List.main.lsl:259 - */ - static java.util.List of(Object[] elements) { - java.util.List result = null; - /* body */ { - final SymbolicList data = Engine.makeSymbolicList(); - final int size = elements.length; - Engine.assume(size >= 0); - if (size != 0) { - int i = 0; - for (i = 0; i < size; i += 1) { - data.insert(i, elements[i]); - } - ; - } - result = (java.util.ArrayList) ((Object) new ArrayList((Void) null, - /* state = */ ArrayList.__$lsl_States.Initialized, - /* storage = */ data, - /* modCount = */ 0 - )); - } - return result; - } - - final class __$lsl_States { - public static final byte Initialized = (byte) 0; - } - - @Approximate(List.class) - final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/Optional.java b/approximations/src/main/java/generated/java/util/Optional.java deleted file mode 100644 index 09a3419a..00000000 --- a/approximations/src/main/java/generated/java/util/Optional.java +++ /dev/null @@ -1,480 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/Optional.lsl:40 -// - java/util/Optional.automata.lsl:22 -// -package generated.java.util; - -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.Runnable; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.NoSuchElementException; -import java.util.function.Consumer; -import java.util.function.Function; -import java.util.function.Predicate; -import java.util.function.Supplier; -import java.util.stream.Stream; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; -import stub.java.util.stream.StreamLSL; - -/** - * OptionalAutomaton for LSLOptional ~> java.util.Optional - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(java.util.Optional.class) -public final class Optional implements LibSLRuntime.Automaton { - private static java.util.Optional EMPTY = null; - - static { - /* OptionalAutomaton::() */ { - EMPTY = (java.util.Optional) ((Object) new Optional((Void) null, - /* state = */ Optional.__$lsl_States.Initialized, - /* value = */ null - )); - } - } - - private byte __$lsl_state = __$lsl_States.Allocated; - - public Object value; - - @LibSLRuntime.AutomatonConstructor - public Optional(Void __$lsl_token, final byte p0, final Object p1) { - this.__$lsl_state = p0; - this.value = p1; - } - - @LibSLRuntime.AutomatonConstructor - public Optional(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Allocated, null); - } - - /** - * [CONSTRUCTOR] OptionalAutomaton::(LSLOptional) -> void - * Source: java/util/Optional.automata.lsl:77 - */ - private Optional() { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - LibSLRuntime.error("Private constructor call"); - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [CONSTRUCTOR] OptionalAutomaton::(LSLOptional, Object) -> void - * Source: java/util/Optional.automata.lsl:87 - */ - private Optional(Object obj) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - LibSLRuntime.error("Private constructor call"); - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [FUNCTION] OptionalAutomaton::empty() -> Optional - * Source: java/util/Optional.automata.lsl:103 - */ - public static java.util.Optional empty() { - java.util.Optional result = null; - // WARNING: no state checks in static context - /* body */ { - result = EMPTY; - } - // WARNING: no state transitions in static context - return result; - } - - /** - * [FUNCTION] OptionalAutomaton::of(Object) -> Optional - * Source: java/util/Optional.automata.lsl:111 - */ - public static java.util.Optional of(Object obj) { - java.util.Optional result = null; - // WARNING: no state checks in static context - /* body */ { - if (obj == null) { - throw new NullPointerException(); - } - result = (java.util.Optional) ((Object) new Optional((Void) null, - /* state = */ Optional.__$lsl_States.Initialized, - /* value = */ obj - )); - } - // WARNING: no state transitions in static context - return result; - } - - /** - * [FUNCTION] OptionalAutomaton::ofNullable(Object) -> Optional - * Source: java/util/Optional.automata.lsl:126 - */ - public static java.util.Optional ofNullable(Object obj) { - java.util.Optional result = null; - // WARNING: no state checks in static context - /* body */ { - if (obj == null) { - result = EMPTY; - } else { - result = (java.util.Optional) ((Object) new Optional((Void) null, - /* state = */ Optional.__$lsl_States.Initialized, - /* value = */ obj - )); - } - } - // WARNING: no state transitions in static context - return result; - } - - /** - * [FUNCTION] OptionalAutomaton::equals(LSLOptional, Object) -> boolean - * Source: java/util/Optional.automata.lsl:141 - */ - public boolean equals(Object other) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (other == this) { - result = true; - } else { - final boolean isSameType = Engine.typeEquals(this, other); - if (isSameType) { - final Object otherValue = ((Optional) ((Object) other)).value; - result = LibSLRuntime.equals(this.value, otherValue); - } else { - result = false; - } - } - } - return result; - } - - /** - * [FUNCTION] OptionalAutomaton::filter(LSLOptional, Predicate) -> LSLOptional - * Source: java/util/Optional.automata.lsl:164 - */ - public Optional filter(Predicate predicate) { - Optional result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (predicate == null) { - throw new NullPointerException(); - } - if (this.value == null) { - result = this; - } else { - final boolean sat = predicate.test(this.value); - if (sat) { - result = this; - } else { - result = ((Optional) ((Object) EMPTY)); - } - } - } - return result; - } - - /** - * [FUNCTION] OptionalAutomaton::flatMap(LSLOptional, Function) -> Optional - * Source: java/util/Optional.automata.lsl:189 - */ - public java.util.Optional flatMap(Function mapper) { - java.util.Optional result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (mapper == null) { - throw new NullPointerException(); - } - if (this.value == null) { - result = EMPTY; - } else { - result = ((java.util.Optional) mapper.apply(this.value)); - if (result == null) { - throw new NullPointerException(); - } - } - } - return result; - } - - /** - * [FUNCTION] OptionalAutomaton::get(LSLOptional) -> Object - * Source: java/util/Optional.automata.lsl:215 - */ - public Object get() { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.value == null) { - throw new NoSuchElementException("No value present"); - } - result = this.value; - } - return result; - } - - /** - * [FUNCTION] OptionalAutomaton::hashCode(LSLOptional) -> int - * Source: java/util/Optional.automata.lsl:224 - */ - public int hashCode() { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = LibSLRuntime.hashCode(this.value); - } - return result; - } - - /** - * [FUNCTION] OptionalAutomaton::ifPresent(LSLOptional, Consumer) -> void - * Source: java/util/Optional.automata.lsl:231 - */ - public void ifPresent(Consumer consumer) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.value != null) { - if (consumer == null) { - throw new NullPointerException(); - } - consumer.accept(this.value); - } - } - } - - /** - * [FUNCTION] OptionalAutomaton::ifPresentOrElse(LSLOptional, Consumer, Runnable) -> void - * Source: java/util/Optional.automata.lsl:246 - */ - public void ifPresentOrElse(Consumer consumer, Runnable emptyAction) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.value != null) { - if (consumer == null) { - throw new NullPointerException(); - } - consumer.accept(this.value); - } else { - if (emptyAction == null) { - throw new NullPointerException(); - } - emptyAction.run(); - } - } - } - - /** - * [FUNCTION] OptionalAutomaton::isEmpty(LSLOptional) -> boolean - * Source: java/util/Optional.automata.lsl:270 - */ - public boolean isEmpty() { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value == null; - } - return result; - } - - /** - * [FUNCTION] OptionalAutomaton::isPresent(LSLOptional) -> boolean - * Source: java/util/Optional.automata.lsl:276 - */ - public boolean isPresent() { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value != null; - } - return result; - } - - /** - * [FUNCTION] OptionalAutomaton::map(LSLOptional, Function) -> Optional - * Source: java/util/Optional.automata.lsl:282 - */ - public java.util.Optional map(Function mapper) { - java.util.Optional result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (mapper == null) { - throw new NullPointerException(); - } - if (this.value == null) { - result = EMPTY; - } else { - final Object mappedValue = mapper.apply(this.value); - if (mappedValue == null) { - result = EMPTY; - } else { - result = (java.util.Optional) ((Object) new Optional((Void) null, - /* state = */ Optional.__$lsl_States.Initialized, - /* value = */ mappedValue - )); - } - } - } - return result; - } - - /** - * [FUNCTION] OptionalAutomaton::or(LSLOptional, Supplier) -> LSLOptional - * Source: java/util/Optional.automata.lsl:312 - */ - public Optional or(Supplier supplier) { - Optional result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (supplier == null) { - throw new NullPointerException(); - } - if (this.value == null) { - result = ((Optional) supplier.get()); - if (result == null) { - throw new NullPointerException(); - } - } else { - result = this; - } - } - return result; - } - - /** - * [FUNCTION] OptionalAutomaton::orElse(LSLOptional, Object) -> Object - * Source: java/util/Optional.automata.lsl:335 - */ - public Object orElse(Object other) { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.value == null) { - result = other; - } else { - result = this.value; - } - } - return result; - } - - /** - * [FUNCTION] OptionalAutomaton::orElseGet(LSLOptional, Supplier) -> Object - * Source: java/util/Optional.automata.lsl:344 - */ - public Object orElseGet(Supplier supplier) { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.value == null) { - result = supplier.get(); - } else { - result = this.value; - } - } - return result; - } - - /** - * [FUNCTION] OptionalAutomaton::orElseThrow(LSLOptional) -> Object - * Source: java/util/Optional.automata.lsl:356 - */ - public Object orElseThrow() { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.value == null) { - throw new NoSuchElementException("No value present"); - } - result = this.value; - } - return result; - } - - /** - * [FUNCTION] OptionalAutomaton::orElseThrow(LSLOptional, Supplier) -> Object - * Source: java/util/Optional.automata.lsl:367 - */ - public Object orElseThrow(Supplier exceptionSupplier) throws java.lang.Throwable { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (exceptionSupplier == null) { - throw new NullPointerException(); - } - if (this.value == null) { - final Object exception = exceptionSupplier.get(); - throw ((Throwable) exception); - } else { - result = this.value; - } - } - return result; - } - - /** - * [FUNCTION] OptionalAutomaton::stream(LSLOptional) -> Stream - * Source: java/util/Optional.automata.lsl:389 - */ - public Stream stream() { - Stream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Object[] items = null; - if (this.value == null) { - items = new Object[0]; - } else { - items = new Object[1]; - items[0] = this.value; - } - result = (StreamLSL) ((Object) new generated.java.util.stream.StreamLSL((Void) null, - /* state = */ generated.java.util.stream.StreamLSL.__$lsl_States.Initialized, - /* storage = */ items, - /* length = */ items.length, - /* closeHandlers = */ Engine.makeSymbolicList(), - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - return result; - } - - /** - * [FUNCTION] OptionalAutomaton::toString(LSLOptional) -> String - * Source: java/util/Optional.automata.lsl:412 - */ - public String toString() { - String result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.value == null) { - result = "Optional.empty"; - } else { - final String valueStr = LibSLRuntime.toString(this.value); - result = "Optional[".concat(valueStr).concat("]"); - } - } - return result; - } - - public static final class __$lsl_States { - public static final byte Allocated = (byte) 0; - - public static final byte Initialized = (byte) 1; - } - - @Approximate(Optional.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/OptionalDouble.java b/approximations/src/main/java/generated/java/util/OptionalDouble.java deleted file mode 100644 index ab612922..00000000 --- a/approximations/src/main/java/generated/java/util/OptionalDouble.java +++ /dev/null @@ -1,370 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/OptionalDouble.lsl:36 -// - java/util/OptionalDouble.automata.lsl:22 -// -package generated.java.util; - -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.Runnable; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.NoSuchElementException; -import java.util.function.DoubleConsumer; -import java.util.function.DoubleSupplier; -import java.util.function.Supplier; -import java.util.stream.DoubleStream; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; -import stub.java.util.stream.DoubleStreamLSL; - -/** - * OptionalDoubleAutomaton for LSLOptionalDouble ~> java.util.OptionalDouble - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(java.util.OptionalDouble.class) -public final class OptionalDouble implements LibSLRuntime.Automaton { - private static java.util.OptionalDouble EMPTY = null; - - static { - /* OptionalDoubleAutomaton::() */ { - EMPTY = (java.util.OptionalDouble) ((Object) new OptionalDouble((Void) null, - /* state = */ OptionalDouble.__$lsl_States.Initialized, - /* value = */ 0.0d, - /* present = */ false - )); - } - } - - private byte __$lsl_state = __$lsl_States.Allocated; - - public double value; - - public boolean present; - - @LibSLRuntime.AutomatonConstructor - public OptionalDouble(Void __$lsl_token, final byte p0, final double p1, final boolean p2) { - this.__$lsl_state = p0; - this.value = p1; - this.present = p2; - } - - @LibSLRuntime.AutomatonConstructor - public OptionalDouble(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Allocated, 0.0d, false); - } - - /** - * [CONSTRUCTOR] OptionalDoubleAutomaton::(LSLOptionalDouble) -> void - * Source: java/util/OptionalDouble.automata.lsl:72 - */ - private OptionalDouble() { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - LibSLRuntime.not_implemented(/* this method can be called using reflection only */); - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [CONSTRUCTOR] OptionalDoubleAutomaton::(LSLOptionalDouble, double) -> void - * Source: java/util/OptionalDouble.automata.lsl:78 - */ - private OptionalDouble(double x) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - LibSLRuntime.not_implemented(/* this method can be called using reflection only */); - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [FUNCTION] OptionalDoubleAutomaton::empty() -> OptionalDouble - * Source: java/util/OptionalDouble.automata.lsl:86 - */ - public static java.util.OptionalDouble empty() { - java.util.OptionalDouble result = null; - // WARNING: no state checks in static context - /* body */ { - result = EMPTY; - } - // WARNING: no state transitions in static context - return result; - } - - /** - * [FUNCTION] OptionalDoubleAutomaton::of(double) -> OptionalDouble - * Source: java/util/OptionalDouble.automata.lsl:92 - */ - public static java.util.OptionalDouble of(double x) { - java.util.OptionalDouble result = null; - // WARNING: no state checks in static context - /* body */ { - result = (java.util.OptionalDouble) ((Object) new OptionalDouble((Void) null, - /* state = */ OptionalDouble.__$lsl_States.Initialized, - /* value = */ x, - /* present = */ true - )); - } - // WARNING: no state transitions in static context - return result; - } - - /** - * [FUNCTION] OptionalDoubleAutomaton::equals(LSLOptionalDouble, Object) -> boolean - * Source: java/util/OptionalDouble.automata.lsl:103 - */ - public boolean equals(Object other) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (other == this) { - result = true; - } else { - final boolean isSameType = Engine.typeEquals(this, other); - if (isSameType) { - final double otherValue = ((OptionalDouble) ((Object) other)).value; - final boolean otherPresent = ((OptionalDouble) ((Object) other)).present; - if (this.present && otherPresent) { - result = LibSLRuntime.equals(this.value, otherValue); - } else { - result = this.present == otherPresent; - } - } else { - result = false; - } - } - } - return result; - } - - /** - * [FUNCTION] OptionalDoubleAutomaton::getAsDouble(LSLOptionalDouble) -> double - * Source: java/util/OptionalDouble.automata.lsl:131 - */ - public double getAsDouble() { - double result = 0.0d; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (!this.present) { - throw new NoSuchElementException("No value present"); - } - result = this.value; - } - return result; - } - - /** - * [FUNCTION] OptionalDoubleAutomaton::hashCode(LSLOptionalDouble) -> int - * Source: java/util/OptionalDouble.automata.lsl:140 - */ - public int hashCode() { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.present) { - result = LibSLRuntime.hashCode(this.value); - } else { - result = 0; - } - } - return result; - } - - /** - * [FUNCTION] OptionalDoubleAutomaton::ifPresent(LSLOptionalDouble, DoubleConsumer) -> void - * Source: java/util/OptionalDouble.automata.lsl:150 - */ - public void ifPresent(DoubleConsumer consumer) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.present) { - if (consumer == null) { - throw new NullPointerException(); - } - consumer.accept(this.value); - } - } - } - - /** - * [FUNCTION] OptionalDoubleAutomaton::ifPresentOrElse(LSLOptionalDouble, DoubleConsumer, Runnable) -> void - * Source: java/util/OptionalDouble.automata.lsl:164 - */ - public void ifPresentOrElse(DoubleConsumer consumer, Runnable emptyAction) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.present) { - if (consumer == null) { - throw new NullPointerException(); - } - consumer.accept(this.value); - } else { - if (emptyAction == null) { - throw new NullPointerException(); - } - emptyAction.run(); - } - } - } - - /** - * [FUNCTION] OptionalDoubleAutomaton::isEmpty(LSLOptionalDouble) -> boolean - * Source: java/util/OptionalDouble.automata.lsl:186 - */ - public boolean isEmpty() { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = !this.present; - } - return result; - } - - /** - * [FUNCTION] OptionalDoubleAutomaton::isPresent(LSLOptionalDouble) -> boolean - * Source: java/util/OptionalDouble.automata.lsl:192 - */ - public boolean isPresent() { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.present; - } - return result; - } - - /** - * [FUNCTION] OptionalDoubleAutomaton::orElse(LSLOptionalDouble, double) -> double - * Source: java/util/OptionalDouble.automata.lsl:198 - */ - public double orElse(double other) { - double result = 0.0d; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.present) { - result = this.value; - } else { - result = other; - } - } - return result; - } - - /** - * [FUNCTION] OptionalDoubleAutomaton::orElseGet(LSLOptionalDouble, DoubleSupplier) -> double - * Source: java/util/OptionalDouble.automata.lsl:207 - */ - public double orElseGet(DoubleSupplier supplier) { - double result = 0.0d; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.present) { - result = this.value; - } else { - result = supplier.getAsDouble(); - } - } - return result; - } - - /** - * [FUNCTION] OptionalDoubleAutomaton::orElseThrow(LSLOptionalDouble) -> double - * Source: java/util/OptionalDouble.automata.lsl:218 - */ - public double orElseThrow() { - double result = 0.0d; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (!this.present) { - throw new NoSuchElementException("No value present"); - } - result = this.value; - } - return result; - } - - /** - * [FUNCTION] OptionalDoubleAutomaton::orElseThrow(LSLOptionalDouble, Supplier) -> double - * Source: java/util/OptionalDouble.automata.lsl:229 - */ - public double orElseThrow(Supplier exceptionSupplier) throws java.lang.Throwable { - double result = 0.0d; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (exceptionSupplier == null) { - throw new NullPointerException(); - } - if (!this.present) { - final Object exception = exceptionSupplier.get(); - throw ((Throwable) exception); - } else { - result = this.value; - } - } - return result; - } - - /** - * [FUNCTION] OptionalDoubleAutomaton::stream(LSLOptionalDouble) -> DoubleStream - * Source: java/util/OptionalDouble.automata.lsl:250 - */ - public DoubleStream stream() { - DoubleStream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - double[] items = null; - if (this.present) { - items = new double[1]; - items[0] = this.value; - } else { - items = new double[0]; - } - result = (DoubleStreamLSL) ((Object) new generated.java.util.stream.DoubleStreamLSL((Void) null, - /* state = */ generated.java.util.stream.DoubleStreamLSL.__$lsl_States.Initialized, - /* storage = */ items, - /* length = */ items.length, - /* closeHandlers = */ Engine.makeSymbolicList(), - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - return result; - } - - /** - * [FUNCTION] OptionalDoubleAutomaton::toString(LSLOptionalDouble) -> String - * Source: java/util/OptionalDouble.automata.lsl:272 - */ - public String toString() { - String result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.present) { - final String valueStr = LibSLRuntime.toString(this.value); - result = "OptionalDouble[".concat(valueStr).concat("]"); - } else { - result = "OptionalDouble.empty"; - } - } - return result; - } - - public static final class __$lsl_States { - public static final byte Allocated = (byte) 0; - - public static final byte Initialized = (byte) 1; - } - - @Approximate(OptionalDouble.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/OptionalInt.java b/approximations/src/main/java/generated/java/util/OptionalInt.java deleted file mode 100644 index 2ee5568b..00000000 --- a/approximations/src/main/java/generated/java/util/OptionalInt.java +++ /dev/null @@ -1,370 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/OptionalInt.lsl:36 -// - java/util/OptionalInt.automata.lsl:22 -// -package generated.java.util; - -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.Runnable; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.NoSuchElementException; -import java.util.function.IntConsumer; -import java.util.function.IntSupplier; -import java.util.function.Supplier; -import java.util.stream.IntStream; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; -import stub.java.util.stream.IntStreamLSL; - -/** - * OptionalIntAutomaton for LSLOptionalInt ~> java.util.OptionalInt - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(java.util.OptionalInt.class) -public final class OptionalInt implements LibSLRuntime.Automaton { - private static java.util.OptionalInt EMPTY = null; - - static { - /* OptionalIntAutomaton::() */ { - EMPTY = (java.util.OptionalInt) ((Object) new OptionalInt((Void) null, - /* state = */ OptionalInt.__$lsl_States.Initialized, - /* value = */ 0, - /* present = */ false - )); - } - } - - private byte __$lsl_state = __$lsl_States.Allocated; - - public int value; - - public boolean present; - - @LibSLRuntime.AutomatonConstructor - public OptionalInt(Void __$lsl_token, final byte p0, final int p1, final boolean p2) { - this.__$lsl_state = p0; - this.value = p1; - this.present = p2; - } - - @LibSLRuntime.AutomatonConstructor - public OptionalInt(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Allocated, 0, false); - } - - /** - * [CONSTRUCTOR] OptionalIntAutomaton::(LSLOptionalInt) -> void - * Source: java/util/OptionalInt.automata.lsl:72 - */ - private OptionalInt() { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - LibSLRuntime.not_implemented(/* this method can be called using reflection only */); - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [CONSTRUCTOR] OptionalIntAutomaton::(LSLOptionalInt, int) -> void - * Source: java/util/OptionalInt.automata.lsl:78 - */ - private OptionalInt(int x) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - LibSLRuntime.not_implemented(/* this method can be called using reflection only */); - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [FUNCTION] OptionalIntAutomaton::empty() -> OptionalInt - * Source: java/util/OptionalInt.automata.lsl:86 - */ - public static java.util.OptionalInt empty() { - java.util.OptionalInt result = null; - // WARNING: no state checks in static context - /* body */ { - result = EMPTY; - } - // WARNING: no state transitions in static context - return result; - } - - /** - * [FUNCTION] OptionalIntAutomaton::of(int) -> OptionalInt - * Source: java/util/OptionalInt.automata.lsl:92 - */ - public static java.util.OptionalInt of(int x) { - java.util.OptionalInt result = null; - // WARNING: no state checks in static context - /* body */ { - result = (java.util.OptionalInt) ((Object) new OptionalInt((Void) null, - /* state = */ OptionalInt.__$lsl_States.Initialized, - /* value = */ x, - /* present = */ true - )); - } - // WARNING: no state transitions in static context - return result; - } - - /** - * [FUNCTION] OptionalIntAutomaton::equals(LSLOptionalInt, Object) -> boolean - * Source: java/util/OptionalInt.automata.lsl:103 - */ - public boolean equals(Object other) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (other == this) { - result = true; - } else { - final boolean isSameType = Engine.typeEquals(this, other); - if (isSameType) { - final int otherValue = ((OptionalInt) ((Object) other)).value; - final boolean otherPresent = ((OptionalInt) ((Object) other)).present; - if (this.present && otherPresent) { - result = this.value == otherValue; - } else { - result = this.present == otherPresent; - } - } else { - result = false; - } - } - } - return result; - } - - /** - * [FUNCTION] OptionalIntAutomaton::getAsInt(LSLOptionalInt) -> int - * Source: java/util/OptionalInt.automata.lsl:131 - */ - public int getAsInt() { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (!this.present) { - throw new NoSuchElementException("No value present"); - } - result = this.value; - } - return result; - } - - /** - * [FUNCTION] OptionalIntAutomaton::hashCode(LSLOptionalInt) -> int - * Source: java/util/OptionalInt.automata.lsl:140 - */ - public int hashCode() { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.present) { - result = LibSLRuntime.hashCode(this.value); - } else { - result = 0; - } - } - return result; - } - - /** - * [FUNCTION] OptionalIntAutomaton::ifPresent(LSLOptionalInt, IntConsumer) -> void - * Source: java/util/OptionalInt.automata.lsl:150 - */ - public void ifPresent(IntConsumer consumer) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.present) { - if (consumer == null) { - throw new NullPointerException(); - } - consumer.accept(this.value); - } - } - } - - /** - * [FUNCTION] OptionalIntAutomaton::ifPresentOrElse(LSLOptionalInt, IntConsumer, Runnable) -> void - * Source: java/util/OptionalInt.automata.lsl:164 - */ - public void ifPresentOrElse(IntConsumer consumer, Runnable emptyAction) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.present) { - if (consumer == null) { - throw new NullPointerException(); - } - consumer.accept(this.value); - } else { - if (emptyAction == null) { - throw new NullPointerException(); - } - emptyAction.run(); - } - } - } - - /** - * [FUNCTION] OptionalIntAutomaton::isEmpty(LSLOptionalInt) -> boolean - * Source: java/util/OptionalInt.automata.lsl:186 - */ - public boolean isEmpty() { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = !this.present; - } - return result; - } - - /** - * [FUNCTION] OptionalIntAutomaton::isPresent(LSLOptionalInt) -> boolean - * Source: java/util/OptionalInt.automata.lsl:192 - */ - public boolean isPresent() { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.present; - } - return result; - } - - /** - * [FUNCTION] OptionalIntAutomaton::orElse(LSLOptionalInt, int) -> int - * Source: java/util/OptionalInt.automata.lsl:198 - */ - public int orElse(int other) { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.present) { - result = this.value; - } else { - result = other; - } - } - return result; - } - - /** - * [FUNCTION] OptionalIntAutomaton::orElseGet(LSLOptionalInt, IntSupplier) -> int - * Source: java/util/OptionalInt.automata.lsl:207 - */ - public int orElseGet(IntSupplier supplier) { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.present) { - result = this.value; - } else { - result = supplier.getAsInt(); - } - } - return result; - } - - /** - * [FUNCTION] OptionalIntAutomaton::orElseThrow(LSLOptionalInt) -> int - * Source: java/util/OptionalInt.automata.lsl:218 - */ - public int orElseThrow() { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (!this.present) { - throw new NoSuchElementException("No value present"); - } - result = this.value; - } - return result; - } - - /** - * [FUNCTION] OptionalIntAutomaton::orElseThrow(LSLOptionalInt, Supplier) -> int - * Source: java/util/OptionalInt.automata.lsl:229 - */ - public int orElseThrow(Supplier exceptionSupplier) throws java.lang.Throwable { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (exceptionSupplier == null) { - throw new NullPointerException(); - } - if (!this.present) { - final Object exception = exceptionSupplier.get(); - throw ((Throwable) exception); - } else { - result = this.value; - } - } - return result; - } - - /** - * [FUNCTION] OptionalIntAutomaton::stream(LSLOptionalInt) -> IntStream - * Source: java/util/OptionalInt.automata.lsl:250 - */ - public IntStream stream() { - IntStream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - int[] items = null; - if (this.present) { - items = new int[1]; - items[0] = this.value; - } else { - items = new int[0]; - } - result = (IntStreamLSL) ((Object) new generated.java.util.stream.IntStreamLSL((Void) null, - /* state = */ generated.java.util.stream.IntStreamLSL.__$lsl_States.Initialized, - /* storage = */ items, - /* length = */ items.length, - /* closeHandlers = */ Engine.makeSymbolicList(), - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - return result; - } - - /** - * [FUNCTION] OptionalIntAutomaton::toString(LSLOptionalInt) -> String - * Source: java/util/OptionalInt.automata.lsl:272 - */ - public String toString() { - String result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.present) { - final String valueStr = LibSLRuntime.toString(this.value); - result = "OptionalInt[".concat(valueStr).concat("]"); - } else { - result = "OptionalInt.empty"; - } - } - return result; - } - - public static final class __$lsl_States { - public static final byte Allocated = (byte) 0; - - public static final byte Initialized = (byte) 1; - } - - @Approximate(OptionalInt.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/OptionalLong.java b/approximations/src/main/java/generated/java/util/OptionalLong.java deleted file mode 100644 index ccd143b4..00000000 --- a/approximations/src/main/java/generated/java/util/OptionalLong.java +++ /dev/null @@ -1,370 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/OptionalLong.lsl:36 -// - java/util/OptionalLong.automata.lsl:22 -// -package generated.java.util; - -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.Runnable; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.NoSuchElementException; -import java.util.function.LongConsumer; -import java.util.function.LongSupplier; -import java.util.function.Supplier; -import java.util.stream.LongStream; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; -import stub.java.util.stream.LongStreamLSL; - -/** - * OptionalLongAutomaton for LSLOptionalLong ~> java.util.OptionalLong - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(java.util.OptionalLong.class) -public final class OptionalLong implements LibSLRuntime.Automaton { - private static java.util.OptionalLong EMPTY = null; - - static { - /* OptionalLongAutomaton::() */ { - EMPTY = (java.util.OptionalLong) ((Object) new OptionalLong((Void) null, - /* state = */ OptionalLong.__$lsl_States.Initialized, - /* value = */ 0L, - /* present = */ false - )); - } - } - - private byte __$lsl_state = __$lsl_States.Allocated; - - public long value; - - public boolean present; - - @LibSLRuntime.AutomatonConstructor - public OptionalLong(Void __$lsl_token, final byte p0, final long p1, final boolean p2) { - this.__$lsl_state = p0; - this.value = p1; - this.present = p2; - } - - @LibSLRuntime.AutomatonConstructor - public OptionalLong(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Allocated, 0L, false); - } - - /** - * [CONSTRUCTOR] OptionalLongAutomaton::(LSLOptionalLong) -> void - * Source: java/util/OptionalLong.automata.lsl:72 - */ - private OptionalLong() { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - LibSLRuntime.not_implemented(/* this method can be called using reflection only */); - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [CONSTRUCTOR] OptionalLongAutomaton::(LSLOptionalLong, long) -> void - * Source: java/util/OptionalLong.automata.lsl:78 - */ - private OptionalLong(long x) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - LibSLRuntime.not_implemented(/* this method can be called using reflection only */); - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [FUNCTION] OptionalLongAutomaton::empty() -> OptionalLong - * Source: java/util/OptionalLong.automata.lsl:86 - */ - public static java.util.OptionalLong empty() { - java.util.OptionalLong result = null; - // WARNING: no state checks in static context - /* body */ { - result = EMPTY; - } - // WARNING: no state transitions in static context - return result; - } - - /** - * [FUNCTION] OptionalLongAutomaton::of(long) -> OptionalLong - * Source: java/util/OptionalLong.automata.lsl:92 - */ - public static java.util.OptionalLong of(long x) { - java.util.OptionalLong result = null; - // WARNING: no state checks in static context - /* body */ { - result = (java.util.OptionalLong) ((Object) new OptionalLong((Void) null, - /* state = */ OptionalLong.__$lsl_States.Initialized, - /* value = */ x, - /* present = */ true - )); - } - // WARNING: no state transitions in static context - return result; - } - - /** - * [FUNCTION] OptionalLongAutomaton::equals(LSLOptionalLong, Object) -> boolean - * Source: java/util/OptionalLong.automata.lsl:103 - */ - public boolean equals(Object other) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (other == this) { - result = true; - } else { - final boolean isSameType = Engine.typeEquals(this, other); - if (isSameType) { - final long otherValue = ((OptionalLong) ((Object) other)).value; - final boolean otherPresent = ((OptionalLong) ((Object) other)).present; - if (this.present && otherPresent) { - result = this.value == otherValue; - } else { - result = this.present == otherPresent; - } - } else { - result = false; - } - } - } - return result; - } - - /** - * [FUNCTION] OptionalLongAutomaton::getAsLong(LSLOptionalLong) -> long - * Source: java/util/OptionalLong.automata.lsl:131 - */ - public long getAsLong() { - long result = 0L; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (!this.present) { - throw new NoSuchElementException("No value present"); - } - result = this.value; - } - return result; - } - - /** - * [FUNCTION] OptionalLongAutomaton::hashCode(LSLOptionalLong) -> int - * Source: java/util/OptionalLong.automata.lsl:140 - */ - public int hashCode() { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.present) { - result = LibSLRuntime.hashCode(this.value); - } else { - result = 0; - } - } - return result; - } - - /** - * [FUNCTION] OptionalLongAutomaton::ifPresent(LSLOptionalLong, LongConsumer) -> void - * Source: java/util/OptionalLong.automata.lsl:150 - */ - public void ifPresent(LongConsumer consumer) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.present) { - if (consumer == null) { - throw new NullPointerException(); - } - consumer.accept(this.value); - } - } - } - - /** - * [FUNCTION] OptionalLongAutomaton::ifPresentOrElse(LSLOptionalLong, LongConsumer, Runnable) -> void - * Source: java/util/OptionalLong.automata.lsl:164 - */ - public void ifPresentOrElse(LongConsumer consumer, Runnable emptyAction) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.present) { - if (consumer == null) { - throw new NullPointerException(); - } - consumer.accept(this.value); - } else { - if (emptyAction == null) { - throw new NullPointerException(); - } - emptyAction.run(); - } - } - } - - /** - * [FUNCTION] OptionalLongAutomaton::isEmpty(LSLOptionalLong) -> boolean - * Source: java/util/OptionalLong.automata.lsl:186 - */ - public boolean isEmpty() { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = !this.present; - } - return result; - } - - /** - * [FUNCTION] OptionalLongAutomaton::isPresent(LSLOptionalLong) -> boolean - * Source: java/util/OptionalLong.automata.lsl:192 - */ - public boolean isPresent() { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.present; - } - return result; - } - - /** - * [FUNCTION] OptionalLongAutomaton::orElse(LSLOptionalLong, long) -> long - * Source: java/util/OptionalLong.automata.lsl:198 - */ - public long orElse(long other) { - long result = 0L; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.present) { - result = this.value; - } else { - result = other; - } - } - return result; - } - - /** - * [FUNCTION] OptionalLongAutomaton::orElseGet(LSLOptionalLong, LongSupplier) -> long - * Source: java/util/OptionalLong.automata.lsl:207 - */ - public long orElseGet(LongSupplier supplier) { - long result = 0L; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.present) { - result = this.value; - } else { - result = supplier.getAsLong(); - } - } - return result; - } - - /** - * [FUNCTION] OptionalLongAutomaton::orElseThrow(LSLOptionalLong) -> long - * Source: java/util/OptionalLong.automata.lsl:218 - */ - public long orElseThrow() { - long result = 0L; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (!this.present) { - throw new NoSuchElementException("No value present"); - } - result = this.value; - } - return result; - } - - /** - * [FUNCTION] OptionalLongAutomaton::orElseThrow(LSLOptionalLong, Supplier) -> long - * Source: java/util/OptionalLong.automata.lsl:229 - */ - public long orElseThrow(Supplier exceptionSupplier) throws java.lang.Throwable { - long result = 0L; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (exceptionSupplier == null) { - throw new NullPointerException(); - } - if (!this.present) { - final Object exception = exceptionSupplier.get(); - throw ((Throwable) exception); - } else { - result = this.value; - } - } - return result; - } - - /** - * [FUNCTION] OptionalLongAutomaton::stream(LSLOptionalLong) -> LongStream - * Source: java/util/OptionalLong.automata.lsl:250 - */ - public LongStream stream() { - LongStream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - long[] items = null; - if (this.present) { - items = new long[1]; - items[0] = this.value; - } else { - items = new long[0]; - } - result = (LongStreamLSL) ((Object) new generated.java.util.stream.LongStreamLSL((Void) null, - /* state = */ generated.java.util.stream.LongStreamLSL.__$lsl_States.Initialized, - /* storage = */ items, - /* length = */ items.length, - /* closeHandlers = */ Engine.makeSymbolicList(), - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - return result; - } - - /** - * [FUNCTION] OptionalLongAutomaton::toString(LSLOptionalLong) -> String - * Source: java/util/OptionalLong.automata.lsl:272 - */ - public String toString() { - String result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.present) { - final String valueStr = LibSLRuntime.toString(this.value); - result = "OptionalLong[".concat(valueStr).concat("]"); - } else { - result = "OptionalLong.empty"; - } - } - return result; - } - - public static final class __$lsl_States { - public static final byte Allocated = (byte) 0; - - public static final byte Initialized = (byte) 1; - } - - @Approximate(OptionalLong.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/Random.java b/approximations/src/main/java/generated/java/util/Random.java deleted file mode 100644 index 8eae9ee3..00000000 --- a/approximations/src/main/java/generated/java/util/Random.java +++ /dev/null @@ -1,607 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/Random.lsl:16 -// - java/util/Random.main.lsl:21 -// -package generated.java.util; - -import generated.runtime.LibSLGlobals; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.ObjectStreamField; -import java.io.Serializable; -import java.lang.IllegalArgumentException; -import java.lang.Object; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.stream.DoubleStream; -import java.util.stream.IntStream; -import java.util.stream.LongStream; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; -import stub.java.util.stream.DoubleStreamLSL; -import stub.java.util.stream.IntStreamLSL; -import stub.java.util.stream.LongStreamLSL; - -/** - * RandomAutomaton for Random ~> java.util.Random - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(java.util.Random.class) -public class Random implements LibSLRuntime.Automaton, Serializable { - private static final long serialVersionUID = 3905348978240129619L; - - private static final ObjectStreamField[] serialPersistentFields = {}; - - static { - Engine.assume(true); - } - - private byte __$lsl_state = __$lsl_States.Allocated; - - @LibSLRuntime.AutomatonConstructor - public Random(Void __$lsl_token, final byte p0) { - this.__$lsl_state = p0; - } - - @LibSLRuntime.AutomatonConstructor - public Random(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Allocated); - } - - /** - * [CONSTRUCTOR] RandomAutomaton::(Random) -> void - * Source: java/util/Random.main.lsl:137 - */ - public Random() { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - Engine.assume(true); - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [CONSTRUCTOR] RandomAutomaton::(Random, long) -> void - * Source: java/util/Random.main.lsl:143 - */ - public Random(long seed) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - Engine.assume(true); - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [SUBROUTINE] RandomAutomaton::_nextBytes(array, int) -> void - * Source: java/util/Random.main.lsl:72 - */ - private static void _nextBytes(byte[] result, int numBytes) { - /* body */ { - final byte[] symbolicArray = Engine.makeSymbolicByteArray(numBytes); - LibSLRuntime.ArrayActions.copy(symbolicArray, 0, result, 0, numBytes); - } - } - - /** - * [SUBROUTINE] RandomAutomaton::_generateRandomIntegerArrayWithBounds(int, int, int) -> array - * Source: java/util/Random.main.lsl:79 - */ - private int[] _generateRandomIntegerArrayWithBounds(int size, int randomNumberOrigin, - int randomNumberBound) { - int[] result = null; - /* body */ { - result = Engine.makeSymbolicIntArray(size); - int i = 0; - for (i = 0; i < size; i += 1) { - Engine.assume(result[i] >= randomNumberOrigin); - Engine.assume(result[i] < randomNumberBound); - } - ; - } - return result; - } - - /** - * [SUBROUTINE] RandomAutomaton::_generateRandomLongArrayWithBounds(int, long, long) -> array - * Source: java/util/Random.main.lsl:97 - */ - private long[] _generateRandomLongArrayWithBounds(int size, long randomNumberOrigin, - long randomNumberBound) { - long[] result = null; - /* body */ { - result = Engine.makeSymbolicLongArray(size); - int i = 0; - for (i = 0; i < size; i += 1) { - Engine.assume(result[i] >= randomNumberOrigin); - Engine.assume(result[i] < randomNumberBound); - } - ; - } - return result; - } - - /** - * [SUBROUTINE] RandomAutomaton::_generateRandomDoubleArrayWithBounds(int, double, double) -> array - * Source: java/util/Random.main.lsl:115 - */ - private double[] _generateRandomDoubleArrayWithBounds(int size, double randomNumberOrigin, - double randomNumberBound) { - double[] result = null; - /* body */ { - result = Engine.makeSymbolicDoubleArray(size); - int i = 0; - for (i = 0; i < size; i += 1) { - final double item = result[i]; - Engine.assume(item == item); - Engine.assume(item >= randomNumberOrigin); - Engine.assume(item < randomNumberBound); - } - ; - } - return result; - } - - /** - * [FUNCTION] RandomAutomaton::doubles(Random) -> DoubleStream - * Source: java/util/Random.main.lsl:153 - */ - public DoubleStream doubles() { - DoubleStream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = (DoubleStreamLSL) ((Object) new generated.java.util.stream.DoubleStreamLSL((Void) null, - /* state = */ generated.java.util.stream.DoubleStreamLSL.__$lsl_States.Initialized, - /* storage = */ _generateRandomDoubleArrayWithBounds(LibSLGlobals.RANDOM_STREAM_SIZE_MAX, 0, 1), - /* length = */ LibSLGlobals.RANDOM_STREAM_SIZE_MAX, - /* closeHandlers = */ Engine.makeSymbolicList(), - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - return result; - } - - /** - * [FUNCTION] RandomAutomaton::doubles(Random, double, double) -> DoubleStream - * Source: java/util/Random.main.lsl:163 - */ - public DoubleStream doubles(double randomNumberOrigin, double randomNumberBound) { - DoubleStream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (randomNumberOrigin >= randomNumberBound) { - throw new IllegalArgumentException(); - } - result = (DoubleStreamLSL) ((Object) new generated.java.util.stream.DoubleStreamLSL((Void) null, - /* state = */ generated.java.util.stream.DoubleStreamLSL.__$lsl_States.Initialized, - /* storage = */ _generateRandomDoubleArrayWithBounds(LibSLGlobals.RANDOM_STREAM_SIZE_MAX, randomNumberOrigin, randomNumberBound), - /* length = */ LibSLGlobals.RANDOM_STREAM_SIZE_MAX, - /* closeHandlers = */ Engine.makeSymbolicList(), - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - return result; - } - - /** - * [FUNCTION] RandomAutomaton::doubles(Random, long) -> DoubleStream - * Source: java/util/Random.main.lsl:175 - */ - public DoubleStream doubles(long streamSize) { - DoubleStream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - int size = ((int) streamSize); - if (size < 0) { - throw new IllegalArgumentException(); - } - if (size > LibSLGlobals.RANDOM_STREAM_SIZE_MAX) { - size = LibSLGlobals.RANDOM_STREAM_SIZE_MAX; - } - result = (DoubleStreamLSL) ((Object) new generated.java.util.stream.DoubleStreamLSL((Void) null, - /* state = */ generated.java.util.stream.DoubleStreamLSL.__$lsl_States.Initialized, - /* storage = */ Engine.makeSymbolicDoubleArray(size), - /* length = */ size, - /* closeHandlers = */ Engine.makeSymbolicList(), - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - return result; - } - - /** - * [FUNCTION] RandomAutomaton::doubles(Random, long, double, double) -> DoubleStream - * Source: java/util/Random.main.lsl:192 - */ - public DoubleStream doubles(long streamSize, double randomNumberOrigin, - double randomNumberBound) { - DoubleStream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - int size = ((int) streamSize); - if (size < 0) { - throw new IllegalArgumentException(); - } - if (randomNumberOrigin >= randomNumberBound) { - throw new IllegalArgumentException(); - } - if (size > LibSLGlobals.RANDOM_STREAM_SIZE_MAX) { - size = LibSLGlobals.RANDOM_STREAM_SIZE_MAX; - } - result = (DoubleStreamLSL) ((Object) new generated.java.util.stream.DoubleStreamLSL((Void) null, - /* state = */ generated.java.util.stream.DoubleStreamLSL.__$lsl_States.Initialized, - /* storage = */ _generateRandomDoubleArrayWithBounds(size, randomNumberOrigin, randomNumberBound), - /* length = */ size, - /* closeHandlers = */ Engine.makeSymbolicList(), - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - return result; - } - - /** - * [FUNCTION] RandomAutomaton::ints(Random) -> IntStream - * Source: java/util/Random.main.lsl:211 - */ - public IntStream ints() { - IntStream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = (IntStreamLSL) ((Object) new generated.java.util.stream.IntStreamLSL((Void) null, - /* state = */ generated.java.util.stream.IntStreamLSL.__$lsl_States.Initialized, - /* storage = */ Engine.makeSymbolicIntArray(LibSLGlobals.RANDOM_STREAM_SIZE_MAX), - /* length = */ LibSLGlobals.RANDOM_STREAM_SIZE_MAX, - /* closeHandlers = */ Engine.makeSymbolicList(), - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - return result; - } - - /** - * [FUNCTION] RandomAutomaton::ints(Random, int, int) -> IntStream - * Source: java/util/Random.main.lsl:221 - */ - public IntStream ints(int randomNumberOrigin, int randomNumberBound) { - IntStream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (randomNumberOrigin >= randomNumberBound) { - throw new IllegalArgumentException(); - } - result = (IntStreamLSL) ((Object) new generated.java.util.stream.IntStreamLSL((Void) null, - /* state = */ generated.java.util.stream.IntStreamLSL.__$lsl_States.Initialized, - /* storage = */ _generateRandomIntegerArrayWithBounds(LibSLGlobals.RANDOM_STREAM_SIZE_MAX, randomNumberOrigin, randomNumberBound), - /* length = */ LibSLGlobals.RANDOM_STREAM_SIZE_MAX, - /* closeHandlers = */ Engine.makeSymbolicList(), - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - return result; - } - - /** - * [FUNCTION] RandomAutomaton::ints(Random, long) -> IntStream - * Source: java/util/Random.main.lsl:233 - */ - public IntStream ints(long streamSize) { - IntStream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - int size = ((int) streamSize); - if (size < 0) { - throw new IllegalArgumentException(); - } - if (size > LibSLGlobals.RANDOM_STREAM_SIZE_MAX) { - size = LibSLGlobals.RANDOM_STREAM_SIZE_MAX; - } - result = (IntStreamLSL) ((Object) new generated.java.util.stream.IntStreamLSL((Void) null, - /* state = */ generated.java.util.stream.IntStreamLSL.__$lsl_States.Initialized, - /* storage = */ Engine.makeSymbolicIntArray(size), - /* length = */ size, - /* closeHandlers = */ Engine.makeSymbolicList(), - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - return result; - } - - /** - * [FUNCTION] RandomAutomaton::ints(Random, long, int, int) -> IntStream - * Source: java/util/Random.main.lsl:250 - */ - public IntStream ints(long streamSize, int randomNumberOrigin, int randomNumberBound) { - IntStream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - int size = ((int) streamSize); - if (size < 0) { - throw new IllegalArgumentException(); - } - if (randomNumberOrigin >= randomNumberBound) { - throw new IllegalArgumentException(); - } - if (size > LibSLGlobals.RANDOM_STREAM_SIZE_MAX) { - size = LibSLGlobals.RANDOM_STREAM_SIZE_MAX; - } - result = (IntStreamLSL) ((Object) new generated.java.util.stream.IntStreamLSL((Void) null, - /* state = */ generated.java.util.stream.IntStreamLSL.__$lsl_States.Initialized, - /* storage = */ _generateRandomIntegerArrayWithBounds(size, randomNumberOrigin, randomNumberBound), - /* length = */ size, - /* closeHandlers = */ Engine.makeSymbolicList(), - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - return result; - } - - /** - * [FUNCTION] RandomAutomaton::longs(Random) -> LongStream - * Source: java/util/Random.main.lsl:269 - */ - public LongStream longs() { - LongStream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = (LongStreamLSL) ((Object) new generated.java.util.stream.LongStreamLSL((Void) null, - /* state = */ generated.java.util.stream.LongStreamLSL.__$lsl_States.Initialized, - /* storage = */ Engine.makeSymbolicLongArray(LibSLGlobals.RANDOM_STREAM_SIZE_MAX), - /* length = */ LibSLGlobals.RANDOM_STREAM_SIZE_MAX, - /* closeHandlers = */ Engine.makeSymbolicList(), - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - return result; - } - - /** - * [FUNCTION] RandomAutomaton::longs(Random, long) -> LongStream - * Source: java/util/Random.main.lsl:279 - */ - public LongStream longs(long streamSize) { - LongStream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - int size = ((int) streamSize); - if (size < 0) { - throw new IllegalArgumentException(); - } - if (size > LibSLGlobals.RANDOM_STREAM_SIZE_MAX) { - size = LibSLGlobals.RANDOM_STREAM_SIZE_MAX; - } - result = (LongStreamLSL) ((Object) new generated.java.util.stream.LongStreamLSL((Void) null, - /* state = */ generated.java.util.stream.LongStreamLSL.__$lsl_States.Initialized, - /* storage = */ Engine.makeSymbolicLongArray(size), - /* length = */ size, - /* closeHandlers = */ Engine.makeSymbolicList(), - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - return result; - } - - /** - * [FUNCTION] RandomAutomaton::longs(Random, long, long) -> LongStream - * Source: java/util/Random.main.lsl:296 - */ - public LongStream longs(long randomNumberOrigin, long randomNumberBound) { - LongStream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (randomNumberOrigin >= randomNumberBound) { - throw new IllegalArgumentException(); - } - result = (LongStreamLSL) ((Object) new generated.java.util.stream.LongStreamLSL((Void) null, - /* state = */ generated.java.util.stream.LongStreamLSL.__$lsl_States.Initialized, - /* storage = */ _generateRandomLongArrayWithBounds(LibSLGlobals.RANDOM_STREAM_SIZE_MAX, randomNumberOrigin, randomNumberBound), - /* length = */ LibSLGlobals.RANDOM_STREAM_SIZE_MAX, - /* closeHandlers = */ Engine.makeSymbolicList(), - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - return result; - } - - /** - * [FUNCTION] RandomAutomaton::longs(Random, long, long, long) -> LongStream - * Source: java/util/Random.main.lsl:308 - */ - public LongStream longs(long streamSize, long randomNumberOrigin, long randomNumberBound) { - LongStream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - int size = ((int) streamSize); - if (size < 0) { - throw new IllegalArgumentException(); - } - if (randomNumberOrigin >= randomNumberBound) { - throw new IllegalArgumentException(); - } - if (size > LibSLGlobals.RANDOM_STREAM_SIZE_MAX) { - size = LibSLGlobals.RANDOM_STREAM_SIZE_MAX; - } - result = (LongStreamLSL) ((Object) new generated.java.util.stream.LongStreamLSL((Void) null, - /* state = */ generated.java.util.stream.LongStreamLSL.__$lsl_States.Initialized, - /* storage = */ _generateRandomLongArrayWithBounds(size, randomNumberOrigin, randomNumberBound), - /* length = */ size, - /* closeHandlers = */ Engine.makeSymbolicList(), - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - return result; - } - - /** - * [FUNCTION] RandomAutomaton::nextBoolean(Random) -> boolean - * Source: java/util/Random.main.lsl:327 - */ - public boolean nextBoolean() { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = Engine.makeSymbolicBoolean(); - } - return result; - } - - /** - * [FUNCTION] RandomAutomaton::nextBytes(Random, array) -> void - * Source: java/util/Random.main.lsl:333 - */ - public void nextBytes(byte[] bytes) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - _nextBytes(bytes, bytes.length); - } - } - - /** - * [FUNCTION] RandomAutomaton::nextDouble(Random) -> double - * Source: java/util/Random.main.lsl:339 - */ - public double nextDouble() { - double result = 0.0d; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = Engine.makeSymbolicDouble(); - Engine.assume(0.0d <= result); - Engine.assume(result < 1.0d); - } - return result; - } - - /** - * [FUNCTION] RandomAutomaton::nextFloat(Random) -> float - * Source: java/util/Random.main.lsl:348 - */ - public float nextFloat() { - float result = 0.0f; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = Engine.makeSymbolicFloat(); - Engine.assume(0.0f <= result); - Engine.assume(result < 1.0f); - } - return result; - } - - /** - * [FUNCTION] RandomAutomaton::nextGaussian(Random) -> double - * Source: java/util/Random.main.lsl:357 - */ - public synchronized double nextGaussian() { - double result = 0.0d; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = Engine.makeSymbolicDouble(); - final boolean isNaN = result != result; - Engine.assume(!isNaN); - } - return result; - } - - /** - * [FUNCTION] RandomAutomaton::nextInt(Random) -> int - * Source: java/util/Random.main.lsl:365 - */ - public int nextInt() { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = Engine.makeSymbolicInt(); - } - return result; - } - - /** - * [FUNCTION] RandomAutomaton::nextInt(Random, int) -> int - * Source: java/util/Random.main.lsl:371 - */ - public int nextInt(int bound) { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (bound <= 0) { - throw new IllegalArgumentException("bound must be positive"); - } - result = Engine.makeSymbolicInt(); - Engine.assume(0 <= result); - Engine.assume(result < bound); - } - return result; - } - - /** - * [FUNCTION] RandomAutomaton::nextLong(Random) -> long - * Source: java/util/Random.main.lsl:383 - */ - public long nextLong() { - long result = 0L; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = Engine.makeSymbolicLong(); - } - return result; - } - - /** - * [FUNCTION] RandomAutomaton::setSeed(Random, long) -> void - * Source: java/util/Random.main.lsl:389 - */ - public synchronized void setSeed(long seed) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - Engine.assume(true); - } - } - - /** - * [FUNCTION] RandomAutomaton::readObject(ObjectInputStream) -> void - * Source: java/util/Random.main.lsl:397 - */ - private void readObject(ObjectInputStream s) throws java.io.IOException, - java.lang.ClassNotFoundException { - /* body */ { - LibSLRuntime.not_implemented(/* no serialization support */); - } - } - - /** - * [FUNCTION] RandomAutomaton::writeObject(ObjectOutputStream) -> void - * Source: java/util/Random.main.lsl:403 - */ - private synchronized void writeObject(ObjectOutputStream s) throws java.io.IOException { - /* body */ { - LibSLRuntime.not_implemented(/* no serialization support */); - } - } - - public static final class __$lsl_States { - public static final byte Allocated = (byte) 0; - - public static final byte Initialized = (byte) 1; - } - - @Approximate(Random.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/RandomImpl.java b/approximations/src/main/java/generated/java/util/RandomImpl.java new file mode 100644 index 00000000..880252f6 --- /dev/null +++ b/approximations/src/main/java/generated/java/util/RandomImpl.java @@ -0,0 +1,237 @@ +package generated.java.util; + +import generated.java.util.stream.DoubleStreamImpl; +import generated.java.util.stream.IntStreamImpl; +import generated.java.util.stream.LongStreamImpl; +import generated.runtime.LibSLGlobals; + +import java.io.*; +import java.lang.IllegalArgumentException; +import java.util.stream.DoubleStream; +import java.util.stream.IntStream; +import java.util.stream.LongStream; +import org.jacodb.approximation.annotation.Approximate; +import org.usvm.api.Engine; +import runtime.LibSLRuntime; + +@SuppressWarnings("unused") +@Approximate(java.util.Random.class) +public class RandomImpl implements Serializable { + + @Serial + private static final long serialVersionUID = 3905348978240129619L; + + @Serial + private static final ObjectStreamField[] serialPersistentFields = {}; + + static { + Engine.assume(true); + } + + public RandomImpl() { + Engine.assume(true); + } + + public RandomImpl(long seed) { + Engine.assume(true); + } + + private int[] _generateRandomIntegerArrayWithBounds(int size, int randomNumberOrigin, int randomNumberBound) { + int[] result = Engine.makeSymbolicIntArray(size); + for (int i = 0; i < size; i++) { + int item = result[i]; + Engine.assume(item >= randomNumberOrigin); + Engine.assume(item < randomNumberBound); + } + return result; + } + + private long[] _generateRandomLongArrayWithBounds(int size, long randomNumberOrigin, long randomNumberBound) { + long[] result = Engine.makeSymbolicLongArray(size); + for (int i = 0; i < size; i++) { + long item = result[i]; + Engine.assume(item >= randomNumberOrigin); + Engine.assume(item < randomNumberBound); + } + return result; + } + + private double[] _generateRandomDoubleArrayWithBounds(int size, double randomNumberOrigin, double randomNumberBound) { + double[] result = Engine.makeSymbolicDoubleArray(size); + for (int i = 0; i < size; i++) { + double item = result[i]; + Engine.assume(item >= randomNumberOrigin); + Engine.assume(item < randomNumberBound); + } + return result; + } + + public DoubleStream doubles() { + double[] items = _generateRandomDoubleArrayWithBounds(LibSLGlobals.RANDOM_STREAM_SIZE_MAX, 0, 1); + return new DoubleStreamImpl(items); + } + + public DoubleStream doubles(double randomNumberOrigin, double randomNumberBound) { + if (randomNumberOrigin >= randomNumberBound) + throw new IllegalArgumentException(); + + double[] items = _generateRandomDoubleArrayWithBounds(LibSLGlobals.RANDOM_STREAM_SIZE_MAX, randomNumberOrigin, randomNumberBound); + return new DoubleStreamImpl(items); + } + + public DoubleStream doubles(long streamSize) { + int size = (int) streamSize; + if (size < 0) + throw new IllegalArgumentException(); + + if (size > LibSLGlobals.RANDOM_STREAM_SIZE_MAX) + size = LibSLGlobals.RANDOM_STREAM_SIZE_MAX; + return new DoubleStreamImpl(Engine.makeSymbolicDoubleArray(size)); + } + + public DoubleStream doubles(long streamSize, double randomNumberOrigin, double randomNumberBound) { + int size = (int) streamSize; + if (size < 0) + throw new IllegalArgumentException(); + + if (randomNumberOrigin >= randomNumberBound) + throw new IllegalArgumentException(); + + if (size > LibSLGlobals.RANDOM_STREAM_SIZE_MAX) + size = LibSLGlobals.RANDOM_STREAM_SIZE_MAX; + + double[] items = _generateRandomDoubleArrayWithBounds(size, randomNumberOrigin, randomNumberBound); + return new DoubleStreamImpl(items); + } + + public IntStream ints() { + int[] items = Engine.makeSymbolicIntArray(LibSLGlobals.RANDOM_STREAM_SIZE_MAX); + return new IntStreamImpl(items); + } + + public IntStream ints(int randomNumberOrigin, int randomNumberBound) { + if (randomNumberOrigin >= randomNumberBound) + throw new IllegalArgumentException(); + + int[] items = _generateRandomIntegerArrayWithBounds(LibSLGlobals.RANDOM_STREAM_SIZE_MAX, randomNumberOrigin, randomNumberBound); + return new IntStreamImpl(items); + } + + public IntStream ints(long streamSize) { + int size = (int) streamSize; + if (size < 0) + throw new IllegalArgumentException(); + + if (size > LibSLGlobals.RANDOM_STREAM_SIZE_MAX) + size = LibSLGlobals.RANDOM_STREAM_SIZE_MAX; + + int[] items = Engine.makeSymbolicIntArray(size); + return new IntStreamImpl(items); + } + + public IntStream ints(long streamSize, int randomNumberOrigin, int randomNumberBound) { + int size = ((int) streamSize); + if (size < 0) + throw new IllegalArgumentException(); + + if (randomNumberOrigin >= randomNumberBound) + throw new IllegalArgumentException(); + + if (size > LibSLGlobals.RANDOM_STREAM_SIZE_MAX) + size = LibSLGlobals.RANDOM_STREAM_SIZE_MAX; + + int[] items = _generateRandomIntegerArrayWithBounds(size, randomNumberOrigin, randomNumberBound); + return new IntStreamImpl(items); + } + + public LongStream longs() { + long[] items = Engine.makeSymbolicLongArray(LibSLGlobals.RANDOM_STREAM_SIZE_MAX); + return new LongStreamImpl(items); + } + + public LongStream longs(long streamSize) { + int size = (int) streamSize; + if (size < 0) + throw new IllegalArgumentException(); + + if (size > LibSLGlobals.RANDOM_STREAM_SIZE_MAX) + size = LibSLGlobals.RANDOM_STREAM_SIZE_MAX; + + return new LongStreamImpl(Engine.makeSymbolicLongArray(size)); + } + + public LongStream longs(long randomNumberOrigin, long randomNumberBound) { + if (randomNumberOrigin >= randomNumberBound) + throw new IllegalArgumentException(); + + long[] items = _generateRandomLongArrayWithBounds(LibSLGlobals.RANDOM_STREAM_SIZE_MAX, randomNumberOrigin, randomNumberBound); + return new LongStreamImpl(items); + } + + public LongStream longs(long streamSize, long randomNumberOrigin, long randomNumberBound) { + int size = (int) streamSize; + if (size < 0) + throw new IllegalArgumentException(); + + if (randomNumberOrigin >= randomNumberBound) + throw new IllegalArgumentException(); + + if (size > LibSLGlobals.RANDOM_STREAM_SIZE_MAX) + size = LibSLGlobals.RANDOM_STREAM_SIZE_MAX; + + return new LongStreamImpl(_generateRandomLongArrayWithBounds(size, randomNumberOrigin, randomNumberBound)); + } + + public boolean nextBoolean() { + return Engine.makeSymbolicBoolean(); + } + + public void nextBytes(byte[] bytes) { + int numBytes = bytes.length; + byte[] symbolicArray = Engine.makeSymbolicByteArray(numBytes); + LibSLRuntime.ArrayActions.copy(symbolicArray, 0, bytes, 0, numBytes); + } + + public double nextDouble() { + double result = Engine.makeSymbolicDouble(); + Engine.assume(0.0d <= result); + Engine.assume(result < 1.0d); + return result; + } + + public float nextFloat() { + float result = Engine.makeSymbolicFloat(); + Engine.assume(0.0f <= result); + Engine.assume(result < 1.0f); + return result; + } + + public synchronized double nextGaussian() { + double result = Engine.makeSymbolicDouble(); + boolean isNaN = result != result; + Engine.assume(!isNaN); + return result; + } + + public int nextInt() { + return Engine.makeSymbolicInt(); + } + + public int nextInt(int bound) { + if (bound <= 0) + throw new IllegalArgumentException("bound must be positive"); + + int result = Engine.makeSymbolicInt(); + Engine.assume(0 <= result); + Engine.assume(result < bound); + return result; + } + + public long nextLong() { + return Engine.makeSymbolicLong(); + } + + public synchronized void setSeed(long seed) { + Engine.assume(true); + } +} diff --git a/approximations/src/main/java/generated/java/util/Spliterators.java b/approximations/src/main/java/generated/java/util/Spliterators.java deleted file mode 100644 index 355b29a9..00000000 --- a/approximations/src/main/java/generated/java/util/Spliterators.java +++ /dev/null @@ -1,204 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/Spliterators.lsl:18 -// - java/util/Spliterators.main.lsl:22 -// -package generated.java.util; - -import generated.runtime.LibSLGlobals; -import java.lang.Object; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.Spliterator; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; - -/** - * SpliteratorsAutomaton for Spliterators ~> java.util.Spliterators - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(java.util.Spliterators.class) -public final class Spliterators implements LibSLRuntime.Automaton { - static { - Engine.assume(true); - } - - @LibSLRuntime.AutomatonConstructor - public Spliterators(Void __$lsl_token, final byte p0) { - } - - @LibSLRuntime.AutomatonConstructor - public Spliterators(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Allocated); - } - - /** - * [CONSTRUCTOR] SpliteratorsAutomaton::(Spliterators) -> void - * Source: java/util/Spliterators.main.lsl:69 - */ - private Spliterators() { - this((Void) null); - /* body */ { - } - } - - /** - * [FUNCTION] SpliteratorsAutomaton::spliterator(array, int) -> Spliterator - * Source: java/util/Spliterators.main.lsl:147 - */ - public static Spliterator spliterator(Object[] arr, int additionalCharacteristics) { - Spliterator result = null; - /* body */ { - result = (stub.java.util.Spliterators_ArraySpliterator) ((Object) new Spliterators_ArraySpliterator((Void) null, - /* state = */ Spliterators_ArraySpliterator.__$lsl_States.Initialized, - /* array = */ arr, - /* index = */ 0, - /* fence = */ arr.length, - /* characteristics = */ additionalCharacteristics | LibSLGlobals.SPLITERATOR_SIZED | LibSLGlobals.SPLITERATOR_SUBSIZED - )); - } - return result; - } - - /** - * [FUNCTION] SpliteratorsAutomaton::spliterator(array, int, int, int) -> Spliterator - * Source: java/util/Spliterators.main.lsl:158 - */ - public static Spliterator spliterator(Object[] arr, int fromIndex, int toIndex, - int additionalCharacteristics) { - Spliterator result = null; - /* body */ { - result = (stub.java.util.Spliterators_ArraySpliterator) ((Object) new Spliterators_ArraySpliterator((Void) null, - /* state = */ Spliterators_ArraySpliterator.__$lsl_States.Initialized, - /* array = */ arr, - /* index = */ fromIndex, - /* fence = */ toIndex, - /* characteristics = */ additionalCharacteristics | LibSLGlobals.SPLITERATOR_SIZED | LibSLGlobals.SPLITERATOR_SUBSIZED - )); - } - return result; - } - - /** - * [FUNCTION] SpliteratorsAutomaton::spliterator(array, int) -> Spliterator_OfDouble - * Source: java/util/Spliterators.main.lsl:190 - */ - public static Spliterator.OfDouble spliterator(double[] arr, int additionalCharacteristics) { - Spliterator.OfDouble result = null; - /* body */ { - result = (stub.java.util.Spliterators_DoubleArraySpliterator) ((Object) new Spliterators_DoubleArraySpliterator((Void) null, - /* state = */ Spliterators_DoubleArraySpliterator.__$lsl_States.Initialized, - /* array = */ arr, - /* index = */ 0, - /* fence = */ arr.length, - /* characteristics = */ additionalCharacteristics | LibSLGlobals.SPLITERATOR_SIZED | LibSLGlobals.SPLITERATOR_SUBSIZED - )); - } - return result; - } - - /** - * [FUNCTION] SpliteratorsAutomaton::spliterator(array, int, int, int) -> Spliterator_OfDouble - * Source: java/util/Spliterators.main.lsl:201 - */ - public static Spliterator.OfDouble spliterator(double[] arr, int fromIndex, int toIndex, - int additionalCharacteristics) { - Spliterator.OfDouble result = null; - /* body */ { - result = (stub.java.util.Spliterators_DoubleArraySpliterator) ((Object) new Spliterators_DoubleArraySpliterator((Void) null, - /* state = */ Spliterators_DoubleArraySpliterator.__$lsl_States.Initialized, - /* array = */ arr, - /* index = */ fromIndex, - /* fence = */ toIndex, - /* characteristics = */ additionalCharacteristics | LibSLGlobals.SPLITERATOR_SIZED | LibSLGlobals.SPLITERATOR_SUBSIZED - )); - } - return result; - } - - /** - * [FUNCTION] SpliteratorsAutomaton::spliterator(array, int) -> Spliterator_OfInt - * Source: java/util/Spliterators.main.lsl:212 - */ - public static Spliterator.OfInt spliterator(int[] arr, int additionalCharacteristics) { - Spliterator.OfInt result = null; - /* body */ { - result = (stub.java.util.Spliterators_IntArraySpliterator) ((Object) new Spliterators_IntArraySpliterator((Void) null, - /* state = */ Spliterators_IntArraySpliterator.__$lsl_States.Initialized, - /* array = */ arr, - /* index = */ 0, - /* fence = */ arr.length, - /* characteristics = */ additionalCharacteristics | LibSLGlobals.SPLITERATOR_SIZED | LibSLGlobals.SPLITERATOR_SUBSIZED - )); - } - return result; - } - - /** - * [FUNCTION] SpliteratorsAutomaton::spliterator(array, int, int, int) -> Spliterator_OfInt - * Source: java/util/Spliterators.main.lsl:223 - */ - public static Spliterator.OfInt spliterator(int[] arr, int fromIndex, int toIndex, - int additionalCharacteristics) { - Spliterator.OfInt result = null; - /* body */ { - result = (stub.java.util.Spliterators_IntArraySpliterator) ((Object) new Spliterators_IntArraySpliterator((Void) null, - /* state = */ Spliterators_IntArraySpliterator.__$lsl_States.Initialized, - /* array = */ arr, - /* index = */ fromIndex, - /* fence = */ toIndex, - /* characteristics = */ additionalCharacteristics | LibSLGlobals.SPLITERATOR_SIZED | LibSLGlobals.SPLITERATOR_SUBSIZED - )); - } - return result; - } - - /** - * [FUNCTION] SpliteratorsAutomaton::spliterator(array, int) -> Spliterator_OfLong - * Source: java/util/Spliterators.main.lsl:234 - */ - public static Spliterator.OfLong spliterator(long[] arr, int additionalCharacteristics) { - Spliterator.OfLong result = null; - /* body */ { - result = (stub.java.util.Spliterators_LongArraySpliterator) ((Object) new Spliterators_LongArraySpliterator((Void) null, - /* state = */ Spliterators_LongArraySpliterator.__$lsl_States.Initialized, - /* array = */ arr, - /* index = */ 0, - /* fence = */ arr.length, - /* characteristics = */ additionalCharacteristics | LibSLGlobals.SPLITERATOR_SIZED | LibSLGlobals.SPLITERATOR_SUBSIZED - )); - } - return result; - } - - /** - * [FUNCTION] SpliteratorsAutomaton::spliterator(array, int, int, int) -> Spliterator_OfLong - * Source: java/util/Spliterators.main.lsl:245 - */ - public static Spliterator.OfLong spliterator(long[] arr, int fromIndex, int toIndex, - int additionalCharacteristics) { - Spliterator.OfLong result = null; - /* body */ { - result = (stub.java.util.Spliterators_LongArraySpliterator) ((Object) new Spliterators_LongArraySpliterator((Void) null, - /* state = */ Spliterators_LongArraySpliterator.__$lsl_States.Initialized, - /* array = */ arr, - /* index = */ fromIndex, - /* fence = */ toIndex, - /* characteristics = */ additionalCharacteristics | LibSLGlobals.SPLITERATOR_SIZED | LibSLGlobals.SPLITERATOR_SUBSIZED - )); - } - return result; - } - - public static final class __$lsl_States { - public static final byte Allocated = (byte) 0; - } - - @Approximate(Spliterators.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/SpliteratorsImpl.java b/approximations/src/main/java/generated/java/util/SpliteratorsImpl.java new file mode 100644 index 00000000..93745e95 --- /dev/null +++ b/approximations/src/main/java/generated/java/util/SpliteratorsImpl.java @@ -0,0 +1,58 @@ +package generated.java.util; + +import generated.java.util.array.ArraySpliteratorImpl; +import generated.java.util.array.DoubleArraySpliteratorImpl; +import generated.java.util.array.IntArraySpliteratorImpl; +import generated.java.util.array.LongArraySpliteratorImpl; +import generated.runtime.LibSLGlobals; +import java.lang.Object; +import java.util.Spliterator; +import org.jacodb.approximation.annotation.Approximate; +import org.usvm.api.Engine; + +@SuppressWarnings("unused") +@Approximate(java.util.Spliterators.class) +public final class SpliteratorsImpl { + + static { + Engine.assume(true); + } + + private SpliteratorsImpl() { } + + public static final int _characteristics = LibSLGlobals.SPLITERATOR_SIZED | LibSLGlobals.SPLITERATOR_SUBSIZED; + + @SuppressWarnings("unchecked") + public static Spliterator spliterator(Object[] arr, int additionalCharacteristics) { + return new ArraySpliteratorImpl<>((T[]) arr, additionalCharacteristics); + } + + @SuppressWarnings("unchecked") + public static Spliterator spliterator(Object[] arr, int fromIndex, int toIndex, int additionalCharacteristics) { + return new ArraySpliteratorImpl<>((T[]) arr, fromIndex, toIndex, additionalCharacteristics); + } + + public static Spliterator.OfDouble spliterator(double[] arr, int additionalCharacteristics) { + return new DoubleArraySpliteratorImpl(arr, additionalCharacteristics); + } + + public static Spliterator.OfDouble spliterator(double[] arr, int fromIndex, int toIndex, int additionalCharacteristics) { + return new DoubleArraySpliteratorImpl(arr, fromIndex, toIndex, additionalCharacteristics); + } + + public static Spliterator.OfInt spliterator(int[] arr, int additionalCharacteristics) { + return new IntArraySpliteratorImpl(arr, additionalCharacteristics); + } + + public static Spliterator.OfInt spliterator(int[] arr, int fromIndex, int toIndex, int additionalCharacteristics) { + return new IntArraySpliteratorImpl(arr, fromIndex, toIndex, additionalCharacteristics); + } + + public static Spliterator.OfLong spliterator(long[] arr, int additionalCharacteristics) { + return new LongArraySpliteratorImpl(arr, additionalCharacteristics); + } + + public static Spliterator.OfLong spliterator(long[] arr, int fromIndex, int toIndex, int additionalCharacteristics) { + return new LongArraySpliteratorImpl(arr, fromIndex, toIndex, additionalCharacteristics); + } +} diff --git a/approximations/src/main/java/generated/java/util/Spliterators_ArraySpliterator.java b/approximations/src/main/java/generated/java/util/Spliterators_ArraySpliterator.java deleted file mode 100644 index 219cc8a5..00000000 --- a/approximations/src/main/java/generated/java/util/Spliterators_ArraySpliterator.java +++ /dev/null @@ -1,256 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/Spliterators.lsl:44 -// - java/util/Spliterators.ArraySpliterator.lsl:21 -// -package generated.java.util; - -import generated.runtime.LibSLGlobals; -import java.lang.IllegalStateException; -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.Comparator; -import java.util.Spliterator; -import java.util.function.Consumer; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; - -/** - * Spliterators_ArraySpliteratorAutomaton for Spliterators_ArraySpliterator ~> java.util.Spliterators_ArraySpliterator - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(stub.java.util.Spliterators_ArraySpliterator.class) -public final class Spliterators_ArraySpliterator implements LibSLRuntime.Automaton, Spliterator { - static { - Engine.assume(true); - } - - private byte __$lsl_state = __$lsl_States.Allocated; - - public Object[] array; - - public int index; - - public int fence; - - public int characteristics; - - @LibSLRuntime.AutomatonConstructor - public Spliterators_ArraySpliterator(Void __$lsl_token, final byte p0, final Object[] p1, - final int p2, final int p3, final int p4) { - this.__$lsl_state = p0; - this.array = p1; - this.index = p2; - this.fence = p3; - this.characteristics = p4; - } - - @LibSLRuntime.AutomatonConstructor - public Spliterators_ArraySpliterator(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Allocated, null, 0, 0, 0); - } - - /** - * [CONSTRUCTOR] Spliterators_ArraySpliteratorAutomaton::(Spliterators_ArraySpliterator, array, int) -> void - * Source: java/util/Spliterators.ArraySpliterator.lsl:79 - */ - public Spliterators_ArraySpliterator(Object[] arr, int additionalCharacteristics) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - this.array = arr; - this.index = 0; - this.fence = arr.length; - this.characteristics = additionalCharacteristics | LibSLGlobals.SPLITERATOR_SIZED | LibSLGlobals.SPLITERATOR_SUBSIZED; - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [CONSTRUCTOR] Spliterators_ArraySpliteratorAutomaton::(Spliterators_ArraySpliterator, array, int, int, int) -> void - * Source: java/util/Spliterators.ArraySpliterator.lsl:91 - */ - public Spliterators_ArraySpliterator(Object[] arr, int origin, int pFence, - int additionalCharacteristics) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - this.array = arr; - this.index = origin; - this.fence = pFence; - this.characteristics = additionalCharacteristics | LibSLGlobals.SPLITERATOR_SIZED | LibSLGlobals.SPLITERATOR_SUBSIZED; - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [SUBROUTINE] Spliterators_ArraySpliteratorAutomaton::_hasCharacteristics(int) -> boolean - * Source: java/util/Spliterators.ArraySpliterator.lsl:71 - */ - private boolean _hasCharacteristics(int _characteristics) { - boolean result = false; - /* body */ { - result = (this.characteristics & _characteristics) == _characteristics; - } - return result; - } - - /** - * [FUNCTION] Spliterators_ArraySpliteratorAutomaton::characteristics(Spliterators_ArraySpliterator) -> int - * Source: java/util/Spliterators.ArraySpliterator.lsl:107 - */ - public int characteristics() { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.characteristics; - } - return result; - } - - /** - * [FUNCTION] Spliterators_ArraySpliteratorAutomaton::estimateSize(Spliterators_ArraySpliterator) -> long - * Source: java/util/Spliterators.ArraySpliterator.lsl:113 - */ - public long estimateSize() { - long result = 0L; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = ((long) (this.fence - this.index)); - } - return result; - } - - /** - * [FUNCTION] Spliterators_ArraySpliteratorAutomaton::forEachRemaining(Spliterators_ArraySpliterator, Consumer) -> void - * Source: java/util/Spliterators.ArraySpliterator.lsl:143 - */ - public void forEachRemaining(Consumer _action) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (_action == null) { - throw new NullPointerException(); - } - final Object[] a = this.array; - int hi = this.fence; - int i = this.index; - this.index = hi; - for (i = i; i < hi; i += 1) { - final Object item = a[i]; - _action.accept(item); - } - ; - } - } - - /** - * [FUNCTION] Spliterators_ArraySpliteratorAutomaton::getComparator(Spliterators_ArraySpliterator) -> Comparator - * Source: java/util/Spliterators.ArraySpliterator.lsl:158 - */ - public Comparator getComparator() { - Comparator result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (_hasCharacteristics(LibSLGlobals.SPLITERATOR_SORTED)) { - result = null; - } else { - throw new IllegalStateException(); - } - } - return result; - } - - /** - * [FUNCTION] Spliterators_ArraySpliteratorAutomaton::getExactSizeIfKnown(Spliterators_ArraySpliterator) -> long - * Source: java/util/Spliterators.ArraySpliterator.lsl:167 - */ - public long getExactSizeIfKnown() { - long result = 0L; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = ((long) (this.fence - this.index)); - } - return result; - } - - /** - * [FUNCTION] Spliterators_ArraySpliteratorAutomaton::hasCharacteristics(Spliterators_ArraySpliterator, int) -> boolean - * Source: java/util/Spliterators.ArraySpliterator.lsl:173 - */ - public boolean hasCharacteristics(int _characteristics) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = _hasCharacteristics(_characteristics); - } - return result; - } - - /** - * [FUNCTION] Spliterators_ArraySpliteratorAutomaton::tryAdvance(Spliterators_ArraySpliterator, Consumer) -> boolean - * Source: java/util/Spliterators.ArraySpliterator.lsl:203 - */ - public boolean tryAdvance(Consumer _action) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (_action == null) { - throw new NullPointerException(); - } - final int hi = this.fence; - final int i = this.index; - if (i < hi) { - this.index = i + 1; - final Object item = array[i]; - _action.accept(item); - result = true; - } else { - result = false; - } - } - return result; - } - - /** - * [FUNCTION] Spliterators_ArraySpliteratorAutomaton::trySplit(Spliterators_ArraySpliterator) -> Spliterator - * Source: java/util/Spliterators.ArraySpliterator.lsl:218 - */ - public Spliterator trySplit() { - Spliterator result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final int hi = this.fence; - final int lo = this.index; - final int mid = (lo + hi) >>> 1; - if (lo >= mid) { - result = null; - } else { - result = (stub.java.util.Spliterators_ArraySpliterator) ((Object) new Spliterators_ArraySpliterator((Void) null, - /* state = */ Spliterators_ArraySpliterator.__$lsl_States.Initialized, - /* array = */ this.array, - /* index = */ lo, - /* fence = */ mid, - /* characteristics = */ this.characteristics - )); - } - this.index = mid; - } - return result; - } - - public static final class __$lsl_States { - public static final byte Allocated = (byte) 0; - - public static final byte Initialized = (byte) 1; - } - - @Approximate(Spliterators_ArraySpliterator.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/Spliterators_DoubleArraySpliterator.java b/approximations/src/main/java/generated/java/util/Spliterators_DoubleArraySpliterator.java deleted file mode 100644 index 599f5e59..00000000 --- a/approximations/src/main/java/generated/java/util/Spliterators_DoubleArraySpliterator.java +++ /dev/null @@ -1,304 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/Spliterators.lsl:53 -// - java/util/Spliterators.DoubleArraySpliterator.lsl:21 -// -package generated.java.util; - -import generated.runtime.LibSLGlobals; -import java.lang.IllegalStateException; -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.Comparator; -import java.util.Spliterator; -import java.util.function.Consumer; -import java.util.function.DoubleConsumer; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; - -/** - * Spliterators_DoubleArraySpliteratorAutomaton for Spliterators_DoubleArraySpliterator ~> java.util.Spliterators_DoubleArraySpliterator - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(stub.java.util.Spliterators_DoubleArraySpliterator.class) -public final class Spliterators_DoubleArraySpliterator implements LibSLRuntime.Automaton, Spliterator.OfDouble { - static { - Engine.assume(true); - } - - private byte __$lsl_state = __$lsl_States.Allocated; - - public double[] array; - - public int index; - - public int fence; - - public int characteristics; - - @LibSLRuntime.AutomatonConstructor - public Spliterators_DoubleArraySpliterator(Void __$lsl_token, final byte p0, final double[] p1, - final int p2, final int p3, final int p4) { - this.__$lsl_state = p0; - this.array = p1; - this.index = p2; - this.fence = p3; - this.characteristics = p4; - } - - @LibSLRuntime.AutomatonConstructor - public Spliterators_DoubleArraySpliterator(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Allocated, null, 0, 0, 0); - } - - /** - * [CONSTRUCTOR] Spliterators_DoubleArraySpliteratorAutomaton::(Spliterators_DoubleArraySpliterator, array, int) -> void - * Source: java/util/Spliterators.DoubleArraySpliterator.lsl:81 - */ - public Spliterators_DoubleArraySpliterator(double[] arr, int additionalCharacteristics) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - this.array = arr; - this.index = 0; - this.fence = arr.length; - this.characteristics = additionalCharacteristics | LibSLGlobals.SPLITERATOR_SIZED | LibSLGlobals.SPLITERATOR_SUBSIZED; - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [CONSTRUCTOR] Spliterators_DoubleArraySpliteratorAutomaton::(Spliterators_DoubleArraySpliterator, array, int, int, int) -> void - * Source: java/util/Spliterators.DoubleArraySpliterator.lsl:93 - */ - public Spliterators_DoubleArraySpliterator(double[] arr, int origin, int pFence, - int additionalCharacteristics) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - this.array = arr; - this.index = origin; - this.fence = pFence; - this.characteristics = additionalCharacteristics | LibSLGlobals.SPLITERATOR_SIZED | LibSLGlobals.SPLITERATOR_SUBSIZED; - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [SUBROUTINE] Spliterators_DoubleArraySpliteratorAutomaton::_hasCharacteristics(int) -> boolean - * Source: java/util/Spliterators.DoubleArraySpliterator.lsl:73 - */ - private boolean _hasCharacteristics(int _characteristics) { - boolean result = false; - /* body */ { - result = (this.characteristics & _characteristics) == _characteristics; - } - return result; - } - - /** - * [FUNCTION] Spliterators_DoubleArraySpliteratorAutomaton::characteristics(Spliterators_DoubleArraySpliterator) -> int - * Source: java/util/Spliterators.DoubleArraySpliterator.lsl:109 - */ - public int characteristics() { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.characteristics; - } - return result; - } - - /** - * [FUNCTION] Spliterators_DoubleArraySpliteratorAutomaton::estimateSize(Spliterators_DoubleArraySpliterator) -> long - * Source: java/util/Spliterators.DoubleArraySpliterator.lsl:115 - */ - public long estimateSize() { - long result = 0L; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = ((long) (this.fence - this.index)); - } - return result; - } - - /** - * [FUNCTION] Spliterators_DoubleArraySpliteratorAutomaton::forEachRemaining(Spliterators_DoubleArraySpliterator, DoubleConsumer) -> void - * Source: java/util/Spliterators.DoubleArraySpliterator.lsl:145 - */ - public void forEachRemaining(DoubleConsumer _action) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (_action == null) { - throw new NullPointerException(); - } - final double[] a = this.array; - int hi = this.fence; - int i = this.index; - this.index = hi; - for (i = i; i < hi; i += 1) { - final double item = a[i]; - _action.accept(item); - } - ; - } - } - - /** - * [FUNCTION] Spliterators_DoubleArraySpliteratorAutomaton::forEachRemaining(Spliterators_DoubleArraySpliterator, Consumer) -> void - * Source: java/util/Spliterators.DoubleArraySpliterator.lsl:151 - */ - public void forEachRemaining(Consumer _action) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (_action == null) { - throw new NullPointerException(); - } - final double[] a = this.array; - int hi = this.fence; - int i = this.index; - this.index = hi; - for (i = i; i < hi; i += 1) { - final double item = a[i]; - _action.accept(item); - } - ; - } - } - - /** - * [FUNCTION] Spliterators_DoubleArraySpliteratorAutomaton::getComparator(Spliterators_DoubleArraySpliterator) -> Comparator - * Source: java/util/Spliterators.DoubleArraySpliterator.lsl:166 - */ - public Comparator getComparator() { - Comparator result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (_hasCharacteristics(LibSLGlobals.SPLITERATOR_SORTED)) { - result = null; - } else { - throw new IllegalStateException(); - } - } - return result; - } - - /** - * [FUNCTION] Spliterators_DoubleArraySpliteratorAutomaton::getExactSizeIfKnown(Spliterators_DoubleArraySpliterator) -> long - * Source: java/util/Spliterators.DoubleArraySpliterator.lsl:175 - */ - public long getExactSizeIfKnown() { - long result = 0L; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = ((long) (this.fence - this.index)); - } - return result; - } - - /** - * [FUNCTION] Spliterators_DoubleArraySpliteratorAutomaton::hasCharacteristics(Spliterators_DoubleArraySpliterator, int) -> boolean - * Source: java/util/Spliterators.DoubleArraySpliterator.lsl:181 - */ - public boolean hasCharacteristics(int _characteristics) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = _hasCharacteristics(_characteristics); - } - return result; - } - - /** - * [FUNCTION] Spliterators_DoubleArraySpliteratorAutomaton::tryAdvance(Spliterators_DoubleArraySpliterator, DoubleConsumer) -> boolean - * Source: java/util/Spliterators.DoubleArraySpliterator.lsl:211 - */ - public boolean tryAdvance(DoubleConsumer _action) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (_action == null) { - throw new NullPointerException(); - } - final int hi = this.fence; - final int i = this.index; - if (i < hi) { - this.index = i + 1; - final double item = array[i]; - _action.accept(item); - result = true; - } else { - result = false; - } - } - return result; - } - - /** - * [FUNCTION] Spliterators_DoubleArraySpliteratorAutomaton::tryAdvance(Spliterators_DoubleArraySpliterator, Consumer) -> boolean - * Source: java/util/Spliterators.DoubleArraySpliterator.lsl:217 - */ - public boolean tryAdvance(Consumer _action) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (_action == null) { - throw new NullPointerException(); - } - final int hi = this.fence; - final int i = this.index; - if (i < hi) { - this.index = i + 1; - final double item = array[i]; - _action.accept(item); - result = true; - } else { - result = false; - } - } - return result; - } - - /** - * [FUNCTION] Spliterators_DoubleArraySpliteratorAutomaton::trySplit(Spliterators_DoubleArraySpliterator) -> Spliterator_OfDouble - * Source: java/util/Spliterators.DoubleArraySpliterator.lsl:232 - */ - public Spliterator.OfDouble trySplit() { - Spliterator.OfDouble result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final int hi = this.fence; - final int lo = this.index; - final int mid = (lo + hi) >>> 1; - if (lo >= mid) { - result = null; - } else { - result = (stub.java.util.Spliterators_DoubleArraySpliterator) ((Object) new Spliterators_DoubleArraySpliterator((Void) null, - /* state = */ Spliterators_DoubleArraySpliterator.__$lsl_States.Initialized, - /* array = */ this.array, - /* index = */ lo, - /* fence = */ mid, - /* characteristics = */ this.characteristics - )); - } - this.index = mid; - } - return result; - } - - public static final class __$lsl_States { - public static final byte Allocated = (byte) 0; - - public static final byte Initialized = (byte) 1; - } - - @Approximate(Spliterators_DoubleArraySpliterator.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/Spliterators_IntArraySpliterator.java b/approximations/src/main/java/generated/java/util/Spliterators_IntArraySpliterator.java deleted file mode 100644 index c0d80fc7..00000000 --- a/approximations/src/main/java/generated/java/util/Spliterators_IntArraySpliterator.java +++ /dev/null @@ -1,304 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/Spliterators.lsl:62 -// - java/util/Spliterators.IntArraySpliterator.lsl:21 -// -package generated.java.util; - -import generated.runtime.LibSLGlobals; -import java.lang.IllegalStateException; -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.Comparator; -import java.util.Spliterator; -import java.util.function.Consumer; -import java.util.function.IntConsumer; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; - -/** - * Spliterators_IntArraySpliteratorAutomaton for Spliterators_IntArraySpliterator ~> java.util.Spliterators_IntArraySpliterator - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(stub.java.util.Spliterators_IntArraySpliterator.class) -public final class Spliterators_IntArraySpliterator implements LibSLRuntime.Automaton, Spliterator.OfInt { - static { - Engine.assume(true); - } - - private byte __$lsl_state = __$lsl_States.Allocated; - - public int[] array; - - public int index; - - public int fence; - - public int characteristics; - - @LibSLRuntime.AutomatonConstructor - public Spliterators_IntArraySpliterator(Void __$lsl_token, final byte p0, final int[] p1, - final int p2, final int p3, final int p4) { - this.__$lsl_state = p0; - this.array = p1; - this.index = p2; - this.fence = p3; - this.characteristics = p4; - } - - @LibSLRuntime.AutomatonConstructor - public Spliterators_IntArraySpliterator(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Allocated, null, 0, 0, 0); - } - - /** - * [CONSTRUCTOR] Spliterators_IntArraySpliteratorAutomaton::(Spliterators_IntArraySpliterator, array, int) -> void - * Source: java/util/Spliterators.IntArraySpliterator.lsl:81 - */ - public Spliterators_IntArraySpliterator(int[] arr, int additionalCharacteristics) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - this.array = arr; - this.index = 0; - this.fence = arr.length; - this.characteristics = additionalCharacteristics | LibSLGlobals.SPLITERATOR_SIZED | LibSLGlobals.SPLITERATOR_SUBSIZED; - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [CONSTRUCTOR] Spliterators_IntArraySpliteratorAutomaton::(Spliterators_IntArraySpliterator, array, int, int, int) -> void - * Source: java/util/Spliterators.IntArraySpliterator.lsl:93 - */ - public Spliterators_IntArraySpliterator(int[] arr, int origin, int pFence, - int additionalCharacteristics) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - this.array = arr; - this.index = origin; - this.fence = pFence; - this.characteristics = additionalCharacteristics | LibSLGlobals.SPLITERATOR_SIZED | LibSLGlobals.SPLITERATOR_SUBSIZED; - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [SUBROUTINE] Spliterators_IntArraySpliteratorAutomaton::_hasCharacteristics(int) -> boolean - * Source: java/util/Spliterators.IntArraySpliterator.lsl:73 - */ - private boolean _hasCharacteristics(int _characteristics) { - boolean result = false; - /* body */ { - result = (this.characteristics & _characteristics) == _characteristics; - } - return result; - } - - /** - * [FUNCTION] Spliterators_IntArraySpliteratorAutomaton::characteristics(Spliterators_IntArraySpliterator) -> int - * Source: java/util/Spliterators.IntArraySpliterator.lsl:109 - */ - public int characteristics() { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.characteristics; - } - return result; - } - - /** - * [FUNCTION] Spliterators_IntArraySpliteratorAutomaton::estimateSize(Spliterators_IntArraySpliterator) -> long - * Source: java/util/Spliterators.IntArraySpliterator.lsl:115 - */ - public long estimateSize() { - long result = 0L; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = ((long) (this.fence - this.index)); - } - return result; - } - - /** - * [FUNCTION] Spliterators_IntArraySpliteratorAutomaton::forEachRemaining(Spliterators_IntArraySpliterator, Consumer) -> void - * Source: java/util/Spliterators.IntArraySpliterator.lsl:145 - */ - public void forEachRemaining(Consumer _action) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (_action == null) { - throw new NullPointerException(); - } - final int[] a = this.array; - int hi = this.fence; - int i = this.index; - this.index = hi; - for (i = i; i < hi; i += 1) { - final int item = a[i]; - _action.accept(item); - } - ; - } - } - - /** - * [FUNCTION] Spliterators_IntArraySpliteratorAutomaton::forEachRemaining(Spliterators_IntArraySpliterator, IntConsumer) -> void - * Source: java/util/Spliterators.IntArraySpliterator.lsl:151 - */ - public void forEachRemaining(IntConsumer _action) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (_action == null) { - throw new NullPointerException(); - } - final int[] a = this.array; - int hi = this.fence; - int i = this.index; - this.index = hi; - for (i = i; i < hi; i += 1) { - final int item = a[i]; - _action.accept(item); - } - ; - } - } - - /** - * [FUNCTION] Spliterators_IntArraySpliteratorAutomaton::getComparator(Spliterators_IntArraySpliterator) -> Comparator - * Source: java/util/Spliterators.IntArraySpliterator.lsl:166 - */ - public Comparator getComparator() { - Comparator result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (_hasCharacteristics(LibSLGlobals.SPLITERATOR_SORTED)) { - result = null; - } else { - throw new IllegalStateException(); - } - } - return result; - } - - /** - * [FUNCTION] Spliterators_IntArraySpliteratorAutomaton::getExactSizeIfKnown(Spliterators_IntArraySpliterator) -> long - * Source: java/util/Spliterators.IntArraySpliterator.lsl:175 - */ - public long getExactSizeIfKnown() { - long result = 0L; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = ((long) (this.fence - this.index)); - } - return result; - } - - /** - * [FUNCTION] Spliterators_IntArraySpliteratorAutomaton::hasCharacteristics(Spliterators_IntArraySpliterator, int) -> boolean - * Source: java/util/Spliterators.IntArraySpliterator.lsl:181 - */ - public boolean hasCharacteristics(int _characteristics) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = _hasCharacteristics(_characteristics); - } - return result; - } - - /** - * [FUNCTION] Spliterators_IntArraySpliteratorAutomaton::tryAdvance(Spliterators_IntArraySpliterator, IntConsumer) -> boolean - * Source: java/util/Spliterators.IntArraySpliterator.lsl:211 - */ - public boolean tryAdvance(IntConsumer _action) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (_action == null) { - throw new NullPointerException(); - } - final int hi = this.fence; - final int i = this.index; - if (i < hi) { - this.index = i + 1; - final int item = array[i]; - _action.accept(item); - result = true; - } else { - result = false; - } - } - return result; - } - - /** - * [FUNCTION] Spliterators_IntArraySpliteratorAutomaton::tryAdvance(Spliterators_IntArraySpliterator, Consumer) -> boolean - * Source: java/util/Spliterators.IntArraySpliterator.lsl:217 - */ - public boolean tryAdvance(Consumer _action) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (_action == null) { - throw new NullPointerException(); - } - final int hi = this.fence; - final int i = this.index; - if (i < hi) { - this.index = i + 1; - final int item = array[i]; - _action.accept(item); - result = true; - } else { - result = false; - } - } - return result; - } - - /** - * [FUNCTION] Spliterators_IntArraySpliteratorAutomaton::trySplit(Spliterators_IntArraySpliterator) -> Spliterator_OfInt - * Source: java/util/Spliterators.IntArraySpliterator.lsl:232 - */ - public Spliterator.OfInt trySplit() { - Spliterator.OfInt result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final int hi = this.fence; - final int lo = this.index; - final int mid = (lo + hi) >>> 1; - if (lo >= mid) { - result = null; - } else { - result = (stub.java.util.Spliterators_IntArraySpliterator) ((Object) new Spliterators_IntArraySpliterator((Void) null, - /* state = */ Spliterators_IntArraySpliterator.__$lsl_States.Initialized, - /* array = */ this.array, - /* index = */ lo, - /* fence = */ mid, - /* characteristics = */ this.characteristics - )); - } - this.index = mid; - } - return result; - } - - public static final class __$lsl_States { - public static final byte Allocated = (byte) 0; - - public static final byte Initialized = (byte) 1; - } - - @Approximate(Spliterators_IntArraySpliterator.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/Spliterators_LongArraySpliterator.java b/approximations/src/main/java/generated/java/util/Spliterators_LongArraySpliterator.java deleted file mode 100644 index 0c3ab260..00000000 --- a/approximations/src/main/java/generated/java/util/Spliterators_LongArraySpliterator.java +++ /dev/null @@ -1,304 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/Spliterators.lsl:71 -// - java/util/Spliterators.LongArraySpliterator.lsl:21 -// -package generated.java.util; - -import generated.runtime.LibSLGlobals; -import java.lang.IllegalStateException; -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.Comparator; -import java.util.Spliterator; -import java.util.function.Consumer; -import java.util.function.LongConsumer; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; - -/** - * Spliterators_LongArraySpliteratorAutomaton for Spliterators_LongArraySpliterator ~> java.util.Spliterators_LongArraySpliterator - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(stub.java.util.Spliterators_LongArraySpliterator.class) -public final class Spliterators_LongArraySpliterator implements LibSLRuntime.Automaton, Spliterator.OfLong { - static { - Engine.assume(true); - } - - private byte __$lsl_state = __$lsl_States.Allocated; - - public long[] array; - - public int index; - - public int fence; - - public int characteristics; - - @LibSLRuntime.AutomatonConstructor - public Spliterators_LongArraySpliterator(Void __$lsl_token, final byte p0, final long[] p1, - final int p2, final int p3, final int p4) { - this.__$lsl_state = p0; - this.array = p1; - this.index = p2; - this.fence = p3; - this.characteristics = p4; - } - - @LibSLRuntime.AutomatonConstructor - public Spliterators_LongArraySpliterator(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Allocated, null, 0, 0, 0); - } - - /** - * [CONSTRUCTOR] Spliterators_LongArraySpliteratorAutomaton::(Spliterators_LongArraySpliterator, array, int) -> void - * Source: java/util/Spliterators.LongArraySpliterator.lsl:81 - */ - public Spliterators_LongArraySpliterator(long[] arr, int additionalCharacteristics) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - this.array = arr; - this.index = 0; - this.fence = arr.length; - this.characteristics = additionalCharacteristics | LibSLGlobals.SPLITERATOR_SIZED | LibSLGlobals.SPLITERATOR_SUBSIZED; - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [CONSTRUCTOR] Spliterators_LongArraySpliteratorAutomaton::(Spliterators_LongArraySpliterator, array, int, int, int) -> void - * Source: java/util/Spliterators.LongArraySpliterator.lsl:93 - */ - public Spliterators_LongArraySpliterator(long[] arr, int origin, int pFence, - int additionalCharacteristics) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - this.array = arr; - this.index = origin; - this.fence = pFence; - this.characteristics = additionalCharacteristics | LibSLGlobals.SPLITERATOR_SIZED | LibSLGlobals.SPLITERATOR_SUBSIZED; - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [SUBROUTINE] Spliterators_LongArraySpliteratorAutomaton::_hasCharacteristics(int) -> boolean - * Source: java/util/Spliterators.LongArraySpliterator.lsl:73 - */ - private boolean _hasCharacteristics(int _characteristics) { - boolean result = false; - /* body */ { - result = (this.characteristics & _characteristics) == _characteristics; - } - return result; - } - - /** - * [FUNCTION] Spliterators_LongArraySpliteratorAutomaton::characteristics(Spliterators_LongArraySpliterator) -> int - * Source: java/util/Spliterators.LongArraySpliterator.lsl:109 - */ - public int characteristics() { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.characteristics; - } - return result; - } - - /** - * [FUNCTION] Spliterators_LongArraySpliteratorAutomaton::estimateSize(Spliterators_LongArraySpliterator) -> long - * Source: java/util/Spliterators.LongArraySpliterator.lsl:115 - */ - public long estimateSize() { - long result = 0L; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = ((long) (this.fence - this.index)); - } - return result; - } - - /** - * [FUNCTION] Spliterators_LongArraySpliteratorAutomaton::forEachRemaining(Spliterators_LongArraySpliterator, Consumer) -> void - * Source: java/util/Spliterators.LongArraySpliterator.lsl:145 - */ - public void forEachRemaining(Consumer _action) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (_action == null) { - throw new NullPointerException(); - } - final long[] a = this.array; - int hi = this.fence; - int i = this.index; - this.index = hi; - for (i = i; i < hi; i += 1) { - final long item = a[i]; - _action.accept(item); - } - ; - } - } - - /** - * [FUNCTION] Spliterators_LongArraySpliteratorAutomaton::forEachRemaining(Spliterators_LongArraySpliterator, LongConsumer) -> void - * Source: java/util/Spliterators.LongArraySpliterator.lsl:151 - */ - public void forEachRemaining(LongConsumer _action) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (_action == null) { - throw new NullPointerException(); - } - final long[] a = this.array; - int hi = this.fence; - int i = this.index; - this.index = hi; - for (i = i; i < hi; i += 1) { - final long item = a[i]; - _action.accept(item); - } - ; - } - } - - /** - * [FUNCTION] Spliterators_LongArraySpliteratorAutomaton::getComparator(Spliterators_LongArraySpliterator) -> Comparator - * Source: java/util/Spliterators.LongArraySpliterator.lsl:166 - */ - public Comparator getComparator() { - Comparator result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (_hasCharacteristics(LibSLGlobals.SPLITERATOR_SORTED)) { - result = null; - } else { - throw new IllegalStateException(); - } - } - return result; - } - - /** - * [FUNCTION] Spliterators_LongArraySpliteratorAutomaton::getExactSizeIfKnown(Spliterators_LongArraySpliterator) -> long - * Source: java/util/Spliterators.LongArraySpliterator.lsl:175 - */ - public long getExactSizeIfKnown() { - long result = 0L; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = ((long) (this.fence - this.index)); - } - return result; - } - - /** - * [FUNCTION] Spliterators_LongArraySpliteratorAutomaton::hasCharacteristics(Spliterators_LongArraySpliterator, int) -> boolean - * Source: java/util/Spliterators.LongArraySpliterator.lsl:181 - */ - public boolean hasCharacteristics(int _characteristics) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = _hasCharacteristics(_characteristics); - } - return result; - } - - /** - * [FUNCTION] Spliterators_LongArraySpliteratorAutomaton::tryAdvance(Spliterators_LongArraySpliterator, LongConsumer) -> boolean - * Source: java/util/Spliterators.LongArraySpliterator.lsl:211 - */ - public boolean tryAdvance(LongConsumer _action) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (_action == null) { - throw new NullPointerException(); - } - final int hi = this.fence; - final int i = this.index; - if (i < hi) { - this.index = i + 1; - final long item = array[i]; - _action.accept(item); - result = true; - } else { - result = false; - } - } - return result; - } - - /** - * [FUNCTION] Spliterators_LongArraySpliteratorAutomaton::tryAdvance(Spliterators_LongArraySpliterator, Consumer) -> boolean - * Source: java/util/Spliterators.LongArraySpliterator.lsl:217 - */ - public boolean tryAdvance(Consumer _action) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (_action == null) { - throw new NullPointerException(); - } - final int hi = this.fence; - final int i = this.index; - if (i < hi) { - this.index = i + 1; - final long item = array[i]; - _action.accept(item); - result = true; - } else { - result = false; - } - } - return result; - } - - /** - * [FUNCTION] Spliterators_LongArraySpliteratorAutomaton::trySplit(Spliterators_LongArraySpliterator) -> Spliterator_OfLong - * Source: java/util/Spliterators.LongArraySpliterator.lsl:232 - */ - public Spliterator.OfLong trySplit() { - Spliterator.OfLong result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final int hi = this.fence; - final int lo = this.index; - final int mid = (lo + hi) >>> 1; - if (lo >= mid) { - result = null; - } else { - result = (stub.java.util.Spliterators_LongArraySpliterator) ((Object) new Spliterators_LongArraySpliterator((Void) null, - /* state = */ Spliterators_LongArraySpliterator.__$lsl_States.Initialized, - /* array = */ this.array, - /* index = */ lo, - /* fence = */ mid, - /* characteristics = */ this.characteristics - )); - } - this.index = mid; - } - return result; - } - - public static final class __$lsl_States { - public static final byte Allocated = (byte) 0; - - public static final byte Initialized = (byte) 1; - } - - @Approximate(Spliterators_LongArraySpliterator.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/array/AbstractArrayIteratorImpl.java b/approximations/src/main/java/generated/java/util/array/AbstractArrayIteratorImpl.java new file mode 100644 index 00000000..3241cae4 --- /dev/null +++ b/approximations/src/main/java/generated/java/util/array/AbstractArrayIteratorImpl.java @@ -0,0 +1,60 @@ +package generated.java.util.array; + +import generated.java.util.AbstractIteratorImpl; +import org.jacodb.approximation.annotation.Approximate; +import stub.java.util.array.AbstractArrayIterator; + +import java.util.NoSuchElementException; +import java.util.function.Consumer; + +@Approximate(AbstractArrayIterator.class) +public abstract class AbstractArrayIteratorImpl extends AbstractIteratorImpl { + + public int cursor; + + AbstractArrayIteratorImpl(int cursor) { + super(0); + this.cursor = cursor; + } + + protected final int _parentModCount() { + return 0; + } + + abstract protected int _getLength(); + + abstract protected E _getItem(int index); + + protected boolean _isEmpty() { + return this.cursor >= _getLength(); + } + + public boolean hasNext() { + return !_isEmpty(); + } + + public E next() { + if (this.cursor >= _getLength()) + throw new NoSuchElementException(); + + return _getItem(this.cursor++); + } + + public void remove() { + throw new UnsupportedOperationException(); + } + + public void forEachRemaining(Consumer userAction) { + if (userAction == null) + throw new NullPointerException(); + + int length = _getLength(); + if (this.cursor >= length) + return; + + while (this.cursor < length) { + E item = _getItem(this.cursor++); + userAction.accept(item); + } + } +} diff --git a/approximations/src/main/java/generated/java/util/array/AbstractArraySpliteratorImpl.java b/approximations/src/main/java/generated/java/util/array/AbstractArraySpliteratorImpl.java new file mode 100644 index 00000000..e1069e55 --- /dev/null +++ b/approximations/src/main/java/generated/java/util/array/AbstractArraySpliteratorImpl.java @@ -0,0 +1,91 @@ +package generated.java.util.array; + +import generated.java.util.AbstractSpliteratorImpl; +import generated.java.util.SpliteratorsImpl; +import generated.runtime.LibSLGlobals; +import org.jacodb.approximation.annotation.Approximate; +import stub.java.util.array.AbstractArraySpliterator; + +import java.util.Comparator; +import java.util.function.Consumer; + +@Approximate(AbstractArraySpliterator.class) +public abstract class AbstractArraySpliteratorImpl extends AbstractSpliteratorImpl { + + public int characteristics; + + public AbstractArraySpliteratorImpl(int index, int fence, int characteristics) { + super(index, fence, 0); + this.characteristics = characteristics | SpliteratorsImpl._characteristics; + } + + protected int _parentModCount() { + return 0; + } + + protected int _storageSize() { + return this.fence; + } + + protected int _getFence() { + return this.fence; + } + + protected void _checkForModification() { + } + + public boolean hasCharacteristics(int _characteristics) { + return (this.characteristics & _characteristics) == _characteristics; + } + + public int characteristics() { + return this.characteristics; + } + + public long estimateSize() { + return super.estimateSize(); + } + + abstract protected E _getItem(int index); + + public void forEachRemaining(Consumer _action) { + if (_action == null) + throw new NullPointerException(); + + int current = this.index; + this.index = this.fence; + for (int i = current; i < this.fence; i++) { + E item = _getItem(i); + _action.accept(item); + } + } + + public Comparator getComparator() { + if (hasCharacteristics(LibSLGlobals.SPLITERATOR_SORTED)) + return null; + + throw new IllegalStateException(); + } + + public long getExactSizeIfKnown() { + return super.getExactSizeIfKnown(); + } + + public boolean tryAdvance(Consumer _action) { + if (_action == null) + throw new NullPointerException(); + + int current = this.index; + if (current >= this.fence) + return false; + + this.index = current + 1; + E item = _getItem(current); + _action.accept(item); + return true; + } + + public AbstractArraySpliteratorImpl trySplit() { + return (AbstractArraySpliteratorImpl) super.trySplit(); + } +} diff --git a/approximations/src/main/java/generated/java/util/array/ArrayIteratorImpl.java b/approximations/src/main/java/generated/java/util/array/ArrayIteratorImpl.java new file mode 100644 index 00000000..25e400ca --- /dev/null +++ b/approximations/src/main/java/generated/java/util/array/ArrayIteratorImpl.java @@ -0,0 +1,54 @@ +package generated.java.util.array; + +import org.jacodb.approximation.annotation.Approximate; +import org.usvm.api.Engine; +import stub.java.util.array.ArrayIterator; + +import java.util.function.Consumer; + +@Approximate(ArrayIterator.class) +public class ArrayIteratorImpl extends AbstractArrayIteratorImpl { + + private final E[] storage; + + public ArrayIteratorImpl(E[] storage, int cursor) { + super(cursor); + this.storage = storage; + } + + public ArrayIteratorImpl(E[] storage) { + this(storage, 0); + } + + @SuppressWarnings({"DataFlowIssue", "ConstantValue"}) + private E[] _getStorage() { + E[] storage = this.storage; + Engine.assume(storage != null); + Engine.assume(storage.length >= 0); + return storage; + } + + protected int _getLength() { + return _getStorage().length; + } + + protected E _getItem(int index) { + return _getStorage()[index]; + } + + public boolean hasNext() { + return super.hasNext(); + } + + public E next() { + return super.next(); + } + + public void remove() { + super.remove(); + } + + public void forEachRemaining(Consumer userAction) { + super.forEachRemaining(userAction); + } +} diff --git a/approximations/src/main/java/generated/java/util/array/ArraySpliteratorImpl.java b/approximations/src/main/java/generated/java/util/array/ArraySpliteratorImpl.java new file mode 100644 index 00000000..b6973f42 --- /dev/null +++ b/approximations/src/main/java/generated/java/util/array/ArraySpliteratorImpl.java @@ -0,0 +1,67 @@ +package generated.java.util.array; + +import java.util.Comparator; +import java.util.function.Consumer; + +import org.jacodb.approximation.annotation.Approximate; +import org.usvm.api.Engine; +import stub.java.util.array.ArraySpliterator; + +@Approximate(ArraySpliterator.class) +public final class ArraySpliteratorImpl extends AbstractArraySpliteratorImpl { + + public E[] array; + + public ArraySpliteratorImpl(E[] array, int index, int fence, int characteristics) { + super(index, fence, characteristics); + Engine.assume(array != null); + this.array = array; + } + + @SuppressWarnings("unused") + public ArraySpliteratorImpl(E[] arr, int additionalCharacteristics) { + this(arr, 0, arr.length, additionalCharacteristics); + } + + protected ArraySpliteratorImpl _create(int index, int fence) { + return new ArraySpliteratorImpl<>(this.array, index, fence, this.characteristics); + } + + @SuppressWarnings("DataFlowIssue") + protected E _getItem(int index) { + Engine.assume(array != null); + return array[index]; + } + + public int characteristics() { + return super.characteristics(); + } + + public long estimateSize() { + return super.estimateSize(); + } + + public void forEachRemaining(Consumer action) { + super.forEachRemaining(action); + } + + public Comparator getComparator() { + return super.getComparator(); + } + + public long getExactSizeIfKnown() { + return super.getExactSizeIfKnown(); + } + + public boolean hasCharacteristics(int characteristics) { + return super.hasCharacteristics(characteristics); + } + + public boolean tryAdvance(Consumer action) { + return super.tryAdvance(action); + } + + public ArraySpliteratorImpl trySplit() { + return (ArraySpliteratorImpl) super.trySplit(); + } +} diff --git a/approximations/src/main/java/generated/java/util/array/DoubleArrayIteratorImpl.java b/approximations/src/main/java/generated/java/util/array/DoubleArrayIteratorImpl.java new file mode 100644 index 00000000..c2f4d910 --- /dev/null +++ b/approximations/src/main/java/generated/java/util/array/DoubleArrayIteratorImpl.java @@ -0,0 +1,79 @@ +package generated.java.util.array; + +import org.jacodb.approximation.annotation.Approximate; +import org.usvm.api.Engine; +import stub.java.util.array.DoubleArrayIterator; + +import java.util.NoSuchElementException; +import java.util.PrimitiveIterator; +import java.util.function.Consumer; +import java.util.function.DoubleConsumer; + +@Approximate(DoubleArrayIterator.class) +public class DoubleArrayIteratorImpl extends AbstractArrayIteratorImpl implements PrimitiveIterator.OfDouble { + + private final double[] storage; + + public DoubleArrayIteratorImpl(double[] storage, int cursor) { + super(cursor); + this.storage = storage; + } + + public DoubleArrayIteratorImpl(double[] storage) { + this(storage, 0); + } + + @SuppressWarnings({"DataFlowIssue", "ConstantValue"}) + private double[] _getStorage() { + double[] storage = this.storage; + Engine.assume(storage != null); + Engine.assume(storage.length >= 0); + return storage; + } + + protected int _getLength() { + return _getStorage().length; + } + + protected Double _getItem(int index) { + return _getStorage()[index]; + } + + public boolean hasNext() { + return super.hasNext(); + } + + public Double next() { + return super.next(); + } + + public double nextDouble() { + if (_isEmpty()) + throw new NoSuchElementException(); + + return _getStorage()[this.cursor++]; + } + + public void remove() { + super.remove(); + } + + public void forEachRemaining(Consumer userAction) { + super.forEachRemaining(userAction); + } + + public void forEachRemaining(DoubleConsumer action) { + if (action == null) + throw new NullPointerException(); + + double[] storage = _getStorage(); + int length = storage.length; + if (this.cursor >= length) + return; + + while (this.cursor < length) { + double item = storage[this.cursor++]; + action.accept(item); + } + } +} diff --git a/approximations/src/main/java/generated/java/util/array/DoubleArraySpliteratorImpl.java b/approximations/src/main/java/generated/java/util/array/DoubleArraySpliteratorImpl.java new file mode 100644 index 00000000..a787c81d --- /dev/null +++ b/approximations/src/main/java/generated/java/util/array/DoubleArraySpliteratorImpl.java @@ -0,0 +1,102 @@ +package generated.java.util.array; + +import java.lang.NullPointerException; +import java.util.Comparator; +import java.util.Spliterator; +import java.util.function.Consumer; +import java.util.function.DoubleConsumer; +import org.jacodb.approximation.annotation.Approximate; +import org.usvm.api.Engine; +import stub.java.util.array.DoubleArraySpliterator; + +@Approximate(DoubleArraySpliterator.class) +public final class DoubleArraySpliteratorImpl extends AbstractArraySpliteratorImpl implements Spliterator.OfDouble { + + public double[] array; + + public DoubleArraySpliteratorImpl(double[] array, int index, int fence, int characteristics) { + super(index, fence, characteristics); + Engine.assume(array != null); + this.array = array; + } + + public DoubleArraySpliteratorImpl(double[] arr, int additionalCharacteristics) { + this(arr, 0, arr.length, additionalCharacteristics); + } + + protected DoubleArraySpliteratorImpl _create(int index, int fence) { + return new DoubleArraySpliteratorImpl(this.array, index, fence, this.characteristics); + } + + private double[] _getArray() { + double[] array = this.array; + Engine.assume(array != null); + return array; + } + + @SuppressWarnings("DataFlowIssue") + protected Double _getItem(int index) { + Engine.assume(array != null); + return array[index]; + } + + public int characteristics() { + return super.characteristics(); + } + + public long estimateSize() { + return super.estimateSize(); + } + + public void forEachRemaining(DoubleConsumer action) { + if (action == null) + throw new NullPointerException(); + + double[] array = _getArray(); + int current = this.index; + this.index = this.fence; + for (int i = current; i < this.fence; i++) { + double item = array[current]; + action.accept(item); + } + } + + public void forEachRemaining(Consumer action) { + super.forEachRemaining(action); + } + + public Comparator getComparator() { + return super.getComparator(); + } + + public long getExactSizeIfKnown() { + return super.getExactSizeIfKnown(); + } + + public boolean hasCharacteristics(int characteristics) { + return super.hasCharacteristics(characteristics); + } + + public boolean tryAdvance(DoubleConsumer action) { + if (action == null) + throw new NullPointerException(); + + int current = this.index; + if (current < this.fence) { + this.index = current + 1; + double item = _getArray()[current]; + action.accept(item); + return true; + } + + return false; + } + + public boolean tryAdvance(Consumer action) { + return super.tryAdvance(action); + } + + public DoubleArraySpliteratorImpl trySplit() { + return (DoubleArraySpliteratorImpl) super.trySplit(); + } +} diff --git a/approximations/src/main/java/generated/java/util/array/IntArrayIteratorImpl.java b/approximations/src/main/java/generated/java/util/array/IntArrayIteratorImpl.java new file mode 100644 index 00000000..5895b8fe --- /dev/null +++ b/approximations/src/main/java/generated/java/util/array/IntArrayIteratorImpl.java @@ -0,0 +1,79 @@ +package generated.java.util.array; + +import org.jacodb.approximation.annotation.Approximate; +import org.usvm.api.Engine; +import stub.java.util.array.IntArrayIterator; + +import java.util.NoSuchElementException; +import java.util.PrimitiveIterator; +import java.util.function.Consumer; +import java.util.function.IntConsumer; + +@Approximate(IntArrayIterator.class) +public class IntArrayIteratorImpl extends AbstractArrayIteratorImpl implements PrimitiveIterator.OfInt { + + private final int[] storage; + + public IntArrayIteratorImpl(int[] storage, int cursor) { + super(cursor); + this.storage = storage; + } + + public IntArrayIteratorImpl(int[] storage) { + this(storage, 0); + } + + @SuppressWarnings({"DataFlowIssue", "ConstantValue"}) + private int[] _getStorage() { + int[] storage = this.storage; + Engine.assume(storage != null); + Engine.assume(storage.length >= 0); + return storage; + } + + protected int _getLength() { + return _getStorage().length; + } + + protected Integer _getItem(int index) { + return _getStorage()[index]; + } + + public boolean hasNext() { + return super.hasNext(); + } + + public Integer next() { + return super.next(); + } + + public int nextInt() { + if (_isEmpty()) + throw new NoSuchElementException(); + + return _getStorage()[this.cursor++]; + } + + public void remove() { + super.remove(); + } + + public void forEachRemaining(Consumer action) { + super.forEachRemaining(action); + } + + public void forEachRemaining(IntConsumer action) { + if (action == null) + throw new NullPointerException(); + + int[] storage = _getStorage(); + int length = storage.length; + if (this.cursor >= length) + return; + + while (this.cursor < length) { + int item = storage[this.cursor++]; + action.accept(item); + } + } +} diff --git a/approximations/src/main/java/generated/java/util/array/IntArraySpliteratorImpl.java b/approximations/src/main/java/generated/java/util/array/IntArraySpliteratorImpl.java new file mode 100644 index 00000000..41c95624 --- /dev/null +++ b/approximations/src/main/java/generated/java/util/array/IntArraySpliteratorImpl.java @@ -0,0 +1,102 @@ +package generated.java.util.array; + +import java.lang.NullPointerException; +import java.util.Comparator; +import java.util.Spliterator; +import java.util.function.Consumer; +import java.util.function.IntConsumer; +import org.jacodb.approximation.annotation.Approximate; +import org.usvm.api.Engine; +import stub.java.util.array.IntArraySpliterator; + +@Approximate(IntArraySpliterator.class) +public final class IntArraySpliteratorImpl extends AbstractArraySpliteratorImpl implements Spliterator.OfInt { + + public int[] array; + + public IntArraySpliteratorImpl(int[] array, int index, int fence, int characteristics) { + super(index, fence, characteristics); + Engine.assume(array != null); + this.array = array; + } + + public IntArraySpliteratorImpl(int[] arr, int additionalCharacteristics) { + this(arr, 0, arr.length, additionalCharacteristics); + } + + protected IntArraySpliteratorImpl _create(int index, int fence) { + return new IntArraySpliteratorImpl(this.array, index, fence, this.characteristics); + } + + private int[] _getArray() { + int[] array = this.array; + Engine.assume(array != null); + return array; + } + + @SuppressWarnings("DataFlowIssue") + protected Integer _getItem(int index) { + Engine.assume(array != null); + return array[index]; + } + + public int characteristics() { + return super.characteristics(); + } + + public long estimateSize() { + return super.estimateSize(); + } + + public void forEachRemaining(Consumer action) { + super.forEachRemaining(action); + } + + public void forEachRemaining(IntConsumer action) { + if (action == null) + throw new NullPointerException(); + + int[] array = _getArray(); + int current = this.index; + this.index = this.fence; + for (int i = current; i < this.fence; i++) { + int item = array[i]; + action.accept(item); + } + } + + public Comparator getComparator() { + return super.getComparator(); + } + + public long getExactSizeIfKnown() { + return super.getExactSizeIfKnown(); + } + + public boolean hasCharacteristics(int characteristics) { + return super.hasCharacteristics(characteristics); + } + + public boolean tryAdvance(IntConsumer action) { + if (action == null) + throw new NullPointerException(); + + int current = this.index; + if (current < this.fence) { + this.index = current + 1; + int item = _getArray()[current]; + action.accept(item); + return true; + } + + return false; + } + + public boolean tryAdvance(Consumer action) { + return super.tryAdvance(action); + } + + public IntArraySpliteratorImpl trySplit() { + return (IntArraySpliteratorImpl) super.trySplit(); + } +} diff --git a/approximations/src/main/java/generated/java/util/array/LongArrayIteratorImpl.java b/approximations/src/main/java/generated/java/util/array/LongArrayIteratorImpl.java new file mode 100644 index 00000000..4df0d968 --- /dev/null +++ b/approximations/src/main/java/generated/java/util/array/LongArrayIteratorImpl.java @@ -0,0 +1,79 @@ +package generated.java.util.array; + +import org.jacodb.approximation.annotation.Approximate; +import org.usvm.api.Engine; +import stub.java.util.array.LongArrayIterator; + +import java.util.NoSuchElementException; +import java.util.PrimitiveIterator; +import java.util.function.Consumer; +import java.util.function.LongConsumer; + +@Approximate(LongArrayIterator.class) +public class LongArrayIteratorImpl extends AbstractArrayIteratorImpl implements PrimitiveIterator.OfLong { + + private final long[] storage; + + public LongArrayIteratorImpl(long[] storage, int cursor) { + super(cursor); + this.storage = storage; + } + + public LongArrayIteratorImpl(long[] storage) { + this(storage, 0); + } + + @SuppressWarnings({"DataFlowIssue", "ConstantValue"}) + private long[] _getStorage() { + long[] storage = this.storage; + Engine.assume(storage != null); + Engine.assume(storage.length >= 0); + return storage; + } + + protected int _getLength() { + return _getStorage().length; + } + + protected Long _getItem(int index) { + return _getStorage()[index]; + } + + public boolean hasNext() { + return super.hasNext(); + } + + public Long next() { + return super.next(); + } + + public long nextLong() { + if (_isEmpty()) + throw new NoSuchElementException(); + + return _getStorage()[this.cursor++]; + } + + public void remove() { + super.remove(); + } + + public void forEachRemaining(Consumer action) { + super.forEachRemaining(action); + } + + public void forEachRemaining(LongConsumer action) { + if (action == null) + throw new NullPointerException(); + + long[] storage = _getStorage(); + int length = storage.length; + if (this.cursor >= length) + return; + + while (this.cursor < length) { + long item = storage[this.cursor++]; + action.accept(item); + } + } +} diff --git a/approximations/src/main/java/generated/java/util/array/LongArraySpliteratorImpl.java b/approximations/src/main/java/generated/java/util/array/LongArraySpliteratorImpl.java new file mode 100644 index 00000000..60f9d15e --- /dev/null +++ b/approximations/src/main/java/generated/java/util/array/LongArraySpliteratorImpl.java @@ -0,0 +1,102 @@ +package generated.java.util.array; + +import java.lang.NullPointerException; +import java.util.Comparator; +import java.util.Spliterator; +import java.util.function.Consumer; +import java.util.function.LongConsumer; +import org.jacodb.approximation.annotation.Approximate; +import org.usvm.api.Engine; +import stub.java.util.array.LongArraySpliterator; + +@Approximate(LongArraySpliterator.class) +public final class LongArraySpliteratorImpl extends AbstractArraySpliteratorImpl implements Spliterator.OfLong { + + public long[] array; + + public LongArraySpliteratorImpl(long[] array, int index, int fence, int characteristics) { + super(index, fence, characteristics); + Engine.assume(array != null); + this.array = array; + } + + public LongArraySpliteratorImpl(long[] arr, int additionalCharacteristics) { + this(arr, 0, arr.length, additionalCharacteristics); + } + + protected LongArraySpliteratorImpl _create(int index, int fence) { + return new LongArraySpliteratorImpl(this.array, index, fence, this.characteristics); + } + + private long[] _getArray() { + long[] array = this.array; + Engine.assume(array != null); + return array; + } + + @SuppressWarnings("DataFlowIssue") + protected Long _getItem(int index) { + Engine.assume(array != null); + return array[index]; + } + + public int characteristics() { + return super.characteristics(); + } + + public long estimateSize() { + return super.estimateSize(); + } + + public void forEachRemaining(Consumer action) { + super.forEachRemaining(action); + } + + public void forEachRemaining(LongConsumer action) { + if (action == null) + throw new NullPointerException(); + + long[] array = _getArray(); + int current = this.index; + this.index = this.fence; + for (int i = current; i < this.fence; i++) { + long item = array[i]; + action.accept(item); + } + } + + public Comparator getComparator() { + return super.getComparator(); + } + + public long getExactSizeIfKnown() { + return super.getExactSizeIfKnown(); + } + + public boolean hasCharacteristics(int characteristics) { + return super.hasCharacteristics(characteristics); + } + + public boolean tryAdvance(LongConsumer action) { + if (action == null) + throw new NullPointerException(); + + int current = this.index; + if (current < this.fence) { + this.index = current + 1; + long item = _getArray()[current]; + action.accept(item); + return true; + } + + return false; + } + + public boolean tryAdvance(Consumer action) { + return super.tryAdvance(action); + } + + public LongArraySpliteratorImpl trySplit() { + return (LongArraySpliteratorImpl) super.trySplit(); + } +} diff --git a/approximations/src/main/java/generated/java/util/concurrent/atomic/AtomicBoolean.java b/approximations/src/main/java/generated/java/util/concurrent/atomic/AtomicBoolean.java deleted file mode 100644 index 44243bff..00000000 --- a/approximations/src/main/java/generated/java/util/concurrent/atomic/AtomicBoolean.java +++ /dev/null @@ -1,449 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/concurrent/atomic/AtomicBoolean.lsl:24 -// - java/util/concurrent/atomic/AtomicBoolean.main.lsl:17 -// -package generated.java.util.concurrent.atomic; - -import java.io.Serializable; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.lang.Void; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; - -/** - * AtomicBooleanAutomaton for LSLAtomicBoolean ~> java.util.concurrent.atomic.AtomicBoolean - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(java.util.concurrent.atomic.AtomicBoolean.class) -public class AtomicBoolean implements LibSLRuntime.Automaton, Serializable { - private static final long serialVersionUID = 4654671469794556979L; - - private static final int FALSE = 0; - - private static final int TRUE = 1; - - static { - Engine.assume(true); - } - - private byte __$lsl_state = __$lsl_States.Allocated; - - private volatile int value; - - @LibSLRuntime.AutomatonConstructor - public AtomicBoolean(Void __$lsl_token, final byte p0, final int p1) { - this.__$lsl_state = p0; - this.value = p1; - } - - @LibSLRuntime.AutomatonConstructor - public AtomicBoolean(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Allocated, 0); - } - - /** - * [CONSTRUCTOR] AtomicBooleanAutomaton::(LSLAtomicBoolean) -> void - * Source: java/util/concurrent/atomic/AtomicBoolean.main.lsl:64 - */ - public AtomicBoolean() { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - this.value = FALSE; - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [CONSTRUCTOR] AtomicBooleanAutomaton::(LSLAtomicBoolean, boolean) -> void - * Source: java/util/concurrent/atomic/AtomicBoolean.main.lsl:70 - */ - public AtomicBoolean(boolean initialValue) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - if (initialValue) { - this.value = TRUE; - } else { - this.value = FALSE; - } - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [FUNCTION] AtomicBooleanAutomaton::compareAndExchange(LSLAtomicBoolean, boolean, boolean) -> boolean - * Source: java/util/concurrent/atomic/AtomicBoolean.main.lsl:83 - */ - public final boolean compareAndExchange(boolean expectedValue, boolean newValue) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value != FALSE; - if (result == expectedValue) { - if (newValue) { - this.value = TRUE; - } else { - this.value = FALSE; - } - } - } - return result; - } - - /** - * [FUNCTION] AtomicBooleanAutomaton::compareAndExchangeAcquire(LSLAtomicBoolean, boolean, boolean) -> boolean - * Source: java/util/concurrent/atomic/AtomicBoolean.main.lsl:96 - */ - public final boolean compareAndExchangeAcquire(boolean expectedValue, boolean newValue) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value != FALSE; - if (result == expectedValue) { - if (newValue) { - this.value = TRUE; - } else { - this.value = FALSE; - } - } - } - return result; - } - - /** - * [FUNCTION] AtomicBooleanAutomaton::compareAndExchangeRelease(LSLAtomicBoolean, boolean, boolean) -> boolean - * Source: java/util/concurrent/atomic/AtomicBoolean.main.lsl:110 - */ - public final boolean compareAndExchangeRelease(boolean expectedValue, boolean newValue) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value != FALSE; - if (result == expectedValue) { - if (newValue) { - this.value = TRUE; - } else { - this.value = FALSE; - } - } - } - return result; - } - - /** - * [FUNCTION] AtomicBooleanAutomaton::compareAndSet(LSLAtomicBoolean, boolean, boolean) -> boolean - * Source: java/util/concurrent/atomic/AtomicBoolean.main.lsl:124 - */ - public final boolean compareAndSet(boolean expectedValue, boolean newValue) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final boolean currentValue = this.value != FALSE; - if (currentValue == expectedValue) { - result = true; - if (newValue) { - this.value = TRUE; - } else { - this.value = FALSE; - } - } else { - result = false; - } - } - return result; - } - - /** - * [FUNCTION] AtomicBooleanAutomaton::get(LSLAtomicBoolean) -> boolean - * Source: java/util/concurrent/atomic/AtomicBoolean.main.lsl:143 - */ - public final boolean get() { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value != FALSE; - } - return result; - } - - /** - * [FUNCTION] AtomicBooleanAutomaton::getAcquire(LSLAtomicBoolean) -> boolean - * Source: java/util/concurrent/atomic/AtomicBoolean.main.lsl:150 - */ - public final boolean getAcquire() { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value != FALSE; - } - return result; - } - - /** - * [FUNCTION] AtomicBooleanAutomaton::getAndSet(LSLAtomicBoolean, boolean) -> boolean - * Source: java/util/concurrent/atomic/AtomicBoolean.main.lsl:157 - */ - public final boolean getAndSet(boolean newValue) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value != FALSE; - if (newValue) { - this.value = TRUE; - } else { - this.value = FALSE; - } - } - return result; - } - - /** - * [FUNCTION] AtomicBooleanAutomaton::getOpaque(LSLAtomicBoolean) -> boolean - * Source: java/util/concurrent/atomic/AtomicBoolean.main.lsl:168 - */ - public final boolean getOpaque() { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value != FALSE; - } - return result; - } - - /** - * [FUNCTION] AtomicBooleanAutomaton::getPlain(LSLAtomicBoolean) -> boolean - * Source: java/util/concurrent/atomic/AtomicBoolean.main.lsl:175 - */ - public final boolean getPlain() { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value != FALSE; - } - return result; - } - - /** - * [FUNCTION] AtomicBooleanAutomaton::lazySet(LSLAtomicBoolean, boolean) -> void - * Source: java/util/concurrent/atomic/AtomicBoolean.main.lsl:181 - */ - public final void lazySet(boolean newValue) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (newValue) { - this.value = TRUE; - } else { - this.value = FALSE; - } - } - } - - /** - * [FUNCTION] AtomicBooleanAutomaton::set(LSLAtomicBoolean, boolean) -> void - * Source: java/util/concurrent/atomic/AtomicBoolean.main.lsl:191 - */ - public final void set(boolean newValue) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (newValue) { - this.value = TRUE; - } else { - this.value = FALSE; - } - } - } - - /** - * [FUNCTION] AtomicBooleanAutomaton::setOpaque(LSLAtomicBoolean, boolean) -> void - * Source: java/util/concurrent/atomic/AtomicBoolean.main.lsl:200 - */ - public final void setOpaque(boolean newValue) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (newValue) { - this.value = TRUE; - } else { - this.value = FALSE; - } - } - } - - /** - * [FUNCTION] AtomicBooleanAutomaton::setPlain(LSLAtomicBoolean, boolean) -> void - * Source: java/util/concurrent/atomic/AtomicBoolean.main.lsl:210 - */ - public final void setPlain(boolean newValue) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (newValue) { - this.value = TRUE; - } else { - this.value = FALSE; - } - } - } - - /** - * [FUNCTION] AtomicBooleanAutomaton::setRelease(LSLAtomicBoolean, boolean) -> void - * Source: java/util/concurrent/atomic/AtomicBoolean.main.lsl:220 - */ - public final void setRelease(boolean newValue) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (newValue) { - this.value = TRUE; - } else { - this.value = FALSE; - } - } - } - - /** - * [FUNCTION] AtomicBooleanAutomaton::toString(LSLAtomicBoolean) -> String - * Source: java/util/concurrent/atomic/AtomicBoolean.main.lsl:230 - */ - public String toString() { - String result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.value == FALSE) { - result = "false"; - } else { - result = "true"; - } - } - return result; - } - - /** - * [FUNCTION] AtomicBooleanAutomaton::weakCompareAndSet(LSLAtomicBoolean, boolean, boolean) -> boolean - * Source: java/util/concurrent/atomic/AtomicBoolean.main.lsl:239 - */ - public boolean weakCompareAndSet(boolean expectedValue, boolean newValue) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final boolean currentValue = this.value != FALSE; - if (currentValue == expectedValue) { - result = true; - if (newValue) { - this.value = TRUE; - } else { - this.value = FALSE; - } - } else { - result = false; - } - } - return result; - } - - /** - * [FUNCTION] AtomicBooleanAutomaton::weakCompareAndSetAcquire(LSLAtomicBoolean, boolean, boolean) -> boolean - * Source: java/util/concurrent/atomic/AtomicBoolean.main.lsl:259 - */ - public final boolean weakCompareAndSetAcquire(boolean expectedValue, boolean newValue) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final boolean currentValue = this.value != FALSE; - if (currentValue == expectedValue) { - result = true; - if (newValue) { - this.value = TRUE; - } else { - this.value = FALSE; - } - } else { - result = false; - } - } - return result; - } - - /** - * [FUNCTION] AtomicBooleanAutomaton::weakCompareAndSetPlain(LSLAtomicBoolean, boolean, boolean) -> boolean - * Source: java/util/concurrent/atomic/AtomicBoolean.main.lsl:279 - */ - public boolean weakCompareAndSetPlain(boolean expectedValue, boolean newValue) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final boolean currentValue = this.value != FALSE; - if (currentValue == expectedValue) { - result = true; - if (newValue) { - this.value = TRUE; - } else { - this.value = FALSE; - } - } else { - result = false; - } - } - return result; - } - - /** - * [FUNCTION] AtomicBooleanAutomaton::weakCompareAndSetRelease(LSLAtomicBoolean, boolean, boolean) -> boolean - * Source: java/util/concurrent/atomic/AtomicBoolean.main.lsl:299 - */ - public final boolean weakCompareAndSetRelease(boolean expectedValue, boolean newValue) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final boolean currentValue = this.value != FALSE; - if (currentValue == expectedValue) { - result = true; - if (newValue) { - this.value = TRUE; - } else { - this.value = FALSE; - } - } else { - result = false; - } - } - return result; - } - - /** - * [FUNCTION] AtomicBooleanAutomaton::weakCompareAndSetVolatile(LSLAtomicBoolean, boolean, boolean) -> boolean - * Source: java/util/concurrent/atomic/AtomicBoolean.main.lsl:319 - */ - public final boolean weakCompareAndSetVolatile(boolean expectedValue, boolean newValue) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final boolean currentValue = this.value != FALSE; - if (currentValue == expectedValue) { - result = true; - if (newValue) { - this.value = TRUE; - } else { - this.value = FALSE; - } - } else { - result = false; - } - } - return result; - } - - public static final class __$lsl_States { - public static final byte Allocated = (byte) 0; - - public static final byte Initialized = (byte) 1; - } - - @Approximate(AtomicBoolean.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/concurrent/atomic/AtomicBooleanImpl.java b/approximations/src/main/java/generated/java/util/concurrent/atomic/AtomicBooleanImpl.java new file mode 100644 index 00000000..b79497d4 --- /dev/null +++ b/approximations/src/main/java/generated/java/util/concurrent/atomic/AtomicBooleanImpl.java @@ -0,0 +1,137 @@ +package generated.java.util.concurrent.atomic; + +import java.io.Serial; +import java.io.Serializable; +import java.lang.String; + +import org.jacodb.approximation.annotation.Approximate; +import org.usvm.api.Engine; + +@SuppressWarnings("unused") +@Approximate(java.util.concurrent.atomic.AtomicBoolean.class) +public class AtomicBooleanImpl implements Serializable { + + @Serial + private static final long serialVersionUID = 4654671469794556979L; + + private static final int FALSE = 0; + + private static final int TRUE = 1; + + static { + Engine.assume(true); + } + + private volatile int value; + + public AtomicBooleanImpl(int value) { + this.value = value; + } + + public AtomicBooleanImpl() { + this(FALSE); + } + + private static int _valueFromBool(boolean value) { + return value ? TRUE : FALSE; + } + + public AtomicBooleanImpl(boolean initialValue) { + this(_valueFromBool(initialValue)); + } + + public final boolean compareAndExchange(boolean expectedValue, boolean newValue) { + boolean result = get(); + if (result == expectedValue) + set(newValue); + + return result; + } + + public final boolean compareAndExchangeAcquire(boolean expectedValue, boolean newValue) { + return compareAndExchange(expectedValue, newValue); + } + + public final boolean compareAndExchangeRelease(boolean expectedValue, boolean newValue) { + return compareAndExchange(expectedValue, newValue); + } + + public final boolean compareAndSet(boolean expectedValue, boolean newValue) { + boolean currentValue = get(); + if (currentValue != expectedValue) + return false; + + set(newValue); + return true; + } + + public final boolean get() { + return this.value != FALSE; + } + + public final boolean getAcquire() { + return get(); + } + + public final boolean getAndSet(boolean newValue) { + boolean result = get(); + set(newValue); + + return result; + } + + public final boolean getOpaque() { + return get(); + } + + public final boolean getPlain() { + return get(); + } + + public final void set(boolean newValue) { + this.value = _valueFromBool(newValue); + } + + public final void lazySet(boolean newValue) { + set(newValue); + } + + public final void setOpaque(boolean newValue) { + set(newValue); + } + + public final void setPlain(boolean newValue) { + set(newValue); + } + + public final void setRelease(boolean newValue) { + set(newValue); + } + + public String toString() { + if (this.value == TRUE) + return "true"; + + return "false"; + } + + public boolean weakCompareAndSet(boolean expectedValue, boolean newValue) { + return compareAndSet(expectedValue, newValue); + } + + public final boolean weakCompareAndSetAcquire(boolean expectedValue, boolean newValue) { + return compareAndSet(expectedValue, newValue); + } + + public boolean weakCompareAndSetPlain(boolean expectedValue, boolean newValue) { + return compareAndSet(expectedValue, newValue); + } + + public final boolean weakCompareAndSetRelease(boolean expectedValue, boolean newValue) { + return compareAndSet(expectedValue, newValue); + } + + public final boolean weakCompareAndSetVolatile(boolean expectedValue, boolean newValue) { + return compareAndSet(expectedValue, newValue); + } +} diff --git a/approximations/src/main/java/generated/java/util/concurrent/atomic/AtomicInteger.java b/approximations/src/main/java/generated/java/util/concurrent/atomic/AtomicInteger.java deleted file mode 100644 index db6e0e55..00000000 --- a/approximations/src/main/java/generated/java/util/concurrent/atomic/AtomicInteger.java +++ /dev/null @@ -1,579 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/concurrent/atomic/AtomicInteger.lsl:25 -// - java/util/concurrent/atomic/AtomicInteger.main.lsl:20 -// -package generated.java.util.concurrent.atomic; - -import java.io.Serializable; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.function.IntBinaryOperator; -import java.util.function.IntUnaryOperator; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; - -/** - * AtomicIntegerAutomaton for LSLAtomicInteger ~> java.util.concurrent.atomic.AtomicInteger - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(java.util.concurrent.atomic.AtomicInteger.class) -public class AtomicInteger implements LibSLRuntime.Automaton, Serializable { - private static final long serialVersionUID = 6214790243416807050L; - - static { - Engine.assume(true); - } - - private byte __$lsl_state = __$lsl_States.Allocated; - - private volatile int value; - - @LibSLRuntime.AutomatonConstructor - public AtomicInteger(Void __$lsl_token, final byte p0, final int p1) { - this.__$lsl_state = p0; - this.value = p1; - } - - @LibSLRuntime.AutomatonConstructor - public AtomicInteger(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Allocated, 0); - } - - /** - * [CONSTRUCTOR] AtomicIntegerAutomaton::(LSLAtomicInteger) -> void - * Source: java/util/concurrent/atomic/AtomicInteger.main.lsl:83 - */ - public AtomicInteger() { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - this.value = 0; - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [CONSTRUCTOR] AtomicIntegerAutomaton::(LSLAtomicInteger, int) -> void - * Source: java/util/concurrent/atomic/AtomicInteger.main.lsl:89 - */ - public AtomicInteger(int initialValue) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - this.value = initialValue; - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [FUNCTION] AtomicIntegerAutomaton::accumulateAndGet(LSLAtomicInteger, int, IntBinaryOperator) -> int - * Source: java/util/concurrent/atomic/AtomicInteger.main.lsl:99 - */ - public final int accumulateAndGet(int x, IntBinaryOperator accumulatorFunction) { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = accumulatorFunction.applyAsInt(this.value, x); - this.value = result; - } - return result; - } - - /** - * [FUNCTION] AtomicIntegerAutomaton::addAndGet(LSLAtomicInteger, int) -> int - * Source: java/util/concurrent/atomic/AtomicInteger.main.lsl:106 - */ - public final int addAndGet(int delta) { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value + delta; - this.value = result; - } - return result; - } - - /** - * [FUNCTION] AtomicIntegerAutomaton::byteValue(LSLAtomicInteger) -> byte - * Source: java/util/concurrent/atomic/AtomicInteger.main.lsl:114 - */ - public byte byteValue() { - byte result = ((byte) 0); - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = ((byte) this.value); - } - return result; - } - - /** - * [FUNCTION] AtomicIntegerAutomaton::compareAndExchange(LSLAtomicInteger, int, int) -> int - * Source: java/util/concurrent/atomic/AtomicInteger.main.lsl:120 - */ - public final int compareAndExchange(int expectedValue, int newValue) { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value; - if (result == expectedValue) { - this.value = newValue; - } - } - return result; - } - - /** - * [FUNCTION] AtomicIntegerAutomaton::compareAndExchangeAcquire(LSLAtomicInteger, int, int) -> int - * Source: java/util/concurrent/atomic/AtomicInteger.main.lsl:128 - */ - public final int compareAndExchangeAcquire(int expectedValue, int newValue) { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value; - if (result == expectedValue) { - this.value = newValue; - } - } - return result; - } - - /** - * [FUNCTION] AtomicIntegerAutomaton::compareAndExchangeRelease(LSLAtomicInteger, int, int) -> int - * Source: java/util/concurrent/atomic/AtomicInteger.main.lsl:137 - */ - public final int compareAndExchangeRelease(int expectedValue, int newValue) { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value; - if (result == expectedValue) { - this.value = newValue; - } - } - return result; - } - - /** - * [FUNCTION] AtomicIntegerAutomaton::compareAndSet(LSLAtomicInteger, int, int) -> boolean - * Source: java/util/concurrent/atomic/AtomicInteger.main.lsl:146 - */ - public final boolean compareAndSet(int expectedValue, int newValue) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value == expectedValue; - if (result) { - this.value = newValue; - } - } - return result; - } - - /** - * [FUNCTION] AtomicIntegerAutomaton::decrementAndGet(LSLAtomicInteger) -> int - * Source: java/util/concurrent/atomic/AtomicInteger.main.lsl:154 - */ - public final int decrementAndGet() { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value - 1; - this.value = result; - } - return result; - } - - /** - * [FUNCTION] AtomicIntegerAutomaton::doubleValue(LSLAtomicInteger) -> double - * Source: java/util/concurrent/atomic/AtomicInteger.main.lsl:161 - */ - public double doubleValue() { - double result = 0.0d; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = ((double) this.value); - } - return result; - } - - /** - * [FUNCTION] AtomicIntegerAutomaton::floatValue(LSLAtomicInteger) -> float - * Source: java/util/concurrent/atomic/AtomicInteger.main.lsl:167 - */ - public float floatValue() { - float result = 0.0f; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = ((float) this.value); - } - return result; - } - - /** - * [FUNCTION] AtomicIntegerAutomaton::get(LSLAtomicInteger) -> int - * Source: java/util/concurrent/atomic/AtomicInteger.main.lsl:173 - */ - public final int get() { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value; - } - return result; - } - - /** - * [FUNCTION] AtomicIntegerAutomaton::getAcquire(LSLAtomicInteger) -> int - * Source: java/util/concurrent/atomic/AtomicInteger.main.lsl:179 - */ - public final int getAcquire() { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value; - } - return result; - } - - /** - * [FUNCTION] AtomicIntegerAutomaton::getAndAccumulate(LSLAtomicInteger, int, IntBinaryOperator) -> int - * Source: java/util/concurrent/atomic/AtomicInteger.main.lsl:186 - */ - public final int getAndAccumulate(int x, IntBinaryOperator accumulatorFunction) { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value; - this.value = accumulatorFunction.applyAsInt(result, x); - } - return result; - } - - /** - * [FUNCTION] AtomicIntegerAutomaton::getAndAdd(LSLAtomicInteger, int) -> int - * Source: java/util/concurrent/atomic/AtomicInteger.main.lsl:193 - */ - public final int getAndAdd(int delta) { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value; - this.value = result + delta; - } - return result; - } - - /** - * [FUNCTION] AtomicIntegerAutomaton::getAndDecrement(LSLAtomicInteger) -> int - * Source: java/util/concurrent/atomic/AtomicInteger.main.lsl:200 - */ - public final int getAndDecrement() { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value; - this.value = result - 1; - } - return result; - } - - /** - * [FUNCTION] AtomicIntegerAutomaton::getAndIncrement(LSLAtomicInteger) -> int - * Source: java/util/concurrent/atomic/AtomicInteger.main.lsl:207 - */ - public final int getAndIncrement() { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value; - this.value = result + 1; - } - return result; - } - - /** - * [FUNCTION] AtomicIntegerAutomaton::getAndSet(LSLAtomicInteger, int) -> int - * Source: java/util/concurrent/atomic/AtomicInteger.main.lsl:214 - */ - public final int getAndSet(int newValue) { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value; - this.value = newValue; - } - return result; - } - - /** - * [FUNCTION] AtomicIntegerAutomaton::getAndUpdate(LSLAtomicInteger, IntUnaryOperator) -> int - * Source: java/util/concurrent/atomic/AtomicInteger.main.lsl:221 - */ - public final int getAndUpdate(IntUnaryOperator updateFunction) { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value; - this.value = updateFunction.applyAsInt(result); - } - return result; - } - - /** - * [FUNCTION] AtomicIntegerAutomaton::getOpaque(LSLAtomicInteger) -> int - * Source: java/util/concurrent/atomic/AtomicInteger.main.lsl:228 - */ - public final int getOpaque() { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value; - } - return result; - } - - /** - * [FUNCTION] AtomicIntegerAutomaton::getPlain(LSLAtomicInteger) -> int - * Source: java/util/concurrent/atomic/AtomicInteger.main.lsl:235 - */ - public final int getPlain() { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value; - } - return result; - } - - /** - * [FUNCTION] AtomicIntegerAutomaton::incrementAndGet(LSLAtomicInteger) -> int - * Source: java/util/concurrent/atomic/AtomicInteger.main.lsl:242 - */ - public final int incrementAndGet() { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value + 1; - this.value = result; - } - return result; - } - - /** - * [FUNCTION] AtomicIntegerAutomaton::intValue(LSLAtomicInteger) -> int - * Source: java/util/concurrent/atomic/AtomicInteger.main.lsl:249 - */ - public int intValue() { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value; - } - return result; - } - - /** - * [FUNCTION] AtomicIntegerAutomaton::lazySet(LSLAtomicInteger, int) -> void - * Source: java/util/concurrent/atomic/AtomicInteger.main.lsl:255 - */ - public final void lazySet(int newValue) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - this.value = newValue; - } - } - - /** - * [FUNCTION] AtomicIntegerAutomaton::longValue(LSLAtomicInteger) -> long - * Source: java/util/concurrent/atomic/AtomicInteger.main.lsl:262 - */ - public long longValue() { - long result = 0L; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = ((long) this.value); - } - return result; - } - - /** - * [FUNCTION] AtomicIntegerAutomaton::set(LSLAtomicInteger, int) -> void - * Source: java/util/concurrent/atomic/AtomicInteger.main.lsl:268 - */ - public final void set(int newValue) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - this.value = newValue; - } - } - - /** - * [FUNCTION] AtomicIntegerAutomaton::setOpaque(LSLAtomicInteger, int) -> void - * Source: java/util/concurrent/atomic/AtomicInteger.main.lsl:274 - */ - public final void setOpaque(int newValue) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - this.value = newValue; - } - } - - /** - * [FUNCTION] AtomicIntegerAutomaton::setPlain(LSLAtomicInteger, int) -> void - * Source: java/util/concurrent/atomic/AtomicInteger.main.lsl:281 - */ - public final void setPlain(int newValue) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - this.value = newValue; - } - } - - /** - * [FUNCTION] AtomicIntegerAutomaton::setRelease(LSLAtomicInteger, int) -> void - * Source: java/util/concurrent/atomic/AtomicInteger.main.lsl:288 - */ - public final void setRelease(int newValue) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - this.value = newValue; - } - } - - /** - * [FUNCTION] AtomicIntegerAutomaton::shortValue(LSLAtomicInteger) -> short - * Source: java/util/concurrent/atomic/AtomicInteger.main.lsl:296 - */ - public short shortValue() { - short result = ((short) 0); - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = ((short) this.value); - } - return result; - } - - /** - * [FUNCTION] AtomicIntegerAutomaton::toString(LSLAtomicInteger) -> String - * Source: java/util/concurrent/atomic/AtomicInteger.main.lsl:302 - */ - public String toString() { - String result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = LibSLRuntime.toString(this.value); - } - return result; - } - - /** - * [FUNCTION] AtomicIntegerAutomaton::updateAndGet(LSLAtomicInteger, IntUnaryOperator) -> int - * Source: java/util/concurrent/atomic/AtomicInteger.main.lsl:308 - */ - public final int updateAndGet(IntUnaryOperator updateFunction) { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = updateFunction.applyAsInt(this.value); - this.value = result; - } - return result; - } - - /** - * [FUNCTION] AtomicIntegerAutomaton::weakCompareAndSet(LSLAtomicInteger, int, int) -> boolean - * Source: java/util/concurrent/atomic/AtomicInteger.main.lsl:315 - */ - public final boolean weakCompareAndSet(int expectedValue, int newValue) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value == expectedValue; - if (result) { - this.value = newValue; - } - } - return result; - } - - /** - * [FUNCTION] AtomicIntegerAutomaton::weakCompareAndSetAcquire(LSLAtomicInteger, int, int) -> boolean - * Source: java/util/concurrent/atomic/AtomicInteger.main.lsl:324 - */ - public final boolean weakCompareAndSetAcquire(int expectedValue, int newValue) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value == expectedValue; - if (result) { - this.value = newValue; - } - } - return result; - } - - /** - * [FUNCTION] AtomicIntegerAutomaton::weakCompareAndSetPlain(LSLAtomicInteger, int, int) -> boolean - * Source: java/util/concurrent/atomic/AtomicInteger.main.lsl:333 - */ - public final boolean weakCompareAndSetPlain(int expectedValue, int newValue) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value == expectedValue; - if (result) { - this.value = newValue; - } - } - return result; - } - - /** - * [FUNCTION] AtomicIntegerAutomaton::weakCompareAndSetRelease(LSLAtomicInteger, int, int) -> boolean - * Source: java/util/concurrent/atomic/AtomicInteger.main.lsl:342 - */ - public final boolean weakCompareAndSetRelease(int expectedValue, int newValue) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value == expectedValue; - if (result) { - this.value = newValue; - } - } - return result; - } - - /** - * [FUNCTION] AtomicIntegerAutomaton::weakCompareAndSetVolatile(LSLAtomicInteger, int, int) -> boolean - * Source: java/util/concurrent/atomic/AtomicInteger.main.lsl:351 - */ - public final boolean weakCompareAndSetVolatile(int expectedValue, int newValue) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value == expectedValue; - if (result) { - this.value = newValue; - } - } - return result; - } - - public static final class __$lsl_States { - public static final byte Allocated = (byte) 0; - - public static final byte Initialized = (byte) 1; - } - - @Approximate(AtomicInteger.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/concurrent/atomic/AtomicIntegerImpl.java b/approximations/src/main/java/generated/java/util/concurrent/atomic/AtomicIntegerImpl.java new file mode 100644 index 00000000..06d48d30 --- /dev/null +++ b/approximations/src/main/java/generated/java/util/concurrent/atomic/AtomicIntegerImpl.java @@ -0,0 +1,213 @@ +package generated.java.util.concurrent.atomic; + +import java.io.Serial; +import java.io.Serializable; +import java.lang.String; +import java.util.function.IntBinaryOperator; +import java.util.function.IntUnaryOperator; +import org.jacodb.approximation.annotation.Approximate; +import org.usvm.api.Engine; +import runtime.LibSLRuntime; + +@SuppressWarnings("unused") +@Approximate(java.util.concurrent.atomic.AtomicInteger.class) +public class AtomicIntegerImpl implements Serializable { + + @Serial + private static final long serialVersionUID = 6214790243416807050L; + + static { + Engine.assume(true); + } + + private volatile int value; + + public AtomicIntegerImpl(int initialValue) { + this.value = initialValue; + } + + public AtomicIntegerImpl() { + this(0); + } + + public final int accumulateAndGet(int x, IntBinaryOperator accumulatorFunction) { + int result = accumulatorFunction.applyAsInt(this.value, x); + this.value = result; + return result; + } + + public final int addAndGet(int delta) { + int result = this.value + delta; + this.value = result; + return result; + } + + public byte byteValue() { + return (byte) this.value; + } + + public final int compareAndExchange(int expectedValue, int newValue) { + int result = this.value; + if (result == expectedValue) + this.value = newValue; + + return result; + } + + public final int compareAndExchangeAcquire(int expectedValue, int newValue) { + return compareAndExchange(expectedValue, newValue); + } + + public final int compareAndExchangeRelease(int expectedValue, int newValue) { + return compareAndExchange(expectedValue, newValue); + } + + public final boolean compareAndSet(int expectedValue, int newValue) { + boolean result = this.value == expectedValue; + if (result) + this.value = newValue; + + return result; + } + + public final int decrementAndGet() { + int result = this.value - 1; + this.value = result; + return result; + } + + public double doubleValue() { + return this.value; + } + + public float floatValue() { + return this.value; + } + + public final int get() { + return this.value; + } + + public final int getAcquire() { + return this.value; + } + + public final int getAndAccumulate(int x, IntBinaryOperator accumulatorFunction) { + int result = this.value; + this.value = accumulatorFunction.applyAsInt(result, x); + return result; + } + + public final int getAndAdd(int delta) { + int result = this.value; + this.value = result + delta; + + return result; + } + + public final int getAndDecrement() { + int result = this.value; + this.value = result - 1; + + return result; + } + + public final int getAndIncrement() { + int result = this.value; + this.value = result + 1; + + return result; + } + + public final int getAndSet(int newValue) { + int result = this.value; + this.value = newValue; + + return result; + } + + public final int getAndUpdate(IntUnaryOperator updateFunction) { + int result = this.value; + this.value = updateFunction.applyAsInt(result); + + return result; + } + + public final int getOpaque() { + return this.value; + } + + public final int getPlain() { + return this.value; + } + + public final int incrementAndGet() { + int result = this.value + 1; + this.value = result; + + return result; + } + + public int intValue() { + return this.value; + } + + public final void lazySet(int newValue) { + this.value = newValue; + } + + public long longValue() { + return this.value; + } + + public final void set(int newValue) { + this.value = newValue; + } + + public final void setOpaque(int newValue) { + this.value = newValue; + } + + public final void setPlain(int newValue) { + this.value = newValue; + } + + public final void setRelease(int newValue) { + this.value = newValue; + } + + public short shortValue() { + return (short) this.value; + } + + public String toString() { + return LibSLRuntime.toString(this.value); + } + + public final int updateAndGet(IntUnaryOperator updateFunction) { + int result = updateFunction.applyAsInt(this.value); + this.value = result; + + return result; + } + + public final boolean weakCompareAndSet(int expectedValue, int newValue) { + return compareAndSet(expectedValue, newValue); + } + + public final boolean weakCompareAndSetAcquire(int expectedValue, int newValue) { + return compareAndSet(expectedValue, newValue); + } + + public final boolean weakCompareAndSetPlain(int expectedValue, int newValue) { + return compareAndSet(expectedValue, newValue); + } + + public final boolean weakCompareAndSetRelease(int expectedValue, int newValue) { + return compareAndSet(expectedValue, newValue); + } + + public final boolean weakCompareAndSetVolatile(int expectedValue, int newValue) { + return compareAndSet(expectedValue, newValue); + } +} diff --git a/approximations/src/main/java/generated/java/util/concurrent/atomic/AtomicLong.java b/approximations/src/main/java/generated/java/util/concurrent/atomic/AtomicLong.java index b9304964..45afbbbc 100644 --- a/approximations/src/main/java/generated/java/util/concurrent/atomic/AtomicLong.java +++ b/approximations/src/main/java/generated/java/util/concurrent/atomic/AtomicLong.java @@ -1,579 +1,218 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/concurrent/atomic/AtomicLong.lsl:25 -// - java/util/concurrent/atomic/AtomicLong.main.lsl:20 -// package generated.java.util.concurrent.atomic; +import java.io.Serial; import java.io.Serializable; import java.lang.String; import java.lang.SuppressWarnings; -import java.lang.Void; import java.util.function.LongBinaryOperator; import java.util.function.LongUnaryOperator; import org.jacodb.approximation.annotation.Approximate; import org.usvm.api.Engine; import runtime.LibSLRuntime; -/** - * AtomicLongAutomaton for LSLAtomicLong ~> java.util.concurrent.atomic.AtomicLong - */ -@SuppressWarnings({"all", "unchecked"}) +@SuppressWarnings("unused") @Approximate(java.util.concurrent.atomic.AtomicLong.class) -public class AtomicLong implements LibSLRuntime.Automaton, Serializable { +public class AtomicLong implements Serializable { + + @Serial private static final long serialVersionUID = 1927816293512124184L; static { Engine.assume(true); } - private byte __$lsl_state = __$lsl_States.Allocated; - private volatile long value; - @LibSLRuntime.AutomatonConstructor - public AtomicLong(Void __$lsl_token, final byte p0, final long p1) { - this.__$lsl_state = p0; - this.value = p1; + public AtomicLong(long initialValue) { + this.value = initialValue; } - @LibSLRuntime.AutomatonConstructor - public AtomicLong(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Allocated, 0L); + public AtomicLong() { + this(0L); } - /** - * [CONSTRUCTOR] AtomicLongAutomaton::(LSLAtomicLong) -> void - * Source: java/util/concurrent/atomic/AtomicLong.main.lsl:83 - */ - public AtomicLong() { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - this.value = 0L; - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [CONSTRUCTOR] AtomicLongAutomaton::(LSLAtomicLong, long) -> void - * Source: java/util/concurrent/atomic/AtomicLong.main.lsl:89 - */ - public AtomicLong(long initialValue) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - this.value = initialValue; - } - this.__$lsl_state = __$lsl_States.Initialized; - } - - /** - * [FUNCTION] AtomicLongAutomaton::accumulateAndGet(LSLAtomicLong, long, LongBinaryOperator) -> long - * Source: java/util/concurrent/atomic/AtomicLong.main.lsl:99 - */ public final long accumulateAndGet(long x, LongBinaryOperator accumulatorFunction) { - long result = 0L; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = accumulatorFunction.applyAsLong(this.value, x); - this.value = result; - } + long result = accumulatorFunction.applyAsLong(this.value, x); + this.value = result; + return result; } - /** - * [FUNCTION] AtomicLongAutomaton::addAndGet(LSLAtomicLong, long) -> long - * Source: java/util/concurrent/atomic/AtomicLong.main.lsl:106 - */ public final long addAndGet(long delta) { - long result = 0L; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value + delta; - this.value = result; - } + long result = this.value + delta; + this.value = result; + return result; } - /** - * [FUNCTION] AtomicLongAutomaton::byteValue(LSLAtomicLong) -> byte - * Source: java/util/concurrent/atomic/AtomicLong.main.lsl:114 - */ public byte byteValue() { - byte result = ((byte) 0); - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = ((byte) this.value); - } - return result; + return (byte) this.value; } - /** - * [FUNCTION] AtomicLongAutomaton::compareAndExchange(LSLAtomicLong, long, long) -> long - * Source: java/util/concurrent/atomic/AtomicLong.main.lsl:120 - */ public final long compareAndExchange(long expectedValue, long newValue) { - long result = 0L; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value; - if (result == expectedValue) { - this.value = newValue; - } - } + long result = this.value; + if (result == expectedValue) + this.value = newValue; + return result; } - /** - * [FUNCTION] AtomicLongAutomaton::compareAndExchangeAcquire(LSLAtomicLong, long, long) -> long - * Source: java/util/concurrent/atomic/AtomicLong.main.lsl:128 - */ public final long compareAndExchangeAcquire(long expectedValue, long newValue) { - long result = 0L; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value; - if (result == expectedValue) { - this.value = newValue; - } - } - return result; + return compareAndExchange(expectedValue, newValue); } - /** - * [FUNCTION] AtomicLongAutomaton::compareAndExchangeRelease(LSLAtomicLong, long, long) -> long - * Source: java/util/concurrent/atomic/AtomicLong.main.lsl:137 - */ public final long compareAndExchangeRelease(long expectedValue, long newValue) { - long result = 0L; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value; - if (result == expectedValue) { - this.value = newValue; - } - } - return result; + return compareAndExchange(expectedValue, newValue); } - /** - * [FUNCTION] AtomicLongAutomaton::compareAndSet(LSLAtomicLong, long, long) -> boolean - * Source: java/util/concurrent/atomic/AtomicLong.main.lsl:146 - */ public final boolean compareAndSet(long expectedValue, long newValue) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value == expectedValue; - if (result) { - this.value = newValue; - } - } + boolean result = this.value == expectedValue; + if (result) + this.value = newValue; + return result; } - /** - * [FUNCTION] AtomicLongAutomaton::decrementAndGet(LSLAtomicLong) -> long - * Source: java/util/concurrent/atomic/AtomicLong.main.lsl:154 - */ public final long decrementAndGet() { - long result = 0L; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value - 1L; - this.value = result; - } + long result = this.value - 1L; + this.value = result; + return result; } - /** - * [FUNCTION] AtomicLongAutomaton::doubleValue(LSLAtomicLong) -> double - * Source: java/util/concurrent/atomic/AtomicLong.main.lsl:161 - */ public double doubleValue() { - double result = 0.0d; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = ((double) this.value); - } - return result; + return (double) this.value; } - /** - * [FUNCTION] AtomicLongAutomaton::floatValue(LSLAtomicLong) -> float - * Source: java/util/concurrent/atomic/AtomicLong.main.lsl:167 - */ public float floatValue() { - float result = 0.0f; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = ((float) this.value); - } - return result; + return (float) this.value; } - /** - * [FUNCTION] AtomicLongAutomaton::get(LSLAtomicLong) -> long - * Source: java/util/concurrent/atomic/AtomicLong.main.lsl:173 - */ public final long get() { - long result = 0L; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value; - } - return result; + return this.value; } - /** - * [FUNCTION] AtomicLongAutomaton::getAcquire(LSLAtomicLong) -> long - * Source: java/util/concurrent/atomic/AtomicLong.main.lsl:179 - */ public final long getAcquire() { - long result = 0L; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value; - } - return result; + return this.value; } - /** - * [FUNCTION] AtomicLongAutomaton::getAndAccumulate(LSLAtomicLong, long, LongBinaryOperator) -> long - * Source: java/util/concurrent/atomic/AtomicLong.main.lsl:186 - */ public final long getAndAccumulate(long x, LongBinaryOperator accumulatorFunction) { - long result = 0L; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value; - this.value = accumulatorFunction.applyAsLong(result, x); - } + long result = this.value; + this.value = accumulatorFunction.applyAsLong(result, x); + return result; } - /** - * [FUNCTION] AtomicLongAutomaton::getAndAdd(LSLAtomicLong, long) -> long - * Source: java/util/concurrent/atomic/AtomicLong.main.lsl:193 - */ public final long getAndAdd(long delta) { - long result = 0L; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value; - this.value = result + delta; - } + long result = this.value; + this.value = result + delta; + return result; } - /** - * [FUNCTION] AtomicLongAutomaton::getAndDecrement(LSLAtomicLong) -> long - * Source: java/util/concurrent/atomic/AtomicLong.main.lsl:200 - */ public final long getAndDecrement() { - long result = 0L; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value; - this.value = result - 1L; - } + long result = this.value; + this.value = result - 1L; + return result; } - /** - * [FUNCTION] AtomicLongAutomaton::getAndIncrement(LSLAtomicLong) -> long - * Source: java/util/concurrent/atomic/AtomicLong.main.lsl:207 - */ public final long getAndIncrement() { - long result = 0L; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value; - this.value = result + 1L; - } + long result = this.value; + this.value = result + 1L; + return result; } - /** - * [FUNCTION] AtomicLongAutomaton::getAndSet(LSLAtomicLong, long) -> long - * Source: java/util/concurrent/atomic/AtomicLong.main.lsl:214 - */ public final long getAndSet(long newValue) { - long result = 0L; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value; - this.value = newValue; - } + long result = this.value; + this.value = newValue; + return result; } - /** - * [FUNCTION] AtomicLongAutomaton::getAndUpdate(LSLAtomicLong, LongUnaryOperator) -> long - * Source: java/util/concurrent/atomic/AtomicLong.main.lsl:221 - */ public final long getAndUpdate(LongUnaryOperator updateFunction) { - long result = 0L; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value; - this.value = updateFunction.applyAsLong(result); - } + long result = this.value; + this.value = updateFunction.applyAsLong(result); + return result; } - /** - * [FUNCTION] AtomicLongAutomaton::getOpaque(LSLAtomicLong) -> long - * Source: java/util/concurrent/atomic/AtomicLong.main.lsl:228 - */ public final long getOpaque() { - long result = 0L; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value; - } - return result; + return this.value; } - /** - * [FUNCTION] AtomicLongAutomaton::getPlain(LSLAtomicLong) -> long - * Source: java/util/concurrent/atomic/AtomicLong.main.lsl:235 - */ public final long getPlain() { - long result = 0L; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value; - } - return result; + return this.value; } - /** - * [FUNCTION] AtomicLongAutomaton::incrementAndGet(LSLAtomicLong) -> long - * Source: java/util/concurrent/atomic/AtomicLong.main.lsl:242 - */ public final long incrementAndGet() { - long result = 0L; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value + 1L; - this.value = result; - } - return result; - } + long result = this.value + 1L; + this.value = result; - /** - * [FUNCTION] AtomicLongAutomaton::intValue(LSLAtomicLong) -> int - * Source: java/util/concurrent/atomic/AtomicLong.main.lsl:249 - */ - public int intValue() { - int result = 0; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = ((int) this.value); - } return result; } - /** - * [FUNCTION] AtomicLongAutomaton::lazySet(LSLAtomicLong, long) -> void - * Source: java/util/concurrent/atomic/AtomicLong.main.lsl:255 - */ - public final void lazySet(long newValue) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - this.value = newValue; - } + public int intValue() { + return (int) this.value; } - /** - * [FUNCTION] AtomicLongAutomaton::longValue(LSLAtomicLong) -> long - * Source: java/util/concurrent/atomic/AtomicLong.main.lsl:262 - */ public long longValue() { - long result = 0L; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value; - } - return result; + return this.value; } - /** - * [FUNCTION] AtomicLongAutomaton::set(LSLAtomicLong, long) -> void - * Source: java/util/concurrent/atomic/AtomicLong.main.lsl:268 - */ public final void set(long newValue) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - this.value = newValue; - } + this.value = newValue; + } + + public final void lazySet(long newValue) { + set(newValue); } - /** - * [FUNCTION] AtomicLongAutomaton::setOpaque(LSLAtomicLong, long) -> void - * Source: java/util/concurrent/atomic/AtomicLong.main.lsl:274 - */ public final void setOpaque(long newValue) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - this.value = newValue; - } + set(newValue); } - /** - * [FUNCTION] AtomicLongAutomaton::setPlain(LSLAtomicLong, long) -> void - * Source: java/util/concurrent/atomic/AtomicLong.main.lsl:281 - */ public final void setPlain(long newValue) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - this.value = newValue; - } + set(newValue); } - /** - * [FUNCTION] AtomicLongAutomaton::setRelease(LSLAtomicLong, long) -> void - * Source: java/util/concurrent/atomic/AtomicLong.main.lsl:288 - */ public final void setRelease(long newValue) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - this.value = newValue; - } + set(newValue); } - /** - * [FUNCTION] AtomicLongAutomaton::shortValue(LSLAtomicLong) -> short - * Source: java/util/concurrent/atomic/AtomicLong.main.lsl:296 - */ public short shortValue() { - short result = ((short) 0); - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = ((short) this.value); - } - return result; + return (short) this.value; } - /** - * [FUNCTION] AtomicLongAutomaton::toString(LSLAtomicLong) -> String - * Source: java/util/concurrent/atomic/AtomicLong.main.lsl:302 - */ public String toString() { - String result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = LibSLRuntime.toString(this.value); - } - return result; + return LibSLRuntime.toString(this.value); } - /** - * [FUNCTION] AtomicLongAutomaton::updateAndGet(LSLAtomicLong, LongUnaryOperator) -> long - * Source: java/util/concurrent/atomic/AtomicLong.main.lsl:308 - */ public final long updateAndGet(LongUnaryOperator updateFunction) { - long result = 0L; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = updateFunction.applyAsLong(this.value); - this.value = result; - } + long result = updateFunction.applyAsLong(this.value); + this.value = result; + return result; } - /** - * [FUNCTION] AtomicLongAutomaton::weakCompareAndSet(LSLAtomicLong, long, long) -> boolean - * Source: java/util/concurrent/atomic/AtomicLong.main.lsl:315 - */ public final boolean weakCompareAndSet(long expectedValue, long newValue) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value == expectedValue; - if (result) { - this.value = newValue; - } - } - return result; + return compareAndSet(expectedValue, newValue); } - /** - * [FUNCTION] AtomicLongAutomaton::weakCompareAndSetAcquire(LSLAtomicLong, long, long) -> boolean - * Source: java/util/concurrent/atomic/AtomicLong.main.lsl:324 - */ public final boolean weakCompareAndSetAcquire(long expectedValue, long newValue) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value == expectedValue; - if (result) { - this.value = newValue; - } - } - return result; + return compareAndSet(expectedValue, newValue); } - /** - * [FUNCTION] AtomicLongAutomaton::weakCompareAndSetPlain(LSLAtomicLong, long, long) -> boolean - * Source: java/util/concurrent/atomic/AtomicLong.main.lsl:333 - */ public final boolean weakCompareAndSetPlain(long expectedValue, long newValue) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value == expectedValue; - if (result) { - this.value = newValue; - } - } - return result; + return compareAndSet(expectedValue, newValue); } - /** - * [FUNCTION] AtomicLongAutomaton::weakCompareAndSetRelease(LSLAtomicLong, long, long) -> boolean - * Source: java/util/concurrent/atomic/AtomicLong.main.lsl:342 - */ public final boolean weakCompareAndSetRelease(long expectedValue, long newValue) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value == expectedValue; - if (result) { - this.value = newValue; - } - } - return result; + return compareAndSet(expectedValue, newValue); } - /** - * [FUNCTION] AtomicLongAutomaton::weakCompareAndSetVolatile(LSLAtomicLong, long, long) -> boolean - * Source: java/util/concurrent/atomic/AtomicLong.main.lsl:351 - */ public final boolean weakCompareAndSetVolatile(long expectedValue, long newValue) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value == expectedValue; - if (result) { - this.value = newValue; - } - } - return result; - } - - public static final class __$lsl_States { - public static final byte Allocated = (byte) 0; - - public static final byte Initialized = (byte) 1; - } - - @Approximate(AtomicLong.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } + return compareAndSet(expectedValue, newValue); } } diff --git a/approximations/src/main/java/generated/java/util/concurrent/atomic/AtomicReference.java b/approximations/src/main/java/generated/java/util/concurrent/atomic/AtomicReference.java index 9c8748bd..d8d8dc73 100644 --- a/approximations/src/main/java/generated/java/util/concurrent/atomic/AtomicReference.java +++ b/approximations/src/main/java/generated/java/util/concurrent/atomic/AtomicReference.java @@ -1,418 +1,153 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/concurrent/atomic/AtomicReference.lsl:24 -// - java/util/concurrent/atomic/AtomicReference.main.lsl:21 -// package generated.java.util.concurrent.atomic; +import java.io.Serial; import java.io.Serializable; import java.lang.Object; import java.lang.String; import java.lang.SuppressWarnings; -import java.lang.Void; import java.util.function.BinaryOperator; import java.util.function.UnaryOperator; import org.jacodb.approximation.annotation.Approximate; import org.usvm.api.Engine; import runtime.LibSLRuntime; -/** - * AtomicReferenceAutomaton for LSLAtomicReference ~> java.util.concurrent.atomic.AtomicReference - */ -@SuppressWarnings({"all", "unchecked"}) +@SuppressWarnings("unused") @Approximate(java.util.concurrent.atomic.AtomicReference.class) -public class AtomicReference implements LibSLRuntime.Automaton, Serializable { +public class AtomicReference implements Serializable { + + @Serial private static final long serialVersionUID = -1848883965231344442L; static { Engine.assume(true); } - private byte __$lsl_state = __$lsl_States.Allocated; - - private volatile Object value; + private transient volatile Object value; - @LibSLRuntime.AutomatonConstructor - public AtomicReference(Void __$lsl_token, final byte p0, final Object p1) { - this.__$lsl_state = p0; - this.value = p1; + public AtomicReference(Object obj) { + this.value = obj; } - @LibSLRuntime.AutomatonConstructor - public AtomicReference(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Allocated, null); - } - - /** - * [CONSTRUCTOR] AtomicReferenceAutomaton::(LSLAtomicReference) -> void - * Source: java/util/concurrent/atomic/AtomicReference.main.lsl:72 - */ public AtomicReference() { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - this.value = null; - } - this.__$lsl_state = __$lsl_States.Initialized; + this(null); } - /** - * [CONSTRUCTOR] AtomicReferenceAutomaton::(LSLAtomicReference, Object) -> void - * Source: java/util/concurrent/atomic/AtomicReference.main.lsl:78 - */ - public AtomicReference(Object initialValue) { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - this.value = initialValue; - } - this.__$lsl_state = __$lsl_States.Initialized; - } + public final Object accumulateAndGet(Object x, BinaryOperator accumulatorFunction) { + Object result = accumulatorFunction.apply(this.value, x); + this.value = result; - /** - * [FUNCTION] AtomicReferenceAutomaton::accumulateAndGet(LSLAtomicReference, Object, BinaryOperator) -> Object - * Source: java/util/concurrent/atomic/AtomicReference.main.lsl:88 - */ - public final Object accumulateAndGet(Object x, BinaryOperator accumulatorFunction) { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = accumulatorFunction.apply(this.value, x); - this.value = result; - } return result; } - /** - * [FUNCTION] AtomicReferenceAutomaton::compareAndExchange(LSLAtomicReference, Object, Object) -> Object - * Source: java/util/concurrent/atomic/AtomicReference.main.lsl:95 - */ public final Object compareAndExchange(Object expectedValue, Object newValue) { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value; - if (result == expectedValue) { - this.value = newValue; - } - } + Object result = this.value; + if (result == expectedValue) + this.value = newValue; + return result; } - /** - * [FUNCTION] AtomicReferenceAutomaton::compareAndExchangeAcquire(LSLAtomicReference, Object, Object) -> Object - * Source: java/util/concurrent/atomic/AtomicReference.main.lsl:103 - */ public final Object compareAndExchangeAcquire(Object expectedValue, Object newValue) { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value; - if (result == expectedValue) { - this.value = newValue; - } - } - return result; + return compareAndExchange(expectedValue, newValue); } - /** - * [FUNCTION] AtomicReferenceAutomaton::compareAndExchangeRelease(LSLAtomicReference, Object, Object) -> Object - * Source: java/util/concurrent/atomic/AtomicReference.main.lsl:112 - */ public final Object compareAndExchangeRelease(Object expectedValue, Object newValue) { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value; - if (result == expectedValue) { - this.value = newValue; - } - } - return result; + return compareAndExchange(expectedValue, newValue); } - /** - * [FUNCTION] AtomicReferenceAutomaton::compareAndSet(LSLAtomicReference, Object, Object) -> boolean - * Source: java/util/concurrent/atomic/AtomicReference.main.lsl:121 - */ public final boolean compareAndSet(Object expectedValue, Object newValue) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value == expectedValue; - if (result) { - this.value = newValue; - } - } + boolean result = this.value == expectedValue; + if (result) + this.value = newValue; + return result; } - /** - * [FUNCTION] AtomicReferenceAutomaton::get(LSLAtomicReference) -> Object - * Source: java/util/concurrent/atomic/AtomicReference.main.lsl:129 - */ public final Object get() { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value; - } - return result; + return this.value; } - /** - * [FUNCTION] AtomicReferenceAutomaton::getAcquire(LSLAtomicReference) -> Object - * Source: java/util/concurrent/atomic/AtomicReference.main.lsl:135 - */ public final Object getAcquire() { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value; - } - return result; + return this.value; } - /** - * [FUNCTION] AtomicReferenceAutomaton::getAndAccumulate(LSLAtomicReference, Object, BinaryOperator) -> Object - * Source: java/util/concurrent/atomic/AtomicReference.main.lsl:142 - */ - public final Object getAndAccumulate(Object x, BinaryOperator accumulatorFunction) { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value; - this.value = accumulatorFunction.apply(result, x); - } + public final Object getAndAccumulate(Object x, BinaryOperator accumulatorFunction) { + Object result = this.value; + this.value = accumulatorFunction.apply(result, x); + return result; } - /** - * [FUNCTION] AtomicReferenceAutomaton::getAndSet(LSLAtomicReference, Object) -> Object - * Source: java/util/concurrent/atomic/AtomicReference.main.lsl:149 - */ public final Object getAndSet(Object newValue) { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value; - this.value = newValue; - } + Object result = this.value; + this.value = newValue; + return result; } - /** - * [FUNCTION] AtomicReferenceAutomaton::getAndUpdate(LSLAtomicReference, UnaryOperator) -> Object - * Source: java/util/concurrent/atomic/AtomicReference.main.lsl:156 - */ - public final Object getAndUpdate(UnaryOperator updateFunction) { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value; - this.value = updateFunction.apply(result); - } + public final Object getAndUpdate(UnaryOperator updateFunction) { + Object result = this.value; + this.value = updateFunction.apply(result); + return result; } - /** - * [FUNCTION] AtomicReferenceAutomaton::getOpaque(LSLAtomicReference) -> Object - * Source: java/util/concurrent/atomic/AtomicReference.main.lsl:163 - */ public final Object getOpaque() { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value; - } - return result; + return this.value; } - /** - * [FUNCTION] AtomicReferenceAutomaton::getPlain(LSLAtomicReference) -> Object - * Source: java/util/concurrent/atomic/AtomicReference.main.lsl:170 - */ public final Object getPlain() { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value; - } - return result; + return this.value; } - /** - * [FUNCTION] AtomicReferenceAutomaton::lazySet(LSLAtomicReference, Object) -> void - * Source: java/util/concurrent/atomic/AtomicReference.main.lsl:177 - */ - public final void lazySet(Object newValue) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - this.value = newValue; - } + public final void set(Object newValue) { + this.value = newValue; } - /** - * [FUNCTION] AtomicReferenceAutomaton::set(LSLAtomicReference, Object) -> void - * Source: java/util/concurrent/atomic/AtomicReference.main.lsl:184 - */ - public final void set(Object newValue) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - this.value = newValue; - } + public final void lazySet(Object newValue) { + this.value = newValue; } - /** - * [FUNCTION] AtomicReferenceAutomaton::setOpaque(LSLAtomicReference, Object) -> void - * Source: java/util/concurrent/atomic/AtomicReference.main.lsl:190 - */ public final void setOpaque(Object newValue) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - this.value = newValue; - } + this.value = newValue; } - /** - * [FUNCTION] AtomicReferenceAutomaton::setPlain(LSLAtomicReference, Object) -> void - * Source: java/util/concurrent/atomic/AtomicReference.main.lsl:197 - */ public final void setPlain(Object newValue) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - this.value = newValue; - } + this.value = newValue; } - /** - * [FUNCTION] AtomicReferenceAutomaton::setRelease(LSLAtomicReference, Object) -> void - * Source: java/util/concurrent/atomic/AtomicReference.main.lsl:204 - */ public final void setRelease(Object newValue) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - this.value = newValue; - } + this.value = newValue; } - /** - * [FUNCTION] AtomicReferenceAutomaton::toString(LSLAtomicReference) -> String - * Source: java/util/concurrent/atomic/AtomicReference.main.lsl:211 - */ public String toString() { - String result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = LibSLRuntime.toString(this.value); - } - return result; + return LibSLRuntime.toString(this.value); } - /** - * [FUNCTION] AtomicReferenceAutomaton::updateAndGet(LSLAtomicReference, UnaryOperator) -> Object - * Source: java/util/concurrent/atomic/AtomicReference.main.lsl:217 - */ - public final Object updateAndGet(UnaryOperator updateFunction) { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = updateFunction.apply(this.value); - this.value = result; - } + public final Object updateAndGet(UnaryOperator updateFunction) { + Object result = updateFunction.apply(this.value); + this.value = result; + return result; } - /** - * [FUNCTION] AtomicReferenceAutomaton::weakCompareAndSet(LSLAtomicReference, Object, Object) -> boolean - * Source: java/util/concurrent/atomic/AtomicReference.main.lsl:224 - */ public final boolean weakCompareAndSet(Object expectedValue, Object newValue) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value == expectedValue; - if (result) { - this.value = newValue; - } - } - return result; + return compareAndSet(expectedValue, newValue); } - /** - * [FUNCTION] AtomicReferenceAutomaton::weakCompareAndSetAcquire(LSLAtomicReference, Object, Object) -> boolean - * Source: java/util/concurrent/atomic/AtomicReference.main.lsl:233 - */ public final boolean weakCompareAndSetAcquire(Object expectedValue, Object newValue) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value == expectedValue; - if (result) { - this.value = newValue; - } - } - return result; + return compareAndSet(expectedValue, newValue); } - /** - * [FUNCTION] AtomicReferenceAutomaton::weakCompareAndSetPlain(LSLAtomicReference, Object, Object) -> boolean - * Source: java/util/concurrent/atomic/AtomicReference.main.lsl:242 - */ public final boolean weakCompareAndSetPlain(Object expectedValue, Object newValue) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value == expectedValue; - if (result) { - this.value = newValue; - } - } - return result; + return compareAndSet(expectedValue, newValue); } - /** - * [FUNCTION] AtomicReferenceAutomaton::weakCompareAndSetRelease(LSLAtomicReference, Object, Object) -> boolean - * Source: java/util/concurrent/atomic/AtomicReference.main.lsl:251 - */ public final boolean weakCompareAndSetRelease(Object expectedValue, Object newValue) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value == expectedValue; - if (result) { - this.value = newValue; - } - } - return result; + return compareAndSet(expectedValue, newValue); } - /** - * [FUNCTION] AtomicReferenceAutomaton::weakCompareAndSetVolatile(LSLAtomicReference, Object, Object) -> boolean - * Source: java/util/concurrent/atomic/AtomicReference.main.lsl:260 - */ public final boolean weakCompareAndSetVolatile(Object expectedValue, Object newValue) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.value == expectedValue; - if (result) { - this.value = newValue; - } - } - return result; - } - - public static final class __$lsl_States { - public static final byte Allocated = (byte) 0; - - public static final byte Initialized = (byte) 1; - } - - @Approximate(AtomicReference.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } + return compareAndSet(expectedValue, newValue); } } diff --git a/approximations/src/main/java/generated/java/util/list/AbstractListImpl.java b/approximations/src/main/java/generated/java/util/list/AbstractListImpl.java new file mode 100644 index 00000000..77318754 --- /dev/null +++ b/approximations/src/main/java/generated/java/util/list/AbstractListImpl.java @@ -0,0 +1,579 @@ +package generated.java.util.list; + +import java.io.Serial; +import java.io.Serializable; +import java.lang.Comparable; +import java.lang.IllegalArgumentException; +import java.lang.IndexOutOfBoundsException; +import java.lang.NullPointerException; +import java.lang.Object; +import java.lang.String; +import java.util.*; +import java.util.function.Consumer; +import java.util.function.IntFunction; +import java.util.function.Predicate; +import java.util.function.UnaryOperator; +import java.util.stream.Stream; + +import generated.java.util.AbstractCollectionImpl; +import generated.java.util.stream.StreamStubImpl; +import org.jacodb.approximation.annotation.Approximate; +import org.jetbrains.annotations.NotNull; +import org.usvm.api.Engine; +import org.usvm.api.SymbolicList; +import runtime.LibSLRuntime; + +@Approximate(java.util.AbstractList.class) +public abstract class AbstractListImpl extends AbstractCollectionImpl implements List { + + public SymbolicList storage; + + public AbstractListImpl(SymbolicList storage, int modCount) { + super(modCount); + this.storage = storage; + } + + public AbstractListImpl() { + this(Engine.makeSymbolicList(), 0); + } + + public AbstractListImpl(Collection c) { + super(0); + + if (c == null) + throw new NullPointerException(); + + this.storage = Engine.makeSymbolicList(); + _addAllElements(0, c); + } + + public AbstractListImpl(int initialCapacity) { + super(0); + + if (initialCapacity < 0) + throw new IllegalArgumentException(); + + this.storage = Engine.makeSymbolicList(); + } + + public SymbolicList _getStorage() { + SymbolicList storage = this.storage; + Engine.assume(storage != null); + return storage; + } + + public boolean _isValidIndex(int index, int length) { + return index >= 0 && index < length; + } + + @SuppressWarnings("BooleanMethodIsAlwaysInverted") + public boolean _isValidIndex(int index) { + return _isValidIndex(index, _getStorage().size()); + } + + public void _checkValidIndex(int index, int length) { + if (!_isValidIndex(index, length)) + throw new IndexOutOfBoundsException(); + } + + public void _checkValidIndex(int index) { + _checkValidIndex(index, _getStorage().size()); + } + + public boolean _isValidAddIndex(int index) { + return index >= 0 && index <= _getStorage().size(); + } + + public void _checkValidAddIndex(int index) { + if (!_isValidAddIndex(index)) + throw new IndexOutOfBoundsException(); + } + + @SuppressWarnings({"DataFlowIssue", "unchecked"}) + public boolean _addAllElements(int index, Collection c) { + SymbolicList storage = _getStorage(); + int oldLength = storage.size(); + if (c instanceof AbstractListImpl) { + AbstractListImpl other = (AbstractListImpl) c; + SymbolicList otherStorage = other._getStorage(); + Engine.assume(otherStorage != null); + int otherLength = otherStorage.size(); + Engine.assume(otherLength >= 0); + otherStorage.copy(storage, 0, index, otherLength); + } else { + for (E item : c) { + storage.insert(index, item); + index++; + } + } + + this.modCount++; + return oldLength != storage.size(); + } + + public void _subListRangeCheck(int fromIndex, int toIndex, int size) { + if (fromIndex < 0) + throw new IndexOutOfBoundsException(); + + if (toIndex > size) + throw new IndexOutOfBoundsException(); + + if (fromIndex > toIndex) + throw new IllegalArgumentException(); + } + + public void _checkForModification(int expectedModCount) { + if (this.modCount != expectedModCount) + throw new ConcurrentModificationException(); + } + + public E _deleteElement(int index) { + SymbolicList storage = _getStorage(); + E result = storage.get(index); + storage.remove(index); + this.modCount++; + return result; + } + + public E _checkedDeleteElement(int index) { + _checkValidIndex(index); + return _deleteElement(index); + } + + public void _addElement(int index, E element) { + _getStorage().insert(index, element); + this.modCount++; + } + + public void _checkedAddElement(int index, E element) { + _checkValidAddIndex(index); + _addElement(index, element); + } + + public E _setElement(int index, E element) { + SymbolicList storage = _getStorage(); + E oldValue = storage.get(index); + storage.set(index, element); + return oldValue; + } + + public E _checkedSetElement(int index, E element) { + _checkValidIndex(index); + return _setElement(index, element); + } + + public E _get(int index) { + return _getStorage().get(index); + } + + public E _checkedGet(int index) { + _checkValidIndex(index); + return _getStorage().get(index); + } + + public void _replaceAllRange(UnaryOperator op, int i, int end) { + int expectedModCount = this.modCount; + SymbolicList storage = _getStorage(); + while (this.modCount == expectedModCount && i < end) { + E oldItem = storage.get(i); + E newItem = op.apply(oldItem); + storage.set(i, newItem); + i++; + } + _checkForModification(expectedModCount); + } + + public boolean _removeIf(Predicate filter, int start, int end) { + if (filter == null) + throw new NullPointerException(); + + SymbolicList storage = _getStorage(); + int oldLength = storage.size(); + int expectedModCount = this.modCount; + Engine.assume(start <= end); + for (int i = end - 1; i > start; i--) { + E item = storage.get(i); + if (filter.test(item)) + storage.remove(i); + } + + _checkForModification(expectedModCount); + return oldLength != storage.size(); + } + + public boolean _equalsStorage(SymbolicList otherStorage, int from, int to) { + SymbolicList storage = _getStorage(); + for (int i = from; i < to; i++) { + E a = otherStorage.get(i); + E b = storage.get(i); + if (!LibSLRuntime.equals(a, b)) + return false; + } + return true; + } + + public boolean _equalsRange(List other, int from, int to) { + if (other instanceof SubListImpl) { + SubListImpl otherSubList = (SubListImpl) other; + AbstractListImpl otherRoot = otherSubList.list; + SymbolicList otherStorage = otherRoot._getStorage(); + if (to != otherSubList.length) + return false; + + return _equalsStorage(otherStorage, from, to); + } + + if (other instanceof AbstractListImpl) { + AbstractListImpl otherList = (AbstractListImpl) other; + SymbolicList otherStorage = otherList._getStorage(); + if (to != otherStorage.size()) + return false; + + return _equalsStorage(otherStorage, from, to); + } + + SymbolicList storage = _getStorage(); + Iterator iter = other.iterator(); + boolean result = true; + int i = from; + while (result && i < to && iter.hasNext()) { + E a = iter.next(); + E b = storage.get(i); + result = LibSLRuntime.equals(a, b); + i++; + } + + return result && !iter.hasNext(); + } + + protected Object[] _mapToArray() { + SymbolicList storage = _getStorage(); + int count = storage.size(); + Object[] items = new Object[count]; + for (int i = 0; i < count; i++) { + items[i] = storage.get(i); + } + return items; + } + + @SuppressWarnings("unchecked") + private Stream _makeStream(boolean parallel) { + E[] items = (E[]) _mapToArray(); + return new StreamStubImpl<>(items, parallel); + } + + @SuppressWarnings({"ConstantValue", "unchecked"}) + public boolean _batchRemove(Collection c, boolean complement, int start, int end) { + if (c == null) + throw new NullPointerException(); + + SymbolicList storage = _getStorage(); + int oldLength = storage.size(); + if (oldLength == 0 || start >= end) + return false; + + int otherLength = c.size(); + if (otherLength == 0) { + if (!complement) + return false; + + this.storage = Engine.makeSymbolicList(); + this.modCount++; + return true; + } + + Engine.assume(otherLength > 0); + start--; + end--; + if (c instanceof List) { + SymbolicList otherStorage = ((AbstractListImpl) c)._getStorage(); + Engine.assume(otherStorage != null); + boolean changed = false; + for (int i = end; i > start; i--) { + Object item = storage.get(i); + int storageSize = storage.size(); + int index = LibSLRuntime.ListActions.find(otherStorage, item, 0, storageSize); + boolean notExists = index == -1; + if (notExists == complement) { + _checkedDeleteElement(i); + changed = true; + } + } + return changed; + } + + boolean changed = false; + for (int i = end; i > start; i--) { + Object item = storage.get(i); + if (c.contains(item) != complement) { + _checkedDeleteElement(i); + changed = true; + } + } + + return changed; + } + + @SuppressWarnings("unchecked") + public void _do_sort(int start, int end, Comparator c) { + if (start >= end) { + this.modCount++; + return; + } + SymbolicList storage = _getStorage(); + int expectedModCount = this.modCount; + Engine.assume(start >= 0); + Engine.assume(end > 0); + int outerLimit = end - 1; + for (int i = start; i < outerLimit; i++) { + int innerLimit = end - i - 1; + for (int j = start; j < innerLimit; j++) { + int idxB = j + 1; + E a = storage.get(j); + E b = storage.get(idxB); + if (c != null && c.compare(a, b) > 0 || c == null && ((Comparable) a).compareTo(b) > 0) { + storage.set(j, b); + storage.set(idxB, a); + } + } + } + _checkForModification(expectedModCount); + } + + public boolean add(E e) { + SymbolicList storage = _getStorage(); + storage.insert(storage.size(), e); + this.modCount++; + return true; + } + + public void add(int index, E element) { + _checkedAddElement(index, element); + } + + public boolean addAll(@NotNull Collection c) { + return _addAllElements(_getStorage().size(), c); + } + + public boolean addAll(int index, @NotNull Collection c) { + _checkValidAddIndex(index); + return _addAllElements(index, c); + } + + public void clear() { + this.storage = Engine.makeSymbolicList(); + this.modCount++; + } + + @SuppressWarnings("unchecked") + public Object clone() throws CloneNotSupportedException { + AbstractListImpl clonedList = (AbstractListImpl) super.clone(); + SymbolicList storageCopy = Engine.makeSymbolicList(); + SymbolicList storage = _getStorage(); + storage.copy(storageCopy, 0, 0, storage.size()); + clonedList.storage = storageCopy; + clonedList.modCount = 0; + return clonedList; + } + + public boolean contains(Object o) { + return indexOf(o) != -1; + } + + @SuppressWarnings({"DataFlowIssue", "unchecked"}) + public boolean containsAll(@NotNull Collection c) { + if (c instanceof AbstractListImpl) { + SymbolicList otherStorage = ((AbstractListImpl) c)._getStorage(); + Engine.assume(otherStorage != null); + int otherLength = otherStorage.size(); + Engine.assume(otherLength >= 0); + boolean result = true; + int i = 0; + while (result && i < otherLength) { + E item = otherStorage.get(i); + result = contains(item); + i++; + } + return result; + } + + for (Object o : c) { + if (!contains(o)) + return false; + } + + return true; + } + + public void ensureCapacity(int minCapacity) { + this.modCount++; + } + + @SuppressWarnings("unchecked") + public boolean equals(Object other) { + if (other == this) + return true; + + if (other instanceof AbstractListImpl) { + AbstractListImpl otherList = (AbstractListImpl) other; + int expectedModCount = this.modCount; + int otherExpectedModCount = otherList.modCount; + SymbolicList otherStorage = otherList._getStorage(); + SymbolicList storage = _getStorage(); + int size = storage.size(); + int otherSize = otherStorage.size(); + boolean result = size == otherSize && LibSLRuntime.equals(storage, otherStorage); + otherList._checkForModification(otherExpectedModCount); + _checkForModification(expectedModCount); + return result; + } + + return false; + } + + public void forEach(Consumer _action) { + if (_action == null) + throw new NullPointerException(); + + int expectedModCount = this.modCount; + int i = 0; + SymbolicList storage = _getStorage(); + while (this.modCount == expectedModCount && i < storage.size()) { + E item = storage.get(i); + _action.accept(item); + i++; + } + _checkForModification(expectedModCount); + } + + public E get(int index) { + return _checkedGet(index); + } + + public int hashCode() { + return LibSLRuntime.hashCode(_getStorage()); + } + + public int indexOf(Object o) { + SymbolicList storage = _getStorage(); + return LibSLRuntime.ListActions.find(storage, o, 0, storage.size()); + } + + public boolean isEmpty() { + return _getStorage().size() == 0; + } + + @NotNull + public Iterator iterator() { + return new ListIteratorStubImpl<>(this); + } + + public int lastIndexOf(Object o) { + SymbolicList storage = _getStorage(); + int size = storage.size(); + if (size == 0) + return -1; + + Engine.assume(size > 0); + for (int i = size - 1; i > -1; i--) { + E e = storage.get(i); + if (LibSLRuntime.equals(o, e)) { + return i; + } + } + return -1; + } + + @NotNull + public ListIterator listIterator() { + return new ListIteratorStubImpl<>(this); + } + + @NotNull + public ListIterator listIterator(int index) { + _checkValidIndex(index); + return new ListIteratorStubImpl<>(this, index); + } + + public Stream parallelStream() { + return _makeStream(true); + } + + public boolean remove(Object o) { + int index = indexOf(o); + if (index == -1) + return false; + + _deleteElement(index); + return true; + + } + + public E remove(int index) { + return _checkedDeleteElement(index); + } + + public boolean removeAll(@NotNull Collection c) { + return _batchRemove(c, false, 0, _getStorage().size()); + } + + public boolean removeIf(Predicate filter) { + return _removeIf(filter, 0, _getStorage().size()); + } + + public void replaceAll(UnaryOperator op) { + if (op == null) + throw new NullPointerException(); + + _replaceAllRange(op, 0, _getStorage().size()); + this.modCount++; + } + + public boolean retainAll(@NotNull Collection c) { + return _batchRemove(c, true, 0, _getStorage().size()); + } + + public E set(int index, E element) { + return _checkedSetElement(index, element); + } + + public int size() { + return _getStorage().size(); + } + + public void sort(Comparator c) { + _do_sort(0, _getStorage().size(), c); + } + + public Spliterator spliterator() { + return new ListSpliteratorStubImpl<>(this); + } + + public Stream stream() { + return _makeStream(false); + } + + @NotNull + public List subList(int fromIndex, int toIndex) { + _subListRangeCheck(fromIndex, toIndex, _getStorage().size()); + return new SubListImpl<>(this, fromIndex, toIndex); + } + + @NotNull + public Object[] toArray() { + return _mapToArray(); + } + + public T[] toArray(IntFunction generator) { + return super.toArray(generator); + } + + @NotNull + public T[] toArray(@NotNull T[] array) { + return super.toArray(array); + } + + public String toString() { + return LibSLRuntime.toString(_getStorage()); + } +} diff --git a/approximations/src/main/java/generated/java/util/list/ArrayListImpl.java b/approximations/src/main/java/generated/java/util/list/ArrayListImpl.java new file mode 100644 index 00000000..2ad8d2fc --- /dev/null +++ b/approximations/src/main/java/generated/java/util/list/ArrayListImpl.java @@ -0,0 +1,201 @@ +package generated.java.util.list; + +import java.io.Serial; +import java.io.Serializable; +import java.lang.Object; +import java.lang.String; +import java.util.*; +import java.util.List; +import java.util.function.Consumer; +import java.util.function.IntFunction; +import java.util.function.Predicate; +import java.util.function.UnaryOperator; +import java.util.stream.Stream; + +import org.jacodb.approximation.annotation.Approximate; +import org.jetbrains.annotations.NotNull; +import org.usvm.api.Engine; +import org.usvm.api.SymbolicList; + +@SuppressWarnings("unused") +@Approximate(java.util.ArrayList.class) +public class ArrayListImpl extends AbstractListImpl implements RandomAccess, Cloneable, Serializable { + + @Serial + private static final long serialVersionUID = 8683452581122892189L; + + static { + Engine.assume(true); + } + + @SuppressWarnings("unused") + public ArrayListImpl(SymbolicList storage, int modCount) { + super(storage, modCount); + } + + @SuppressWarnings("unused") + public ArrayListImpl() { + super(); + } + + @SuppressWarnings("unused") + public ArrayListImpl(Collection c) { + super(c); + } + + @SuppressWarnings("unused") + public ArrayListImpl(int initialCapacity) { + super(initialCapacity); + } + + public boolean add(E e) { + return super.add(e); + } + + public void add(int index, E element) { + super.add(index, element); + } + + public boolean addAll(@NotNull Collection c) { + return super.addAll(c); + } + + public boolean addAll(int index, @NotNull Collection c) { + return super.addAll(index, c); + } + + public void clear() { + super.clear(); + } + + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + public boolean contains(Object o) { + return super.contains(o); + } + + @SuppressWarnings("SlowListContainsAll") + public boolean containsAll(@NotNull Collection c) { + return super.containsAll(c); + } + + public void ensureCapacity(int minCapacity) { + super.ensureCapacity(minCapacity); + } + + public boolean equals(Object other) { + return Engine.typeIs(other, ArrayListImpl.class) && super.equals(other); + } + + public void forEach(Consumer _action) { + super.forEach(_action); + } + + public E get(int index) { + return super.get(index); + } + + public int hashCode() { + return super.hashCode(); + } + + public int indexOf(Object o) { + return super.indexOf(o); + } + + public boolean isEmpty() { + return super.isEmpty(); + } + + @NotNull + public Iterator iterator() { + return super.iterator(); + } + + public int lastIndexOf(Object o) { + return super.lastIndexOf(o); + } + + @NotNull + public ListIterator listIterator() { + return super.listIterator(); + } + + @NotNull + public ListIterator listIterator(int index) { + return super.listIterator(index); + } + + public Stream parallelStream() { + return super.parallelStream(); + } + + public boolean remove(Object o) { + return super.remove(o); + } + + public E remove(int index) { + return super.remove(index); + } + + public boolean removeAll(@NotNull Collection c) { + return super.removeAll(c); + } + + public boolean removeIf(Predicate filter) { + return super.removeIf(filter); + } + + public void replaceAll(UnaryOperator op) { + super.replaceAll(op); + } + + public boolean retainAll(@NotNull Collection c) { + return super.retainAll(c); + } + + public E set(int index, E element) { + return super.set(index, element); + } + + public int size() { + return super.size(); + } + + public void sort(Comparator c) { + super.sort(c); + } + + public Spliterator spliterator() { + return super.spliterator(); + } + + public Stream stream() { + return super.stream(); + } + + @NotNull + public List subList(int fromIndex, int toIndex) { + return super.subList(fromIndex, toIndex); + } + + @NotNull + public Object[] toArray() { + return super.toArray(); + } + + public T[] toArray(IntFunction generator) { + return super.toArray(generator); + } + + @NotNull + public T[] toArray(@NotNull T[] array) { + return super.toArray(array); + } + + public String toString() { + return super.toString(); + } +} diff --git a/approximations/src/main/java/generated/java/util/list/LinkedListImpl.java b/approximations/src/main/java/generated/java/util/list/LinkedListImpl.java new file mode 100644 index 00000000..81d40859 --- /dev/null +++ b/approximations/src/main/java/generated/java/util/list/LinkedListImpl.java @@ -0,0 +1,342 @@ +package generated.java.util.list; + +import java.io.Serial; +import java.io.Serializable; +import java.lang.Object; +import java.lang.String; +import java.util.Collection; +import java.util.Comparator; +import java.util.Deque; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; +import java.util.Spliterator; +import java.util.function.Consumer; +import java.util.function.IntFunction; +import java.util.function.Predicate; +import java.util.function.UnaryOperator; +import java.util.stream.Stream; + +import org.jacodb.approximation.annotation.Approximate; +import org.jetbrains.annotations.NotNull; +import org.usvm.api.Engine; +import org.usvm.api.SymbolicList; +import runtime.LibSLRuntime; + +@Approximate(java.util.LinkedList.class) +public class LinkedListImpl extends AbstractListImpl implements Deque, Cloneable, Serializable { + + @Serial + private static final long serialVersionUID = 876323262645176354L; + + static { + Engine.assume(true); + } + + @SuppressWarnings("unused") + public LinkedListImpl(SymbolicList storage, int modCount) { + super(storage, modCount); + } + + @SuppressWarnings("unused") + public LinkedListImpl() { + super(); + } + + @SuppressWarnings("unused") + public LinkedListImpl(Collection c) { + super(c); + } + + private E _unlinkFirst() { + if (!_isValidIndex(0)) + throw new NoSuchElementException(); + + return _deleteElement(0); + } + + private E _getFirstElement() { + if (!_isValidIndex(0)) + throw new NoSuchElementException(); + + return _get(0); + } + + public boolean add(E e) { + return super.add(e); + } + + public void add(int index, E element) { + super.add(index, element); + } + + public boolean addAll(@NotNull Collection c) { + return super.addAll(c); + } + + public boolean addAll(int index, @NotNull Collection c) { + return super.addAll(index, c); + } + + public void addFirst(E e) { + _addElement(0, e); + } + + public void addLast(E e) { + _addElement(_getStorage().size(), e); + } + + public void clear() { + super.clear(); + } + + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + public boolean contains(Object o) { + return super.contains(o); + } + + @SuppressWarnings("SlowListContainsAll") + public boolean containsAll(@NotNull Collection c) { + return super.containsAll(c); + } + + @NotNull + public Iterator descendingIterator() { + return new LinkedList_DescendingIteratorImpl<>(this); + } + + public E element() { + return _getFirstElement(); + } + + public boolean equals(Object o) { + return Engine.typeIs(o, LinkedListImpl.class) && super.equals(o); + } + + public void forEach(Consumer _action) { + super.forEach(_action); + } + + public E get(int index) { + return super.get(index); + } + + public E getFirst() { + return _getFirstElement(); + } + + public E getLast() { + return super.get(_getStorage().size() - 1); + } + + public int hashCode() { + return super.hashCode(); + } + + public int indexOf(Object o) { + return super.indexOf(o); + } + + public boolean isEmpty() { + return super.isEmpty(); + } + + @NotNull + public Iterator iterator() { + return super.iterator(); + } + + public int lastIndexOf(Object o) { + return super.lastIndexOf(o); + } + + @NotNull + public ListIterator listIterator() { + return super.listIterator(); + } + + @NotNull + public ListIterator listIterator(int index) { + return super.listIterator(index); + } + + public boolean offer(E e) { + return add(e); + } + + public boolean offerFirst(E e) { + addFirst(e); + return true; + } + + public boolean offerLast(E e) { + addLast(e); + return true; + } + + public Stream parallelStream() { + return super.parallelStream(); + } + + public E peek() { + if (isEmpty()) + return null; + + return _get(0); + } + + public E peekFirst() { + return peek(); + } + + public E peekLast() { + int size = _getStorage().size(); + if (size == 0) + return null; + + return _get(size - 1); + } + + public E poll() { + if (isEmpty()) + return null; + + return _deleteElement(0); + } + + public E pollFirst() { + return poll(); + } + + public E pollLast() { + int size = _getStorage().size(); + if (size == 0) + return null; + + return _deleteElement(size - 1); + } + + public E pop() { + return _unlinkFirst(); + } + + public void push(E e) { + _addElement(0, e); + } + + public E remove() { + return _unlinkFirst(); + } + + public boolean remove(Object o) { + return super.remove(o); + } + + public E remove(int index) { + return super.remove(index); + } + + public boolean removeAll(@NotNull Collection c) { + return super.removeAll(c); + } + + public E removeFirst() { + return remove(); + } + + public boolean removeFirstOccurrence(Object o) { + return remove(o); + } + + public boolean removeIf(Predicate filter) { + return super.removeIf(filter); + } + + public E removeLast() { + int size = _getStorage().size(); + if (size == 0) { + throw new NoSuchElementException(); + } + + return _deleteElement(size - 1); + } + + public boolean removeLastOccurrence(Object o) { + SymbolicList storage = _getStorage(); + int size = storage.size(); + if (size == 0) + return false; + + Engine.assume(size > 0); + int index; + for (index = size - 1; index >= 0; index--) { + Object item = storage.get(index); + if (LibSLRuntime.equals(item, o)) { + break; + } + } + + if (index != -1) { + storage.remove(index); + this.modCount++; + return true; + } + + return false; + } + + public void replaceAll(UnaryOperator op) { + super.replaceAll(op); + } + + public boolean retainAll(@NotNull Collection c) { + return super.retainAll(c); + } + + public E set(int index, E element) { + return super.set(index, element); + } + + public int size() { + return super.size(); + } + + public void sort(Comparator c) { + super.sort(c); + } + + public Spliterator spliterator() { + return super.spliterator(); + } + + public Stream stream() { + return super.stream(); + } + + @NotNull + public List subList(int fromIndex, int toIndex) { + return super.subList(fromIndex, toIndex); + } + + @NotNull + public Object[] toArray() { + return super.toArray(); + } + + public T[] toArray(IntFunction generator) { + return super.toArray(generator); + } + + @NotNull + public T[] toArray(@NotNull T[] a) { + return super.toArray(a); + } + + public String toString() { + return super.toString(); + } +} diff --git a/approximations/src/main/java/generated/java/util/list/LinkedList_DescendingIteratorImpl.java b/approximations/src/main/java/generated/java/util/list/LinkedList_DescendingIteratorImpl.java new file mode 100644 index 00000000..66776808 --- /dev/null +++ b/approximations/src/main/java/generated/java/util/list/LinkedList_DescendingIteratorImpl.java @@ -0,0 +1,50 @@ +package generated.java.util.list; + +import java.lang.NullPointerException; +import java.util.function.Consumer; + +import org.jacodb.approximation.annotation.Approximate; +import org.usvm.api.SymbolicList; +import stub.java.util.list.LinkedList_DescendingIterator; + +@Approximate(LinkedList_DescendingIterator.class) +public final class LinkedList_DescendingIteratorImpl extends ListIteratorStubImpl { + + public LinkedList_DescendingIteratorImpl(LinkedListImpl list) { + super(list, list._getStorage().size()); + } + + @SuppressWarnings("unused") + private boolean _isEmpty() { + return !super.hasPrevious(); + } + + public boolean hasNext() { + return super.hasPrevious(); + } + + public E next() { + return super.previous(); + } + + public void remove() { + super.remove(); + } + + public void forEachRemaining(Consumer userAction) { + if (userAction == null) + throw new NullPointerException(); + + _checkForModification(); + int i = this.cursor; + SymbolicList storage = _getList()._getStorage(); + while (i >= 0) { + E item = storage.get(i); + userAction.accept(item); + i--; + _checkForModification(); + } + this.cursor = i; + this.lastRet = i + 1; + } +} diff --git a/approximations/src/main/java/generated/java/util/list/ListImpl.java b/approximations/src/main/java/generated/java/util/list/ListImpl.java new file mode 100644 index 00000000..a14458ca --- /dev/null +++ b/approximations/src/main/java/generated/java/util/list/ListImpl.java @@ -0,0 +1,137 @@ +package generated.java.util.list; + +import java.util.Collection; +import java.util.List; + +import org.jacodb.approximation.annotation.Approximate; +import org.usvm.api.Engine; +import org.usvm.api.SymbolicList; + +@SuppressWarnings("unused") +@Approximate(java.util.List.class) +public interface ListImpl extends Collection { + + static List copyOf(Collection coll) { + return new ArrayListImpl<>(coll); + } + + static List of() { + return new ArrayListImpl<>(); + } + + static List of(E element) { + SymbolicList data = Engine.makeSymbolicList(); + data.insert(0, element); + return new ArrayListImpl<>(data, 0); + } + + static List of(E element1, E element2) { + SymbolicList data = Engine.makeSymbolicList(); + data.insert(0, element1); + data.insert(1, element2); + return new ArrayListImpl<>(data, 0); + } + + static List of(E e1, E e2, E e3) { + SymbolicList data = Engine.makeSymbolicList(); + data.insert(0, e1); + data.insert(1, e2); + data.insert(2, e3); + return new ArrayListImpl<>(data, 0); + } + + static List of(E e1, E e2, E e3, E e4) { + SymbolicList data = Engine.makeSymbolicList(); + data.insert(0, e1); + data.insert(1, e2); + data.insert(2, e3); + data.insert(3, e4); + return new ArrayListImpl<>(data, 0); + } + + static List of(E e1, E e2, E e3, E e4, E e5) { + SymbolicList data = Engine.makeSymbolicList(); + data.insert(0, e1); + data.insert(1, e2); + data.insert(2, e3); + data.insert(3, e4); + data.insert(4, e5); + return new ArrayListImpl<>(data, 0); + } + + static List of(E e1, E e2, E e3, E e4, E e5, E e6) { + SymbolicList data = Engine.makeSymbolicList(); + data.insert(0, e1); + data.insert(1, e2); + data.insert(2, e3); + data.insert(3, e4); + data.insert(4, e5); + data.insert(5, e6); + return new ArrayListImpl<>(data, 0); + } + + static List of(E e1, E e2, E e3, E e4, E e5, E e6, E e7) { + SymbolicList data = Engine.makeSymbolicList(); + data.insert(0, e1); + data.insert(1, e2); + data.insert(2, e3); + data.insert(3, e4); + data.insert(4, e5); + data.insert(5, e6); + data.insert(6, e7); + return new ArrayListImpl<>(data, 0); + } + + static List of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8) { + SymbolicList data = Engine.makeSymbolicList(); + data.insert(0, e1); + data.insert(1, e2); + data.insert(2, e3); + data.insert(3, e4); + data.insert(4, e5); + data.insert(5, e6); + data.insert(6, e7); + data.insert(7, e8); + return new ArrayListImpl<>(data, 0); + } + + static List of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9) { + SymbolicList data = Engine.makeSymbolicList(); + data.insert(0, e1); + data.insert(1, e2); + data.insert(2, e3); + data.insert(3, e4); + data.insert(4, e5); + data.insert(5, e6); + data.insert(6, e7); + data.insert(7, e8); + data.insert(8, e9); + return new ArrayListImpl<>(data, 0); + } + + static List of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9, E e10) { + SymbolicList data = Engine.makeSymbolicList(); + data.insert(0, e1); + data.insert(1, e2); + data.insert(2, e3); + data.insert(3, e4); + data.insert(4, e5); + data.insert(5, e6); + data.insert(6, e7); + data.insert(7, e8); + data.insert(8, e9); + data.insert(9, e10); + return new ArrayListImpl<>(data, 0); + } + + @SuppressWarnings("ConstantValue") + static List of(E[] elements) { + SymbolicList data = Engine.makeSymbolicList(); + int size = elements.length; + Engine.assume(size >= 0); + for (int i = 0; i < size; i++) { + data.insert(i, elements[i]); + } + return new ArrayListImpl<>(data, 0); + } +} diff --git a/approximations/src/main/java/generated/java/util/list/ListIteratorStubImpl.java b/approximations/src/main/java/generated/java/util/list/ListIteratorStubImpl.java new file mode 100644 index 00000000..b97694fd --- /dev/null +++ b/approximations/src/main/java/generated/java/util/list/ListIteratorStubImpl.java @@ -0,0 +1,145 @@ +package generated.java.util.list; + +import java.lang.IllegalStateException; +import java.lang.NullPointerException; +import java.util.ListIterator; +import java.util.NoSuchElementException; +import java.util.function.Consumer; + +import generated.java.util.AbstractIteratorImpl; +import org.jacodb.approximation.annotation.Approximate; +import org.usvm.api.Engine; +import org.usvm.api.SymbolicList; +import stub.java.util.list.ListIteratorStub; + +@Approximate(ListIteratorStub.class) +public class ListIteratorStubImpl extends AbstractIteratorImpl implements ListIterator { + + public AbstractListImpl list; + + public int cursor; + + public int lastRet; + + public ListIteratorStubImpl(AbstractListImpl list, int index, int expectedModCount) { + super(expectedModCount); + Engine.assume(list != null); + this.list = list; + Engine.assume(index >= 0); + this.cursor = index; + this.lastRet = -1; + } + + public ListIteratorStubImpl(AbstractListImpl list, int index) { + this(list, index, list.modCount); + } + + public ListIteratorStubImpl(AbstractListImpl list) { + this(list, 0); + } + + protected AbstractListImpl _getList() { + AbstractListImpl result = this.list; + Engine.assume(result != null); + return result; + } + + protected int _parentModCount() { + return _getList().modCount; + } + + protected int _getSize(SymbolicList storage) { + return storage.size(); + } + + public boolean hasPrevious() { + return this.cursor > 0; + } + + public int nextIndex() { + return this.cursor; + } + + public int previousIndex() { + return this.cursor - 1; + } + + protected boolean _hasNext(int size) { + return this.cursor < size; + } + + public boolean hasNext() { + return _hasNext(_getList()._getStorage().size()); + } + + public E next() { + _checkForModification(); + if (!hasNext()) + throw new NoSuchElementException(); + + int i = this.cursor; + this.cursor = i + 1; + this.lastRet = i; + return _getList()._getStorage().get(i); + } + + public E previous() { + _checkForModification(); + if (!hasPrevious()) + throw new NoSuchElementException(); + + this.cursor--; + this.lastRet = this.cursor; + return _getList()._getStorage().get(this.cursor); + } + + public void remove() { + if (this.lastRet < 0) + throw new IllegalStateException(); + + _checkForModification(); + AbstractListImpl list = _getList(); + SymbolicList storage = list._getStorage(); + list.modCount++; + storage.remove(this.lastRet); + this.cursor = this.lastRet; + this.lastRet = -1; + this.expectedModCount = list.modCount; + } + + public void set(E e) { + if (this.lastRet < 0) + throw new IllegalStateException(); + + _checkForModification(); + SymbolicList storage = _getList()._getStorage(); + storage.set(this.lastRet, e); + } + + public void add(E e) { + _checkForModification(); + AbstractListImpl list = _getList(); + SymbolicList storage = list._getStorage(); + list.modCount++; + storage.insert(this.cursor, e); + this.cursor++; + this.lastRet = -1; + this.expectedModCount = list.modCount; + } + + public void forEachRemaining(Consumer userAction) { + if (userAction == null) + throw new NullPointerException(); + + _checkForModification(); + SymbolicList storage = _getList()._getStorage(); + int size = _getSize(storage); + while (this.cursor < size) { + E item = storage.get(this.cursor); + userAction.accept(item); + this.lastRet = this.cursor; + this.cursor++; + _checkForModification(); + } + } +} diff --git a/approximations/src/main/java/generated/java/util/list/ListSpliteratorStubImpl.java b/approximations/src/main/java/generated/java/util/list/ListSpliteratorStubImpl.java new file mode 100644 index 00000000..0ee02268 --- /dev/null +++ b/approximations/src/main/java/generated/java/util/list/ListSpliteratorStubImpl.java @@ -0,0 +1,92 @@ +package generated.java.util.list; + +import generated.java.util.AbstractSpliteratorImpl; +import generated.runtime.LibSLGlobals; +import java.lang.NullPointerException; +import java.util.function.Consumer; +import org.jacodb.approximation.annotation.Approximate; +import org.usvm.api.Engine; +import org.usvm.api.SymbolicList; +import stub.java.util.list.ListSpliteratorStub; + +@Approximate(ListSpliteratorStub.class) +public class ListSpliteratorStubImpl extends AbstractSpliteratorImpl { + + public AbstractListImpl list; + + protected ListSpliteratorStubImpl(AbstractListImpl list, int index, int fence, int expectedModCount) { + super(index, fence, expectedModCount); + Engine.assume(list != null); + this.list = list; + } + + public ListSpliteratorStubImpl(AbstractListImpl list) { + this(list, 0, -1, 0); + } + + private AbstractListImpl _getList() { + AbstractListImpl result = this.list; + Engine.assume(result != null); + return result; + } + + protected ListSpliteratorStubImpl _create(int index, int fence) { + return new ListSpliteratorStubImpl<>(this.list, index, fence, this.expectedModCount); + } + + protected int _parentModCount() { + return _getList().modCount; + } + + protected int _storageSize() { + return _getList()._getStorage().size(); + } + + public int characteristics() { + return LibSLGlobals.SPLITERATOR_ORDERED | LibSLGlobals.SPLITERATOR_SIZED | LibSLGlobals.SPLITERATOR_SUBSIZED; + } + + public long estimateSize() { + return super.estimateSize(); + } + + public void forEachRemaining(Consumer _action) { + if (_action == null) + throw new NullPointerException(); + + SymbolicList storage = _getList()._getStorage(); + int fence = _getFence(); + for (int i = this.index; i < fence; i++) { + E item = storage.get(i); + _action.accept(item); + } + this.index = fence; + _checkForModification(); + } + + public long getExactSizeIfKnown() { + return super.getExactSizeIfKnown(); + } + + public boolean tryAdvance(Consumer _action) { + if (_action == null) + throw new NullPointerException(); + + int fence = _getFence(); + int current = this.index; + if (current >= fence) + return false; + + this.index = current + 1; + SymbolicList storage = _getList()._getStorage(); + E item = storage.get(current); + _action.accept(item); + _checkForModification(); + + return true; + } + + public ListSpliteratorStubImpl trySplit() { + return (ListSpliteratorStubImpl) super.trySplit(); + } +} diff --git a/approximations/src/main/java/generated/java/util/list/SubListImpl.java b/approximations/src/main/java/generated/java/util/list/SubListImpl.java new file mode 100644 index 00000000..7aab3c14 --- /dev/null +++ b/approximations/src/main/java/generated/java/util/list/SubListImpl.java @@ -0,0 +1,462 @@ +package generated.java.util.list; + +import java.io.Serial; +import java.io.Serializable; +import java.lang.Object; +import java.lang.String; +import java.util.*; +import java.util.function.Consumer; +import java.util.function.IntFunction; +import java.util.function.Predicate; +import java.util.function.UnaryOperator; +import java.util.stream.Stream; + +import generated.java.util.stream.StreamStubImpl; +import org.jacodb.approximation.annotation.Approximate; +import org.jetbrains.annotations.NotNull; +import org.usvm.api.Engine; +import org.usvm.api.SymbolicList; +import runtime.LibSLRuntime; +import stub.java.util.list.SubList; + +@Approximate(SubList.class) +public final class SubListImpl extends AbstractListImpl implements RandomAccess, Cloneable, Serializable { + + @Serial + private static final long serialVersionUID = 8683452581122892189L; + + public transient AbstractListImpl list; + + public SubListImpl parentSubList; + + public int offset; + + public int length; + + public int modCount; + + @SuppressWarnings("DataFlowIssue") + private SubListImpl(AbstractListImpl list, SubListImpl parent, int offset, int length, int modCount) { + Engine.assume(list != null); + Engine.assume(offset >= 0); + Engine.assume(length >= 0); + Engine.assume(offset + length <= list._getStorage().size()); + this.list = list; + this.parentSubList = parent; + this.offset = offset; + this.length = length; + this.modCount = modCount; + } + + public SubListImpl(AbstractListImpl list, int fromIndex, int toIndex) { + this(list, null, fromIndex, toIndex - fromIndex, 0); + } + + public AbstractListImpl _getList() { + AbstractListImpl result = this.list; + Engine.assume(result != null); + return result; + } + + private int _effectiveIndex(int index) { + return this.offset + index; + } + + public int _endIndex() { + return _effectiveIndex(this.length); + } + + public boolean _addAllElements(int index, Collection c) { + list._checkValidIndex(index, this.length); + int effectiveIndex = _effectiveIndex(index); + AbstractListImpl list = _getList(); + if (c.isEmpty()) + return false; + + list._checkForModification(this.modCount); + list._addAllElements(effectiveIndex, c); + _updateSizeAndModCount(c.size()); + + return true; + } + + public void _updateSizeAndModCount(int sizeChange) { + this.length += sizeChange; + AbstractListImpl list = _getList(); + this.modCount = list.modCount; + SubListImpl parentSubList = this.parentSubList; + while (parentSubList != null) { + parentSubList.length += sizeChange; + parentSubList.modCount = this.modCount; + parentSubList = parentSubList.parentSubList; + } + } + + private int _indexOfElement(AbstractListImpl list, Object o) { + return LibSLRuntime.ListActions.find(list._getStorage(), o, this.offset, _endIndex()); + } + + private int _indexOfElement(Object o) { + AbstractListImpl list = _getList(); + list._checkForModification(this.modCount); + int index = _indexOfElement(list, o); + if (index != -1) + return index - this.offset; + + return -1; + } + + protected Object[] _mapToArray() { + AbstractListImpl list = _getList(); + list._checkForModification(this.modCount); + SymbolicList storage = list._getStorage(); + Object[] items = new Object[this.length]; + int endIndex = _endIndex(); + for (int i = this.offset; i < endIndex; i++) { + items[i] = storage.get(i); + } + return items; + } + + @SuppressWarnings("unchecked") + private Stream _makeStream(boolean parallel) { + E[] items = (E[]) _mapToArray(); + return new StreamStubImpl<>(items, parallel); + } + + private boolean _batchRemove(Collection c, boolean complement) { + AbstractListImpl list = _getList(); + list._checkForModification(this.modCount); + if (isEmpty()) + return false; + + SymbolicList storage = list._getStorage(); + int oldRootLength = storage.size(); + if (list._batchRemove(c, complement, this.offset, _endIndex())) { + int newRootLength = storage.size(); + _updateSizeAndModCount(newRootLength - oldRootLength); + return true; + } + + return false; + } + + public void add(int index, E element) { + AbstractListImpl list = _getList(); + list._checkForModification(this.modCount); + int effectiveIndex = _effectiveIndex(index); + list._checkedAddElement(effectiveIndex, element); + _updateSizeAndModCount(1); + } + + public boolean add(E e) { + add(this.length, e); + return true; + } + + public boolean addAll(@NotNull Collection c) { + return _addAllElements(this.length, c); + } + + public boolean addAll(int index, @NotNull Collection c) { + return _addAllElements(index, c); + } + + public void clear() { + AbstractListImpl list = _getList(); + list._checkForModification(this.modCount); + int size = this.length; + if (size == 0) + return; + + Engine.assume(size > 0); + int end = this.offset - 1; + int start = end + size; + SymbolicList rootStorage = list._getStorage(); + for (int i = start; i > end; i--) { + rootStorage.remove(i); + } + list.modCount++; + _updateSizeAndModCount(-size); + } + + @SuppressWarnings("unchecked") + public Object clone() throws CloneNotSupportedException { + SubListImpl cloned = (SubListImpl) super.clone(); + cloned.list = (AbstractListImpl) this.list.clone(); + cloned.parentSubList = (SubListImpl) this.parentSubList.clone(); + cloned.modCount = 0; + return cloned; + } + + public boolean contains(Object o) { + return _indexOfElement(o) != -1; + } + + @SuppressWarnings({"unchecked"}) + public boolean containsAll(@NotNull Collection c) { + if (c.isEmpty()) + return true; + + AbstractListImpl list = _getList(); + SymbolicList rootStorage = list._getStorage(); + int start = this.offset; + int end = _endIndex(); + if (c instanceof SubListImpl) { + SubListImpl otherSubList = (SubListImpl) c; + AbstractListImpl otherRoot = otherSubList._getList(); + SymbolicList otherStorage = otherRoot._getStorage(); + int otherOffset = otherSubList.offset; + int otherEnd = otherOffset + otherSubList.length; + Engine.assume(otherOffset >= 0); + Engine.assume(otherEnd >= 0); + for (int i = otherOffset; i < otherEnd; i++) { + E item = otherStorage.get(i); + if (LibSLRuntime.ListActions.find(rootStorage, item, start, end) == -1) + return false; + } + + return true; + } + + for (Object item : c) { + if (LibSLRuntime.ListActions.find(rootStorage, item, start, end) == -1) + return false; + } + + return true; + } + + @SuppressWarnings({"unchecked", "EqualsWhichDoesntCheckParameterClass"}) + public boolean equals(Object o) { + if (o == this) + return true; + + if (o == null || !Engine.typeIs(o, SubListImpl.class)) + return false; + + SubListImpl other = (SubListImpl) o; + int otherLength = other.length; + Engine.assume(otherLength >= 0); + if (this.length != otherLength) + return false; + + AbstractListImpl list = _getList(); + boolean result = list._equalsRange(other, this.offset, _endIndex()); + list._checkForModification(this.modCount); + + return result; + } + + public void forEach(Consumer _action) { + if (isEmpty()) + return; + + Engine.assume(this.length > 0); + AbstractListImpl list = _getList(); + SymbolicList rootStorage = list._getStorage(); + int expectedModCount = list.modCount; + this.modCount = expectedModCount; + int end = _endIndex(); + list._checkForModification(expectedModCount); + for (int i = this.offset; i < end; i++) { + _action.accept(rootStorage.get(i)); + list._checkForModification(expectedModCount); + } + } + + public E get(int index) { + AbstractListImpl list = _getList(); + list._checkValidIndex(index, this.length); + list._checkForModification(this.modCount); + int effectiveIndex = _effectiveIndex(index); + return list._getStorage().get(effectiveIndex); + } + + public int hashCode() { + int result = 1; + if (isEmpty()) + return result; + + Engine.assume(this.length > 0); + AbstractListImpl list = _getList(); + SymbolicList rootStorage = list._getStorage(); + result = LibSLRuntime.hashCode(rootStorage, this.offset, _endIndex()); + list._checkForModification(this.modCount); + + return result; + } + + public int indexOf(Object o) { + return _indexOfElement(o); + } + + public boolean isEmpty() { + return this.length == 0; + } + + @NotNull + public Iterator iterator() { + return new SubListIteratorStubImpl<>(this); + } + + public int lastIndexOf(Object o) { + AbstractListImpl list = _getList(); + list._checkForModification(this.modCount); + if (isEmpty()) + return -1; + + Engine.assume(this.length > 0); + int end = _endIndex(); + SymbolicList rootStorage = list._getStorage(); + int result = LibSLRuntime.ListActions.findBack(rootStorage, o, this.offset, end); + if (result == -1) + return result; + + result -= this.offset; + return result; + } + + @NotNull + public ListIterator listIterator() { + return new SubListIteratorStubImpl<>(this); + } + + @NotNull + public ListIterator listIterator(int index) { + return new SubListIteratorStubImpl<>(this, index); + } + + public Stream parallelStream() { + return _makeStream(true); + } + + public boolean remove(Object o) { + AbstractListImpl list = _getList(); + int index = _indexOfElement(list, o); + if (index == -1) + return false; + + list._checkForModification(this.modCount); + list._checkedDeleteElement(index); + _updateSizeAndModCount(-1); + + return true; + } + + public E remove(int index) { + AbstractListImpl list = _getList(); + list._checkValidIndex(index, this.length); + list._checkForModification(this.modCount); + int effectiveIndex = _effectiveIndex(index); + E result = list._checkedDeleteElement(effectiveIndex); + _updateSizeAndModCount(-1); + + return result; + } + + public boolean removeAll(@NotNull Collection c) { + return _batchRemove(c, false); + } + + public boolean removeIf(Predicate filter) { + AbstractListImpl list = _getList(); + list._checkForModification(this.modCount); + if (isEmpty()) + return false; + + SymbolicList storage = list._getStorage(); + int oldRootLength = storage.size(); + if (list._removeIf(filter, this.offset, _endIndex())) { + int newRootLength = storage.size(); + _updateSizeAndModCount(newRootLength - oldRootLength); + return true; + } + + return false; + } + + public void replaceAll(UnaryOperator operator) { + if (operator == null) + throw new NullPointerException(); + + _getList()._replaceAllRange(operator, this.offset, _endIndex()); + } + + public boolean retainAll(@NotNull Collection c) { + return _batchRemove(c, true); + } + + public E set(int index, E element) { + AbstractListImpl list = _getList(); + list._checkValidIndex(index, this.length); + list._checkForModification(this.modCount); + SymbolicList parentStorage = list._getStorage(); + int effectiveIndex = _effectiveIndex(index); + E oldValue = parentStorage.get(effectiveIndex); + parentStorage.set(effectiveIndex, element); + + return oldValue; + } + + public int size() { + _getList()._checkForModification(this.modCount); + return this.length; + } + + public void sort(Comparator c) { + AbstractListImpl list = _getList(); + list._do_sort(this.offset, _endIndex(), c); + this.modCount = list.modCount; + } + + public Spliterator spliterator() { + return new SubListSpliteratorStubImpl<>(this); + } + + public Stream stream() { + return _makeStream(false); + } + + @NotNull + public List subList(int fromIndex, int toIndex) { + AbstractListImpl list = _getList(); + list._subListRangeCheck(fromIndex, toIndex, this.length); + + return new SubListImpl<>(list, this, _effectiveIndex(fromIndex), toIndex - fromIndex, this.modCount); + } + + @NotNull + public Object[] toArray() { + return super.toArray(); + } + + public T[] toArray(IntFunction generator) { + return super.toArray(generator); + } + + @NotNull + public T[] toArray(@NotNull T[] array) { + return super.toArray(array); + } + + public String toString() { + if (this.length == 0) + return "[]"; + + String result = "["; + AbstractListImpl list = _getList(); + SymbolicList rootStorage = list._getStorage(); + int end = _endIndex(); + int counter = this.length; + for (int i = this.offset; i < end; i++) { + E item = rootStorage.get(i); + result = result.concat(LibSLRuntime.toString(item)); + counter--; + if (counter != 0) + result = result.concat(", "); + } + + return result.concat("]"); + } +} diff --git a/approximations/src/main/java/generated/java/util/list/SubListIteratorStubImpl.java b/approximations/src/main/java/generated/java/util/list/SubListIteratorStubImpl.java new file mode 100644 index 00000000..7747a590 --- /dev/null +++ b/approximations/src/main/java/generated/java/util/list/SubListIteratorStubImpl.java @@ -0,0 +1,95 @@ +package generated.java.util.list; + +import java.util.function.Consumer; + +import org.jacodb.approximation.annotation.Approximate; +import org.usvm.api.Engine; +import org.usvm.api.SymbolicList; +import stub.java.util.list.SubListIteratorStub; + +@Approximate(SubListIteratorStub.class) +public final class SubListIteratorStubImpl extends ListIteratorStubImpl { + + private final SubListImpl subList; + + private final int startIndex; + + private int endIndex; + + public SubListIteratorStubImpl( + AbstractListImpl list, + SubListImpl subList, + int cursor, + int expectedModCount, + int offset, + int length + ) { + super(list, cursor + offset, expectedModCount); + Engine.assume(list != null); + Engine.assume(subList != null); + this.subList = subList; + this.startIndex = offset; + this.endIndex = offset + length; + } + + public SubListIteratorStubImpl(SubListImpl subList, int index) { + this(subList._getList(), subList, index, subList.modCount, subList.offset, subList.length); + } + + public SubListIteratorStubImpl(SubListImpl subList) { + this(subList, 0); + } + + protected int _getSize(SymbolicList storage) { + return endIndex; + } + + private SubListImpl _getSubList() { + SubListImpl subList = this.subList; + Engine.assume(subList != null); + return subList; + } + + public boolean hasPrevious() { + return this.cursor > startIndex; + } + + public int nextIndex() { + return super.nextIndex(); + } + + public int previousIndex() { + return super.previousIndex(); + } + + public boolean hasNext() { + return _hasNext(endIndex); + } + + public E next() { + return super.next(); + } + + public E previous() { + return super.previous(); + } + + public void remove() { + super.remove(); + _getSubList()._updateSizeAndModCount(-1); + } + + public void set(E e) { + super.set(e); + } + + public void add(E e) { + super.add(e); + _getSubList()._updateSizeAndModCount(1); + this.endIndex++; + } + + public void forEachRemaining(Consumer userAction) { + super.forEachRemaining(userAction); + } +} diff --git a/approximations/src/main/java/generated/java/util/list/SubListSpliteratorStubImpl.java b/approximations/src/main/java/generated/java/util/list/SubListSpliteratorStubImpl.java new file mode 100644 index 00000000..602276cc --- /dev/null +++ b/approximations/src/main/java/generated/java/util/list/SubListSpliteratorStubImpl.java @@ -0,0 +1,66 @@ +package generated.java.util.list; + +import java.util.function.Consumer; +import org.jacodb.approximation.annotation.Approximate; +import stub.java.util.list.SubListSpliteratorStub; + +@Approximate(SubListSpliteratorStub.class) +public final class SubListSpliteratorStubImpl extends ListSpliteratorStubImpl { + + public SubListImpl subList; + + public SubListSpliteratorStubImpl( + AbstractListImpl list, + SubListImpl subList, + int index, + int fence, + int expectedModCount + ) { + super(list, subList.offset + index, fence, expectedModCount); + this.subList = subList; + } + + public SubListSpliteratorStubImpl(SubListImpl subList, int index) { + this(subList._getList(), subList, index, -1, 0); + } + + public SubListSpliteratorStubImpl(SubListImpl subList) { + this(subList, 0); + } + + protected SubListSpliteratorStubImpl _create(int index, int fence) { + return new SubListSpliteratorStubImpl<>(this.list, subList, index, fence, this.expectedModCount); + } + + protected int _parentModCount() { + return this.subList.modCount; + } + + protected int _storageSize() { + return subList._endIndex(); + } + + public int characteristics() { + return super.characteristics(); + } + + public long estimateSize() { + return super.estimateSize(); + } + + public void forEachRemaining(Consumer _action) { + super.forEachRemaining(_action); + } + + public long getExactSizeIfKnown() { + return super.getExactSizeIfKnown(); + } + + public boolean tryAdvance(Consumer _action) { + return super.tryAdvance(_action); + } + + public SubListSpliteratorStubImpl trySplit() { + return (SubListSpliteratorStubImpl) super.trySplit(); + } +} diff --git a/approximations/src/main/java/generated/java/util/map/AbstractMapImpl.java b/approximations/src/main/java/generated/java/util/map/AbstractMapImpl.java new file mode 100644 index 00000000..a7c3ba1b --- /dev/null +++ b/approximations/src/main/java/generated/java/util/map/AbstractMapImpl.java @@ -0,0 +1,499 @@ +package generated.java.util.map; + +import org.jacodb.approximation.annotation.Approximate; +import org.jetbrains.annotations.NotNull; +import org.usvm.api.Engine; +import runtime.LibSLRuntime; + +import java.util.*; +import java.util.function.BiConsumer; +import java.util.function.BiFunction; +import java.util.function.Function; + +@Approximate(java.util.AbstractMap.class) +public abstract class AbstractMapImpl implements Map { + + public LibSLRuntime.Map> storage; + + public transient int modCount; + + final boolean isHashMap; + + static LibSLRuntime.Map.Container> createContainer(boolean isHashMap) { + if (isHashMap) + return new LibSLRuntime.HashMapContainer<>(); + + return new LibSLRuntime.IdentityMapContainer<>(); + } + + static LibSLRuntime.Map> createStorage(boolean isHashMap) { + return new LibSLRuntime.Map<>(createContainer(isHashMap)); + } + + public AbstractMapImpl(boolean isHashMap) { + this.storage = createStorage(isHashMap); + this.modCount = 0; + this.isHashMap = isHashMap; + } + + public AbstractMapImpl(boolean isHashMap, Map m) { + this(isHashMap); + _addAllElements(m); + } + + public AbstractMapImpl(boolean isHashMap, int initialCapacity) { + if (initialCapacity < 0) + throw new IllegalArgumentException(); + + this.storage = createStorage(isHashMap); + this.modCount = 0; + this.isHashMap = isHashMap; + } + + public AbstractMapImpl(boolean isHashMap, int initialCapacity, float loadFactor) { + if (initialCapacity < 0) + throw new IllegalArgumentException(); + + if (loadFactor <= 0 || loadFactor != loadFactor) + throw new IllegalArgumentException(); + + this.storage = createStorage(isHashMap); + this.modCount = 0; + this.isHashMap = isHashMap; + } + + public LibSLRuntime.Map> _getStorage() { + LibSLRuntime.Map> result = this.storage; + Engine.assume(result != null); + return result; + } + + @SuppressWarnings("unchecked") + private void _addAllElements(Map m) { + LibSLRuntime.Map> storage = _getStorage(); + if (m instanceof AbstractMapImpl) { + AbstractMapImpl other = (AbstractMapImpl) m; + LibSLRuntime.Map> otherStorage = other._getStorage(); + storage.union(otherStorage); + return; + } + + Set> entrySet = m.entrySet(); + for (Entry oEntry : entrySet) { + K key = oEntry.getKey(); + V value = oEntry.getValue(); + if (storage.hasKey(key)) { + Entry entry = storage.get(key); + entry.setValue(value); + } else { + Entry entry = new AbstractMap_EntryImpl<>(key, value); + storage.set(key, entry); + } + this.modCount++; + } + } + + public void _checkForModification(int expectedModCount) { + if (this.modCount != expectedModCount) + throw new ConcurrentModificationException(); + } + + public void clear() { + this.modCount++; + this.storage = createStorage(this.isHashMap); + } + + @SuppressWarnings("unchecked") + public Object clone() throws CloneNotSupportedException { + AbstractMapImpl clonedMap = (AbstractMapImpl) super.clone(); + clonedMap.storage = _getStorage().duplicate(); + clonedMap.modCount = 0; + return clonedMap; + } + + private Map.Entry _getEntry(K key) { + LibSLRuntime.Map> storage = _getStorage(); + if (storage.hasKey(key)) + return storage.get(key); + + return null; + } + + private V _getEntryValueIfNotNull(Map.Entry entry, V defaultValue) { + if (entry != null) + return entry.getValue(); + + return defaultValue; + } + + private V _getEntryValueIfNotNull(Map.Entry entry) { + return _getEntryValueIfNotNull(entry, null); + } + + private void _update(K key, Map.Entry entry, V newValue) { + LibSLRuntime.Map> storage = _getStorage(); + if (newValue == null) { + storage.remove(key); + } else { + if (entry != null) { + entry.setValue(newValue); + } else { + entry = new AbstractMap_EntryImpl<>(key, newValue); + storage.set(key, entry); + } + } + } + + @SuppressWarnings("ConstantValue") + public V compute(K key, @NotNull BiFunction remappingFunction) { + if (remappingFunction == null) + throw new NullPointerException(); + + Map.Entry entry = _getEntry(key); + V oldValue = _getEntryValueIfNotNull(entry); + + int expectedModCount = this.modCount; + V newValue = remappingFunction.apply(key, oldValue); + _checkForModification(expectedModCount); + _update(key, entry, newValue); + + return newValue; + } + + @SuppressWarnings("ConstantValue") + public V computeIfAbsent(K key, @NotNull Function mappingFunction) { + if (mappingFunction == null) + throw new NullPointerException(); + + Map.Entry entry = _getEntry(key); + V oldValue = _getEntryValueIfNotNull(entry); + + if (oldValue != null) + return oldValue; + + int expectedModCount = this.modCount; + V newValue = mappingFunction.apply(key); + _checkForModification(expectedModCount); + _update(key, entry, newValue); + + return newValue; + } + + @SuppressWarnings("ConstantValue") + public V computeIfPresent(K key, @NotNull BiFunction remappingFunction) { + if (remappingFunction == null) + throw new NullPointerException(); + + Map.Entry entry = _getEntry(key); + V oldValue = _getEntryValueIfNotNull(entry); + + if (oldValue == null) + return oldValue; + + int expectedModCount = this.modCount; + V newValue = remappingFunction.apply(key, oldValue); + _checkForModification(expectedModCount); + _update(key, entry, newValue); + + return newValue; + } + + @SuppressWarnings("unchecked") + public boolean containsKey(Object key) { + LibSLRuntime.Map> storage = _getStorage(); + return storage.size() != 0 && storage.hasKey((K) key); + } + + public boolean containsValue(Object value) { + LibSLRuntime.Map> storage = _getStorage(); + int storageSize = storage.size(); + if (storageSize == 0) + return false; + + LibSLRuntime.Map> unseen = storage.duplicate(); + while (storageSize != 0) { + K curKey = unseen.anyKey(); + Map.Entry entry = unseen.get(curKey); + V curValue = entry.getValue(); + if (LibSLRuntime.equals(curValue, value)) + return true; + + unseen.remove(curKey); + storageSize--; + } + + return false; + } + + @NotNull + public Set> entrySet() { + return new Map_EntrySetImpl<>(this); + } + + @SuppressWarnings({"unchecked", "ConstantValue"}) + public boolean equals(Object other) { + if (other == this) + return true; + + if (!(other instanceof Map)) + return false; + + Map m = (Map) other; + LibSLRuntime.Map> storage = _getStorage(); + int thisLength = storage.size(); + if (thisLength != m.size()) + return false; + + Engine.assume(thisLength >= 0); + try { + LibSLRuntime.Map> unseen = storage.duplicate(); + while (thisLength > 0) { + K key = unseen.anyKey(); + Map.Entry entry = unseen.get(key); + V value = entry.getValue(); + if (value == null && m.get(key) != null) + return false; + if (value == null && !m.containsKey(key)) + return false; + if (value != null && !LibSLRuntime.equals(value, m.get(key))) + return false; + + unseen.remove(key); + thisLength--; + } + } catch (ClassCastException | NullPointerException e) { + return false; + } + + return true; + } + + public void forEach(BiConsumer userAction) { + if (userAction == null) + throw new NullPointerException(); + + LibSLRuntime.Map> storage = _getStorage(); + int storageSize = storage.size(); + if (storageSize == 0) + return; + + Engine.assume(storageSize > 0); + int expectedModCount = this.modCount; + LibSLRuntime.Map> unseen = storage.duplicate(); + for (int i = 0; i < storageSize; i++) { + K curKey = unseen.anyKey(); + Map.Entry entry = unseen.get(curKey); + V curValue = entry.getValue(); + userAction.accept(curKey, curValue); + unseen.remove(curKey); + } + _checkForModification(expectedModCount); + } + + @SuppressWarnings("unchecked") + public V get(Object key) { + return _getEntryValueIfNotNull(_getEntry((K) key)); + } + + @SuppressWarnings("unchecked") + public V getOrDefault(Object key, V defaultValue) { + return _getEntryValueIfNotNull(_getEntry((K) key), defaultValue); + } + + public int hashCode() { + return LibSLRuntime.hashCode(_getStorage()); + } + + public boolean isEmpty() { + return _getStorage().size() == 0; + } + + @NotNull + public Set keySet() { + return new Map_KeySetImpl<>(this); + } + + @SuppressWarnings("ConstantValue") + public V merge(K key, @NotNull V value, @NotNull BiFunction remappingFunction) { + if (value == null) + throw new NullPointerException(); + + if (remappingFunction == null) + throw new NullPointerException(); + + LibSLRuntime.Map> storage = _getStorage(); + if (storage.hasKey(key)) { + Map.Entry entry = storage.get(key); + V oldValue = entry.getValue(); + V result; + if (oldValue == null) { + result = value; + } else { + int expectedModCount = this.modCount; + result = remappingFunction.apply(oldValue, value); + _checkForModification(expectedModCount); + } + if (result == null) { + storage.remove(key); + } else { + entry.setValue(result); + } + return result; + } + + Map.Entry entry = new AbstractMap_EntryImpl<>(key, value); + storage.set(key, entry); + this.modCount++; + return value; + } + + public V put(K key, V value) { + this.modCount++; + LibSLRuntime.Map> storage = _getStorage(); + if (storage.hasKey(key)) { + Map.Entry entry = storage.get(key); + V result = entry.getValue(); + entry.setValue(value); + return result; + } + + Map.Entry entry = new AbstractMap_EntryImpl<>(key, value); + storage.set(key, entry); + + return null; + } + + @SuppressWarnings("ConstantValue") + public void putAll(@NotNull Map m) { + if (m == null) + throw new NullPointerException(); + + _addAllElements(m); + } + + public V putIfAbsent(K key, V value) { + LibSLRuntime.Map> storage = _getStorage(); + if (storage.hasKey(key)) { + Map.Entry entry = storage.get(key); + return entry.getValue(); + } + + Map.Entry entry = new AbstractMap_EntryImpl<>(key, value); + storage.set(key, entry); + this.modCount++; + + return null; + } + + @SuppressWarnings("unchecked") + public V remove(Object key) { + K typedKey = (K) key; + LibSLRuntime.Map> storage = _getStorage(); + if (storage.hasKey(typedKey)) { + Map.Entry entry = storage.get(typedKey); + V result = entry.getValue(); + storage.remove(typedKey); + this.modCount++; + return result; + } + + return null; + } + + @SuppressWarnings("unchecked") + public boolean remove(Object key, Object value) { + K typedKey = (K) key; + LibSLRuntime.Map> storage = _getStorage(); + if (storage.hasKey(typedKey)) { + Map.Entry entry = storage.get(typedKey); + V curValue = entry.getValue(); + if (LibSLRuntime.equals(curValue, value)) { + storage.remove(typedKey); + this.modCount++; + return true; + } + } + + return false; + } + + public V replace(K key, V value) { + LibSLRuntime.Map> storage = _getStorage(); + if (storage.hasKey(key)) { + Map.Entry entry = storage.get(key); + V result = entry.getValue(); + entry.setValue(value); + return result; + } + + return null; + } + + public boolean replace(K key, V oldValue, V newValue) { + LibSLRuntime.Map> storage = _getStorage(); + if (storage.hasKey(key)) { + Map.Entry entry = storage.get(key); + V curValue = entry.getValue(); + if (LibSLRuntime.equals(curValue, oldValue)) { + entry.setValue(newValue); + return true; + } + } + + return false; + } + + public void replaceAll(BiFunction function) { + if (function == null) + throw new NullPointerException(); + + LibSLRuntime.Map> storage = _getStorage(); + int size = storage.size(); + if (size == 0) + return; + + Engine.assume(size > 0); + int expectedModCount = this.modCount; + LibSLRuntime.Map> unseen = storage.duplicate(); + for (int i = 0; i < size; i++) { + K key = unseen.anyKey(); + Map.Entry entry = unseen.get(key); + entry.setValue(function.apply(key, entry.getValue())); + unseen.remove(key); + } + _checkForModification(expectedModCount); + } + + public int size() { + return _getStorage().size(); + } + + public String toString() { + LibSLRuntime.Map> storage = _getStorage(); + int size = storage.size(); + if (size == 0) + return "{}"; + + Engine.assume(size > 0); + String result = "{"; + LibSLRuntime.Map> unseen = storage.duplicate(); + Engine.assume(size > 0); + int lastIndex = size - 1; + for (int i = 0; i < size; i++) { + K key = unseen.anyKey(); + Map.Entry entry = unseen.get(key); + unseen.remove(key); + result = result.concat(LibSLRuntime.toString(entry)); + if (i != lastIndex) + result = result.concat(", "); + } + + return result.concat("}"); + } + + @NotNull + public Collection values() { + return new Map_ValuesImpl<>(this); + } + +} diff --git a/approximations/src/main/java/generated/java/util/map/AbstractMap_EntryImpl.java b/approximations/src/main/java/generated/java/util/map/AbstractMap_EntryImpl.java new file mode 100644 index 00000000..74ca5686 --- /dev/null +++ b/approximations/src/main/java/generated/java/util/map/AbstractMap_EntryImpl.java @@ -0,0 +1,66 @@ +package generated.java.util.map; + +import java.lang.Object; +import java.lang.String; +import java.util.Map; + +import org.jacodb.approximation.annotation.Approximate; +import runtime.LibSLRuntime; +import stub.java.util.map.AbstractMap_Entry; + +@Approximate(AbstractMap_Entry.class) +public class AbstractMap_EntryImpl implements Map.Entry { + + public K key; + + public V value; + + @SuppressWarnings("unused") + public AbstractMap_EntryImpl(Map.Entry entry) { + this.key = entry.getKey(); + this.value = entry.getValue(); + } + + @SuppressWarnings("unused") + public AbstractMap_EntryImpl(K key, V value) { + this.key = key; + this.value = value; + } + + @SuppressWarnings("unchecked") + public boolean equals(Object other) { + if (other == this) + return true; + + if (other instanceof Map.Entry) { + Map.Entry oEntry = ((Map.Entry) other); + Object otherKey = oEntry.getKey(); + Object otherValue = oEntry.getValue(); + return LibSLRuntime.equals(this.key, otherKey) && LibSLRuntime.equals(this.value, otherValue); + } + + return false; + } + + public K getKey() { + return this.key; + } + + public V getValue() { + return this.value; + } + + public int hashCode() { + return LibSLRuntime.hashCode(this.key) ^ LibSLRuntime.hashCode(this.value); + } + + public V setValue(V value) { + V oldValue = this.value; + this.value = value; + return oldValue; + } + + public String toString() { + return LibSLRuntime.toString(this.key).concat("=").concat(LibSLRuntime.toString(this.value)); + } +} diff --git a/approximations/src/main/java/generated/java/util/map/ConcurrentHashMapImpl.java b/approximations/src/main/java/generated/java/util/map/ConcurrentHashMapImpl.java new file mode 100644 index 00000000..3074b9d5 --- /dev/null +++ b/approximations/src/main/java/generated/java/util/map/ConcurrentHashMapImpl.java @@ -0,0 +1,155 @@ +package generated.java.util.map; + +import org.jacodb.approximation.annotation.Approximate; +import org.jetbrains.annotations.NotNull; +import org.usvm.api.Engine; + +import java.io.Serial; +import java.io.Serializable; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.function.BiConsumer; +import java.util.function.BiFunction; +import java.util.function.Function; + +@Approximate(ConcurrentHashMap.class) +public class ConcurrentHashMapImpl extends AbstractMapImpl implements ConcurrentMap, Serializable { + + @Serial + private static final long serialVersionUID = 7249069246763182397L; + + static { + Engine.assume(true); + } + + @SuppressWarnings("unused") + public ConcurrentHashMapImpl() { + super(true); + } + + public ConcurrentHashMapImpl(Map m) { + super(true, m); + } + + @SuppressWarnings("unused") + public ConcurrentHashMapImpl(int initialCapacity) { + super(true, initialCapacity); + } + + @SuppressWarnings("unused") + public ConcurrentHashMapImpl(int initialCapacity, float loadFactor) { + super(true, initialCapacity, loadFactor); + } + + public void clear() { + super.clear(); + } + + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + public V compute(K key, @NotNull BiFunction remappingFunction) { + return super.compute(key, remappingFunction); + } + + public V computeIfAbsent(K key, @NotNull Function mappingFunction) { + return super.computeIfAbsent(key, mappingFunction); + } + + public V computeIfPresent(K key, @NotNull BiFunction remappingFunction) { + return super.computeIfPresent(key, remappingFunction); + } + + public boolean containsKey(Object key) { + return super.containsKey(key); + } + + public boolean containsValue(Object value) { + return super.containsValue(value); + } + + @NotNull + public Set> entrySet() { + return super.entrySet(); + } + + public boolean equals(Object other) { + return Engine.typeIs(other, ConcurrentHashMapImpl.class) && super.equals(other); + } + + public void forEach(BiConsumer userAction) { + super.forEach(userAction); + } + + public V get(Object key) { + return super.get(key); + } + + public V getOrDefault(Object key, V defaultValue) { + return super.getOrDefault(key, defaultValue); + } + + public int hashCode() { + return super.hashCode(); + } + + public boolean isEmpty() { + return super.isEmpty(); + } + + @NotNull + public Set keySet() { + return super.keySet(); + } + + public V merge(K key, @NotNull V value, @NotNull BiFunction remappingFunction) { + return super.merge(key, value, remappingFunction); + } + + public V put(K key, V value) { + return super.put(key, value); + } + + public void putAll(@NotNull Map m) { + super.putAll(m); + } + + public V putIfAbsent(@NotNull K key, V value) { + return super.putIfAbsent(key, value); + } + + public V remove(Object key) { + return super.remove(key); + } + + public boolean remove(@NotNull Object key, Object value) { + return super.remove(key, value); + } + + public V replace(@NotNull K key, @NotNull V value) { + return super.replace(key, value); + } + + public boolean replace(@NotNull K key, @NotNull V oldValue, @NotNull V newValue) { + return super.replace(key, oldValue, newValue); + } + + public void replaceAll(BiFunction function) { + super.replaceAll(function); + } + + public int size() { + return super.size(); + } + + public String toString() { + return super.toString(); + } + + @NotNull + public Collection values() { + return super.values(); + } +} diff --git a/approximations/src/main/java/generated/java/util/map/HashMapImpl.java b/approximations/src/main/java/generated/java/util/map/HashMapImpl.java new file mode 100644 index 00000000..3788bf1d --- /dev/null +++ b/approximations/src/main/java/generated/java/util/map/HashMapImpl.java @@ -0,0 +1,157 @@ +package generated.java.util.map; + +import java.io.Serial; +import java.io.Serializable; +import java.lang.Object; +import java.lang.String; +import java.util.Collection; +import java.util.Map; +import java.util.Set; +import java.util.function.BiConsumer; +import java.util.function.BiFunction; +import java.util.function.Function; + +import org.jacodb.approximation.annotation.Approximate; +import org.jetbrains.annotations.NotNull; +import org.usvm.api.Engine; + +@Approximate(java.util.HashMap.class) +public class HashMapImpl extends AbstractMapImpl implements Cloneable, Serializable { + + @Serial + private static final long serialVersionUID = 362498820763181265L; + + static { + Engine.assume(true); + } + + @SuppressWarnings("unused") + public HashMapImpl() { + super(true); + } + + public HashMapImpl(Map m) { + super(true, m); + } + + @SuppressWarnings("unused") + public HashMapImpl(int initialCapacity) { + super(true, initialCapacity); + } + + @SuppressWarnings("unused") + public HashMapImpl(int initialCapacity, float loadFactor) { + super(true, initialCapacity, loadFactor); + } + + public void clear() { + super.clear(); + } + + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + public V compute(K key, @NotNull BiFunction remappingFunction) { + return super.compute(key, remappingFunction); + } + + public V computeIfAbsent(K key, @NotNull Function mappingFunction) { + return super.computeIfAbsent(key, mappingFunction); + } + + public V computeIfPresent(K key, @NotNull BiFunction remappingFunction) { + return super.computeIfPresent(key, remappingFunction); + } + + public boolean containsKey(Object key) { + return super.containsKey(key); + } + + public boolean containsValue(Object value) { + return super.containsValue(value); + } + + @NotNull + public Set> entrySet() { + return super.entrySet(); + } + + public boolean equals(Object other) { + return Engine.typeIs(other, HashMapImpl.class) && super.equals(other); + } + + public void forEach(BiConsumer userAction) { + super.forEach(userAction); + } + + public V get(Object key) { + return super.get(key); + } + + public V getOrDefault(Object key, V defaultValue) { + return super.getOrDefault(key, defaultValue); + } + + public int hashCode() { + return super.hashCode(); + } + + public boolean isEmpty() { + return super.isEmpty(); + } + + @NotNull + public Set keySet() { + return super.keySet(); + } + + public V merge(K key, @NotNull V value, @NotNull BiFunction remappingFunction) { + return super.merge(key, value, remappingFunction); + } + + public V put(K key, V value) { + return super.put(key, value); + } + + public void putAll(@NotNull Map m) { + super.putAll(m); + } + + public V putIfAbsent(K key, V value) { + return super.putIfAbsent(key, value); + } + + public V remove(Object key) { + return super.remove(key); + } + + public boolean remove(Object key, Object value) { + return super.remove(key, value); + } + + public V replace(K key, V value) { + return super.replace(key, value); + } + + public boolean replace(K key, V oldValue, V newValue) { + return super.replace(key, oldValue, newValue); + } + + public void replaceAll(BiFunction function) { + super.replaceAll(function); + } + + public int size() { + return super.size(); + } + + public String toString() { + return super.toString(); + } + + @NotNull + public Collection values() { + return super.values(); + } +} diff --git a/approximations/src/main/java/generated/java/util/map/LinkedHashMapImpl.java b/approximations/src/main/java/generated/java/util/map/LinkedHashMapImpl.java new file mode 100644 index 00000000..791058b4 --- /dev/null +++ b/approximations/src/main/java/generated/java/util/map/LinkedHashMapImpl.java @@ -0,0 +1,157 @@ +package generated.java.util.map; + +import java.io.Serial; +import java.lang.Object; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Collection; +import java.util.Map; +import java.util.Set; +import java.util.function.BiConsumer; +import java.util.function.BiFunction; +import java.util.function.Function; +import org.jacodb.approximation.annotation.Approximate; +import org.jetbrains.annotations.NotNull; +import org.usvm.api.Engine; + +@Approximate(java.util.LinkedHashMap.class) +public class LinkedHashMapImpl extends HashMapImpl { + + @Serial + private static final long serialVersionUID = 3801124242820219131L; + + static { + Engine.assume(true); + } + + @SuppressWarnings("unused") + public LinkedHashMapImpl() { + super(); + } + + @SuppressWarnings("unused") + public LinkedHashMapImpl(Map m) { + super(m); + } + + @SuppressWarnings("unused") + public LinkedHashMapImpl(int initialCapacity) { + super(initialCapacity); + } + + @SuppressWarnings("unused") + public LinkedHashMapImpl(int initialCapacity, float loadFactor) { + super(initialCapacity, loadFactor); + } + + public void clear() { + super.clear(); + } + + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + public V compute(K key, @NotNull BiFunction remappingFunction) { + return super.compute(key, remappingFunction); + } + + public V computeIfAbsent(K key, @NotNull Function mappingFunction) { + return super.computeIfAbsent(key, mappingFunction); + } + + public V computeIfPresent(K key, @NotNull BiFunction remappingFunction) { + return super.computeIfPresent(key, remappingFunction); + } + + public boolean containsKey(Object key) { + return super.containsKey(key); + } + + public boolean containsValue(Object value) { + return super.containsValue(value); + } + + @NotNull + public Set> entrySet() { + return super.entrySet(); + } + + public boolean equals(Object other) { + return Engine.typeIs(other, LinkedHashMapImpl.class) && super.equals(other); + } + + public void forEach(BiConsumer userAction) { + super.forEach(userAction); + } + + public V get(Object key) { + return super.get(key); + } + + public V getOrDefault(Object key, V defaultValue) { + return super.getOrDefault(key, defaultValue); + } + + public int hashCode() { + return super.hashCode(); + } + + public boolean isEmpty() { + return super.isEmpty(); + } + + @NotNull + public Set keySet() { + return super.keySet(); + } + + public V merge(K key, @NotNull V value, @NotNull BiFunction remappingFunction) { + return super.merge(key, value, remappingFunction); + } + + public V put(K key, V value) { + return super.put(key, value); + } + + public void putAll(@NotNull Map m) { + super.putAll(m); + } + + public V putIfAbsent(K key, V value) { + return super.putIfAbsent(key, value); + } + + public V remove(Object key) { + return super.remove(key); + } + + public boolean remove(Object key, Object value) { + return super.remove(key, value); + } + + public V replace(K key, V value) { + return super.replace(key, value); + } + + public boolean replace(K key, V oldValue, V newValue) { + return super.replace(key, oldValue, newValue); + } + + public void replaceAll(BiFunction function) { + super.replaceAll(function); + } + + public int size() { + return super.size(); + } + + public String toString() { + return super.toString(); + } + + @NotNull + public Collection values() { + return super.values(); + } +} diff --git a/approximations/src/main/java/generated/java/util/map/Map_ContentsImpl.java b/approximations/src/main/java/generated/java/util/map/Map_ContentsImpl.java new file mode 100644 index 00000000..45166aa2 --- /dev/null +++ b/approximations/src/main/java/generated/java/util/map/Map_ContentsImpl.java @@ -0,0 +1,275 @@ +package generated.java.util.map; + +import generated.java.util.AbstractCollectionImpl; +import generated.java.util.stream.StreamStubImpl; +import org.jacodb.approximation.annotation.Approximate; +import org.jetbrains.annotations.NotNull; +import org.usvm.api.Engine; +import runtime.LibSLRuntime; +import stub.java.util.map.Map_Contents; + +import java.util.*; +import java.util.function.Consumer; +import java.util.function.IntFunction; +import java.util.function.Predicate; +import java.util.stream.Stream; + +@Approximate(Map_Contents.class) +public abstract class Map_ContentsImpl extends AbstractCollectionImpl { + + public AbstractMapImpl map; + + public Map_ContentsImpl(AbstractMapImpl map) { + super(0); + this.map = map; + } + + @SuppressWarnings("DataFlowIssue") + LibSLRuntime.Map> getStorage() { + Engine.assume(this.map != null); + return this.map._getStorage(); + } + + abstract Content _contentByKey(LibSLRuntime.Map> storage, K key); + + @SuppressWarnings("ConstantValue") + protected Object[] _mapToArray() { + LibSLRuntime.Map> storage = getStorage(); + int storageSize = storage.size(); + Object[] result = new Object[storageSize]; + if (storageSize == 0) + return result; + + Engine.assume(storageSize > 0); + LibSLRuntime.Map> unseen = storage.duplicate(); + for (int i = 0; i < storageSize; i++) { + K curKey = unseen.anyKey(); + result[i] = _contentByKey(storage, curKey); + unseen.remove(curKey); + } + return result; + } + + public boolean add(Content e) { + throw new UnsupportedOperationException(); + } + + public boolean addAll(@NotNull Collection c) { + throw new UnsupportedOperationException(); + } + + public void clear() { + this.map.clear(); + } + + abstract boolean _containsInStorage(LibSLRuntime.Map> storage, Object o); + + public boolean contains(Object obj) { + LibSLRuntime.Map> storage = getStorage(); + if (storage.size() == 0) + return false; + + return _containsInStorage(storage, obj); + } + + public boolean containsAll(@NotNull Collection c) { + if (c == this || c.isEmpty()) + return true; + + for (Object elem : c) { + if (!contains(elem)) + return false; + } + + return true; + } + + Collection _equalsTypeCheck(Object other) { + if (other instanceof Collection) + return (Collection) other; + + return null; + } + + @SuppressWarnings("EqualsWhichDoesntCheckParameterClass") + public boolean equals(Object other) { + if (other == this) + return true; + + Collection c = _equalsTypeCheck(other); + if (c == null) + return false; + + if (getStorage().size() != c.size()) + return false; + + return containsAll(c); + } + + public void forEach(Consumer userAction) { + if (userAction == null) + throw new NullPointerException(); + + LibSLRuntime.Map> storage = getStorage(); + int size = storage.size(); + if (size == 0) + return; + + Engine.assume(size > 0); + int expectedModCount = this.map.modCount; + LibSLRuntime.Map> unseen = storage.duplicate(); + for (int i = 0; i < size; i++) { + K key = unseen.anyKey(); + userAction.accept(_contentByKey(storage, key)); + unseen.remove(key); + } + this.map._checkForModification(expectedModCount); + } + + public int hashCode() { + return LibSLRuntime.hashCode(getStorage()); + } + + public boolean isEmpty() { + return getStorage().size() == 0; + } + + @NotNull + public Iterator iterator() { + return new Map_Contents_IteratorImpl<>(this, getStorage().duplicate(), this.map.modCount); + } + + @SuppressWarnings("unchecked") + public Stream parallelStream() { + Content[] items = (Content[]) _mapToArray(); + return new StreamStubImpl<>(items, true); + } + + public abstract boolean remove(Object o); + + @SuppressWarnings("ConstantValue") + public boolean removeAll(@NotNull Collection c) { + if (c == null) + throw new NullPointerException(); + + LibSLRuntime.Map> storage = getStorage(); + int startStorageSize = storage.size(); + int cSize = c.size(); + if (startStorageSize == 0 || cSize == 0) + return false; + + if (startStorageSize <= cSize) { + LibSLRuntime.Map> unseen = storage.duplicate(); + for (int i = 0; i < startStorageSize; i++) { + K key = unseen.anyKey(); + if (c.contains(_contentByKey(storage, key))) { + storage.remove(key); + this.map.modCount++; + } + unseen.remove(key); + } + + return startStorageSize != storage.size(); + } + + for (Object key : c) { + remove(key); + } + + return startStorageSize != storage.size(); + } + + public boolean removeIf(Predicate filter) { + if (filter == null) + throw new NullPointerException(); + + LibSLRuntime.Map> storage = getStorage(); + int startStorageSize = storage.size(); + if (startStorageSize == 0) + return false; + + LibSLRuntime.Map> unseen = storage.duplicate(); + for (int i = 0; i < startStorageSize; i++) { + K curKey = unseen.anyKey(); + if (filter.test(_contentByKey(storage, curKey))) { + storage.remove(curKey); + this.map.modCount++; + } + unseen.remove(curKey); + } + + return startStorageSize != storage.size(); + } + + @SuppressWarnings("ConstantValue") + public boolean retainAll(@NotNull Collection c) { + if (c == null) + throw new NullPointerException(); + + LibSLRuntime.Map> storage = getStorage(); + int startStorageSize = storage.size(); + int cSize = c.size(); + if (startStorageSize == 0 || cSize == 0) + return false; + + LibSLRuntime.Map> unseen = storage.duplicate(); + for (int i = 0; i < startStorageSize; i++) { + K curKey = unseen.anyKey(); + if (!c.contains(_contentByKey(storage, curKey))) { + storage.remove(curKey); + this.map.modCount++; + } + } + + return startStorageSize != storage.size(); + } + + public int size() { + return this.map.size(); + } + + public Spliterator spliterator() { + return new Map_Contents_SpliteratorImpl<>(this); + } + + @SuppressWarnings("unchecked") + public Stream stream() { + Content[] items = (Content[]) _mapToArray(); + return new StreamStubImpl<>(items); + } + + @NotNull + public Object[] toArray() { + return super.toArray(); + } + + public T[] toArray(IntFunction generator) { + return super.toArray(generator); + } + + @NotNull + public T[] toArray(@NotNull T[] array) { + return super.toArray(array); + } + + public String toString() { + LibSLRuntime.Map> storage = getStorage(); + int size = storage.size(); + if (size == 0) + return "[]"; + + String result = "["; + LibSLRuntime.Map> unseen = storage.duplicate(); + Engine.assume(size > 0); + int lastIndex = size - 1; + for (int i = 0; i < size; i++) { + K key = unseen.anyKey(); + unseen.remove(key); + result = result.concat(LibSLRuntime.toString(_contentByKey(storage, key))); + if (i != lastIndex) + result = result.concat(", "); + } + + return result.concat("]"); + } +} diff --git a/approximations/src/main/java/generated/java/util/map/Map_ContentsSetImpl.java b/approximations/src/main/java/generated/java/util/map/Map_ContentsSetImpl.java new file mode 100644 index 00000000..aeb1d5f6 --- /dev/null +++ b/approximations/src/main/java/generated/java/util/map/Map_ContentsSetImpl.java @@ -0,0 +1,113 @@ +package generated.java.util.map; + +import org.jacodb.approximation.annotation.Approximate; +import org.jetbrains.annotations.NotNull; +import stub.java.util.map.Map_ContentsSet; + +import java.util.*; +import java.util.function.Consumer; +import java.util.function.IntFunction; +import java.util.function.Predicate; +import java.util.stream.Stream; + +@Approximate(Map_ContentsSet.class) +public abstract class Map_ContentsSetImpl extends Map_ContentsImpl implements Set { + + public Map_ContentsSetImpl(AbstractMapImpl map) { + super(map); + } + + public boolean add(Content e) { + return super.add(e); + } + + public boolean addAll(@NotNull Collection c) { + return super.addAll(c); + } + + public void clear() { + super.clear(); + } + + public boolean contains(Object obj) { + return super.contains(obj); + } + + public boolean containsAll(@NotNull Collection c) { + return super.containsAll(c); + } + + Set _equalsTypeCheck(Object other) { + if (other instanceof Set) + return (Set) other; + + return null; + } + + public boolean equals(Object other) { + return super.equals(other); + } + + public void forEach(Consumer userAction) { + super.forEach(userAction); + } + + public int hashCode() { + return super.hashCode(); + } + + public boolean isEmpty() { + return super.isEmpty(); + } + + @NotNull + public Iterator iterator() { + return super.iterator(); + } + + public Stream parallelStream() { + return super.parallelStream(); + } + + public boolean removeAll(@NotNull Collection c) { + return super.removeAll(c); + } + + public boolean removeIf(Predicate filter) { + return super.removeIf(filter); + } + + public boolean retainAll(@NotNull Collection c) { + return super.retainAll(c); + } + + public int size() { + return super.size(); + } + + public Spliterator spliterator() { + return new Map_ContentsSet_SpliteratorImpl<>(this); + } + + public Stream stream() { + return super.stream(); + } + + @NotNull + public Object[] toArray() { + return super.toArray(); + } + + public T[] toArray(IntFunction generator) { + return super.toArray(generator); + } + + @NotNull + public T[] toArray(@NotNull T[] array) { + return super.toArray(array); + } + + public String toString() { + return super.toString(); + } +} diff --git a/approximations/src/main/java/generated/java/util/map/Map_ContentsSet_SpliteratorImpl.java b/approximations/src/main/java/generated/java/util/map/Map_ContentsSet_SpliteratorImpl.java new file mode 100644 index 00000000..e26bc6b6 --- /dev/null +++ b/approximations/src/main/java/generated/java/util/map/Map_ContentsSet_SpliteratorImpl.java @@ -0,0 +1,66 @@ +package generated.java.util.map; + +import generated.runtime.LibSLGlobals; +import org.jacodb.approximation.annotation.Approximate; +import org.usvm.api.SymbolicList; +import stub.java.util.map.Map_ContentsSet_Spliterator; + +import java.util.function.Consumer; + +@Approximate(Map_ContentsSet_Spliterator.class) +public class Map_ContentsSet_SpliteratorImpl extends Map_Contents_SpliteratorImpl { + + Map_ContentsSet_SpliteratorImpl( + Map_ContentsSetImpl set, + SymbolicList seenKeys, + SymbolicList unseenKeys, + int index, + int fence, + int expectedModCount + ) { + super(set, seenKeys, unseenKeys, index, fence, expectedModCount); + } + + public Map_ContentsSet_SpliteratorImpl(Map_ContentsSetImpl set) { + super(set); + } + + Map_ContentsSet_SpliteratorImpl _createSpliterator( + SymbolicList seenKeys, + SymbolicList unseenKeys, + int index, + int fence, + int expectedModCount + ) { + Map_ContentsSetImpl typedContents = (Map_ContentsSetImpl) this.contents; + return new Map_ContentsSet_SpliteratorImpl<>(typedContents, seenKeys, unseenKeys, index, fence, expectedModCount); + } + + protected int _defaultCharacteristics() { + return LibSLGlobals.SPLITERATOR_DISTINCT; + } + + public int characteristics() { + return super.characteristics(); + } + + public long estimateSize() { + return super.estimateSize(); + } + + public void forEachRemaining(Consumer userAction) { + super.forEachRemaining(userAction); + } + + public long getExactSizeIfKnown() { + return super.getExactSizeIfKnown(); + } + + public boolean tryAdvance(Consumer userAction) { + return super.tryAdvance(userAction); + } + + public Map_ContentsSet_SpliteratorImpl trySplit() { + return (Map_ContentsSet_SpliteratorImpl) super.trySplit(); + } +} diff --git a/approximations/src/main/java/generated/java/util/map/Map_Contents_IteratorImpl.java b/approximations/src/main/java/generated/java/util/map/Map_Contents_IteratorImpl.java new file mode 100644 index 00000000..258d5a3a --- /dev/null +++ b/approximations/src/main/java/generated/java/util/map/Map_Contents_IteratorImpl.java @@ -0,0 +1,99 @@ +package generated.java.util.map; + +import generated.java.util.AbstractIteratorImpl; +import org.jacodb.approximation.annotation.Approximate; +import org.usvm.api.Engine; +import runtime.LibSLRuntime; +import stub.java.util.map.Map_Contents_Iterator; + +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.function.Consumer; + +@Approximate(Map_Contents_Iterator.class) +public class Map_Contents_IteratorImpl extends AbstractIteratorImpl { + + public Map_ContentsImpl contents; + + public LibSLRuntime.Map> unseen; + + public K currentKey; + + public Map_Contents_IteratorImpl( + Map_ContentsImpl contents, + LibSLRuntime.Map> unseen, + int expectedModCount + ) { + super(expectedModCount); + this.contents = contents; + this.unseen = unseen; + this.currentKey = null; + } + + private Map_ContentsImpl _getContents() { + Map_ContentsImpl result = this.contents; + Engine.assume(result != null); + return result; + } + + private AbstractMapImpl _getMap() { + AbstractMapImpl result = _getContents().map; + Engine.assume(result != null); + return result; + } + + protected int _parentModCount() { + return _getMap().modCount; + } + + private boolean _isEmpty() { + return this.unseen.size() == 0; + } + + public void forEachRemaining(Consumer userAction) { + if (userAction == null) + throw new NullPointerException(); + + int size = this.unseen.size(); + Engine.assume(size >= 0); + Map_ContentsImpl contents = _getContents(); + while (size > 0) { + _checkForModification(); + K curKey = this.unseen.anyKey(); + userAction.accept(contents._contentByKey(this.unseen, curKey)); + this.unseen.remove(curKey); + size--; + } + } + + public boolean hasNext() { + return !_isEmpty(); + } + + public Content next() { + _checkForModification(); + if (_isEmpty()) + throw new NoSuchElementException(); + + K curKey = this.unseen.anyKey(); + Map_ContentsImpl contents = _getContents(); + Content result = contents._contentByKey(this.unseen, curKey); + this.unseen.remove(curKey); + this.currentKey = curKey; + return result; + } + + public void remove() { + K key = this.currentKey; + if (key == null) + throw new IllegalStateException(); + + _checkForModification(); + AbstractMapImpl map = _getMap(); + map._getStorage().remove(key); + map.modCount++; + this.unseen.remove(key); + this.expectedModCount = map.modCount; + this.currentKey = null; + } +} diff --git a/approximations/src/main/java/generated/java/util/map/Map_Contents_SpliteratorImpl.java b/approximations/src/main/java/generated/java/util/map/Map_Contents_SpliteratorImpl.java new file mode 100644 index 00000000..bb3ac0e3 --- /dev/null +++ b/approximations/src/main/java/generated/java/util/map/Map_Contents_SpliteratorImpl.java @@ -0,0 +1,203 @@ +package generated.java.util.map; + +import generated.java.util.AbstractSpliteratorImpl; +import generated.runtime.LibSLGlobals; +import org.jacodb.approximation.annotation.Approximate; +import org.usvm.api.Engine; +import org.usvm.api.SymbolicList; +import runtime.LibSLRuntime; +import stub.java.util.map.Map_Contents_Spliterator; + +import java.util.Map; +import java.util.function.Consumer; + +import static runtime.LibSLRuntime.error; + +@Approximate(Map_Contents_Spliterator.class) +public class Map_Contents_SpliteratorImpl extends AbstractSpliteratorImpl { + + Map_ContentsImpl contents; + + SymbolicList seenKeys; + + SymbolicList unseenKeys; + + Map_Contents_SpliteratorImpl( + Map_ContentsImpl contents, + SymbolicList seenKeys, + SymbolicList unseenKeys, + int index, + int fence, + int expectedModCount + ) { + super(index, fence, expectedModCount); + this.contents = contents; + this.seenKeys = seenKeys; + this.unseenKeys = unseenKeys; + } + + public Map_Contents_SpliteratorImpl(Map_ContentsImpl contents) { + this(contents, Engine.makeSymbolicList(), null, 0, -1, 0); + } + + protected AbstractSpliteratorImpl _create(int index, int fence) { + return null; + } + + Map_Contents_SpliteratorImpl _createSpliterator( + SymbolicList seenKeys, + SymbolicList unseenKeys, + int index, + int fence, + int expectedModCount + ) { + return new Map_Contents_SpliteratorImpl<>(this.contents, seenKeys, unseenKeys, index, fence, expectedModCount); + } + + private Map_ContentsImpl _getContents() { + Map_ContentsImpl result = this.contents; + Engine.assume(result != null); + return result; + } + + private AbstractMapImpl _getMap() { + AbstractMapImpl result = _getContents().map; + Engine.assume(result != null); + return result; + } + + protected int _parentModCount() { + return _getMap().modCount; + } + + protected int _storageSize() { + return _getContents().getStorage().size(); + } + + protected int _defaultCharacteristics() { + return 0; + } + + public int characteristics() { + if (this.fence < 0 || this.index == 0 && this.fence == _storageSize()) + return LibSLGlobals.SPLITERATOR_SIZED | _defaultCharacteristics(); + + return _defaultCharacteristics(); + } + + public long estimateSize() { + return super.estimateSize(); + } + + private int _checkSizeOfUnseenKeys() { + int size = unseenKeys.size(); + if (size != estimateSize()) + error("invariant violation"); + + return size; + } + + private int _checkSizeOfSeenKeys() { + int size = seenKeys.size(); + if (size != index) + error("invariant violation"); + + return size; + } + + private LibSLRuntime.Map> _removeSeenKeys() { + LibSLRuntime.Map> storage = _getContents().getStorage().duplicate(); + int size = _checkSizeOfSeenKeys(); + for (int i = 0; i < size; i++) { + K key = seenKeys.get(i); + storage.remove(key); + } + + return storage; + } + + public void forEachRemaining(Consumer userAction) { + if (userAction == null) + throw new NullPointerException(); + + int fence = _getFence(); + Map_ContentsImpl contents = _getContents(); + if (unseenKeys != null) { + _checkSizeOfSeenKeys(); + int size = _checkSizeOfUnseenKeys(); + LibSLRuntime.Map> storage = contents.getStorage(); + for (int i = 0; i < size; i++) { + K key = unseenKeys.get(i); + userAction.accept(contents._contentByKey(storage, key)); + } + unseenKeys.copy(seenKeys, 0, 0, size); + } else { + LibSLRuntime.Map> unseenStorage = _removeSeenKeys(); + for (int i = this.index; i < fence; i++) { + K key = unseenStorage.anyKey(); + userAction.accept(contents._contentByKey(unseenStorage, key)); + unseenStorage.remove(key); + seenKeys.insert(i, key); + } + } + + this.index = fence; + _checkForModification(); + } + + public long getExactSizeIfKnown() { + return super.getExactSizeIfKnown(); + } + + public boolean tryAdvance(Consumer userAction) { + if (userAction == null) + throw new NullPointerException(); + + int hi = _getFence(); + if (this.index >= hi) + return false; + + Map_ContentsImpl contents = _getContents(); + if (unseenKeys != null) { + _checkSizeOfSeenKeys(); + _checkSizeOfUnseenKeys(); + K key = unseenKeys.get(0); + LibSLRuntime.Map> storage = contents.getStorage(); + userAction.accept(contents._contentByKey(storage, key)); + unseenKeys.remove(0); + seenKeys.insert(this.index, key); + } else { + LibSLRuntime.Map> unseenStorage = _removeSeenKeys(); + K key = unseenStorage.anyKey(); + userAction.accept(contents._contentByKey(unseenStorage, key)); + seenKeys.insert(this.index, key); + } + + this.index++; + _checkForModification(); + + return true; + } + + public Map_Contents_SpliteratorImpl trySplit() { + int hi = _getFence(); + int lo = this.index; + int mid = (hi + lo) >>> 1; + if (lo >= mid) + return null; + + LibSLRuntime.Map> unseenStorage = _removeSeenKeys(); + SymbolicList newUnseenKeys = Engine.makeSymbolicList(); + SymbolicList newSeenKeys = Engine.makeSymbolicList(); + + int j = 0; + for (int i = lo; i < mid; i++) { + K key = unseenStorage.anyKey(); + seenKeys.insert(i, key); + newUnseenKeys.insert(j++, key); + } + + this.index = mid; + return _createSpliterator(newSeenKeys, newUnseenKeys, lo, mid, this.expectedModCount); + } +} diff --git a/approximations/src/main/java/generated/java/util/map/Map_EntrySetImpl.java b/approximations/src/main/java/generated/java/util/map/Map_EntrySetImpl.java new file mode 100644 index 00000000..92c18664 --- /dev/null +++ b/approximations/src/main/java/generated/java/util/map/Map_EntrySetImpl.java @@ -0,0 +1,146 @@ +package generated.java.util.map; + +import java.lang.Object; +import java.lang.String; +import java.util.*; +import java.util.function.Consumer; +import java.util.function.IntFunction; +import java.util.function.Predicate; +import java.util.stream.Stream; + +import org.jacodb.approximation.annotation.Approximate; +import org.jetbrains.annotations.NotNull; +import runtime.LibSLRuntime; +import stub.java.util.map.Map_EntrySet; + +@Approximate(Map_EntrySet.class) +public final class Map_EntrySetImpl extends Map_ContentsSetImpl> { + + public Map_EntrySetImpl(AbstractMapImpl parent) { + super(parent); + } + + Map.Entry _contentByKey(LibSLRuntime.Map> storage, K key) { + return storage.get(key); + } + + public boolean add(Map.Entry e) { + return super.add(e); + } + + public boolean addAll(@NotNull Collection> c) { + return super.addAll(c); + } + + public void clear() { + super.clear(); + } + + @SuppressWarnings("unchecked") + boolean _containsInStorage(LibSLRuntime.Map> storage, Object o) { + if (o instanceof Map.Entry) { + Map.Entry oEntry = (Map.Entry) o; + K key = oEntry.getKey(); + if (storage.hasKey(key)) { + Map.Entry entry = storage.get(key); + return LibSLRuntime.equals(entry, oEntry); + } + } + return false; + } + + public boolean contains(Object o) { + return super.contains(o); + } + + public boolean containsAll(@NotNull Collection c) { + return super.containsAll(c); + } + + public boolean equals(Object other) { + return super.equals(other); + } + + public void forEach(Consumer> userAction) { + super.forEach(userAction); + } + + public int hashCode() { + return super.hashCode(); + } + + public boolean isEmpty() { + return super.isEmpty(); + } + + @NotNull + public Iterator> iterator() { + return super.iterator(); + } + + public Stream> parallelStream() { + return super.parallelStream(); + } + + @SuppressWarnings("unchecked") + public boolean remove(Object o) { + if (!(o instanceof Map.Entry)) + return false; + + Map.Entry typedOtherEntry = (Map.Entry) o; + K key = typedOtherEntry.getKey(); + LibSLRuntime.Map> storage = getStorage(); + if (storage.hasKey(key)) { + Map.Entry entry = storage.get(key); + if (LibSLRuntime.equals(entry, typedOtherEntry)) { + storage.remove(key); + this.map.modCount++; + return true; + } + } + + return false; + } + + public boolean removeAll(@NotNull Collection c) { + return super.removeAll(c); + } + + public boolean removeIf(Predicate> filter) { + return super.removeIf(filter); + } + + public boolean retainAll(@NotNull Collection c) { + return super.retainAll(c); + } + + public int size() { + return super.size(); + } + + public Spliterator> spliterator() { + return super.spliterator(); + } + + public Stream> stream() { + return super.stream(); + } + + @NotNull + public Object[] toArray() { + return super.toArray(); + } + + public T[] toArray(IntFunction generator) { + return super.toArray(generator); + } + + @NotNull + public T[] toArray(@NotNull T[] array) { + return super.toArray(array); + } + + public String toString() { + return super.toString(); + } +} diff --git a/approximations/src/main/java/generated/java/util/map/Map_KeySetImpl.java b/approximations/src/main/java/generated/java/util/map/Map_KeySetImpl.java new file mode 100644 index 00000000..4caa9c6d --- /dev/null +++ b/approximations/src/main/java/generated/java/util/map/Map_KeySetImpl.java @@ -0,0 +1,131 @@ +package generated.java.util.map; + +import java.lang.Object; +import java.lang.String; +import java.util.*; +import java.util.function.Consumer; +import java.util.function.IntFunction; +import java.util.function.Predicate; +import java.util.stream.Stream; + +import org.jacodb.approximation.annotation.Approximate; +import org.jetbrains.annotations.NotNull; +import runtime.LibSLRuntime; +import stub.java.util.map.Map_KeySet; + +@Approximate(Map_KeySet.class) +public final class Map_KeySetImpl extends Map_ContentsSetImpl { + + public Map_KeySetImpl(AbstractMapImpl parent) { + super(parent); + } + + K _contentByKey(LibSLRuntime.Map> storage, K key) { + return key; + } + + public boolean add(K e) { + return super.add(e); + } + + public boolean addAll(@NotNull Collection c) { + return super.addAll(c); + } + + public void clear() { + super.clear(); + } + + @SuppressWarnings("unchecked") + boolean _containsInStorage(LibSLRuntime.Map> storage, Object o) { + return storage.hasKey((K) o); + } + + public boolean contains(Object key) { + return super.contains(key); + } + + public boolean containsAll(@NotNull Collection c) { + return super.containsAll(c); + } + + public boolean equals(Object other) { + return super.equals(other); + } + + public void forEach(Consumer userAction) { + super.forEach(userAction); + } + + public int hashCode() { + return super.hashCode(); + } + + public boolean isEmpty() { + return super.isEmpty(); + } + + @NotNull + public Iterator iterator() { + return super.iterator(); + } + + public Stream parallelStream() { + return super.parallelStream(); + } + + @SuppressWarnings("unchecked") + public boolean remove(Object key) { + K typedKey = (K) key; + LibSLRuntime.Map> storage = getStorage(); + if (storage.hasKey(typedKey)) { + storage.remove(typedKey); + this.map.modCount++; + return true; + } + + return false; + } + + public boolean removeAll(@NotNull Collection c) { + return super.removeAll(c); + } + + public boolean removeIf(Predicate filter) { + return super.removeIf(filter); + } + + public boolean retainAll(@NotNull Collection c) { + return super.retainAll(c); + } + + public int size() { + return super.size(); + } + + public Spliterator spliterator() { + return super.spliterator(); + } + + public Stream stream() { + return super.stream(); + } + + @NotNull + public Object[] toArray() { + return super.toArray(); + } + + public T[] toArray(IntFunction generator) { + return super.toArray(generator); + } + + @NotNull + public T[] toArray(@NotNull T[] array) { + return super.toArray(array); + } + + public String toString() { + return super.toString(); + } +} diff --git a/approximations/src/main/java/generated/java/util/map/Map_ValuesImpl.java b/approximations/src/main/java/generated/java/util/map/Map_ValuesImpl.java new file mode 100644 index 00000000..9ce4255b --- /dev/null +++ b/approximations/src/main/java/generated/java/util/map/Map_ValuesImpl.java @@ -0,0 +1,145 @@ +package generated.java.util.map; + +import java.lang.Object; +import java.lang.String; +import java.util.*; +import java.util.function.Consumer; +import java.util.function.IntFunction; +import java.util.function.Predicate; +import java.util.stream.Stream; + +import org.jacodb.approximation.annotation.Approximate; +import org.jetbrains.annotations.NotNull; +import org.usvm.api.Engine; +import runtime.LibSLRuntime; +import stub.java.util.map.Map_Values; + +@Approximate(Map_Values.class) +public class Map_ValuesImpl extends Map_ContentsImpl { + + public Map_ValuesImpl(AbstractMapImpl parent) { + super(parent); + } + + V _contentByKey(LibSLRuntime.Map> storage, K key) { + Map.Entry entry = storage.get(key); + return entry.getValue(); + } + + public boolean add(V e) { + return super.add(e); + } + + public boolean addAll(@NotNull Collection c) { + return super.addAll(c); + } + + public void clear() { + super.clear(); + } + + boolean _containsInStorage(LibSLRuntime.Map> storage, Object value) { + LibSLRuntime.Map> unseen = getStorage().duplicate(); + int size = unseen.size(); + Engine.assume(size > 0); + for (int i = 0; i < size; i++) { + K key = unseen.anyKey(); + Map.Entry entry = unseen.get(key); + V curValue = entry.getValue(); + if (LibSLRuntime.equals(curValue, value)) + return true; + + unseen.remove(key); + } + + return false; + } + + public boolean contains(Object value) { + return super.contains(value); + } + + public boolean containsAll(@NotNull Collection c) { + return super.containsAll(c); + } + + public void forEach(Consumer userAction) { + super.forEach(userAction); + } + + public boolean isEmpty() { + return super.isEmpty(); + } + + @NotNull + public Iterator iterator() { + return super.iterator(); + } + + public Stream parallelStream() { + return super.parallelStream(); + } + + public boolean remove(Object value) { + LibSLRuntime.Map> storage = getStorage(); + LibSLRuntime.Map> unseen = storage.duplicate(); + int size = unseen.size(); + Engine.assume(size >= 0); + for (int i = 0; i < size; i++) { + K key = unseen.anyKey(); + Map.Entry entry = unseen.get(key); + V curValue = entry.getValue(); + if (LibSLRuntime.equals(curValue, value)) { + storage.remove(key); + this.map.modCount++; + return true; + } + + unseen.remove(key); + } + + return false; + } + + public boolean removeAll(@NotNull Collection c) { + return super.removeAll(c); + } + + public boolean removeIf(Predicate filter) { + return super.removeIf(filter); + } + + public boolean retainAll(@NotNull Collection c) { + return super.retainAll(c); + } + + public int size() { + return super.size(); + } + + public Spliterator spliterator() { + return super.spliterator(); + } + + public Stream stream() { + return super.stream(); + } + + @NotNull + public Object[] toArray() { + return super.toArray(); + } + + public T[] toArray(IntFunction generator) { + return super.toArray(generator); + } + + @NotNull + public T[] toArray(@NotNull T[] array) { + return super.toArray(array); + } + + public String toString() { + return super.toString(); + } +} diff --git a/approximations/src/main/java/generated/java/util/optional/OptionalDoubleImpl.java b/approximations/src/main/java/generated/java/util/optional/OptionalDoubleImpl.java new file mode 100644 index 00000000..a049296e --- /dev/null +++ b/approximations/src/main/java/generated/java/util/optional/OptionalDoubleImpl.java @@ -0,0 +1,169 @@ +package generated.java.util.optional; + +import java.lang.NullPointerException; +import java.lang.Object; +import java.lang.Runnable; +import java.lang.String; +import java.util.NoSuchElementException; +import java.util.function.DoubleConsumer; +import java.util.function.DoubleSupplier; +import java.util.function.Supplier; +import java.util.stream.DoubleStream; + +import generated.java.util.stream.DoubleStreamImpl; +import org.jacodb.approximation.annotation.Approximate; +import org.usvm.api.Engine; +import runtime.LibSLRuntime; + +@SuppressWarnings("unused") +@Approximate(java.util.OptionalDouble.class) +public final class OptionalDoubleImpl { + + private static final OptionalDoubleImpl EMPTY = new OptionalDoubleImpl(0.0d, false); + + static { + Engine.assume(true); + } + + public double value; + + public boolean isPresent; + + public OptionalDoubleImpl(double value, boolean isPresent) { + this.value = value; + this.isPresent = isPresent; + } + + private OptionalDoubleImpl() { + LibSLRuntime.error("Private constructor call"); + } + + private OptionalDoubleImpl(double x) { + LibSLRuntime.error("Private constructor call"); + } + + public static OptionalDoubleImpl empty() { + return EMPTY; + } + + public static OptionalDoubleImpl of(double x) { + return new OptionalDoubleImpl(x, true); + } + + @SuppressWarnings("EqualsWhichDoesntCheckParameterClass") + public boolean equals(Object other) { + if (other == this) + return true; + + if (Engine.typeIs(other, OptionalDoubleImpl.class)) { + OptionalDoubleImpl otherOptional = (OptionalDoubleImpl) other; + double otherValue = otherOptional.value; + boolean otherPresent = otherOptional.isPresent; + if (this.isPresent && otherPresent) + return LibSLRuntime.equals(this.value, otherValue); + + return this.isPresent == otherPresent; + } + + return false; + } + + public double getAsDouble() { + if (!this.isPresent) + throw new NoSuchElementException("No value present"); + + return this.value; + } + + public int hashCode() { + if (this.isPresent) + return LibSLRuntime.hashCode(this.value); + + return 0; + } + + public void ifPresent(DoubleConsumer consumer) { + if (!this.isPresent) + return; + + if (consumer == null) + throw new NullPointerException(); + + consumer.accept(this.value); + } + + public void ifPresentOrElse(DoubleConsumer consumer, Runnable emptyAction) { + if (this.isPresent) { + if (consumer == null) + throw new NullPointerException(); + + consumer.accept(this.value); + return; + } + + if (emptyAction == null) + throw new NullPointerException(); + + emptyAction.run(); + } + + public boolean isEmpty() { + return !this.isPresent; + } + + public boolean isPresent() { + return this.isPresent; + } + + public double orElse(double other) { + if (this.isPresent) + return this.value; + + return other; + } + + public double orElseGet(DoubleSupplier supplier) { + if (this.isPresent) + return this.value; + + return supplier.getAsDouble(); + } + + public double orElseThrow() { + if (!this.isPresent) + throw new NoSuchElementException("No value present"); + + return this.value; + } + + public double orElseThrow(Supplier exceptionSupplier) throws Throwable { + if (exceptionSupplier == null) + throw new NullPointerException(); + + if (!this.isPresent) + throw exceptionSupplier.get(); + + return this.value; + } + + public DoubleStream stream() { + double[] items; + if (this.isPresent) { + items = new double[1]; + items[0] = this.value; + } else { + items = new double[0]; + } + + return new DoubleStreamImpl(items); + } + + public String toString() { + if (this.isPresent) { + String valueStr = LibSLRuntime.toString(this.value); + return "OptionalDouble[".concat(valueStr).concat("]"); + } + + return "OptionalDouble.empty"; + } +} diff --git a/approximations/src/main/java/generated/java/util/optional/OptionalImpl.java b/approximations/src/main/java/generated/java/util/optional/OptionalImpl.java new file mode 100644 index 00000000..2e5071ed --- /dev/null +++ b/approximations/src/main/java/generated/java/util/optional/OptionalImpl.java @@ -0,0 +1,216 @@ +package generated.java.util.optional; + +import java.lang.NullPointerException; +import java.lang.Object; +import java.lang.Runnable; +import java.lang.String; +import java.util.NoSuchElementException; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.function.Predicate; +import java.util.function.Supplier; +import java.util.stream.Stream; + +import generated.java.util.stream.StreamStubImpl; +import org.jacodb.approximation.annotation.Approximate; +import org.usvm.api.Engine; +import runtime.LibSLRuntime; + +@SuppressWarnings("unused") +@Approximate(java.util.Optional.class) +public final class OptionalImpl { + + private static final OptionalImpl EMPTY = new OptionalImpl<>(null); + + static { + Engine.assume(true); + } + + public T value; + + private OptionalImpl(T value) { + this.value = value; + } + + private OptionalImpl() { + LibSLRuntime.error("Private constructor call"); + } + + @SuppressWarnings("unchecked") + public static OptionalImpl empty() { + return (OptionalImpl) EMPTY; + } + + public static OptionalImpl of(T obj) { + return new OptionalImpl<>(obj); + } + + public static OptionalImpl ofNullable(T obj) { + if (obj == null) + return empty(); + + return new OptionalImpl<>(obj); + } + + @SuppressWarnings({"unchecked", "EqualsWhichDoesntCheckParameterClass"}) + public boolean equals(Object other) { + if (other == this) + return true; + + if (Engine.typeIs(other, OptionalImpl.class)) { + T otherValue = ((OptionalImpl) other).value; + return LibSLRuntime.equals(this.value, otherValue); + } + + return false; + } + + public OptionalImpl filter(Predicate predicate) { + if (predicate == null) + throw new NullPointerException(); + + if (isEmpty()) + return this; + + if (predicate.test(this.value)) + return this; + + return empty(); + } + + @SuppressWarnings("unchecked") + public OptionalImpl flatMap(Function> mapper) { + if (mapper == null) + throw new NullPointerException(); + + if (isEmpty()) + return empty(); + + OptionalImpl result = (OptionalImpl) mapper.apply(this.value); + if (result == null) + throw new NullPointerException(); + + return result; + } + + public T get() { + if (isEmpty()) + throw new NoSuchElementException("No value present"); + + return this.value; + } + + public int hashCode() { + return LibSLRuntime.hashCode(this.value); + } + + public void ifPresent(Consumer consumer) { + if (isEmpty()) + return; + + if (consumer == null) + throw new NullPointerException(); + + consumer.accept(this.value); + } + + public void ifPresentOrElse(Consumer consumer, Runnable emptyAction) { + if (isPresent()) { + if (consumer == null) + throw new NullPointerException(); + + consumer.accept(this.value); + return; + } + + if (emptyAction == null) + throw new NullPointerException(); + + emptyAction.run(); + } + + public boolean isEmpty() { + return this.value == null; + } + + public boolean isPresent() { + return !isEmpty(); + } + + public OptionalImpl map(Function mapper) { + if (mapper == null) + throw new NullPointerException(); + + if (isEmpty()) + return empty(); + + U mappedValue = mapper.apply(this.value); + if (mappedValue == null) + return empty(); + + return new OptionalImpl<>(mappedValue); + } + + @SuppressWarnings("unchecked") + public OptionalImpl or(Supplier> supplier) { + if (supplier == null) + throw new NullPointerException(); + + if (isPresent()) + return this; + + OptionalImpl result = (OptionalImpl) supplier.get(); + if (result == null) + throw new NullPointerException(); + + return result; + } + + public T orElse(T other) { + if (isEmpty()) + return other; + + return this.value; + } + + public T orElseGet(Supplier supplier) { + if (isEmpty()) + return supplier.get(); + + return this.value; + } + + public T orElseThrow() { + if (isEmpty()) + throw new NoSuchElementException("No value present"); + + return this.value; + } + + public T orElseThrow(Supplier exceptionSupplier) throws X { + if (isEmpty()) + throw exceptionSupplier.get(); + + return this.value; + } + + @SuppressWarnings("unchecked") + public Stream stream() { + T[] items; + if (isEmpty()) { + items = (T[]) new Object[0]; + } else { + items = (T[]) new Object[1]; + items[0] = this.value; + } + return new StreamStubImpl<>(items); + } + + public String toString() { + if (isEmpty()) + return "Optional.empty"; + + String valueStr = LibSLRuntime.toString(this.value); + return "Optional[".concat(valueStr).concat("]"); + } +} diff --git a/approximations/src/main/java/generated/java/util/optional/OptionalIntImpl.java b/approximations/src/main/java/generated/java/util/optional/OptionalIntImpl.java new file mode 100644 index 00000000..9844f30b --- /dev/null +++ b/approximations/src/main/java/generated/java/util/optional/OptionalIntImpl.java @@ -0,0 +1,168 @@ +package generated.java.util.optional; + +import java.lang.NullPointerException; +import java.lang.Object; +import java.lang.Runnable; +import java.lang.String; +import java.util.NoSuchElementException; +import java.util.function.IntConsumer; +import java.util.function.IntSupplier; +import java.util.function.Supplier; +import java.util.stream.IntStream; + +import generated.java.util.stream.IntStreamImpl; +import org.jacodb.approximation.annotation.Approximate; +import org.usvm.api.Engine; +import runtime.LibSLRuntime; + +@SuppressWarnings("unused") +@Approximate(java.util.OptionalInt.class) +public final class OptionalIntImpl { + + private static final OptionalIntImpl EMPTY = new OptionalIntImpl(0, false); + + static { + Engine.assume(true); + } + + public int value; + + public boolean isPresent; + + public OptionalIntImpl(int value, boolean isPresent) { + this.value = value; + this.isPresent = isPresent; + } + + private OptionalIntImpl() { + LibSLRuntime.error("Private constructor call"); + } + + private OptionalIntImpl(int x) { + LibSLRuntime.error("Private constructor call"); + } + + public static OptionalIntImpl empty() { + return EMPTY; + } + + public static OptionalIntImpl of(int x) { + return new OptionalIntImpl(x, true); + } + + @SuppressWarnings("EqualsWhichDoesntCheckParameterClass") + public boolean equals(Object other) { + if (other == this) + return true; + + if (Engine.typeIs(other, OptionalIntImpl.class)) { + OptionalIntImpl otherOptional = (OptionalIntImpl) other; + int otherValue = otherOptional.value; + boolean otherPresent = otherOptional.isPresent; + if (this.isPresent && otherPresent) + return this.value == otherValue; + + return this.isPresent == otherPresent; + } + + return false; + } + + public int getAsInt() { + if (!this.isPresent) + throw new NoSuchElementException("No value present"); + + return this.value; + } + + public int hashCode() { + if (this.isPresent) + return LibSLRuntime.hashCode(this.value); + + return 0; + } + + public void ifPresent(IntConsumer consumer) { + if (!this.isPresent) + return; + + if (consumer == null) + throw new NullPointerException(); + + consumer.accept(this.value); + } + + public void ifPresentOrElse(IntConsumer consumer, Runnable emptyAction) { + if (this.isPresent) { + if (consumer == null) { + throw new NullPointerException(); + } + consumer.accept(this.value); + return; + } + + if (emptyAction == null) { + throw new NullPointerException(); + } + emptyAction.run(); + } + + public boolean isEmpty() { + return !this.isPresent; + } + + public boolean isPresent() { + return this.isPresent; + } + + public int orElse(int other) { + if (this.isPresent) + return this.value; + + return other; + } + + public int orElseGet(IntSupplier supplier) { + if (this.isPresent) + return this.value; + + return supplier.getAsInt(); + } + + public int orElseThrow() { + if (!this.isPresent) + throw new NoSuchElementException("No value present"); + + return this.value; + } + + public int orElseThrow(Supplier exceptionSupplier) throws Throwable { + if (exceptionSupplier == null) + throw new NullPointerException(); + + if (!this.isPresent) + throw exceptionSupplier.get(); + + return this.value; + } + + public IntStream stream() { + int[] items; + if (this.isPresent) { + items = new int[1]; + items[0] = this.value; + } else { + items = new int[0]; + } + return new IntStreamImpl(items); + } + + public String toString() { + if (this.isPresent) { + String valueStr = LibSLRuntime.toString(this.value); + return "OptionalInt[".concat(valueStr).concat("]"); + } + + return "OptionalInt.empty"; + } +} diff --git a/approximations/src/main/java/generated/java/util/optional/OptionalLongImpl.java b/approximations/src/main/java/generated/java/util/optional/OptionalLongImpl.java new file mode 100644 index 00000000..d639da8f --- /dev/null +++ b/approximations/src/main/java/generated/java/util/optional/OptionalLongImpl.java @@ -0,0 +1,167 @@ +package generated.java.util.optional; + +import java.lang.NullPointerException; +import java.lang.Object; +import java.lang.Runnable; +import java.lang.String; +import java.util.NoSuchElementException; +import java.util.function.LongConsumer; +import java.util.function.LongSupplier; +import java.util.function.Supplier; +import java.util.stream.LongStream; + +import generated.java.util.stream.LongStreamImpl; +import org.jacodb.approximation.annotation.Approximate; +import org.usvm.api.Engine; +import runtime.LibSLRuntime; + +@SuppressWarnings("unused") +@Approximate(java.util.OptionalLong.class) +public final class OptionalLongImpl { + private static final OptionalLongImpl EMPTY = new OptionalLongImpl(0, false); + + static { + Engine.assume(true); + } + + public long value; + + public boolean isPresent; + + public OptionalLongImpl(long value, boolean isPresent) { + this.value = value; + this.isPresent = isPresent; + } + + private OptionalLongImpl() { + LibSLRuntime.error("Private constructor call"); + } + + private OptionalLongImpl(long x) { + LibSLRuntime.error("Private constructor call"); + } + + public static OptionalLongImpl empty() { + return EMPTY; + } + + public static OptionalLongImpl of(long x) { + return new OptionalLongImpl(x); + } + + @SuppressWarnings("EqualsWhichDoesntCheckParameterClass") + public boolean equals(Object other) { + if (other == this) + return true; + + if (Engine.typeIs(other, OptionalLongImpl.class)) { + OptionalLongImpl otherOptional = (OptionalLongImpl) other; + long otherValue = otherOptional.value; + boolean otherPresent = otherOptional.isPresent; + if (this.isPresent && otherPresent) + return this.value == otherValue; + + return this.isPresent == otherPresent; + } + + return false; + } + + public long getAsLong() { + if (!this.isPresent) + throw new NoSuchElementException("No value present"); + + return this.value; + } + + public int hashCode() { + if (this.isPresent) + return LibSLRuntime.hashCode(this.value); + + return 0; + } + + public void ifPresent(LongConsumer consumer) { + if (!this.isPresent) + return; + + if (consumer == null) + throw new NullPointerException(); + + consumer.accept(this.value); + } + + public void ifPresentOrElse(LongConsumer consumer, Runnable emptyAction) { + if (this.isPresent) { + if (consumer == null) + throw new NullPointerException(); + + consumer.accept(this.value); + } else { + if (emptyAction == null) + throw new NullPointerException(); + + emptyAction.run(); + } + } + + public boolean isEmpty() { + return !this.isPresent; + } + + public boolean isPresent() { + return this.isPresent; + } + + public long orElse(long other) { + if (this.isPresent) + return this.value; + + return other; + } + + public long orElseGet(LongSupplier supplier) { + if (this.isPresent) + return this.value; + + return supplier.getAsLong(); + } + + public long orElseThrow() { + if (!this.isPresent) + throw new NoSuchElementException("No value present"); + + return this.value; + } + + public long orElseThrow(Supplier exceptionSupplier) throws Throwable { + if (exceptionSupplier == null) + throw new NullPointerException(); + + if (!this.isPresent) + throw exceptionSupplier.get(); + + return this.value; + } + + public LongStream stream() { + long[] items; + if (this.isPresent) { + items = new long[1]; + items[0] = this.value; + } else { + items = new long[0]; + } + + return new LongStreamImpl(items); + } + + public String toString() { + if (this.isPresent) { + String valueStr = LibSLRuntime.toString(this.value); + return "OptionalLong[".concat(valueStr).concat("]"); + } + + return "OptionalLong.empty"; + } +} diff --git a/approximations/src/main/java/generated/java/util/set/AbstractSetImpl.java b/approximations/src/main/java/generated/java/util/set/AbstractSetImpl.java new file mode 100644 index 00000000..78116933 --- /dev/null +++ b/approximations/src/main/java/generated/java/util/set/AbstractSetImpl.java @@ -0,0 +1,385 @@ +package generated.java.util.set; + +import generated.java.util.AbstractCollectionImpl; +import generated.java.util.stream.StreamStubImpl; +import generated.runtime.LibSLGlobals; + +import java.lang.IllegalArgumentException; +import java.lang.NullPointerException; +import java.lang.Object; +import java.lang.String; +import java.util.*; +import java.util.function.Consumer; +import java.util.function.IntFunction; +import java.util.function.Predicate; +import java.util.stream.Stream; +import org.jacodb.approximation.annotation.Approximate; +import org.jetbrains.annotations.NotNull; +import org.usvm.api.Engine; +import runtime.LibSLRuntime; + +@Approximate(java.util.AbstractSet.class) +public abstract class AbstractSetImpl extends AbstractCollectionImpl implements Set { + + public LibSLRuntime.Map storage; + + private boolean isHashSet; + + private static LibSLRuntime.Map.Container createContainer(boolean isHashSet) { + if (isHashSet) + return new LibSLRuntime.HashMapContainer<>(); + + return new LibSLRuntime.IdentityMapContainer<>(); + } + + private static LibSLRuntime.Map createStorage(boolean isHashSet) { + return new LibSLRuntime.Map<>(createContainer(isHashSet)); + } + + public AbstractSetImpl(LibSLRuntime.Map storage, int modCount, boolean isHashSet) { + super(modCount); + this.storage = storage; + this.isHashSet = isHashSet; + } + + public AbstractSetImpl(boolean isHashSet) { + this(createStorage(isHashSet), 0, isHashSet); + } + + @SuppressWarnings("unused") + public AbstractSetImpl(boolean isHashSet, Collection c) { + this(isHashSet); + _addAllElements(c); + } + + @SuppressWarnings("unused") + public AbstractSetImpl(boolean isHashSet, int initialCapacity) { + super(0); + + if (initialCapacity < 0) + throw new IllegalArgumentException(); + + this.storage = createStorage(isHashSet); + this.isHashSet = isHashSet; + } + + @SuppressWarnings("unused") + public AbstractSetImpl(boolean isHashSet, int initialCapacity, float loadFactor) { + super(0); + + if (initialCapacity < 0) + throw new IllegalArgumentException(); + + if (loadFactor <= 0 || loadFactor != loadFactor) + throw new IllegalArgumentException(); + + this.storage = createStorage(isHashSet); + this.isHashSet = isHashSet; + } + + @SuppressWarnings("unused") + public AbstractSetImpl(int initialCapacity, float loadFactor, boolean dummy) { + super(0); + LibSLRuntime.error("Private constructor call"); + } + + public LibSLRuntime.Map _getStorage() { + LibSLRuntime.Map storage = this.storage; + Engine.assume(storage != null); + return storage; + } + + private void _add(E key) { + _getStorage().set(key, LibSLGlobals.SOMETHING); + } + + @SuppressWarnings("unchecked") + public boolean _addAllElements(Collection c) { + LibSLRuntime.Map storage = _getStorage(); + int lengthBeforeAdd = storage.size(); + + if (c instanceof AbstractSetImpl) { + AbstractSetImpl other = (AbstractSetImpl) c; + LibSLRuntime.Map otherStorage = other._getStorage(); + storage.union(otherStorage); + } else { + for (E key : c) { + if (!storage.hasKey(key)) + _add(key); + } + } + + if (lengthBeforeAdd != storage.size()) { + this.modCount++; + return true; + } + + return false; + } + + protected Object[] _mapToArray() { + int size = _getStorage().size(); + Object[] items = new Object[size]; + LibSLRuntime.Map unseen = _getStorage().duplicate(); + for (int i = 0; i < size; i++) { + E key = unseen.anyKey(); + unseen.remove(key); + items[i] = key; + } + return items; + } + + @SuppressWarnings("unchecked") + public Stream _makeStream(boolean parallel) { + E[] items = (E[]) _mapToArray(); + return new StreamStubImpl<>(items, parallel); + } + + public boolean add(E obj) { + LibSLRuntime.Map storage = _getStorage(); + this.modCount++; + if (storage.hasKey(obj)) + return false; + + storage.set(obj, LibSLGlobals.SOMETHING); + return true; + } + + public void clear() { + this.storage = createStorage(this.isHashSet); + this.modCount++; + } + + @SuppressWarnings("unchecked") + public Object clone() throws CloneNotSupportedException { + AbstractSetImpl clonedSet = (AbstractSetImpl) super.clone(); + clonedSet.modCount = 0; + clonedSet.storage = _getStorage().duplicate(); + return clonedSet; + } + + @SuppressWarnings("unchecked") + public boolean contains(Object obj) { + if (isEmpty()) + return false; + + return _getStorage().hasKey((E) obj); + } + + public boolean isEmpty() { + return _getStorage().size() == 0; + } + + @NotNull + public Iterator iterator() { + LibSLRuntime.Map unseenKeys = _getStorage().duplicate(); + return new Set_IteratorImpl<>(this.modCount, unseenKeys, this, null); + } + + @SuppressWarnings("unchecked") + public boolean remove(Object elem) { + E typedElem = (E) elem; + LibSLRuntime.Map storage = _getStorage(); + if (storage.hasKey(typedElem)) { + storage.remove(typedElem); + this.modCount++; + return true; + } + + return false; + } + + public int size() { + return _getStorage().size(); + } + + public Spliterator spliterator() { + return new Set_SpliteratorImpl<>(this); + } + + @SuppressWarnings("unchecked") + public boolean equals(Object other) { + if (other == this) + return true; + + if (!(other instanceof Set)) + return false; + + int expectedModCount = this.modCount; + AbstractSetImpl otherSet = (AbstractSetImpl) other; + int otherExpectedModCount = otherSet.modCount; + LibSLRuntime.Map otherStorage = otherSet._getStorage(); + + LibSLRuntime.Map storage = _getStorage(); + if (storage.size() != otherStorage.size()) + return false; + + boolean result = LibSLRuntime.equals(storage, otherStorage); + otherSet._checkForModification(otherExpectedModCount); + this._checkForModification(expectedModCount); + + return result; + } + + public int hashCode() { + return LibSLRuntime.hashCode(_getStorage()); + } + + @SuppressWarnings({"ConstantValue", "unchecked"}) + public boolean removeAll(@NotNull Collection c) { + if (c == null) { + throw new NullPointerException(); + } + + int expectedModCount = this.modCount; + int otherSize = c.size(); + LibSLRuntime.Map storage = _getStorage(); + int lengthBeforeRemoving = storage.size(); + if (storage.size() > otherSize) { + for (Object key : c) { + E eKey = (E) key; + if (storage.hasKey(eKey)) + storage.remove(eKey); + } + } else { + LibSLRuntime.Map unseenKeys = storage.duplicate(); + int i = 0; + while (i < lengthBeforeRemoving) { + E key = unseenKeys.anyKey(); + unseenKeys.remove(key); + if (c.contains(key)) { + storage.remove(key); + } + i++; + } + } + _checkForModification(expectedModCount); + this.modCount++; + return lengthBeforeRemoving != storage.size(); + } + + @NotNull + public Object[] toArray() { + return super.toArray(); + } + + @NotNull + public T[] toArray(@NotNull T[] array) { + return super.toArray(array); + } + + public T[] toArray(IntFunction generator) { + return super.toArray(generator); + } + + @SuppressWarnings("unchecked") + public boolean containsAll(@NotNull Collection c) { + LibSLRuntime.Map storage = _getStorage(); + for (Object key : c) { + if (!storage.hasKey((E) key)) + return false; + } + + return true; + } + + public boolean addAll(@NotNull Collection c) { + return _addAllElements(c); + } + + @SuppressWarnings("ConstantValue") + public boolean retainAll(@NotNull Collection c) { + if (c == null) + throw new NullPointerException(); + + LibSLRuntime.Map storage = _getStorage(); + int lengthBeforeAdd = storage.size(); + LibSLRuntime.Map unseenKeys = storage.duplicate(); + int i = 0; + while (i < lengthBeforeAdd) { + E key = unseenKeys.anyKey(); + unseenKeys.remove(key); + if (!c.contains(key)) + storage.remove(key); + i++; + } + if (lengthBeforeAdd != storage.size()) { + this.modCount++; + return true; + } + + return false; + } + + public boolean removeIf(Predicate filter) { + if (filter == null) + throw new NullPointerException(); + + LibSLRuntime.Map storage = _getStorage(); + int lengthBeforeAdd = storage.size(); + int expectedModCount = this.modCount; + LibSLRuntime.Map unseenKeys = storage.duplicate(); + int i = 0; + while (i < lengthBeforeAdd) { + E key = unseenKeys.anyKey(); + unseenKeys.remove(key); + if (filter.test(key)) + storage.remove(key); + i++; + } + _checkForModification(expectedModCount); + if (lengthBeforeAdd != storage.size()) { + this.modCount++; + return true; + } + + return false; + } + + public void forEach(Consumer userAction) { + if (userAction == null) + throw new NullPointerException(); + + LibSLRuntime.Map storage = _getStorage(); + int count = storage.size(); + int expectedModCount = this.modCount; + LibSLRuntime.Map unseenKeys = storage.duplicate(); + int i = 0; + while (i < count) { + E key = unseenKeys.anyKey(); + unseenKeys.remove(key); + userAction.accept(key); + i++; + } + _checkForModification(expectedModCount); + } + + public Stream stream() { + return _makeStream(false); + } + + public Stream parallelStream() { + return _makeStream(true); + } + + public String toString() { + LibSLRuntime.Map storage = _getStorage(); + int count = storage.size(); + if (count == 0) + return "[]"; + + Engine.assume(count > 0); + String result = "["; + LibSLRuntime.Map unseen = storage.duplicate(); + while (count != 0) { + E key = unseen.anyKey(); + unseen.remove(key); + result = result.concat(LibSLRuntime.toString(key)); + if (count > 1) + result = result.concat(", "); + count--; + } + + return result.concat("]"); + } +} diff --git a/approximations/src/main/java/generated/java/util/set/HashSetImpl.java b/approximations/src/main/java/generated/java/util/set/HashSetImpl.java new file mode 100644 index 00000000..722abe06 --- /dev/null +++ b/approximations/src/main/java/generated/java/util/set/HashSetImpl.java @@ -0,0 +1,143 @@ +package generated.java.util.set; + +import java.io.Serial; +import java.io.Serializable; +import java.lang.Object; +import java.lang.String; +import java.util.Collection; +import java.util.Iterator; +import java.util.Spliterator; +import java.util.function.Consumer; +import java.util.function.IntFunction; +import java.util.function.Predicate; +import java.util.stream.Stream; +import org.jacodb.approximation.annotation.Approximate; +import org.jetbrains.annotations.NotNull; +import org.usvm.api.Engine; + +@Approximate(java.util.HashSet.class) +public class HashSetImpl extends AbstractSetImpl implements Cloneable, Serializable { + + @Serial + private static final long serialVersionUID = -5024744406713321676L; + + static { + Engine.assume(true); + } + + public HashSetImpl() { + super(true); + } + + public HashSetImpl(Collection c) { + super(true, c); + } + + public HashSetImpl(int initialCapacity) { + super(true, initialCapacity); + } + + public HashSetImpl(int initialCapacity, float loadFactor) { + super(true, initialCapacity, loadFactor); + } + + @SuppressWarnings("unused") + private HashSetImpl(int initialCapacity, float loadFactor, boolean dummy) { + super(initialCapacity, loadFactor, dummy); + } + + public boolean add(E obj) { + return super.add(obj); + } + + public void clear() { + super.clear(); + } + + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + public boolean contains(Object obj) { + return super.contains(obj); + } + + public boolean isEmpty() { + return super.isEmpty(); + } + + @NotNull + public Iterator iterator() { + return super.iterator(); + } + + public boolean remove(Object elem) { + return super.remove(elem); + } + + public int size() { + return super.size(); + } + + public Spliterator spliterator() { + return super.spliterator(); + } + + public boolean equals(Object other) { + return Engine.typeIs(other, HashSetImpl.class) && super.equals(other); + } + + public int hashCode() { + return super.hashCode(); + } + + public boolean removeAll(@NotNull Collection c) { + return super.removeAll(c); + } + + @NotNull + public Object[] toArray() { + return super.toArray(); + } + + @NotNull + public T[] toArray(@NotNull T[] a) { + return super.toArray(a); + } + + public T[] toArray(IntFunction generator) { + return super.toArray(generator); + } + + public boolean containsAll(@NotNull Collection c) { + return super.containsAll(c); + } + + public boolean addAll(@NotNull Collection c) { + return super.addAll(c); + } + + public boolean retainAll(@NotNull Collection c) { + return super.retainAll(c); + } + + public boolean removeIf(Predicate filter) { + return super.removeIf(filter); + } + + public void forEach(Consumer userAction) { + super.forEach(userAction); + } + + public Stream stream() { + return super.stream(); + } + + public Stream parallelStream() { + return super.parallelStream(); + } + + public String toString() { + return super.toString(); + } +} diff --git a/approximations/src/main/java/generated/java/util/set/LinkedHashSetImpl.java b/approximations/src/main/java/generated/java/util/set/LinkedHashSetImpl.java new file mode 100644 index 00000000..46fe05df --- /dev/null +++ b/approximations/src/main/java/generated/java/util/set/LinkedHashSetImpl.java @@ -0,0 +1,137 @@ +package generated.java.util.set; + +import java.io.Serial; +import java.io.Serializable; +import java.lang.Object; +import java.lang.String; +import java.util.*; +import java.util.function.Consumer; +import java.util.function.IntFunction; +import java.util.function.Predicate; +import java.util.stream.Stream; +import org.jacodb.approximation.annotation.Approximate; +import org.jetbrains.annotations.NotNull; +import org.usvm.api.Engine; + +@SuppressWarnings("unused") +@Approximate(java.util.LinkedHashSet.class) +public class LinkedHashSetImpl extends HashSetImpl implements Cloneable, Serializable { + + @Serial + private static final long serialVersionUID = -2851667679971038690L; + + static { + Engine.assume(true); + } + + public LinkedHashSetImpl() { + super(); + } + + public LinkedHashSetImpl(Collection c) { + super(c); + } + + public LinkedHashSetImpl(int initialCapacity) { + super(initialCapacity); + } + + public LinkedHashSetImpl(int initialCapacity, float loadFactor) { + super(initialCapacity, loadFactor); + } + + public boolean add(E obj) { + return super.add(obj); + } + + public void clear() { + super.clear(); + } + + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + public boolean contains(Object obj) { + return super.contains(obj); + } + + public boolean isEmpty() { + return super.isEmpty(); + } + + @NotNull + public Iterator iterator() { + return super.iterator(); + } + + public boolean remove(Object elem) { + return super.remove(elem); + } + + public int size() { + return super.size(); + } + + public Spliterator spliterator() { + return super.spliterator(); + } + + public boolean equals(Object other) { + return Engine.typeIs(other, LinkedHashSetImpl.class) && super.equals(other); + } + + public int hashCode() { + return super.hashCode(); + } + + public boolean removeAll(@NotNull Collection c) { + return super.removeAll(c); + } + + @NotNull + public Object[] toArray() { + return super.toArray(); + } + + @NotNull + public T[] toArray(@NotNull T[] a) { + return super.toArray(a); + } + + public T[] toArray(IntFunction generator) { + return super.toArray(generator); + } + + public boolean containsAll(@NotNull Collection c) { + return super.containsAll(c); + } + + public boolean addAll(@NotNull Collection c) { + return super.addAll(c); + } + + public boolean retainAll(@NotNull Collection c) { + return super.retainAll(c); + } + + public boolean removeIf(Predicate filter) { + return super.removeIf(filter); + } + + public void forEach(Consumer userAction) { + super.forEach(userAction); + } + + public Stream stream() { + return super.stream(); + } + + public Stream parallelStream() { + return super.parallelStream(); + } + + public String toString() { + return super.toString(); + } +} diff --git a/approximations/src/main/java/generated/java/util/set/Set_IteratorImpl.java b/approximations/src/main/java/generated/java/util/set/Set_IteratorImpl.java new file mode 100644 index 00000000..450cd3e0 --- /dev/null +++ b/approximations/src/main/java/generated/java/util/set/Set_IteratorImpl.java @@ -0,0 +1,93 @@ +package generated.java.util.set; + +import java.lang.IllegalStateException; +import java.lang.NullPointerException; +import java.lang.Object; +import java.util.NoSuchElementException; +import java.util.function.Consumer; + +import generated.java.util.AbstractIteratorImpl; +import org.jacodb.approximation.annotation.Approximate; +import org.usvm.api.Engine; +import runtime.LibSLRuntime; +import stub.java.util.set.Set_Iterator; + +@Approximate(Set_Iterator.class) +public final class Set_IteratorImpl extends AbstractIteratorImpl { + + public AbstractSetImpl set; + + public LibSLRuntime.Map unseen; + + public E currentKey; + + public Set_IteratorImpl( + int expectedModCount, + LibSLRuntime.Map unseen, + AbstractSetImpl set, + E currentKey + ) { + super(expectedModCount); + this.unseen = unseen; + this.set = set; + this.currentKey = currentKey; + } + + private AbstractSetImpl _getSet() { + AbstractSetImpl result = this.set; + Engine.assume(result != null); + return result; + } + + protected int _parentModCount() { + return _getSet().modCount; + } + + private boolean _isEmpty() { + return this.unseen.size() == 0; + } + + public void forEachRemaining(Consumer userAction) { + if (userAction == null) + throw new NullPointerException(); + + int size = this.unseen.size(); + Engine.assume(size >= 0); + while (size > 0) { + _checkForModification(); + E curKey = this.unseen.anyKey(); + userAction.accept(curKey); + this.unseen.remove(curKey); + size--; + } + } + + public boolean hasNext() { + return !_isEmpty(); + } + + public E next() { + _checkForModification(); + if (_isEmpty()) + throw new NoSuchElementException(); + + E curKey = this.unseen.anyKey(); + this.unseen.remove(curKey); + this.currentKey = curKey; + return curKey; + } + + public void remove() { + E key = this.currentKey; + if (key == null) + throw new IllegalStateException(); + + _checkForModification(); + AbstractSetImpl set = _getSet(); + set._getStorage().remove(key); + set.modCount++; + this.unseen.remove(key); + this.expectedModCount = set.modCount; + this.currentKey = null; + } +} diff --git a/approximations/src/main/java/generated/java/util/set/Set_SpliteratorImpl.java b/approximations/src/main/java/generated/java/util/set/Set_SpliteratorImpl.java new file mode 100644 index 00000000..2afb32fe --- /dev/null +++ b/approximations/src/main/java/generated/java/util/set/Set_SpliteratorImpl.java @@ -0,0 +1,179 @@ +package generated.java.util.set; + +import generated.java.util.AbstractSpliteratorImpl; +import generated.runtime.LibSLGlobals; +import java.lang.NullPointerException; +import java.lang.Object; +import java.util.function.Consumer; +import org.jacodb.approximation.annotation.Approximate; +import org.usvm.api.Engine; +import org.usvm.api.SymbolicList; +import runtime.LibSLRuntime; +import stub.java.util.set.Set_Spliterator; + +import static runtime.LibSLRuntime.error; + +@Approximate(Set_Spliterator.class) +public final class Set_SpliteratorImpl extends AbstractSpliteratorImpl { + + AbstractSetImpl set; + + SymbolicList seenKeys; + + SymbolicList unseenKeys; + + Set_SpliteratorImpl( + AbstractSetImpl set, + SymbolicList seenKeys, + SymbolicList unseenKeys, + int index, + int fence, + int expectedModCount + ) { + super(index, fence, expectedModCount); + this.set = set; + this.seenKeys = seenKeys; + this.unseenKeys = unseenKeys; + } + + public Set_SpliteratorImpl(AbstractSetImpl set) { + this(set, Engine.makeSymbolicList(), null, 0, -1, 0); + } + + protected AbstractSpliteratorImpl _create(int index, int fence) { + return null; + } + + private AbstractSetImpl _getSet() { + AbstractSetImpl result = this.set; + Engine.assume(result != null); + return result; + } + + protected int _parentModCount() { + return _getSet().modCount; + } + + protected int _storageSize() { + return _getSet()._getStorage().size(); + } + + public int characteristics() { + if (this.fence < 0 || this.index == 0 && this.fence == _storageSize()) + return LibSLGlobals.SPLITERATOR_SIZED | LibSLGlobals.SPLITERATOR_DISTINCT; + + return LibSLGlobals.SPLITERATOR_DISTINCT; + } + + public long estimateSize() { + return super.estimateSize(); + } + + private int _checkSizeOfUnseenKeys() { + int size = unseenKeys.size(); + if (size != estimateSize()) + error("invariant violation"); + + return size; + } + + private int _checkSizeOfSeenKeys() { + int size = seenKeys.size(); + if (size != index) + error("invariant violation"); + + return size; + } + + private LibSLRuntime.Map _removeSeenKeys() { + LibSLRuntime.Map storage = _getSet()._getStorage().duplicate(); + int size = _checkSizeOfSeenKeys(); + for (int i = 0; i < size; i++) { + E key = seenKeys.get(i); + storage.remove(key); + } + + return storage; + } + + public void forEachRemaining(Consumer userAction) { + if (userAction == null) + throw new NullPointerException(); + + int fence = _getFence(); + if (unseenKeys != null) { + _checkSizeOfSeenKeys(); + int size = _checkSizeOfUnseenKeys(); + for (int i = 0; i < size; i++) { + E key = unseenKeys.get(i); + userAction.accept(key); + } + unseenKeys.copy(seenKeys, 0, 0, size); + } else { + LibSLRuntime.Map unseenStorage = _removeSeenKeys(); + for (int i = this.index; i < fence; i++) { + E key = unseenStorage.anyKey(); + userAction.accept(key); + unseenStorage.remove(key); + seenKeys.insert(i, key); + } + } + + this.index = fence; + _checkForModification(); + } + + public long getExactSizeIfKnown() { + return super.getExactSizeIfKnown(); + } + + public boolean tryAdvance(Consumer userAction) { + if (userAction == null) + throw new NullPointerException(); + + int hi = _getFence(); + if (this.index >= hi) + return false; + + if (unseenKeys != null) { + _checkSizeOfSeenKeys(); + _checkSizeOfUnseenKeys(); + E key = unseenKeys.get(0); + userAction.accept(key); + unseenKeys.remove(0); + seenKeys.insert(this.index, key); + } else { + LibSLRuntime.Map unseenStorage = _removeSeenKeys(); + E key = unseenStorage.anyKey(); + userAction.accept(key); + seenKeys.insert(this.index, key); + } + + this.index++; + _checkForModification(); + + return true; + } + + public Set_SpliteratorImpl trySplit() { + int hi = _getFence(); + int lo = this.index; + int mid = (hi + lo) >>> 1; + if (lo >= mid) + return null; + + LibSLRuntime.Map unseenStorage = _removeSeenKeys(); + SymbolicList newUnseenKeys = Engine.makeSymbolicList(); + SymbolicList newSeenKeys = Engine.makeSymbolicList(); + + int j = 0; + for (int i = lo; i < mid; i++) { + E key = unseenStorage.anyKey(); + seenKeys.insert(i, key); + newUnseenKeys.insert(j++, key); + } + + this.index = mid; + return new Set_SpliteratorImpl<>(this.set, newSeenKeys, newUnseenKeys, lo, mid, this.expectedModCount); + } +} diff --git a/approximations/src/main/java/generated/java/util/stream/BaseStreamImpl.java b/approximations/src/main/java/generated/java/util/stream/BaseStreamImpl.java new file mode 100644 index 00000000..df1dbe22 --- /dev/null +++ b/approximations/src/main/java/generated/java/util/stream/BaseStreamImpl.java @@ -0,0 +1,106 @@ +package generated.java.util.stream; + +import generated.runtime.LibSLGlobals; +import org.jacodb.approximation.annotation.Approximate; +import org.jetbrains.annotations.NotNull; +import org.usvm.api.Engine; +import org.usvm.api.SymbolicList; +import stub.java.util.stream.BaseStreamStub; + +@Approximate(BaseStreamStub.class) +public abstract class BaseStreamImpl { + + private SymbolicList closeHandlers; + + public boolean isParallel; + + public boolean linkedOrConsumed; + + public int spliteratorCharacteristics = + LibSLGlobals.SPLITERATOR_ORDERED + | LibSLGlobals.SPLITERATOR_IMMUTABLE + | LibSLGlobals.SPLITERATOR_SIZED + | LibSLGlobals.SPLITERATOR_SUBSIZED; + + public BaseStreamImpl( + SymbolicList closeHandlers, + boolean isParallel, + boolean linkedOrConsumed + ) { + this.closeHandlers = closeHandlers; + this.isParallel = isParallel; + this.linkedOrConsumed = linkedOrConsumed; + } + + protected SymbolicList _getCloseHandlers() { + SymbolicList closeHandlers = this.closeHandlers; + Engine.assume(closeHandlers != null); + return closeHandlers; + } + + protected StreamStubImpl _copyToObjStream(T[] storage) { + return new StreamStubImpl<>(storage, _getCloseHandlers(), isParallel, linkedOrConsumed); + } + + protected IntStreamImpl _copyToIntStream(int[] storage) { + return new IntStreamImpl(storage, _getCloseHandlers(), isParallel, linkedOrConsumed); + } + + protected LongStreamImpl _copyToLongStream(long[] storage) { + return new LongStreamImpl(storage, _getCloseHandlers(), isParallel, linkedOrConsumed); + } + + protected DoubleStreamImpl _copyToDoubleStream(double[] storage) { + return new DoubleStreamImpl(storage, _getCloseHandlers(), isParallel, linkedOrConsumed); + } + + public void evaluate() { + if (this.linkedOrConsumed) + throw new IllegalStateException(); + + this.linkedOrConsumed = true; + } + + public boolean isParallel() { + return this.isParallel; + } + + @NotNull + public BaseStreamImpl sequential() { + this.isParallel = false; + return this; + } + + @NotNull + public BaseStreamImpl parallel() { + this.isParallel = true; + return this; + } + + abstract protected int _getLength(); + + public long count() { + evaluate(); + return _getLength(); + } + + @NotNull + public BaseStreamImpl onClose(@NotNull Runnable closeHandler) { + if (this.linkedOrConsumed) + throw new IllegalStateException(); + + int listLength = this.closeHandlers.size(); + this.closeHandlers.insert(listLength, closeHandler); + return this; + } + + public void close() { + int listLength = this.closeHandlers.size(); + for (int i = 0; i < listLength; i++) { + Runnable currentHandler = this.closeHandlers.get(i); + currentHandler.run(); + } + this.closeHandlers = Engine.makeSymbolicList(); + this.linkedOrConsumed = true; + } +} diff --git a/approximations/src/main/java/generated/java/util/stream/DoubleStreamImpl.java b/approximations/src/main/java/generated/java/util/stream/DoubleStreamImpl.java new file mode 100644 index 00000000..c5779c9b --- /dev/null +++ b/approximations/src/main/java/generated/java/util/stream/DoubleStreamImpl.java @@ -0,0 +1,655 @@ +package generated.java.util.stream; + +import generated.java.util.array.DoubleArrayIteratorImpl; +import generated.java.util.array.DoubleArraySpliteratorImpl; +import generated.runtime.LibSLGlobals; +import java.lang.Double; +import java.lang.IllegalArgumentException; +import java.lang.NullPointerException; +import java.lang.Object; +import java.lang.Runnable; +import java.util.*; +import java.util.function.BiConsumer; +import java.util.function.DoubleBinaryOperator; +import java.util.function.DoubleConsumer; +import java.util.function.DoubleFunction; +import java.util.function.DoublePredicate; +import java.util.function.DoubleToIntFunction; +import java.util.function.DoubleToLongFunction; +import java.util.function.DoubleUnaryOperator; +import java.util.function.ObjDoubleConsumer; +import java.util.function.Supplier; +import java.util.stream.DoubleStream; +import java.util.stream.Stream; + +import org.jacodb.approximation.annotation.Approximate; +import org.jetbrains.annotations.NotNull; +import org.usvm.api.Engine; +import org.usvm.api.SymbolicList; +import runtime.LibSLRuntime; +import stub.java.util.stream.*; +import generated.java.lang.DoubleImpl; + +@Approximate(DoubleStreamStub.class) +public class DoubleStreamImpl extends BaseStreamImpl implements DoubleStream { + + private final double[] storage; + + public DoubleStreamImpl( + double[] storage, + SymbolicList closeHandlers, + boolean isParallel, + boolean linkedOrConsumed + ) { + super(closeHandlers, isParallel, linkedOrConsumed); + this.storage = storage; + } + + public DoubleStreamImpl(double[] storage, SymbolicList closeHandlers, boolean isParallel) { + this(storage, closeHandlers, isParallel, false); + } + + public DoubleStreamImpl(double[] storage, SymbolicList closeHandlers) { + this(storage, closeHandlers, false); + } + + public DoubleStreamImpl(double[] storage) { + this(storage, Engine.makeSymbolicList()); + } + + private double[] _getStorage() { + double[] storage = this.storage; + Engine.assume(storage != null); + return storage; + } + + protected int _getLength() { + return _getStorage().length; + } + + private DoubleStreamImpl _copy(double[] storage) { + return new DoubleStreamImpl(storage, _getCloseHandlers(), isParallel, linkedOrConsumed); + } + + private DoubleStreamImpl _copy() { + return _copy(_getStorage()); + } + + private void _actionApply(DoubleConsumer _action) { + if (_action == null) + throw new NullPointerException(); + + double[] storage = _getStorage(); + for (double v : storage) { + _action.accept(v); + } + } + + private OptionalDouble _findFirst() { + double[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return OptionalDouble.empty(); + + double first = storage[0]; + return OptionalDouble.of(first); + } + + private double _sum() { + double[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return 0; + + double result = 0; + boolean anyNaN = false; + boolean anyPositiveInfinity = false; + boolean anyNegativeInfinity = false; + for (double element : storage) { + result += element; + if (element != element) + anyNaN = true; + if (element == DoubleImpl.POSITIVE_INFINITY) + anyPositiveInfinity = true; + if (element == DoubleImpl.NEGATIVE_INFINITY) + anyNegativeInfinity = true; + } + + if (anyNaN) + return DoubleImpl.NaN; + + if (anyPositiveInfinity && anyNegativeInfinity) + return DoubleImpl.NaN; + + if (anyPositiveInfinity && (result == DoubleImpl.NEGATIVE_INFINITY)) + return DoubleImpl.NaN; + + if (anyNegativeInfinity && (result == DoubleImpl.POSITIVE_INFINITY)) + return DoubleImpl.NaN; + + return result; + } + + @NotNull + @SuppressWarnings("ConstantValue") + public DoubleStreamImpl filter(@NotNull DoublePredicate predicate) { + super.evaluate(); + + if (predicate == null) + throw new NullPointerException(); + + double[] storage = _getStorage(); + int length = storage.length; + double[] filteredStorage = Arrays.copyOf(storage, length); + int filteredLength = 0; + for (double e : storage) { + if (predicate.test(e)) { + filteredStorage[filteredLength] = e; + filteredLength++; + } + } + + Engine.assume(filteredLength <= length); + double[] resultStorage = Arrays.copyOf(filteredStorage, filteredLength); + return _copy(resultStorage); + } + + @NotNull + @SuppressWarnings("ConstantValue") + public DoubleStreamImpl map(@NotNull DoubleUnaryOperator mapper) { + super.evaluate(); + + if (mapper == null) + throw new NullPointerException(); + + double[] storage = _getStorage(); + int length = storage.length; + double[] mappedStorage = new double[length]; + for (int i = 0; i < length; i++) { + mappedStorage[i] = mapper.applyAsDouble(storage[i]); + } + + return _copy(mappedStorage); + } + + @NotNull + @SuppressWarnings({"unchecked", "ConstantValue"}) + public StreamStubImpl mapToObj(@NotNull DoubleFunction mapper) { + super.evaluate(); + + if (mapper == null) + throw new NullPointerException(); + + double[] storage = _getStorage(); + int length = storage.length; + T[] objStorage = (T[]) new Object[length]; + for (int i = 0; i < length; i++) { + objStorage[i] = mapper.apply(storage[i]); + } + + return _copyToObjStream(objStorage); + } + + @NotNull + @SuppressWarnings("ConstantValue") + public LongStreamImpl mapToLong(@NotNull DoubleToLongFunction mapper) { + super.evaluate(); + + if (mapper == null) + throw new NullPointerException(); + + double[] storage = _getStorage(); + int length = storage.length; + long[] mappedStorage = new long[length]; + for (int i = 0; i < length; i++) { + mappedStorage[i] = mapper.applyAsLong(storage[i]); + } + + return _copyToLongStream(mappedStorage); + } + + @NotNull + @SuppressWarnings("ConstantValue") + public IntStreamImpl mapToInt(@NotNull DoubleToIntFunction mapper) { + super.evaluate(); + + if (mapper == null) + throw new NullPointerException(); + + double[] storage = _getStorage(); + int length = storage.length; + int[] mappedStorage = new int[length]; + for (int i = 0; i < length; i++) { + mappedStorage[i] = mapper.applyAsInt(storage[i]); + } + + return _copyToIntStream(mappedStorage); + } + + @SuppressWarnings("ConstantValue") + public DoubleStream flatMap(@NotNull DoubleFunction mapper) { + // TODO: approximate + super.evaluate(); + + if (mapper == null) + throw new NullPointerException(); + + DoubleStream result = Engine.makeSymbolic(DoubleStream.class); + Engine.assume(result != null); + return result; + } + + @NotNull + public DoubleStreamImpl sorted() { + super.evaluate(); + + double[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return _copy(); + + int outerLimit = length - 1; + for (int i = 0; i < outerLimit; i++) { + int innerLimit = length - i - 1; + for (int j = 0; j < innerLimit; j++) { + int idxB = j + 1; + double a = storage[j]; + double b = storage[idxB]; + if (a > b) { + storage[j] = b; + storage[idxB] = a; + } + } + } + + return _copy(); + } + + @NotNull + public DoubleStreamImpl distinct() { + super.evaluate(); + + double[] storage = _getStorage(); + double[] distinctStorage; + int length = storage.length; + if (length == 0) { + distinctStorage = Arrays.copyOf(storage, 0); + return _copy(distinctStorage); + } + + int distinctLength = 0; + distinctStorage = Arrays.copyOf(storage, length); + LibSLRuntime.Map visited = new LibSLRuntime.Map<>(new LibSLRuntime.HashMapContainer<>()); + for (double item : storage) { + if (!visited.hasKey(item)) { + visited.set(item, LibSLGlobals.SOMETHING); + distinctStorage[distinctLength] = item; + distinctLength++; + } + } + + Engine.assume(distinctLength <= length); + double[] resultStorage = Arrays.copyOf(distinctStorage, distinctLength); + return _copy(resultStorage); + } + + @NotNull + public DoubleStreamImpl peek(@NotNull DoubleConsumer _action) { + super.evaluate(); + _actionApply(_action); + return _copy(); + } + + @NotNull + public DoubleStreamImpl limit(long maxSize) { + super.evaluate(); + + int maxSizeInt = (int) maxSize; + + if (maxSizeInt < 0) + throw new IllegalArgumentException(); + + if (maxSizeInt == 0) + return _copy(Arrays.copyOf(_getStorage(), 0)); + + double[] storage = _getStorage(); + int length = storage.length; + if (maxSizeInt > length) + return _copy(); + + double[] limitStorage = Arrays.copyOf(storage, maxSizeInt); + return _copy(limitStorage); + } + + @NotNull + public DoubleStreamImpl skip(long n) { + super.evaluate(); + + int offset = (int) n; + + if (offset < 0) + throw new IllegalArgumentException(); + + if (offset == 0) + return _copy(); + + double[] storage = _getStorage(); + int length = storage.length; + if (offset >= length) + return _copy(Arrays.copyOf(_getStorage(), 0)); + + double[] skipStorage = Arrays.copyOfRange(storage, offset, length); + return _copy(skipStorage); + } + + public void forEach(DoubleConsumer _action) { + super.evaluate(); + _actionApply(_action); + } + + public void forEachOrdered(DoubleConsumer _action) { + forEach(_action); + } + + public double[] toArray() { + super.evaluate(); + return _getStorage(); + } + + public double reduce(double identity, DoubleBinaryOperator accumulator) { + super.evaluate(); + + if (accumulator == null) + throw new NullPointerException(); + + double result = identity; + double[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return result; + + for (double item : storage) { + result = accumulator.applyAsDouble(result, item); + } + + return result; + } + + public OptionalDouble reduce(DoubleBinaryOperator accumulator) { + super.evaluate(); + + if (accumulator == null) + throw new NullPointerException(); + + double[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return OptionalDouble.empty(); + + double value = storage[0]; + for (int i = 1; i < length; i++) { + value = accumulator.applyAsDouble(value, storage[i]); + } + + return OptionalDouble.of(value); + } + + public R collect(Supplier supplier, ObjDoubleConsumer accumulator, BiConsumer combiner) { + super.evaluate(); + + if (supplier == null) + throw new NullPointerException(); + + if (accumulator == null) + throw new NullPointerException(); + + if (combiner == null) + throw new NullPointerException(); + + R result = supplier.get(); + double[] storage = _getStorage(); + for (double item : storage) { + accumulator.accept(result, item); + } + + return result; + } + + public OptionalDouble min() { + super.evaluate(); + + double[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return OptionalDouble.empty(); + + double min = storage[0]; + for (int i = 1; i < length; i++) { + double item = storage[i]; + if (min > item) + min = item; + } + + return OptionalDouble.of(min); + } + + public OptionalDouble max() { + super.evaluate(); + + double[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return OptionalDouble.empty(); + + double max = storage[0]; + for (int i = 1; i < length; i++) { + double item = storage[i]; + if (max < item) + max = item; + } + + return OptionalDouble.of(max); + } + + public long count() { + return super.count(); + } + + public boolean anyMatch(DoublePredicate predicate) { + super.evaluate(); + + if (predicate == null) + throw new NullPointerException(); + + double[] storage = _getStorage(); + for (double item : storage) { + if (predicate.test(item)) + return true; + } + + return false; + } + + public boolean allMatch(DoublePredicate predicate) { + super.evaluate(); + + if (predicate == null) + throw new NullPointerException(); + + double[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return true; + + for (double item : storage) { + if (!predicate.test(item)) + return false; + } + + return true; + } + + public boolean noneMatch(DoublePredicate predicate) { + super.evaluate(); + + if (predicate == null) + throw new NullPointerException(); + + double[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return true; + + for (double item : storage) { + if (predicate.test(item)) + return false; + } + + return true; + } + + public OptionalDouble findFirst() { + super.evaluate(); + return _findFirst(); + } + + public OptionalDouble findAny() { + return findFirst(); + } + + @NotNull + public PrimitiveIterator.OfDouble iterator() { + super.evaluate(); + return new DoubleArrayIteratorImpl(_getStorage()); + } + + @NotNull + public Spliterator.OfDouble spliterator() { + super.evaluate(); + double[] storage = _getStorage(); + return new DoubleArraySpliteratorImpl(storage, spliteratorCharacteristics); + } + + public boolean isParallel() { + return super.isParallel(); + } + + @NotNull + public DoubleStreamImpl sequential() { + return (DoubleStreamImpl) super.sequential(); + } + + @NotNull + public DoubleStreamImpl parallel() { + return (DoubleStreamImpl) super.parallel(); + } + + @NotNull + public DoubleStreamImpl unordered() { + super.evaluate(); + return _copy(); + } + + @NotNull + public DoubleStreamImpl onClose(@NotNull Runnable closeHandler) { + return (DoubleStreamImpl) super.onClose(closeHandler); + } + + public void close() { + super.close(); + } + + @NotNull + @SuppressWarnings("ConstantValue") + public DoubleStreamImpl dropWhile(@NotNull DoublePredicate predicate) { + super.evaluate(); + + if (predicate == null) + throw new NullPointerException(); + + double[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return _copy(Arrays.copyOf(storage, 0)); + + int dropLength = 0; + while (dropLength < length && predicate.test(storage[dropLength])) { + dropLength++; + } + + if (dropLength == 0) + return _copy(); + + int newLength = length - dropLength; + double[] newStorage = Arrays.copyOf(storage, newLength); + return _copy(newStorage); + } + + @NotNull + @SuppressWarnings("ConstantValue") + public DoubleStreamImpl takeWhile(@NotNull DoublePredicate predicate) { + super.evaluate(); + + if (predicate == null) + throw new NullPointerException(); + + double[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return _copy(Arrays.copyOf(storage, 0)); + + int takeLength = 0; + while (takeLength < length && predicate.test(storage[takeLength])) { + takeLength++; + } + + if (takeLength == length) + return _copy(); + + double[] newStorage = Arrays.copyOf(storage, takeLength); + return _copy(newStorage); + } + + public double sum() { + super.evaluate(); + return _sum(); + } + + public OptionalDouble average() { + super.evaluate(); + + double[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return OptionalDouble.empty(); + + double curSum = _sum(); + double divisionResult = curSum / length; + return OptionalDouble.of(divisionResult); + } + + public DoubleSummaryStatistics summaryStatistics() { + super.evaluate(); + + double[] storage = _getStorage(); + DoubleSummaryStatistics result = new DoubleSummaryStatistics(); + for (double v : storage) { + result.accept(v); + } + + return result; + } + + public Stream boxed() { + super.evaluate(); + + double[] storage = _getStorage(); + int length = storage.length; + Double[] doubleArray = new Double[length]; + for (int i = 0; i < length; i++) { + doubleArray[i] = storage[i]; + } + + return _copyToObjStream(doubleArray); + } +} diff --git a/approximations/src/main/java/generated/java/util/stream/DoubleStreamLSL.java b/approximations/src/main/java/generated/java/util/stream/DoubleStreamLSL.java deleted file mode 100644 index e80d69ea..00000000 --- a/approximations/src/main/java/generated/java/util/stream/DoubleStreamLSL.java +++ /dev/null @@ -1,1286 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/stream/DoubleStream.lsl:26 -// - java/util/stream/DoubleStream.main.lsl:29 -// -package generated.java.util.stream; - -import generated.runtime.LibSLGlobals; -import java.lang.Double; -import java.lang.IllegalArgumentException; -import java.lang.IllegalStateException; -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.Runnable; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.DoubleSummaryStatistics; -import java.util.OptionalDouble; -import java.util.PrimitiveIterator; -import java.util.Spliterator; -import java.util.function.BiConsumer; -import java.util.function.DoubleBinaryOperator; -import java.util.function.DoubleConsumer; -import java.util.function.DoubleFunction; -import java.util.function.DoublePredicate; -import java.util.function.DoubleToIntFunction; -import java.util.function.DoubleToLongFunction; -import java.util.function.DoubleUnaryOperator; -import java.util.function.ObjDoubleConsumer; -import java.util.function.Supplier; -import java.util.stream.DoubleStream; -import java.util.stream.IntStream; -import java.util.stream.LongStream; -import java.util.stream.Stream; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import org.usvm.api.SymbolicList; -import runtime.LibSLRuntime; -import stub.java.util.Spliterators_DoubleArraySpliterator; - -/** - * DoubleStreamAutomaton for DoubleStreamLSL ~> java.util.stream.DoubleStreamLSL - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(stub.java.util.stream.DoubleStreamLSL.class) -public class DoubleStreamLSL implements LibSLRuntime.Automaton, DoubleStream { - private static final double DOUBLE_POSITIVE_INFINITY = 1.0d / 0.0d; - - private static final double DOUBLE_NEGATIVE_INFINITY = -1.0d / 0.0d; - - private static final double DOUBLE_NAN = 0.0d / 0.0d; - - static { - Engine.assume(true); - } - - public double[] storage; - - public transient int length; - - public SymbolicList closeHandlers; - - public boolean isParallel; - - public boolean linkedOrConsumed; - - @LibSLRuntime.AutomatonConstructor - public DoubleStreamLSL(Void __$lsl_token, final byte p0, final double[] p1, final int p2, - final SymbolicList p3, final boolean p4, final boolean p5) { - this.storage = p1; - this.length = p2; - this.closeHandlers = p3; - this.isParallel = p4; - this.linkedOrConsumed = p5; - } - - @LibSLRuntime.AutomatonConstructor - public DoubleStreamLSL(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Initialized, null, 0, null, false, false); - } - - /** - * [SUBROUTINE] DoubleStreamAutomaton::_actionApply(DoubleConsumer) -> void - * Source: java/util/stream/DoubleStream.main.lsl:117 - */ - private void _actionApply(DoubleConsumer _action) { - /* body */ { - if (_action == null) { - throw new NullPointerException(); - } - int i = 0; - for (i = 0; i < this.length; i += 1) { - _action.accept(storage[i]); - } - ; - } - } - - /** - * [SUBROUTINE] DoubleStreamAutomaton::_findFirst() -> OptionalDouble - * Source: java/util/stream/DoubleStream.main.lsl:136 - */ - private OptionalDouble _findFirst() { - OptionalDouble result = null; - /* body */ { - if (this.length == 0) { - result = OptionalDouble.empty(); - } else { - final double first = storage[0]; - result = OptionalDouble.of(first); - } - } - return result; - } - - /** - * [SUBROUTINE] DoubleStreamAutomaton::_sum() -> double - * Source: java/util/stream/DoubleStream.main.lsl:150 - */ - private double _sum() { - double result = 0.0d; - /* body */ { - result = 0; - if (this.length != 0) { - boolean anyNaN = false; - boolean anyPositiveInfinity = false; - boolean anyNegativeInfinity = false; - int i = 0; - for (i = 0; i < this.length; i += 1) { - final double element = storage[i]; - result += element; - if (element != element) { - anyNaN = true; - } - if (element == DOUBLE_POSITIVE_INFINITY) { - anyPositiveInfinity = true; - } - if (element == DOUBLE_NEGATIVE_INFINITY) { - anyNegativeInfinity = true; - } - } - ; - if (anyNaN) { - result = DOUBLE_NAN; - } else { - if (anyPositiveInfinity && anyNegativeInfinity) { - result = DOUBLE_NAN; - } else { - if (anyPositiveInfinity && (result == DOUBLE_NEGATIVE_INFINITY)) { - result = DOUBLE_NAN; - } else { - if (anyNegativeInfinity && (result == DOUBLE_POSITIVE_INFINITY)) { - result = DOUBLE_NAN; - } - } - } - } - } - } - return result; - } - - /** - * [FUNCTION] DoubleStreamAutomaton::filter(DoubleStream, DoublePredicate) -> DoubleStream - * Source: java/util/stream/DoubleStream.main.lsl:197 - */ - public DoubleStream filter(DoublePredicate predicate) { - DoubleStream result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (predicate == null) { - throw new NullPointerException(); - } - double[] filteredStorage = new double[this.length]; - int filteredLength = 0; - int i = 0; - for (i = 0; i < this.length; i += 1) { - if (predicate.test(storage[i])) { - filteredStorage[filteredLength] = storage[i]; - filteredLength += 1; - } - } - ; - Engine.assume(filteredLength <= this.length); - double[] resultStorage = new double[filteredLength]; - LibSLRuntime.ArrayActions.copy(filteredStorage, 0, resultStorage, 0, filteredLength); - result = (stub.java.util.stream.DoubleStreamLSL) ((Object) new DoubleStreamLSL((Void) null, - /* state = */ DoubleStreamLSL.__$lsl_States.Initialized, - /* storage = */ resultStorage, - /* length = */ filteredLength, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] DoubleStreamAutomaton::map(DoubleStream, DoubleUnaryOperator) -> DoubleStream - * Source: java/util/stream/DoubleStream.main.lsl:238 - */ - public DoubleStream map(DoubleUnaryOperator mapper) { - DoubleStream result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (mapper == null) { - throw new NullPointerException(); - } - double[] mappedStorage = new double[this.length]; - int i = 0; - for (i = 0; i < this.length; i += 1) { - mappedStorage[i] = mapper.applyAsDouble(storage[i]); - } - ; - result = (stub.java.util.stream.DoubleStreamLSL) ((Object) new DoubleStreamLSL((Void) null, - /* state = */ DoubleStreamLSL.__$lsl_States.Initialized, - /* storage = */ mappedStorage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] DoubleStreamAutomaton::mapToObj(DoubleStream, DoubleFunction) -> Stream - * Source: java/util/stream/DoubleStream.main.lsl:269 - */ - public Stream mapToObj(DoubleFunction mapper) { - Stream result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - final Object[] objStorage = new Object[this.length]; - int i = 0; - for (i = 0; i < this.length; i += 1) { - objStorage[i] = mapper.apply(storage[i]); - } - ; - result = (stub.java.util.stream.StreamLSL) ((Object) new StreamLSL((Void) null, - /* state = */ StreamLSL.__$lsl_States.Initialized, - /* storage = */ objStorage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] DoubleStreamAutomaton::mapToLong(DoubleStream, DoubleToLongFunction) -> LongStream - * Source: java/util/stream/DoubleStream.main.lsl:298 - */ - public LongStream mapToLong(DoubleToLongFunction mapper) { - LongStream result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (mapper == null) { - throw new NullPointerException(); - } - long[] mappedStorage = new long[this.length]; - int i = 0; - for (i = 0; i < this.length; i += 1) { - mappedStorage[i] = mapper.applyAsLong(storage[i]); - } - ; - result = (stub.java.util.stream.LongStreamLSL) ((Object) new LongStreamLSL((Void) null, - /* state = */ LongStreamLSL.__$lsl_States.Initialized, - /* storage = */ mappedStorage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] DoubleStreamAutomaton::mapToInt(DoubleStream, DoubleToIntFunction) -> IntStream - * Source: java/util/stream/DoubleStream.main.lsl:329 - */ - public IntStream mapToInt(DoubleToIntFunction mapper) { - IntStream result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (mapper == null) { - throw new NullPointerException(); - } - int[] mappedStorage = new int[this.length]; - int i = 0; - for (i = 0; i < this.length; i += 1) { - mappedStorage[i] = mapper.applyAsInt(storage[i]); - } - ; - result = (stub.java.util.stream.IntStreamLSL) ((Object) new IntStreamLSL((Void) null, - /* state = */ IntStreamLSL.__$lsl_States.Initialized, - /* storage = */ mappedStorage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] DoubleStreamAutomaton::flatMap(DoubleStream, DoubleFunction) -> DoubleStream - * Source: java/util/stream/DoubleStream.main.lsl:360 - */ - public DoubleStream flatMap(DoubleFunction mapper) { - DoubleStream result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (mapper == null) { - throw new NullPointerException(); - } - result = Engine.makeSymbolic(DoubleStream.class); - Engine.assume(result != null); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] DoubleStreamAutomaton::sorted(DoubleStream) -> DoubleStream - * Source: java/util/stream/DoubleStream.main.lsl:376 - */ - public DoubleStream sorted() { - DoubleStream result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (this.length == 0) { - result = (stub.java.util.stream.DoubleStreamLSL) ((Object) new DoubleStreamLSL((Void) null, - /* state = */ DoubleStreamLSL.__$lsl_States.Initialized, - /* storage = */ this.storage, - /* length = */ 0, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } else { - Engine.assume(this.length > 0); - final int outerLimit = this.length - 1; - int innerLimit = 0; - int i = 0; - int j = 0; - for (i = 0; i < outerLimit; i += 1) { - innerLimit = (this.length - i) - 1; - for (j = 0; j < innerLimit; j += 1) { - final int idxA = j; - final int idxB = j + 1; - final double a = storage[idxA]; - final double b = storage[idxB]; - if (a > b) { - storage[idxA] = b; - storage[idxB] = a; - } - } - ; - } - ; - result = (stub.java.util.stream.DoubleStreamLSL) ((Object) new DoubleStreamLSL((Void) null, - /* state = */ DoubleStreamLSL.__$lsl_States.Initialized, - /* storage = */ this.storage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] DoubleStreamAutomaton::distinct(DoubleStream) -> DoubleStream - * Source: java/util/stream/DoubleStream.main.lsl:439 - */ - public DoubleStream distinct() { - DoubleStream result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - double[] distinctStorage = null; - int distinctLength = 0; - final int size = this.length; - if (size == 0) { - distinctStorage = new double[0]; - distinctLength = 0; - } else { - final double[] items = this.storage; - Engine.assume(items != null); - Engine.assume(items.length != 0); - Engine.assume(size == items.length); - int i = 0; - int j = 0; - final SymbolicList uniqueItems = Engine.makeSymbolicList(); - final LibSLRuntime.Map visited = new LibSLRuntime.Map<>(new LibSLRuntime.HashMapContainer<>()); - for (i = 0; i < size; i += 1) { - final double item = items[i]; - if (!visited.hasKey(item)) { - visited.set(item, LibSLGlobals.SOMETHING); - uniqueItems.insert(j, item); - j += 1; - } - } - ; - distinctLength = j; - Engine.assume(distinctLength > 0); - Engine.assume(distinctLength <= size); - distinctStorage = new double[distinctLength]; - for (i = 0; i < distinctLength; i += 1) { - final Double item = uniqueItems.get(i); - Engine.assume(item != null); - distinctStorage[i] = ((double) item); - } - ; - } - result = (stub.java.util.stream.DoubleStreamLSL) ((Object) new DoubleStreamLSL((Void) null, - /* state = */ DoubleStreamLSL.__$lsl_States.Initialized, - /* storage = */ distinctStorage, - /* length = */ distinctLength, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] DoubleStreamAutomaton::peek(Stream, DoubleConsumer) -> DoubleStream - * Source: java/util/stream/DoubleStream.main.lsl:511 - */ - public DoubleStream peek(DoubleConsumer _action) { - DoubleStream result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - _actionApply(_action); - result = (stub.java.util.stream.DoubleStreamLSL) ((Object) new DoubleStreamLSL((Void) null, - /* state = */ DoubleStreamLSL.__$lsl_States.Initialized, - /* storage = */ this.storage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] DoubleStreamAutomaton::limit(DoubleStream, long) -> DoubleStream - * Source: java/util/stream/DoubleStream.main.lsl:527 - */ - public DoubleStream limit(long maxSize) { - DoubleStream result = null; - /* body */ { - final int maxSizeInt = ((int) maxSize); - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (maxSizeInt < 0) { - throw new IllegalArgumentException(); - } - if (maxSizeInt == 0) { - result = (stub.java.util.stream.DoubleStreamLSL) ((Object) new DoubleStreamLSL((Void) null, - /* state = */ DoubleStreamLSL.__$lsl_States.Initialized, - /* storage = */ this.storage, - /* length = */ 0, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } else { - if (maxSizeInt > this.length) { - result = (stub.java.util.stream.DoubleStreamLSL) ((Object) new DoubleStreamLSL((Void) null, - /* state = */ DoubleStreamLSL.__$lsl_States.Initialized, - /* storage = */ this.storage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } else { - final double[] limitStorage = new double[maxSizeInt]; - LibSLRuntime.ArrayActions.copy(this.storage, 0, limitStorage, 0, maxSizeInt); - result = (stub.java.util.stream.DoubleStreamLSL) ((Object) new DoubleStreamLSL((Void) null, - /* state = */ DoubleStreamLSL.__$lsl_States.Initialized, - /* storage = */ limitStorage, - /* length = */ maxSizeInt, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] DoubleStreamAutomaton::skip(DoubleStream, long) -> DoubleStream - * Source: java/util/stream/DoubleStream.main.lsl:569 - */ - public DoubleStream skip(long n) { - DoubleStream result = null; - /* body */ { - final int offset = ((int) n); - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (offset < 0) { - throw new IllegalArgumentException(); - } - if (offset == 0) { - result = (stub.java.util.stream.DoubleStreamLSL) ((Object) new DoubleStreamLSL((Void) null, - /* state = */ DoubleStreamLSL.__$lsl_States.Initialized, - /* storage = */ this.storage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } else { - if (offset >= this.length) { - double[] newArray = {}; - result = (stub.java.util.stream.DoubleStreamLSL) ((Object) new DoubleStreamLSL((Void) null, - /* state = */ DoubleStreamLSL.__$lsl_States.Initialized, - /* storage = */ newArray, - /* length = */ 0, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } else { - final int newLength = this.length - offset; - final double[] skipStorage = new double[newLength]; - int i = 0; - int skipIndex = 0; - for (i = offset; i < this.length; i += 1) { - skipStorage[skipIndex] = storage[i]; - skipIndex += 1; - } - ; - result = (stub.java.util.stream.DoubleStreamLSL) ((Object) new DoubleStreamLSL((Void) null, - /* state = */ DoubleStreamLSL.__$lsl_States.Initialized, - /* storage = */ skipStorage, - /* length = */ newLength, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] DoubleStreamAutomaton::forEach(DoubleStream, DoubleConsumer) -> void - * Source: java/util/stream/DoubleStream.main.lsl:625 - */ - public void forEach(DoubleConsumer _action) { - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - _actionApply(_action); - this.linkedOrConsumed = true; - } - } - - /** - * [FUNCTION] DoubleStreamAutomaton::forEachOrdered(DoubleStream, DoubleConsumer) -> void - * Source: java/util/stream/DoubleStream.main.lsl:634 - */ - public void forEachOrdered(DoubleConsumer _action) { - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - _actionApply(_action); - this.linkedOrConsumed = true; - } - } - - /** - * [FUNCTION] DoubleStreamAutomaton::toArray(DoubleStream) -> array - * Source: java/util/stream/DoubleStream.main.lsl:643 - */ - public double[] toArray() { - double[] result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - result = this.storage; - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] DoubleStreamAutomaton::reduce(DoubleStream, double, DoubleBinaryOperator) -> double - * Source: java/util/stream/DoubleStream.main.lsl:652 - */ - public double reduce(double identity, DoubleBinaryOperator accumulator) { - double result = 0.0d; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (accumulator == null) { - throw new NullPointerException(); - } - result = identity; - if (this.length != 0) { - Engine.assume(this.length > 0); - int i = 0; - for (i = 0; i < this.length; i += 1) { - result = accumulator.applyAsDouble(result, storage[i]); - } - ; - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] DoubleStreamAutomaton::reduce(DoubleStream, DoubleBinaryOperator) -> OptionalDouble - * Source: java/util/stream/DoubleStream.main.lsl:681 - */ - public OptionalDouble reduce(DoubleBinaryOperator accumulator) { - OptionalDouble result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (accumulator == null) { - throw new NullPointerException(); - } - if (this.length == 0) { - result = OptionalDouble.empty(); - } else { - if (this.length > 0) { - double value = storage[0]; - int i = 0; - for (i = 1; i < this.length; i += 1) { - value = accumulator.applyAsDouble(value, storage[i]); - } - ; - result = OptionalDouble.of(value); - } - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] DoubleStreamAutomaton::collect(DoubleStream, Supplier, ObjDoubleConsumer, BiConsumer) -> Object - * Source: java/util/stream/DoubleStream.main.lsl:715 - */ - public Object collect(Supplier supplier, ObjDoubleConsumer accumulator, BiConsumer combiner) { - Object result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (supplier == null) { - throw new NullPointerException(); - } - if (accumulator == null) { - throw new NullPointerException(); - } - if (combiner == null) { - throw new NullPointerException(); - } - result = supplier.get(); - int i = 0; - for (i = 0; i < this.length; i += 1) { - accumulator.accept(result, storage[i]); - } - ; - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] DoubleStreamAutomaton::min(DoubleStream) -> OptionalDouble - * Source: java/util/stream/DoubleStream.main.lsl:747 - */ - public OptionalDouble min() { - OptionalDouble result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (this.length == 0) { - result = OptionalDouble.empty(); - } else { - double min = storage[0]; - int i = 0; - for (i = 1; i < this.length; i += 1) { - if (min > storage[i]) { - min = storage[i]; - } - } - ; - result = OptionalDouble.of(min); - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] DoubleStreamAutomaton::max(DoubleStream) -> OptionalDouble - * Source: java/util/stream/DoubleStream.main.lsl:779 - */ - public OptionalDouble max() { - OptionalDouble result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (this.length == 0) { - result = OptionalDouble.empty(); - } else { - double max = storage[0]; - int i = 0; - for (i = 1; i < this.length; i += 1) { - if (max < storage[i]) { - max = storage[i]; - } - } - ; - result = OptionalDouble.of(max); - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] DoubleStreamAutomaton::count(DoubleStream) -> long - * Source: java/util/stream/DoubleStream.main.lsl:811 - */ - public long count() { - long result = 0L; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - result = this.length; - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] DoubleStreamAutomaton::anyMatch(DoubleStream, DoublePredicate) -> boolean - * Source: java/util/stream/DoubleStream.main.lsl:820 - */ - public boolean anyMatch(DoublePredicate predicate) { - boolean result = false; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (predicate == null) { - throw new NullPointerException(); - } - result = false; - int i = 0; - while ((i < this.length) && !predicate.test(storage[i])) { - i += 1; - } - ; - if (i < this.length) { - result = true; - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] DoubleStreamAutomaton::allMatch(DoubleStream, DoublePredicate) -> boolean - * Source: java/util/stream/DoubleStream.main.lsl:848 - */ - public boolean allMatch(DoublePredicate predicate) { - boolean result = false; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (predicate == null) { - throw new NullPointerException(); - } - result = true; - if (this.length > 0) { - result = false; - int i = 0; - while ((i < this.length) && predicate.test(storage[i])) { - i += 1; - } - ; - if (i == this.length) { - result = true; - } - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] DoubleStreamAutomaton::noneMatch(DoubleStream, DoublePredicate) -> boolean - * Source: java/util/stream/DoubleStream.main.lsl:874 - */ - public boolean noneMatch(DoublePredicate predicate) { - boolean result = false; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (predicate == null) { - throw new NullPointerException(); - } - result = true; - if (this.length > 0) { - result = false; - int i = 0; - while ((i < this.length) && !predicate.test(storage[i])) { - i += 1; - } - ; - if (i == this.length) { - result = true; - } - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] DoubleStreamAutomaton::findFirst(DoubleStream) -> OptionalDouble - * Source: java/util/stream/DoubleStream.main.lsl:900 - */ - public OptionalDouble findFirst() { - OptionalDouble result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - result = _findFirst(); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] DoubleStreamAutomaton::findAny(DoubleStream) -> OptionalDouble - * Source: java/util/stream/DoubleStream.main.lsl:909 - */ - public OptionalDouble findAny() { - OptionalDouble result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - result = _findFirst(); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] DoubleStreamAutomaton::iterator(DoubleStream) -> PrimitiveIterator_OfDouble - * Source: java/util/stream/DoubleStream.main.lsl:918 - */ - public PrimitiveIterator.OfDouble iterator() { - PrimitiveIterator.OfDouble result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - result = (stub.java.util.stream.DoubleStreamLSLIterator) ((Object) new DoubleStreamLSLIterator((Void) null, - /* state = */ DoubleStreamLSLIterator.__$lsl_States.Initialized, - /* parent = */ this, - /* cursor = */ 0 - )); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] DoubleStreamAutomaton::spliterator(DoubleStream) -> Spliterator_OfDouble - * Source: java/util/stream/DoubleStream.main.lsl:932 - */ - public Spliterator.OfDouble spliterator() { - Spliterator.OfDouble result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - result = (Spliterators_DoubleArraySpliterator) ((Object) new generated.java.util.Spliterators_DoubleArraySpliterator((Void) null, - /* state = */ generated.java.util.Spliterators_DoubleArraySpliterator.__$lsl_States.Initialized, - /* array = */ this.storage, - /* index = */ 0, - /* fence = */ this.length, - /* characteristics = */ LibSLGlobals.SPLITERATOR_ORDERED | LibSLGlobals.SPLITERATOR_IMMUTABLE | LibSLGlobals.SPLITERATOR_SIZED | LibSLGlobals.SPLITERATOR_SUBSIZED - )); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] DoubleStreamAutomaton::isParallel(DoubleStream) -> boolean - * Source: java/util/stream/DoubleStream.main.lsl:948 - */ - public boolean isParallel() { - boolean result = false; - /* body */ { - result = this.isParallel; - } - return result; - } - - /** - * [FUNCTION] DoubleStreamAutomaton::sequential(DoubleStream) -> DoubleStream - * Source: java/util/stream/DoubleStream.main.lsl:954 - */ - public DoubleStream sequential() { - DoubleStream result = null; - /* body */ { - this.isParallel = false; - result = this; - } - return result; - } - - /** - * [FUNCTION] DoubleStreamAutomaton::parallel(DoubleStream) -> DoubleStream - * Source: java/util/stream/DoubleStream.main.lsl:961 - */ - public DoubleStream parallel() { - DoubleStream result = null; - /* body */ { - this.isParallel = true; - result = this; - } - return result; - } - - /** - * [FUNCTION] DoubleStreamAutomaton::unordered(DoubleStream) -> DoubleStream - * Source: java/util/stream/DoubleStream.main.lsl:968 - */ - public DoubleStream unordered() { - DoubleStream result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - result = (stub.java.util.stream.DoubleStreamLSL) ((Object) new DoubleStreamLSL((Void) null, - /* state = */ DoubleStreamLSL.__$lsl_States.Initialized, - /* storage = */ this.storage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] DoubleStreamAutomaton::onClose(DoubleStream, Runnable) -> DoubleStream - * Source: java/util/stream/DoubleStream.main.lsl:981 - */ - public DoubleStream onClose(Runnable closeHandler) { - DoubleStream result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - final int listLength = this.closeHandlers.size(); - this.closeHandlers.insert(listLength, closeHandler); - result = this; - } - return result; - } - - /** - * [FUNCTION] DoubleStreamAutomaton::close(DoubleStream) -> void - * Source: java/util/stream/DoubleStream.main.lsl:993 - */ - public void close() { - /* body */ { - final int listLength = this.closeHandlers.size(); - int i = 0; - for (i = 0; i < listLength; i += 1) { - final Runnable currentHandler = ((Runnable) this.closeHandlers.get(i)); - currentHandler.run(); - } - ; - this.closeHandlers = Engine.makeSymbolicList(); - this.linkedOrConsumed = true; - } - } - - /** - * [FUNCTION] DoubleStreamAutomaton::dropWhile(DoubleStream, DoublePredicate) -> DoubleStream - * Source: java/util/stream/DoubleStream.main.lsl:1017 - */ - public DoubleStream dropWhile(DoublePredicate predicate) { - DoubleStream result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (predicate == null) { - throw new NullPointerException(); - } - if (this.length == 0) { - final double[] emptyStorage = new double[0]; - result = (stub.java.util.stream.DoubleStreamLSL) ((Object) new DoubleStreamLSL((Void) null, - /* state = */ DoubleStreamLSL.__$lsl_States.Initialized, - /* storage = */ emptyStorage, - /* length = */ 0, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } else { - Engine.assume(this.length > 0); - int dropLength = 0; - int i = 0; - while ((i < this.length) && predicate.test(storage[i])) { - dropLength += 1; - i += 1; - } - ; - if (dropLength == 0) { - result = (stub.java.util.stream.DoubleStreamLSL) ((Object) new DoubleStreamLSL((Void) null, - /* state = */ DoubleStreamLSL.__$lsl_States.Initialized, - /* storage = */ this.storage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } else { - final int newLength = this.length - dropLength; - final double[] newStorage = new double[newLength]; - int j = dropLength; - i = dropLength; - while (i < this.length) { - newStorage[j] = storage[i]; - j += 1; - i += 1; - } - ; - result = (stub.java.util.stream.DoubleStreamLSL) ((Object) new DoubleStreamLSL((Void) null, - /* state = */ DoubleStreamLSL.__$lsl_States.Initialized, - /* storage = */ newStorage, - /* length = */ newLength, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] DoubleStreamAutomaton::takeWhile(DoubleStream, DoublePredicate) -> DoubleStream - * Source: java/util/stream/DoubleStream.main.lsl:1092 - */ - public DoubleStream takeWhile(DoublePredicate predicate) { - DoubleStream result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (predicate == null) { - throw new NullPointerException(); - } - if (this.length == 0) { - final double[] emptyStorage = new double[0]; - result = (stub.java.util.stream.DoubleStreamLSL) ((Object) new DoubleStreamLSL((Void) null, - /* state = */ DoubleStreamLSL.__$lsl_States.Initialized, - /* storage = */ emptyStorage, - /* length = */ 0, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } else { - Engine.assume(this.length > 0); - int takeLength = 0; - int i = 0; - while ((i < this.length) && predicate.test(storage[i])) { - takeLength += 1; - i += 1; - } - ; - if (takeLength == this.length) { - result = (stub.java.util.stream.DoubleStreamLSL) ((Object) new DoubleStreamLSL((Void) null, - /* state = */ DoubleStreamLSL.__$lsl_States.Initialized, - /* storage = */ this.storage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } else { - final int newLength = takeLength; - final double[] newStorage = new double[newLength]; - int j = 0; - i = 0; - while (i < takeLength) { - newStorage[j] = storage[i]; - j += 1; - i += 1; - } - ; - result = (stub.java.util.stream.DoubleStreamLSL) ((Object) new DoubleStreamLSL((Void) null, - /* state = */ DoubleStreamLSL.__$lsl_States.Initialized, - /* storage = */ newStorage, - /* length = */ newLength, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] DoubleStreamAutomaton::sum(DoubleStream) -> double - * Source: java/util/stream/DoubleStream.main.lsl:1167 - */ - public double sum() { - double result = 0.0d; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - result = _sum(); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] DoubleStreamAutomaton::average(DoubleStream) -> OptionalDouble - * Source: java/util/stream/DoubleStream.main.lsl:1177 - */ - public OptionalDouble average() { - OptionalDouble result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (this.length == 0) { - result = OptionalDouble.empty(); - } else { - double curSum = _sum(); - double divisionResult = curSum / this.length; - result = OptionalDouble.of(divisionResult); - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] DoubleStreamAutomaton::summaryStatistics(DoubleStream) -> DoubleSummaryStatistics - * Source: java/util/stream/DoubleStream.main.lsl:1196 - */ - public DoubleSummaryStatistics summaryStatistics() { - DoubleSummaryStatistics result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - result = new DoubleSummaryStatistics(); - int i = 0; - for (i = 0; i < this.length; i += 1) { - result.accept(storage[i]); - } - ; - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] DoubleStreamAutomaton::boxed(DoubleStream) -> Stream - * Source: java/util/stream/DoubleStream.main.lsl:1217 - */ - public Stream boxed() { - Stream result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - final Double[] doubleArray = new Double[this.length]; - int i = 0; - for (i = 0; i < this.length; i += 1) { - doubleArray[i] = storage[i]; - } - ; - result = (stub.java.util.stream.StreamLSL) ((Object) new StreamLSL((Void) null, - /* state = */ StreamLSL.__$lsl_States.Initialized, - /* storage = */ doubleArray, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - this.linkedOrConsumed = true; - } - return result; - } - - public static final class __$lsl_States { - public static final byte Initialized = (byte) 0; - } - - @Approximate(DoubleStreamLSL.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/stream/DoubleStreamLSLIterator.java b/approximations/src/main/java/generated/java/util/stream/DoubleStreamLSLIterator.java deleted file mode 100644 index 2dfb3362..00000000 --- a/approximations/src/main/java/generated/java/util/stream/DoubleStreamLSLIterator.java +++ /dev/null @@ -1,169 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/stream/DoubleStream.lsl:39 -// - java/util/stream/DoubleStream.Iterator.lsl:18 -// -package generated.java.util.stream; - -import java.lang.Double; -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.SuppressWarnings; -import java.lang.UnsupportedOperationException; -import java.lang.Void; -import java.util.NoSuchElementException; -import java.util.PrimitiveIterator; -import java.util.function.Consumer; -import java.util.function.DoubleConsumer; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; - -/** - * DoubleStreamIteratorAutomaton for DoubleStreamLSLIterator ~> java.util.stream.DoubleStreamLSLIterator - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(stub.java.util.stream.DoubleStreamLSLIterator.class) -public class DoubleStreamLSLIterator implements LibSLRuntime.Automaton, PrimitiveIterator.OfDouble { - static { - Engine.assume(true); - } - - public DoubleStreamLSL parent; - - public int cursor; - - @LibSLRuntime.AutomatonConstructor - public DoubleStreamLSLIterator(Void __$lsl_token, final byte p0, final DoubleStreamLSL p1, - final int p2) { - this.parent = p1; - this.cursor = p2; - } - - @LibSLRuntime.AutomatonConstructor - public DoubleStreamLSLIterator(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Initialized, null, 0); - } - - /** - * [FUNCTION] DoubleStreamIteratorAutomaton::hasNext(DoubleStreamLSLIterator) -> boolean - * Source: java/util/stream/DoubleStream.Iterator.lsl:41 - */ - public boolean hasNext() { - boolean result = false; - /* body */ { - Engine.assume(this.parent != null); - result = this.cursor != ((DoubleStreamLSL) ((Object) this.parent)).length; - } - return result; - } - - /** - * [FUNCTION] DoubleStreamIteratorAutomaton::next(DoubleStreamLSLIterator) -> Double - * Source: java/util/stream/DoubleStream.Iterator.lsl:50 - */ - public Double next() { - Double result = null; - /* body */ { - Engine.assume(this.parent != null); - final double[] parentStorage = ((DoubleStreamLSL) ((Object) this.parent)).storage; - final int i = this.cursor; - if (i >= ((DoubleStreamLSL) ((Object) this.parent)).length) { - throw new NoSuchElementException(); - } - this.cursor = i + 1; - result = parentStorage[i]; - } - return result; - } - - /** - * [FUNCTION] DoubleStreamIteratorAutomaton::nextDouble(DoubleStreamLSLIterator) -> double - * Source: java/util/stream/DoubleStream.Iterator.lsl:66 - */ - public double nextDouble() { - double result = 0.0d; - /* body */ { - Engine.assume(this.parent != null); - final double[] parentStorage = ((DoubleStreamLSL) ((Object) this.parent)).storage; - final int i = this.cursor; - if (i >= ((DoubleStreamLSL) ((Object) this.parent)).length) { - throw new NoSuchElementException(); - } - this.cursor = i + 1; - result = parentStorage[i]; - } - return result; - } - - /** - * [FUNCTION] DoubleStreamIteratorAutomaton::remove(DoubleStreamLSLIterator) -> void - * Source: java/util/stream/DoubleStream.Iterator.lsl:82 - */ - public void remove() { - /* body */ { - throw new UnsupportedOperationException(); - } - } - - /** - * [FUNCTION] DoubleStreamIteratorAutomaton::forEachRemaining(DoubleStreamLSLIterator, Consumer) -> void - * Source: java/util/stream/DoubleStream.Iterator.lsl:88 - */ - public void forEachRemaining(Consumer userAction) { - /* body */ { - Engine.assume(this.parent != null); - if (userAction == null) { - throw new NullPointerException(); - } - int i = this.cursor; - final int size = ((DoubleStreamLSL) ((Object) this.parent)).length; - if (i != size) { - final double[] pStorage = ((DoubleStreamLSL) ((Object) this.parent)).storage; - while (i < size) { - final double item = pStorage[i]; - userAction.accept(item); - i += 1; - } - ; - this.cursor = i; - } - } - } - - /** - * [FUNCTION] DoubleStreamIteratorAutomaton::forEachRemaining(DoubleStreamLSLIterator, DoubleConsumer) -> void - * Source: java/util/stream/DoubleStream.Iterator.lsl:113 - */ - public void forEachRemaining(DoubleConsumer userAction) { - /* body */ { - Engine.assume(this.parent != null); - if (userAction == null) { - throw new NullPointerException(); - } - int i = this.cursor; - final int size = ((DoubleStreamLSL) ((Object) this.parent)).length; - if (i != size) { - final double[] pStorage = ((DoubleStreamLSL) ((Object) this.parent)).storage; - while (i < size) { - final double item = pStorage[i]; - userAction.accept(item); - i += 1; - } - ; - this.cursor = i; - } - } - } - - public static final class __$lsl_States { - public static final byte Initialized = (byte) 0; - } - - @Approximate(DoubleStreamLSLIterator.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/stream/IntStreamImpl.java b/approximations/src/main/java/generated/java/util/stream/IntStreamImpl.java new file mode 100644 index 00000000..04f57a43 --- /dev/null +++ b/approximations/src/main/java/generated/java/util/stream/IntStreamImpl.java @@ -0,0 +1,654 @@ +package generated.java.util.stream; + +import generated.java.util.array.IntArrayIteratorImpl; +import generated.java.util.array.IntArraySpliteratorImpl; +import generated.runtime.LibSLGlobals; +import java.lang.IllegalArgumentException; +import java.lang.Integer; +import java.lang.NullPointerException; +import java.lang.Object; +import java.lang.Runnable; +import java.util.*; +import java.util.function.BiConsumer; +import java.util.function.IntBinaryOperator; +import java.util.function.IntConsumer; +import java.util.function.IntFunction; +import java.util.function.IntPredicate; +import java.util.function.IntToDoubleFunction; +import java.util.function.IntToLongFunction; +import java.util.function.IntUnaryOperator; +import java.util.function.ObjIntConsumer; +import java.util.function.Supplier; +import java.util.stream.IntStream; +import java.util.stream.Stream; +import org.jacodb.approximation.annotation.Approximate; +import org.jetbrains.annotations.NotNull; +import org.usvm.api.Engine; +import org.usvm.api.SymbolicList; +import runtime.LibSLRuntime; +import stub.java.util.stream.*; + +@Approximate(IntStreamStub.class) +public class IntStreamImpl extends BaseStreamImpl implements IntStream { + + public int[] storage; + + public IntStreamImpl( + int[] storage, + SymbolicList closeHandlers, + boolean isParallel, + boolean linkedOrConsumed + ) { + super(closeHandlers, isParallel, linkedOrConsumed); + this.storage = storage; + } + + public IntStreamImpl(int[] storage, SymbolicList closeHandlers, boolean isParallel) { + this(storage, closeHandlers, isParallel, false); + } + + public IntStreamImpl(int[] storage, SymbolicList closeHandlers) { + this(storage, closeHandlers, false); + } + + public IntStreamImpl(int[] storage) { + this(storage, Engine.makeSymbolicList()); + } + + private int[] _getStorage() { + int[] storage = this.storage; + Engine.assume(storage != null); + return storage; + } + + protected int _getLength() { + return _getStorage().length; + } + + private IntStreamImpl _copy(int[] storage) { + return new IntStreamImpl(storage, _getCloseHandlers(), isParallel, linkedOrConsumed); + } + + private IntStreamImpl _copy() { + return _copy(_getStorage()); + } + + private void _actionApply(IntConsumer _action) { + if (_action == null) + throw new NullPointerException(); + + int[] storage = _getStorage(); + for (int j : storage) { + _action.accept(j); + } + } + + private OptionalInt _findFirst() { + int[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return OptionalInt.empty(); + + int first = storage[0]; + return OptionalInt.of(first); + } + + private int _sum() { + int[] storage = _getStorage(); + int result = 0; + for (int j : storage) { + result += j; + } + return result; + } + + @NotNull + @SuppressWarnings("ConstantValue") + public IntStreamImpl filter(@NotNull IntPredicate predicate) { + super.evaluate(); + + if (predicate == null) + throw new NullPointerException(); + + int[] storage = _getStorage(); + int length = storage.length; + int[] filteredStorage = Arrays.copyOf(storage, length); + int filteredLength = 0; + for (int e : storage) { + if (predicate.test(e)) { + filteredStorage[filteredLength] = e; + filteredLength++; + } + } + + Engine.assume(filteredLength <= length); + int[] resultStorage = Arrays.copyOf(filteredStorage, filteredLength); + return _copy(resultStorage); + } + + @NotNull + @SuppressWarnings("ConstantValue") + public IntStreamImpl map(@NotNull IntUnaryOperator mapper) { + super.evaluate(); + + if (mapper == null) + throw new NullPointerException(); + + int[] storage = _getStorage(); + int length = storage.length; + int[] mappedStorage = new int[length]; + for (int i = 0; i < length; i++) { + mappedStorage[i] = mapper.applyAsInt(storage[i]); + } + + return _copy(mappedStorage); + } + + @NotNull + @SuppressWarnings({"unchecked", "ConstantValue"}) + public StreamStubImpl mapToObj(@NotNull IntFunction mapper) { + super.evaluate(); + + if (mapper == null) + throw new NullPointerException(); + + int[] storage = _getStorage(); + int length = storage.length; + T[] objStorage = (T[]) new Object[length]; + for (int i = 0; i < length; i++) { + objStorage[i] = mapper.apply(storage[i]); + } + + return _copyToObjStream(objStorage); + } + + @NotNull + @SuppressWarnings("ConstantValue") + public LongStreamImpl mapToLong(@NotNull IntToLongFunction mapper) { + super.evaluate(); + + if (mapper == null) + throw new NullPointerException(); + + int[] storage = _getStorage(); + int length = storage.length; + long[] mappedStorage = new long[length]; + for (int i = 0; i < length; i++) { + mappedStorage[i] = mapper.applyAsLong(storage[i]); + } + + return _copyToLongStream(mappedStorage); + } + + @NotNull + @SuppressWarnings("ConstantValue") + public DoubleStreamImpl mapToDouble(@NotNull IntToDoubleFunction mapper) { + super.evaluate(); + + if (mapper == null) + throw new NullPointerException(); + + int[] storage = _getStorage(); + int length = storage.length; + double[] mappedStorage = new double[length]; + for (int i = 0; i < length; i++) { + mappedStorage[i] = mapper.applyAsDouble(storage[i]); + } + + return _copyToDoubleStream(mappedStorage); + } + + @NotNull + @SuppressWarnings({"ConstantValue", "DataFlowIssue"}) + public IntStream flatMap(@NotNull IntFunction mapper) { + // TODO: approximate + super.evaluate(); + + if (mapper == null) + throw new NullPointerException(); + + IntStream result = Engine.makeSymbolic(IntStream.class); + Engine.assume(result != null); + return result; + } + + @NotNull + public IntStreamImpl sorted() { + super.evaluate(); + + int[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return _copy(); + + int outerLimit = length - 1; + for (int i = 0; i < outerLimit; i++) { + int innerLimit = length - i - 1; + for (int j = 0; j < innerLimit; j++) { + int idxB = j + 1; + int a = storage[j]; + int b = storage[idxB]; + if (a > b) { + storage[j] = b; + storage[idxB] = a; + } + } + } + + return _copy(); + } + + @NotNull + public IntStreamImpl distinct() { + super.evaluate(); + + int[] storage = _getStorage(); + int[] distinctStorage; + int length = storage.length; + if (length == 0) { + distinctStorage = Arrays.copyOf(storage, 0); + return _copy(distinctStorage); + } + + int distinctLength = 0; + distinctStorage = Arrays.copyOf(storage, length); + LibSLRuntime.Map visited = new LibSLRuntime.Map<>(new LibSLRuntime.HashMapContainer<>()); + for (int item : storage) { + if (!visited.hasKey(item)) { + visited.set(item, LibSLGlobals.SOMETHING); + distinctStorage[distinctLength] = item; + distinctLength++; + } + } + + Engine.assume(distinctLength <= length); + int[] resultStorage = Arrays.copyOf(distinctStorage, distinctLength); + return _copy(resultStorage); + } + + @NotNull + public IntStreamImpl peek(@NotNull IntConsumer _action) { + super.evaluate(); + _actionApply(_action); + return _copy(); + } + + @NotNull + public IntStreamImpl limit(long maxSize) { + super.evaluate(); + + int maxSizeInt = (int) maxSize; + + if (maxSizeInt < 0) + throw new IllegalArgumentException(); + + if (maxSizeInt == 0) + return _copy(Arrays.copyOf(_getStorage(), 0)); + + int[] storage = _getStorage(); + int length = storage.length; + if (maxSizeInt > length) + return _copy(); + + int[] limitStorage = Arrays.copyOf(storage, maxSizeInt); + return _copy(limitStorage); + } + + @NotNull + public IntStreamImpl skip(long n) { + super.evaluate(); + + int offset = (int) n; + + if (offset < 0) + throw new IllegalArgumentException(); + + if (offset == 0) + return _copy(); + + int[] storage = _getStorage(); + int length = storage.length; + if (offset >= length) + return _copy(Arrays.copyOf(_getStorage(), 0)); + + int[] skipStorage = Arrays.copyOfRange(storage, offset, length); + return _copy(skipStorage); + } + + public void forEach(IntConsumer _action) { + super.evaluate(); + _actionApply(_action); + } + + public void forEachOrdered(IntConsumer _action) { + forEach(_action); + } + + public int[] toArray() { + super.evaluate(); + return _getStorage(); + } + + public int reduce(int identity, IntBinaryOperator accumulator) { + super.evaluate(); + + if (accumulator == null) + throw new NullPointerException(); + + int result = identity; + int[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return result; + + for (int item : storage) { + result = accumulator.applyAsInt(result, item); + } + + return result; + } + + public OptionalInt reduce(IntBinaryOperator accumulator) { + super.evaluate(); + + if (accumulator == null) + throw new NullPointerException(); + + int[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return OptionalInt.empty(); + + int value = storage[0]; + for (int i = 1; i < length; i++) { + value = accumulator.applyAsInt(value, storage[i]); + } + + return OptionalInt.of(value); + } + + public R collect(Supplier supplier, ObjIntConsumer accumulator, BiConsumer combiner) { + super.evaluate(); + + if (supplier == null) + throw new NullPointerException(); + + if (accumulator == null) + throw new NullPointerException(); + + if (combiner == null) + throw new NullPointerException(); + + R result = supplier.get(); + int[] storage = _getStorage(); + for (int item : storage) { + accumulator.accept(result, item); + } + + return result; + } + + public OptionalInt min() { + super.evaluate(); + + int[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return OptionalInt.empty(); + + int min = storage[0]; + for (int i = 1; i < length; i++) { + int item = storage[i]; + if (min > item) + min = item; + } + + return OptionalInt.of(min); + } + + public OptionalInt max() { + super.evaluate(); + + int[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return OptionalInt.empty(); + + int max = storage[0]; + for (int i = 1; i < length; i++) { + int item = storage[i]; + if (max < item) + max = item; + } + + return OptionalInt.of(max); + } + + public long count() { + return super.count(); + } + + public boolean anyMatch(IntPredicate predicate) { + super.evaluate(); + + if (predicate == null) + throw new NullPointerException(); + + int[] storage = _getStorage(); + for (int item : storage) { + if (predicate.test(item)) + return true; + } + + return false; + } + + public boolean allMatch(IntPredicate predicate) { + super.evaluate(); + + if (predicate == null) + throw new NullPointerException(); + + int[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return true; + + for (int item : storage) { + if (!predicate.test(item)) + return false; + } + + return true; + } + + public boolean noneMatch(IntPredicate predicate) { + super.evaluate(); + + if (predicate == null) + throw new NullPointerException(); + + int[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return true; + + for (int item : storage) { + if (predicate.test(item)) + return false; + } + + return true; + } + + public OptionalInt findFirst() { + super.evaluate(); + return _findFirst(); + } + + public OptionalInt findAny() { + return findFirst(); + } + + @NotNull + public PrimitiveIterator.OfInt iterator() { + super.evaluate(); + return new IntArrayIteratorImpl(_getStorage()); + } + + @NotNull + public Spliterator.OfInt spliterator() { + super.evaluate(); + int[] storage = _getStorage(); + return new IntArraySpliteratorImpl(storage, spliteratorCharacteristics); + } + + public boolean isParallel() { + return super.isParallel(); + } + + @NotNull + public IntStreamImpl sequential() { + return (IntStreamImpl) super.sequential(); + } + + @NotNull + public IntStreamImpl parallel() { + return (IntStreamImpl) super.parallel(); + } + + @NotNull + public IntStreamImpl unordered() { + super.evaluate(); + return _copy(); + } + + @NotNull + public IntStreamImpl onClose(@NotNull Runnable closeHandler) { + return (IntStreamImpl) super.onClose(closeHandler); + } + + public void close() { + super.close(); + } + + @NotNull + @SuppressWarnings("ConstantValue") + public IntStreamImpl dropWhile(@NotNull IntPredicate predicate) { + super.evaluate(); + + if (predicate == null) + throw new NullPointerException(); + + int[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return _copy(Arrays.copyOf(storage, 0)); + + int dropLength = 0; + while (dropLength < length && predicate.test(storage[dropLength])) { + dropLength++; + } + + if (dropLength == 0) + return _copy(); + + int newLength = length - dropLength; + int[] newStorage = Arrays.copyOf(storage, newLength); + return _copy(newStorage); + } + + @NotNull + @SuppressWarnings("ConstantValue") + public IntStreamImpl takeWhile(@NotNull IntPredicate predicate) { + super.evaluate(); + + if (predicate == null) + throw new NullPointerException(); + + int[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return _copy(Arrays.copyOf(storage, 0)); + + int takeLength = 0; + while (takeLength < length && predicate.test(storage[takeLength])) { + takeLength++; + } + + if (takeLength == length) + return _copy(); + + int[] newStorage = Arrays.copyOf(storage, takeLength); + return _copy(newStorage); + } + + public LongStreamImpl asLongStream() { + super.evaluate(); + + int[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return _copyToLongStream(new long[0]); + + long[] newStorage = new long[length]; + LibSLRuntime.ArrayActions.copy(storage, 0, newStorage, 0, length); + return _copyToLongStream(newStorage); + } + + public DoubleStreamImpl asDoubleStream() { + super.evaluate(); + + int[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return _copyToDoubleStream(new double[0]); + + double[] newStorage = new double[length]; + LibSLRuntime.ArrayActions.copy(storage, 0, newStorage, 0, length); + return _copyToDoubleStream(newStorage); + } + + public int sum() { + super.evaluate(); + return _sum(); + } + + public OptionalDouble average() { + super.evaluate(); + + int[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return OptionalDouble.empty(); + + double curSum = _sum(); + double divisionResult = curSum / length; + return OptionalDouble.of(divisionResult); + } + + public IntSummaryStatistics summaryStatistics() { + super.evaluate(); + + int[] storage = _getStorage(); + IntSummaryStatistics result = new IntSummaryStatistics(); + for (int j : storage) { + result.accept(j); + } + + return result; + } + + public Stream boxed() { + super.evaluate(); + + int[] storage = _getStorage(); + int length = storage.length; + Integer[] integerArray = new Integer[length]; + for (int i = 0; i < length; i++) { + integerArray[i] = storage[i]; + } + + return _copyToObjStream(integerArray); + } +} diff --git a/approximations/src/main/java/generated/java/util/stream/IntStreamLSL.java b/approximations/src/main/java/generated/java/util/stream/IntStreamLSL.java deleted file mode 100644 index ee52e738..00000000 --- a/approximations/src/main/java/generated/java/util/stream/IntStreamLSL.java +++ /dev/null @@ -1,1337 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/stream/IntStream.lsl:26 -// - java/util/stream/IntStream.main.lsl:27 -// -package generated.java.util.stream; - -import generated.runtime.LibSLGlobals; -import java.lang.IllegalArgumentException; -import java.lang.IllegalStateException; -import java.lang.Integer; -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.Runnable; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.IntSummaryStatistics; -import java.util.OptionalDouble; -import java.util.OptionalInt; -import java.util.PrimitiveIterator; -import java.util.Spliterator; -import java.util.function.BiConsumer; -import java.util.function.IntBinaryOperator; -import java.util.function.IntConsumer; -import java.util.function.IntFunction; -import java.util.function.IntPredicate; -import java.util.function.IntToDoubleFunction; -import java.util.function.IntToLongFunction; -import java.util.function.IntUnaryOperator; -import java.util.function.ObjIntConsumer; -import java.util.function.Supplier; -import java.util.stream.DoubleStream; -import java.util.stream.IntStream; -import java.util.stream.LongStream; -import java.util.stream.Stream; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import org.usvm.api.SymbolicList; -import runtime.LibSLRuntime; -import stub.java.util.Spliterators_IntArraySpliterator; - -/** - * IntStreamAutomaton for IntStreamLSL ~> java.util.stream.IntStreamLSL - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(stub.java.util.stream.IntStreamLSL.class) -public class IntStreamLSL implements LibSLRuntime.Automaton, IntStream { - static { - Engine.assume(true); - } - - public int[] storage; - - public transient int length; - - public SymbolicList closeHandlers; - - public boolean isParallel; - - public boolean linkedOrConsumed; - - @LibSLRuntime.AutomatonConstructor - public IntStreamLSL(Void __$lsl_token, final byte p0, final int[] p1, final int p2, - final SymbolicList p3, final boolean p4, final boolean p5) { - this.storage = p1; - this.length = p2; - this.closeHandlers = p3; - this.isParallel = p4; - this.linkedOrConsumed = p5; - } - - @LibSLRuntime.AutomatonConstructor - public IntStreamLSL(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Initialized, null, 0, null, false, false); - } - - /** - * [SUBROUTINE] IntStreamAutomaton::_actionApply(IntConsumer) -> void - * Source: java/util/stream/IntStream.main.lsl:117 - */ - private void _actionApply(IntConsumer _action) { - /* body */ { - if (_action == null) { - throw new NullPointerException(); - } - int i = 0; - for (i = 0; i < this.length; i += 1) { - _action.accept(storage[i]); - } - ; - } - } - - /** - * [SUBROUTINE] IntStreamAutomaton::_findFirst() -> OptionalInt - * Source: java/util/stream/IntStream.main.lsl:136 - */ - private OptionalInt _findFirst() { - OptionalInt result = null; - /* body */ { - if (this.length == 0) { - result = OptionalInt.empty(); - } else { - final int first = storage[0]; - result = OptionalInt.of(first); - } - } - return result; - } - - /** - * [SUBROUTINE] IntStreamAutomaton::_sum() -> int - * Source: java/util/stream/IntStream.main.lsl:150 - */ - private int _sum() { - int result = 0; - /* body */ { - result = 0; - if (this.length != 0) { - int i = 0; - for (i = 0; i < this.length; i += 1) { - result += storage[i]; - } - ; - } - } - return result; - } - - /** - * [FUNCTION] IntStreamAutomaton::filter(IntStream, IntPredicate) -> IntStream - * Source: java/util/stream/IntStream.main.lsl:172 - */ - public IntStream filter(IntPredicate predicate) { - IntStream result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (predicate == null) { - throw new NullPointerException(); - } - int[] filteredStorage = new int[this.length]; - int filteredLength = 0; - int i = 0; - for (i = 0; i < this.length; i += 1) { - if (predicate.test(storage[i])) { - filteredStorage[filteredLength] = storage[i]; - filteredLength += 1; - } - } - ; - Engine.assume(filteredLength <= this.length); - int[] resultStorage = new int[filteredLength]; - LibSLRuntime.ArrayActions.copy(filteredStorage, 0, resultStorage, 0, filteredLength); - result = (stub.java.util.stream.IntStreamLSL) ((Object) new IntStreamLSL((Void) null, - /* state = */ IntStreamLSL.__$lsl_States.Initialized, - /* storage = */ resultStorage, - /* length = */ filteredLength, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] IntStreamAutomaton::map(IntStream, IntUnaryOperator) -> IntStream - * Source: java/util/stream/IntStream.main.lsl:213 - */ - public IntStream map(IntUnaryOperator mapper) { - IntStream result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (mapper == null) { - throw new NullPointerException(); - } - int[] mappedStorage = new int[this.length]; - int i = 0; - for (i = 0; i < this.length; i += 1) { - mappedStorage[i] = mapper.applyAsInt(storage[i]); - } - ; - result = (stub.java.util.stream.IntStreamLSL) ((Object) new IntStreamLSL((Void) null, - /* state = */ IntStreamLSL.__$lsl_States.Initialized, - /* storage = */ mappedStorage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] IntStreamAutomaton::mapToObj(IntStream, IntFunction) -> Stream - * Source: java/util/stream/IntStream.main.lsl:244 - */ - public Stream mapToObj(IntFunction mapper) { - Stream result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - final Object[] objStorage = new Object[this.length]; - int i = 0; - for (i = 0; i < this.length; i += 1) { - objStorage[i] = mapper.apply(storage[i]); - } - ; - result = (stub.java.util.stream.StreamLSL) ((Object) new StreamLSL((Void) null, - /* state = */ StreamLSL.__$lsl_States.Initialized, - /* storage = */ objStorage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] IntStreamAutomaton::mapToLong(IntStream, IntToLongFunction) -> LongStream - * Source: java/util/stream/IntStream.main.lsl:273 - */ - public LongStream mapToLong(IntToLongFunction mapper) { - LongStream result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (mapper == null) { - throw new NullPointerException(); - } - long[] mappedStorage = new long[this.length]; - int i = 0; - for (i = 0; i < this.length; i += 1) { - mappedStorage[i] = mapper.applyAsLong(storage[i]); - } - ; - result = (stub.java.util.stream.LongStreamLSL) ((Object) new LongStreamLSL((Void) null, - /* state = */ LongStreamLSL.__$lsl_States.Initialized, - /* storage = */ mappedStorage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] IntStreamAutomaton::mapToDouble(IntStream, IntToDoubleFunction) -> DoubleStream - * Source: java/util/stream/IntStream.main.lsl:304 - */ - public DoubleStream mapToDouble(IntToDoubleFunction mapper) { - DoubleStream result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (mapper == null) { - throw new NullPointerException(); - } - double[] mappedStorage = new double[this.length]; - int i = 0; - for (i = 0; i < this.length; i += 1) { - mappedStorage[i] = mapper.applyAsDouble(storage[i]); - } - ; - result = (stub.java.util.stream.DoubleStreamLSL) ((Object) new DoubleStreamLSL((Void) null, - /* state = */ DoubleStreamLSL.__$lsl_States.Initialized, - /* storage = */ mappedStorage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] IntStreamAutomaton::flatMap(IntStream, IntFunction) -> IntStream - * Source: java/util/stream/IntStream.main.lsl:335 - */ - public IntStream flatMap(IntFunction mapper) { - IntStream result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (mapper == null) { - throw new NullPointerException(); - } - result = Engine.makeSymbolic(IntStream.class); - Engine.assume(result != null); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] IntStreamAutomaton::sorted(IntStream) -> IntStream - * Source: java/util/stream/IntStream.main.lsl:351 - */ - public IntStream sorted() { - IntStream result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (this.length == 0) { - result = (stub.java.util.stream.IntStreamLSL) ((Object) new IntStreamLSL((Void) null, - /* state = */ IntStreamLSL.__$lsl_States.Initialized, - /* storage = */ this.storage, - /* length = */ 0, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } else { - Engine.assume(this.length > 0); - final int outerLimit = this.length - 1; - int innerLimit = 0; - int i = 0; - int j = 0; - for (i = 0; i < outerLimit; i += 1) { - innerLimit = (this.length - i) - 1; - for (j = 0; j < innerLimit; j += 1) { - final int idxA = j; - final int idxB = j + 1; - final int a = storage[idxA]; - final int b = storage[idxB]; - if (a > b) { - storage[idxA] = b; - storage[idxB] = a; - } - } - ; - } - ; - result = (stub.java.util.stream.IntStreamLSL) ((Object) new IntStreamLSL((Void) null, - /* state = */ IntStreamLSL.__$lsl_States.Initialized, - /* storage = */ this.storage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] IntStreamAutomaton::distinct(IntStream) -> IntStream - * Source: java/util/stream/IntStream.main.lsl:414 - */ - public IntStream distinct() { - IntStream result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - int[] distinctStorage = null; - int distinctLength = 0; - final int size = this.length; - if (size == 0) { - distinctStorage = new int[0]; - distinctLength = 0; - } else { - final int[] items = this.storage; - Engine.assume(items != null); - Engine.assume(items.length != 0); - Engine.assume(size == items.length); - int i = 0; - int j = 0; - final SymbolicList uniqueItems = Engine.makeSymbolicList(); - final LibSLRuntime.Map visited = new LibSLRuntime.Map<>(new LibSLRuntime.HashMapContainer<>()); - for (i = 0; i < size; i += 1) { - final int item = items[i]; - if (!visited.hasKey(item)) { - visited.set(item, LibSLGlobals.SOMETHING); - uniqueItems.insert(j, item); - j += 1; - } - } - ; - distinctLength = j; - Engine.assume(distinctLength > 0); - Engine.assume(distinctLength <= size); - distinctStorage = new int[distinctLength]; - for (i = 0; i < distinctLength; i += 1) { - final Integer item = uniqueItems.get(i); - Engine.assume(item != null); - distinctStorage[i] = ((int) item); - } - ; - } - result = (stub.java.util.stream.IntStreamLSL) ((Object) new IntStreamLSL((Void) null, - /* state = */ IntStreamLSL.__$lsl_States.Initialized, - /* storage = */ distinctStorage, - /* length = */ distinctLength, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] IntStreamAutomaton::peek(IntStream, IntConsumer) -> IntStream - * Source: java/util/stream/IntStream.main.lsl:486 - */ - public IntStream peek(IntConsumer _action) { - IntStream result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - _actionApply(_action); - result = (stub.java.util.stream.IntStreamLSL) ((Object) new IntStreamLSL((Void) null, - /* state = */ IntStreamLSL.__$lsl_States.Initialized, - /* storage = */ this.storage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] IntStreamAutomaton::limit(IntStream, long) -> IntStream - * Source: java/util/stream/IntStream.main.lsl:502 - */ - public IntStream limit(long maxSize) { - IntStream result = null; - /* body */ { - final int maxSizeInt = ((int) maxSize); - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (maxSizeInt < 0) { - throw new IllegalArgumentException(); - } - if (maxSizeInt == 0) { - result = (stub.java.util.stream.IntStreamLSL) ((Object) new IntStreamLSL((Void) null, - /* state = */ IntStreamLSL.__$lsl_States.Initialized, - /* storage = */ this.storage, - /* length = */ 0, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } else { - if (maxSizeInt > this.length) { - result = (stub.java.util.stream.IntStreamLSL) ((Object) new IntStreamLSL((Void) null, - /* state = */ IntStreamLSL.__$lsl_States.Initialized, - /* storage = */ this.storage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } else { - final int[] limitStorage = new int[maxSizeInt]; - LibSLRuntime.ArrayActions.copy(this.storage, 0, limitStorage, 0, maxSizeInt); - result = (stub.java.util.stream.IntStreamLSL) ((Object) new IntStreamLSL((Void) null, - /* state = */ IntStreamLSL.__$lsl_States.Initialized, - /* storage = */ limitStorage, - /* length = */ maxSizeInt, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] IntStreamAutomaton::skip(IntStream, long) -> IntStream - * Source: java/util/stream/IntStream.main.lsl:544 - */ - public IntStream skip(long n) { - IntStream result = null; - /* body */ { - final int offset = ((int) n); - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (offset < 0) { - throw new IllegalArgumentException(); - } - if (offset == 0) { - result = (stub.java.util.stream.IntStreamLSL) ((Object) new IntStreamLSL((Void) null, - /* state = */ IntStreamLSL.__$lsl_States.Initialized, - /* storage = */ this.storage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } else { - if (offset >= this.length) { - int[] newArray = {}; - result = (stub.java.util.stream.IntStreamLSL) ((Object) new IntStreamLSL((Void) null, - /* state = */ IntStreamLSL.__$lsl_States.Initialized, - /* storage = */ newArray, - /* length = */ 0, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } else { - final int newLength = this.length - offset; - final int[] skipStorage = new int[newLength]; - int i = 0; - int skipIndex = 0; - for (i = offset; i < this.length; i += 1) { - skipStorage[skipIndex] = storage[i]; - skipIndex += 1; - } - ; - result = (stub.java.util.stream.IntStreamLSL) ((Object) new IntStreamLSL((Void) null, - /* state = */ IntStreamLSL.__$lsl_States.Initialized, - /* storage = */ skipStorage, - /* length = */ newLength, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] IntStreamAutomaton::forEach(IntStream, IntConsumer) -> void - * Source: java/util/stream/IntStream.main.lsl:599 - */ - public void forEach(IntConsumer _action) { - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - _actionApply(_action); - this.linkedOrConsumed = true; - } - } - - /** - * [FUNCTION] IntStreamAutomaton::forEachOrdered(IntStream, IntConsumer) -> void - * Source: java/util/stream/IntStream.main.lsl:608 - */ - public void forEachOrdered(IntConsumer _action) { - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - _actionApply(_action); - this.linkedOrConsumed = true; - } - } - - /** - * [FUNCTION] IntStreamAutomaton::toArray(IntStream) -> array - * Source: java/util/stream/IntStream.main.lsl:617 - */ - public int[] toArray() { - int[] result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - result = this.storage; - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] IntStreamAutomaton::reduce(IntStream, int, IntBinaryOperator) -> int - * Source: java/util/stream/IntStream.main.lsl:626 - */ - public int reduce(int identity, IntBinaryOperator accumulator) { - int result = 0; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (accumulator == null) { - throw new NullPointerException(); - } - result = identity; - if (this.length != 0) { - Engine.assume(this.length > 0); - int i = 0; - for (i = 0; i < this.length; i += 1) { - result = accumulator.applyAsInt(result, storage[i]); - } - ; - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] IntStreamAutomaton::reduce(IntStream, IntBinaryOperator) -> OptionalInt - * Source: java/util/stream/IntStream.main.lsl:655 - */ - public OptionalInt reduce(IntBinaryOperator accumulator) { - OptionalInt result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (accumulator == null) { - throw new NullPointerException(); - } - if (this.length == 0) { - result = OptionalInt.empty(); - } else { - if (this.length > 0) { - int value = storage[0]; - int i = 0; - for (i = 1; i < this.length; i += 1) { - value = accumulator.applyAsInt(value, storage[i]); - } - ; - result = OptionalInt.of(value); - } - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] IntStreamAutomaton::collect(IntStream, Supplier, ObjIntConsumer, BiConsumer) -> Object - * Source: java/util/stream/IntStream.main.lsl:689 - */ - public Object collect(Supplier supplier, ObjIntConsumer accumulator, BiConsumer combiner) { - Object result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (supplier == null) { - throw new NullPointerException(); - } - if (accumulator == null) { - throw new NullPointerException(); - } - if (combiner == null) { - throw new NullPointerException(); - } - result = supplier.get(); - int i = 0; - for (i = 0; i < this.length; i += 1) { - accumulator.accept(result, storage[i]); - } - ; - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] IntStreamAutomaton::min(IntStream) -> OptionalInt - * Source: java/util/stream/IntStream.main.lsl:721 - */ - public OptionalInt min() { - OptionalInt result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (this.length == 0) { - result = OptionalInt.empty(); - } else { - int min = storage[0]; - int i = 0; - for (i = 1; i < this.length; i += 1) { - if (min > storage[i]) { - min = storage[i]; - } - } - ; - result = OptionalInt.of(min); - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] IntStreamAutomaton::max(IntStream) -> OptionalInt - * Source: java/util/stream/IntStream.main.lsl:753 - */ - public OptionalInt max() { - OptionalInt result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (this.length == 0) { - result = OptionalInt.empty(); - } else { - int max = storage[0]; - int i = 0; - for (i = 1; i < this.length; i += 1) { - if (max < storage[i]) { - max = storage[i]; - } - } - ; - result = OptionalInt.of(max); - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] IntStreamAutomaton::count(IntStream) -> long - * Source: java/util/stream/IntStream.main.lsl:785 - */ - public long count() { - long result = 0L; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - result = this.length; - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] IntStreamAutomaton::anyMatch(IntStream, IntPredicate) -> boolean - * Source: java/util/stream/IntStream.main.lsl:794 - */ - public boolean anyMatch(IntPredicate predicate) { - boolean result = false; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (predicate == null) { - throw new NullPointerException(); - } - result = false; - int i = 0; - while ((i < this.length) && !predicate.test(storage[i])) { - i += 1; - } - ; - if (i < this.length) { - result = true; - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] IntStreamAutomaton::allMatch(IntStream, IntPredicate) -> boolean - * Source: java/util/stream/IntStream.main.lsl:822 - */ - public boolean allMatch(IntPredicate predicate) { - boolean result = false; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (predicate == null) { - throw new NullPointerException(); - } - result = true; - if (this.length > 0) { - result = false; - int i = 0; - while ((i < this.length) && predicate.test(storage[i])) { - i += 1; - } - ; - if (i == this.length) { - result = true; - } - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] IntStreamAutomaton::noneMatch(IntStream, IntPredicate) -> boolean - * Source: java/util/stream/IntStream.main.lsl:848 - */ - public boolean noneMatch(IntPredicate predicate) { - boolean result = false; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (predicate == null) { - throw new NullPointerException(); - } - result = true; - if (this.length > 0) { - result = false; - int i = 0; - while ((i < this.length) && !predicate.test(storage[i])) { - i += 1; - } - ; - if (i == this.length) { - result = true; - } - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] IntStreamAutomaton::findFirst(IntStream) -> OptionalInt - * Source: java/util/stream/IntStream.main.lsl:874 - */ - public OptionalInt findFirst() { - OptionalInt result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - result = _findFirst(); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] IntStreamAutomaton::findAny(IntStream) -> OptionalInt - * Source: java/util/stream/IntStream.main.lsl:883 - */ - public OptionalInt findAny() { - OptionalInt result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - result = _findFirst(); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] IntStreamAutomaton::iterator(IntStream) -> PrimitiveIterator_OfInt - * Source: java/util/stream/IntStream.main.lsl:892 - */ - public PrimitiveIterator.OfInt iterator() { - PrimitiveIterator.OfInt result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - result = (stub.java.util.stream.IntStreamLSLIterator) ((Object) new IntStreamLSLIterator((Void) null, - /* state = */ IntStreamLSLIterator.__$lsl_States.Initialized, - /* parent = */ this, - /* cursor = */ 0 - )); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] IntStreamAutomaton::spliterator(IntStream) -> Spliterator_OfInt - * Source: java/util/stream/IntStream.main.lsl:906 - */ - public Spliterator.OfInt spliterator() { - Spliterator.OfInt result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - result = (Spliterators_IntArraySpliterator) ((Object) new generated.java.util.Spliterators_IntArraySpliterator((Void) null, - /* state = */ generated.java.util.Spliterators_IntArraySpliterator.__$lsl_States.Initialized, - /* array = */ this.storage, - /* index = */ 0, - /* fence = */ this.length, - /* characteristics = */ LibSLGlobals.SPLITERATOR_ORDERED | LibSLGlobals.SPLITERATOR_IMMUTABLE | LibSLGlobals.SPLITERATOR_SIZED | LibSLGlobals.SPLITERATOR_SUBSIZED - )); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] IntStreamAutomaton::isParallel(IntStream) -> boolean - * Source: java/util/stream/IntStream.main.lsl:922 - */ - public boolean isParallel() { - boolean result = false; - /* body */ { - result = this.isParallel; - } - return result; - } - - /** - * [FUNCTION] IntStreamAutomaton::sequential(IntStream) -> IntStream - * Source: java/util/stream/IntStream.main.lsl:928 - */ - public IntStream sequential() { - IntStream result = null; - /* body */ { - this.isParallel = false; - result = this; - } - return result; - } - - /** - * [FUNCTION] IntStreamAutomaton::parallel(IntStream) -> IntStream - * Source: java/util/stream/IntStream.main.lsl:935 - */ - public IntStream parallel() { - IntStream result = null; - /* body */ { - this.isParallel = true; - result = this; - } - return result; - } - - /** - * [FUNCTION] IntStreamAutomaton::unordered(IntStream) -> IntStream - * Source: java/util/stream/IntStream.main.lsl:942 - */ - public IntStream unordered() { - IntStream result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - result = (stub.java.util.stream.IntStreamLSL) ((Object) new IntStreamLSL((Void) null, - /* state = */ IntStreamLSL.__$lsl_States.Initialized, - /* storage = */ this.storage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] IntStreamAutomaton::onClose(IntStream, Runnable) -> IntStream - * Source: java/util/stream/IntStream.main.lsl:955 - */ - public IntStream onClose(Runnable closeHandler) { - IntStream result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - final int listLength = this.closeHandlers.size(); - this.closeHandlers.insert(listLength, closeHandler); - result = this; - } - return result; - } - - /** - * [FUNCTION] IntStreamAutomaton::close(IntStream) -> void - * Source: java/util/stream/IntStream.main.lsl:967 - */ - public void close() { - /* body */ { - final int listLength = this.closeHandlers.size(); - int i = 0; - for (i = 0; i < listLength; i += 1) { - final Runnable currentHandler = ((Runnable) this.closeHandlers.get(i)); - currentHandler.run(); - } - ; - this.closeHandlers = Engine.makeSymbolicList(); - this.linkedOrConsumed = true; - } - } - - /** - * [FUNCTION] IntStreamAutomaton::dropWhile(IntStream, IntPredicate) -> IntStream - * Source: java/util/stream/IntStream.main.lsl:991 - */ - public IntStream dropWhile(IntPredicate predicate) { - IntStream result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (predicate == null) { - throw new NullPointerException(); - } - if (this.length == 0) { - final int[] emptyStorage = new int[0]; - result = (stub.java.util.stream.IntStreamLSL) ((Object) new IntStreamLSL((Void) null, - /* state = */ IntStreamLSL.__$lsl_States.Initialized, - /* storage = */ emptyStorage, - /* length = */ 0, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } else { - Engine.assume(this.length > 0); - int dropLength = 0; - int i = 0; - while ((i < this.length) && predicate.test(storage[i])) { - dropLength += 1; - i += 1; - } - ; - if (dropLength == 0) { - result = (stub.java.util.stream.IntStreamLSL) ((Object) new IntStreamLSL((Void) null, - /* state = */ IntStreamLSL.__$lsl_States.Initialized, - /* storage = */ this.storage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } else { - final int newLength = this.length - dropLength; - final int[] newStorage = new int[newLength]; - int j = dropLength; - i = dropLength; - while (i < this.length) { - newStorage[j] = storage[i]; - j += 1; - i += 1; - } - ; - result = (stub.java.util.stream.IntStreamLSL) ((Object) new IntStreamLSL((Void) null, - /* state = */ IntStreamLSL.__$lsl_States.Initialized, - /* storage = */ newStorage, - /* length = */ newLength, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] IntStreamAutomaton::takeWhile(IntStream, IntPredicate) -> IntStream - * Source: java/util/stream/IntStream.main.lsl:1066 - */ - public IntStream takeWhile(IntPredicate predicate) { - IntStream result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (predicate == null) { - throw new NullPointerException(); - } - if (this.length == 0) { - final int[] emptyStorage = new int[0]; - result = (stub.java.util.stream.IntStreamLSL) ((Object) new IntStreamLSL((Void) null, - /* state = */ IntStreamLSL.__$lsl_States.Initialized, - /* storage = */ emptyStorage, - /* length = */ 0, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } else { - Engine.assume(this.length > 0); - int takeLength = 0; - int i = 0; - while ((i < this.length) && predicate.test(storage[i])) { - takeLength += 1; - i += 1; - } - ; - if (takeLength == this.length) { - result = (stub.java.util.stream.IntStreamLSL) ((Object) new IntStreamLSL((Void) null, - /* state = */ IntStreamLSL.__$lsl_States.Initialized, - /* storage = */ this.storage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } else { - final int newLength = takeLength; - final int[] newStorage = new int[newLength]; - int j = 0; - i = 0; - while (i < takeLength) { - newStorage[j] = storage[i]; - j += 1; - i += 1; - } - ; - result = (stub.java.util.stream.IntStreamLSL) ((Object) new IntStreamLSL((Void) null, - /* state = */ IntStreamLSL.__$lsl_States.Initialized, - /* storage = */ newStorage, - /* length = */ newLength, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] IntStreamAutomaton::asLongStream(IntStream) -> LongStream - * Source: java/util/stream/IntStream.main.lsl:1141 - */ - public LongStream asLongStream() { - LongStream result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (this.length == 0) { - final long[] emptyArray = {}; - result = (stub.java.util.stream.LongStreamLSL) ((Object) new LongStreamLSL((Void) null, - /* state = */ LongStreamLSL.__$lsl_States.Initialized, - /* storage = */ emptyArray, - /* length = */ 0, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } else { - Engine.assume(this.length > 0); - final long[] newStorage = new long[this.length]; - int i = 0; - for (i = 0; i < this.length; i += 1) { - newStorage[i] = ((long) storage[i]); - } - ; - result = (stub.java.util.stream.LongStreamLSL) ((Object) new LongStreamLSL((Void) null, - /* state = */ LongStreamLSL.__$lsl_States.Initialized, - /* storage = */ newStorage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] IntStreamAutomaton::asDoubleStream(IntStream) -> DoubleStream - * Source: java/util/stream/IntStream.main.lsl:1183 - */ - public DoubleStream asDoubleStream() { - DoubleStream result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (this.length == 0) { - final double[] emptyArray = {}; - result = (stub.java.util.stream.DoubleStreamLSL) ((Object) new DoubleStreamLSL((Void) null, - /* state = */ DoubleStreamLSL.__$lsl_States.Initialized, - /* storage = */ emptyArray, - /* length = */ 0, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } else { - Engine.assume(this.length > 0); - final double[] newStorage = new double[this.length]; - int i = 0; - for (i = 0; i < this.length; i += 1) { - newStorage[i] = ((double) storage[i]); - } - ; - result = (stub.java.util.stream.DoubleStreamLSL) ((Object) new DoubleStreamLSL((Void) null, - /* state = */ DoubleStreamLSL.__$lsl_States.Initialized, - /* storage = */ newStorage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] IntStreamAutomaton::sum(IntStream) -> int - * Source: java/util/stream/IntStream.main.lsl:1225 - */ - public int sum() { - int result = 0; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - result = _sum(); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] IntStreamAutomaton::average(IntStream) -> OptionalDouble - * Source: java/util/stream/IntStream.main.lsl:1235 - */ - public OptionalDouble average() { - OptionalDouble result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (this.length == 0) { - result = OptionalDouble.empty(); - } else { - double curSum = _sum(); - double divisionResult = curSum / this.length; - result = OptionalDouble.of(divisionResult); - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] IntStreamAutomaton::summaryStatistics(IntStream) -> IntSummaryStatistics - * Source: java/util/stream/IntStream.main.lsl:1254 - */ - public IntSummaryStatistics summaryStatistics() { - IntSummaryStatistics result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - result = new IntSummaryStatistics(); - int i = 0; - for (i = 0; i < this.length; i += 1) { - result.accept(storage[i]); - } - ; - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] IntStreamAutomaton::boxed(IntStream) -> Stream - * Source: java/util/stream/IntStream.main.lsl:1275 - */ - public Stream boxed() { - Stream result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - final Integer[] integerArray = new Integer[this.length]; - int i = 0; - for (i = 0; i < this.length; i += 1) { - integerArray[i] = storage[i]; - } - ; - result = (stub.java.util.stream.StreamLSL) ((Object) new StreamLSL((Void) null, - /* state = */ StreamLSL.__$lsl_States.Initialized, - /* storage = */ integerArray, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - this.linkedOrConsumed = true; - } - return result; - } - - public static final class __$lsl_States { - public static final byte Initialized = (byte) 0; - } - - @Approximate(IntStreamLSL.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/stream/IntStreamLSLIterator.java b/approximations/src/main/java/generated/java/util/stream/IntStreamLSLIterator.java deleted file mode 100644 index 7b2f7507..00000000 --- a/approximations/src/main/java/generated/java/util/stream/IntStreamLSLIterator.java +++ /dev/null @@ -1,169 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/stream/IntStream.lsl:35 -// - java/util/stream/IntStream.Iterator.lsl:18 -// -package generated.java.util.stream; - -import java.lang.Integer; -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.SuppressWarnings; -import java.lang.UnsupportedOperationException; -import java.lang.Void; -import java.util.NoSuchElementException; -import java.util.PrimitiveIterator; -import java.util.function.Consumer; -import java.util.function.IntConsumer; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; - -/** - * IntStreamIteratorAutomaton for IntStreamLSLIterator ~> java.util.stream.IntStreamLSLIterator - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(stub.java.util.stream.IntStreamLSLIterator.class) -public class IntStreamLSLIterator implements LibSLRuntime.Automaton, PrimitiveIterator.OfInt { - static { - Engine.assume(true); - } - - public IntStreamLSL parent; - - public int cursor; - - @LibSLRuntime.AutomatonConstructor - public IntStreamLSLIterator(Void __$lsl_token, final byte p0, final IntStreamLSL p1, - final int p2) { - this.parent = p1; - this.cursor = p2; - } - - @LibSLRuntime.AutomatonConstructor - public IntStreamLSLIterator(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Initialized, null, 0); - } - - /** - * [FUNCTION] IntStreamIteratorAutomaton::hasNext(IntStreamLSLIterator) -> boolean - * Source: java/util/stream/IntStream.Iterator.lsl:41 - */ - public boolean hasNext() { - boolean result = false; - /* body */ { - Engine.assume(this.parent != null); - result = this.cursor != ((IntStreamLSL) ((Object) this.parent)).length; - } - return result; - } - - /** - * [FUNCTION] IntStreamIteratorAutomaton::next(IntStreamLSLIterator) -> Integer - * Source: java/util/stream/IntStream.Iterator.lsl:50 - */ - public Integer next() { - Integer result = null; - /* body */ { - Engine.assume(this.parent != null); - final int[] parentStorage = ((IntStreamLSL) ((Object) this.parent)).storage; - final int i = this.cursor; - if (i >= ((IntStreamLSL) ((Object) this.parent)).length) { - throw new NoSuchElementException(); - } - this.cursor = i + 1; - result = parentStorage[i]; - } - return result; - } - - /** - * [FUNCTION] IntStreamIteratorAutomaton::nextInt(IntStreamLSLIterator) -> int - * Source: java/util/stream/IntStream.Iterator.lsl:66 - */ - public int nextInt() { - int result = 0; - /* body */ { - Engine.assume(this.parent != null); - final int[] parentStorage = ((IntStreamLSL) ((Object) this.parent)).storage; - final int i = this.cursor; - if (i >= ((IntStreamLSL) ((Object) this.parent)).length) { - throw new NoSuchElementException(); - } - this.cursor = i + 1; - result = parentStorage[i]; - } - return result; - } - - /** - * [FUNCTION] IntStreamIteratorAutomaton::remove(IntStreamLSLIterator) -> void - * Source: java/util/stream/IntStream.Iterator.lsl:82 - */ - public void remove() { - /* body */ { - throw new UnsupportedOperationException(); - } - } - - /** - * [FUNCTION] IntStreamIteratorAutomaton::forEachRemaining(IntStreamLSLIterator, Consumer) -> void - * Source: java/util/stream/IntStream.Iterator.lsl:88 - */ - public void forEachRemaining(Consumer userAction) { - /* body */ { - Engine.assume(this.parent != null); - if (userAction == null) { - throw new NullPointerException(); - } - int i = this.cursor; - final int size = ((IntStreamLSL) ((Object) this.parent)).length; - if (i != size) { - final int[] pStorage = ((IntStreamLSL) ((Object) this.parent)).storage; - while (i < size) { - final int item = pStorage[i]; - userAction.accept(item); - i += 1; - } - ; - this.cursor = i; - } - } - } - - /** - * [FUNCTION] IntStreamIteratorAutomaton::forEachRemaining(IntStreamLSLIterator, IntConsumer) -> void - * Source: java/util/stream/IntStream.Iterator.lsl:113 - */ - public void forEachRemaining(IntConsumer userAction) { - /* body */ { - Engine.assume(this.parent != null); - if (userAction == null) { - throw new NullPointerException(); - } - int i = this.cursor; - final int size = ((IntStreamLSL) ((Object) this.parent)).length; - if (i != size) { - final int[] pStorage = ((IntStreamLSL) ((Object) this.parent)).storage; - while (i < size) { - final int item = pStorage[i]; - userAction.accept(item); - i += 1; - } - ; - this.cursor = i; - } - } - } - - public static final class __$lsl_States { - public static final byte Initialized = (byte) 0; - } - - @Approximate(IntStreamLSLIterator.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/stream/LongStreamImpl.java b/approximations/src/main/java/generated/java/util/stream/LongStreamImpl.java new file mode 100644 index 00000000..b7ba0843 --- /dev/null +++ b/approximations/src/main/java/generated/java/util/stream/LongStreamImpl.java @@ -0,0 +1,646 @@ +package generated.java.util.stream; + +import generated.java.util.array.LongArrayIteratorImpl; +import generated.java.util.array.LongArraySpliteratorImpl; +import generated.runtime.LibSLGlobals; +import java.lang.IllegalArgumentException; +import java.lang.Long; +import java.lang.NullPointerException; +import java.lang.Object; +import java.lang.Runnable; +import java.util.*; +import java.util.function.BiConsumer; +import java.util.function.LongBinaryOperator; +import java.util.function.LongConsumer; +import java.util.function.LongFunction; +import java.util.function.LongPredicate; +import java.util.function.LongToDoubleFunction; +import java.util.function.LongToIntFunction; +import java.util.function.LongUnaryOperator; +import java.util.function.ObjLongConsumer; +import java.util.function.Supplier; +import java.util.stream.LongStream; +import java.util.stream.Stream; +import org.jacodb.approximation.annotation.Approximate; +import org.jetbrains.annotations.NotNull; +import org.usvm.api.Engine; +import org.usvm.api.SymbolicList; +import runtime.LibSLRuntime; +import stub.java.util.stream.*; + +@Approximate(LongStreamStub.class) +public class LongStreamImpl extends BaseStreamImpl implements LongStream { + + public long[] storage; + + public LongStreamImpl( + long[] storage, + SymbolicList closeHandlers, + boolean isParallel, + boolean linkedOrConsumed + ) { + super(closeHandlers, isParallel, linkedOrConsumed); + this.storage = storage; + } + + public LongStreamImpl(long[] storage, SymbolicList closeHandlers, boolean isParallel) { + this(storage, closeHandlers, isParallel, false); + } + + public LongStreamImpl(long[] storage, SymbolicList closeHandlers) { + this(storage, closeHandlers, false); + } + + public LongStreamImpl(long[] storage) { + this(storage, Engine.makeSymbolicList()); + } + + private long[] _getStorage() { + long[] storage = this.storage; + Engine.assume(storage != null); + return storage; + } + + protected int _getLength() { + return _getStorage().length; + } + + private LongStreamImpl _copy(long[] storage) { + return new LongStreamImpl(storage, _getCloseHandlers(), isParallel, linkedOrConsumed); + } + + private LongStreamImpl _copy() { + return _copy(_getStorage()); + } + + private void _actionApply(LongConsumer _action) { + if (_action == null) + throw new NullPointerException(); + + long[] storage = _getStorage(); + for (long j : storage) { + _action.accept(j); + } + } + + private OptionalLong _findFirst() { + long[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return OptionalLong.empty(); + + long first = storage[0]; + return OptionalLong.of(first); + } + + private long _sum() { + long[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return 0; + + long result = 0; + for (long l : storage) { + result += l; + } + + return result; + } + + @NotNull + @SuppressWarnings("ConstantValue") + public LongStreamImpl filter(@NotNull LongPredicate predicate) { + super.evaluate(); + + if (predicate == null) + throw new NullPointerException(); + + long[] storage = _getStorage(); + int length = storage.length; + long[] filteredStorage = Arrays.copyOf(storage, length); + int filteredLength = 0; + for (long e : storage) { + if (predicate.test(e)) { + filteredStorage[filteredLength] = e; + filteredLength++; + } + } + + Engine.assume(filteredLength <= length); + long[] resultStorage = Arrays.copyOf(filteredStorage, filteredLength); + return _copy(resultStorage); + } + + @NotNull + @SuppressWarnings("ConstantValue") + public LongStreamImpl map(@NotNull LongUnaryOperator mapper) { + super.evaluate(); + + if (mapper == null) + throw new NullPointerException(); + + long[] storage = _getStorage(); + int length = storage.length; + long[] mappedStorage = new long[length]; + for (int i = 0; i < length; i++) { + mappedStorage[i] = mapper.applyAsLong(storage[i]); + } + + return _copy(mappedStorage); + } + + @NotNull + @SuppressWarnings({"unchecked", "ConstantValue"}) + public StreamStubImpl mapToObj(@NotNull LongFunction mapper) { + super.evaluate(); + + if (mapper == null) + throw new NullPointerException(); + + long[] storage = _getStorage(); + int length = storage.length; + T[] objStorage = (T[]) new Object[length]; + for (int i = 0; i < length; i++) { + objStorage[i] = mapper.apply(storage[i]); + } + + return _copyToObjStream(objStorage); + } + + @NotNull + @SuppressWarnings("ConstantValue") + public IntStreamImpl mapToInt(@NotNull LongToIntFunction mapper) { + super.evaluate(); + + if (mapper == null) + throw new NullPointerException(); + + long[] storage = _getStorage(); + int length = storage.length; + int[] mappedStorage = new int[length]; + for (int i = 0; i < length; i++) { + mappedStorage[i] = mapper.applyAsInt(storage[i]); + } + + return _copyToIntStream(mappedStorage); + } + + @NotNull + @SuppressWarnings("ConstantValue") + public DoubleStreamImpl mapToDouble(@NotNull LongToDoubleFunction mapper) { + super.evaluate(); + + if (mapper == null) + throw new NullPointerException(); + + long[] storage = _getStorage(); + int length = storage.length; + double[] mappedStorage = new double[length]; + for (int i = 0; i < length; i++) { + mappedStorage[i] = mapper.applyAsDouble(storage[i]); + } + + return _copyToDoubleStream(mappedStorage); + } + + @NotNull + @SuppressWarnings({"ConstantValue", "DataFlowIssue"}) + public LongStream flatMap(@NotNull LongFunction mapper) { + // TODO: approximate + super.evaluate(); + + if (mapper == null) + throw new NullPointerException(); + + LongStream result = Engine.makeSymbolic(LongStream.class); + Engine.assume(result != null); + return result; + } + + @NotNull + public LongStreamImpl sorted() { + super.evaluate(); + + long[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return _copy(); + + int outerLimit = length - 1; + for (int i = 0; i < outerLimit; i++) { + int innerLimit = length - i - 1; + for (int j = 0; j < innerLimit; j++) { + int idxB = j + 1; + long a = storage[j]; + long b = storage[idxB]; + if (a > b) { + storage[j] = b; + storage[idxB] = a; + } + } + } + + return _copy(); + } + + @NotNull + public LongStreamImpl distinct() { + super.evaluate(); + + long[] storage = _getStorage(); + long[] distinctStorage; + int length = storage.length; + if (length == 0) { + distinctStorage = Arrays.copyOf(storage, 0); + return _copy(distinctStorage); + } + + int distinctLength = 0; + distinctStorage = Arrays.copyOf(storage, length); + LibSLRuntime.Map visited = new LibSLRuntime.Map<>(new LibSLRuntime.HashMapContainer<>()); + for (long item : storage) { + if (!visited.hasKey(item)) { + visited.set(item, LibSLGlobals.SOMETHING); + distinctStorage[distinctLength] = item; + distinctLength++; + } + } + + Engine.assume(distinctLength <= length); + long[] resultStorage = Arrays.copyOf(distinctStorage, distinctLength); + return _copy(resultStorage); + } + + @NotNull + public LongStreamImpl peek(@NotNull LongConsumer _action) { + super.evaluate(); + _actionApply(_action); + return _copy(); + } + + @NotNull + public LongStreamImpl limit(long maxSize) { + super.evaluate(); + + int maxSizeInt = (int) maxSize; + + if (maxSizeInt < 0) + throw new IllegalArgumentException(); + + if (maxSizeInt == 0) + return _copy(Arrays.copyOf(_getStorage(), 0)); + + long[] storage = _getStorage(); + int length = storage.length; + if (maxSizeInt > length) + return _copy(); + + long[] limitStorage = Arrays.copyOf(storage, maxSizeInt); + return _copy(limitStorage); + } + + @NotNull + public LongStreamImpl skip(long n) { + super.evaluate(); + + int offset = (int) n; + + if (offset < 0) + throw new IllegalArgumentException(); + + if (offset == 0) + return _copy(); + + long[] storage = _getStorage(); + int length = storage.length; + if (offset >= length) + return _copy(Arrays.copyOf(_getStorage(), 0)); + + long[] skipStorage = Arrays.copyOfRange(storage, offset, length); + return _copy(skipStorage); + } + + public void forEach(LongConsumer _action) { + super.evaluate(); + _actionApply(_action); + } + + public void forEachOrdered(LongConsumer _action) { + forEach(_action); + } + + public long[] toArray() { + super.evaluate(); + return _getStorage(); + } + + public long reduce(long identity, LongBinaryOperator accumulator) { + super.evaluate(); + + if (accumulator == null) + throw new NullPointerException(); + + long result = identity; + long[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return result; + + for (long item : storage) { + result = accumulator.applyAsLong(result, item); + } + + return result; + } + + public OptionalLong reduce(LongBinaryOperator accumulator) { + super.evaluate(); + + if (accumulator == null) + throw new NullPointerException(); + + long[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return OptionalLong.empty(); + + long value = storage[0]; + for (int i = 1; i < length; i++) { + value = accumulator.applyAsLong(value, storage[i]); + } + + return OptionalLong.of(value); + } + + public R collect(Supplier supplier, ObjLongConsumer accumulator, BiConsumer combiner) { + super.evaluate(); + + if (supplier == null) + throw new NullPointerException(); + + if (accumulator == null) + throw new NullPointerException(); + + if (combiner == null) + throw new NullPointerException(); + + R result = supplier.get(); + long[] storage = _getStorage(); + for (long item : storage) { + accumulator.accept(result, item); + } + + return result; + } + + public OptionalLong min() { + super.evaluate(); + + long[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return OptionalLong.empty(); + + long min = storage[0]; + for (int i = 1; i < length; i++) { + long item = storage[i]; + if (min > item) + min = item; + } + + return OptionalLong.of(min); + } + + public OptionalLong max() { + super.evaluate(); + + long[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return OptionalLong.empty(); + + long max = storage[0]; + for (int i = 1; i < length; i++) { + long item = storage[i]; + if (max < item) + max = item; + } + + return OptionalLong.of(max); + } + + public long count() { + return super.count(); + } + + public boolean anyMatch(LongPredicate predicate) { + super.evaluate(); + + if (predicate == null) + throw new NullPointerException(); + + long[] storage = _getStorage(); + for (long item : storage) { + if (predicate.test(item)) + return true; + } + + return false; + } + + public boolean allMatch(LongPredicate predicate) { + super.evaluate(); + + if (predicate == null) + throw new NullPointerException(); + + long[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return true; + + for (long item : storage) { + if (!predicate.test(item)) + return false; + } + + return true; + } + + public boolean noneMatch(LongPredicate predicate) { + super.evaluate(); + + if (predicate == null) + throw new NullPointerException(); + + long[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return true; + + for (long item : storage) { + if (predicate.test(item)) + return false; + } + + return true; + } + + public OptionalLong findFirst() { + super.evaluate(); + return _findFirst(); + } + + public OptionalLong findAny() { + return findFirst(); + } + + @NotNull + public PrimitiveIterator.OfLong iterator() { + super.evaluate(); + return new LongArrayIteratorImpl(_getStorage()); + } + + @NotNull + public Spliterator.OfLong spliterator() { + super.evaluate(); + long[] storage = _getStorage(); + return new LongArraySpliteratorImpl(storage, spliteratorCharacteristics); + } + + public boolean isParallel() { + return super.isParallel(); + } + + @NotNull + public LongStreamImpl sequential() { + return (LongStreamImpl) super.sequential(); + } + + @NotNull + public LongStreamImpl parallel() { + return (LongStreamImpl) super.parallel(); + } + + @NotNull + public LongStreamImpl unordered() { + super.evaluate(); + return _copy(); + } + + @NotNull + public LongStreamImpl onClose(@NotNull Runnable closeHandler) { + return (LongStreamImpl) super.onClose(closeHandler); + } + + public void close() { + super.close(); + } + + @NotNull + @SuppressWarnings("ConstantValue") + public LongStreamImpl dropWhile(@NotNull LongPredicate predicate) { + super.evaluate(); + + if (predicate == null) + throw new NullPointerException(); + + long[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return _copy(Arrays.copyOf(storage, 0)); + + int dropLength = 0; + while (dropLength < length && predicate.test(storage[dropLength])) { + dropLength++; + } + + if (dropLength == 0) + return _copy(); + + int newLength = length - dropLength; + long[] newStorage = Arrays.copyOf(storage, newLength); + return _copy(newStorage); + } + + @NotNull + @SuppressWarnings("ConstantValue") + public LongStreamImpl takeWhile(@NotNull LongPredicate predicate) { + super.evaluate(); + + if (predicate == null) + throw new NullPointerException(); + + long[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return _copy(Arrays.copyOf(storage, 0)); + + int takeLength = 0; + while (takeLength < length && predicate.test(storage[takeLength])) { + takeLength++; + } + + if (takeLength == length) + return _copy(); + + long[] newStorage = Arrays.copyOf(storage, takeLength); + return _copy(newStorage); + } + + public DoubleStreamImpl asDoubleStream() { + super.evaluate(); + + long[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return _copyToDoubleStream(new double[0]); + + double[] newStorage = new double[length]; + LibSLRuntime.ArrayActions.copy(storage, 0, newStorage, 0, length); + return _copyToDoubleStream(newStorage); + } + + public long sum() { + super.evaluate(); + return _sum(); + } + + public OptionalDouble average() { + super.evaluate(); + + long[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return OptionalDouble.empty(); + + double curSum = _sum(); + double divisionResult = curSum / length; + return OptionalDouble.of(divisionResult); + } + + public LongSummaryStatistics summaryStatistics() { + super.evaluate(); + + long[] storage = _getStorage(); + LongSummaryStatistics result = new LongSummaryStatistics(); + for (long j : storage) { + result.accept(j); + } + + return result; + } + + public Stream boxed() { + super.evaluate(); + + long[] storage = _getStorage(); + int length = storage.length; + Long[] integerArray = new Long[length]; + for (int i = 0; i < length; i++) { + integerArray[i] = storage[i]; + } + + return _copyToObjStream(integerArray); + } +} diff --git a/approximations/src/main/java/generated/java/util/stream/LongStreamLSL.java b/approximations/src/main/java/generated/java/util/stream/LongStreamLSL.java deleted file mode 100644 index 10493de8..00000000 --- a/approximations/src/main/java/generated/java/util/stream/LongStreamLSL.java +++ /dev/null @@ -1,1295 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/stream/LongStream.lsl:26 -// - java/util/stream/LongStream.main.lsl:28 -// -package generated.java.util.stream; - -import generated.runtime.LibSLGlobals; -import java.lang.IllegalArgumentException; -import java.lang.IllegalStateException; -import java.lang.Long; -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.Runnable; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.LongSummaryStatistics; -import java.util.OptionalDouble; -import java.util.OptionalLong; -import java.util.PrimitiveIterator; -import java.util.Spliterator; -import java.util.function.BiConsumer; -import java.util.function.LongBinaryOperator; -import java.util.function.LongConsumer; -import java.util.function.LongFunction; -import java.util.function.LongPredicate; -import java.util.function.LongToDoubleFunction; -import java.util.function.LongToIntFunction; -import java.util.function.LongUnaryOperator; -import java.util.function.ObjLongConsumer; -import java.util.function.Supplier; -import java.util.stream.DoubleStream; -import java.util.stream.IntStream; -import java.util.stream.LongStream; -import java.util.stream.Stream; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import org.usvm.api.SymbolicList; -import runtime.LibSLRuntime; -import stub.java.util.Spliterators_LongArraySpliterator; - -/** - * LongStreamAutomaton for LongStreamLSL ~> java.util.stream.LongStreamLSL - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(stub.java.util.stream.LongStreamLSL.class) -public class LongStreamLSL implements LibSLRuntime.Automaton, LongStream { - static { - Engine.assume(true); - } - - public long[] storage; - - public transient int length; - - public SymbolicList closeHandlers; - - public boolean isParallel; - - public boolean linkedOrConsumed; - - @LibSLRuntime.AutomatonConstructor - public LongStreamLSL(Void __$lsl_token, final byte p0, final long[] p1, final int p2, - final SymbolicList p3, final boolean p4, final boolean p5) { - this.storage = p1; - this.length = p2; - this.closeHandlers = p3; - this.isParallel = p4; - this.linkedOrConsumed = p5; - } - - @LibSLRuntime.AutomatonConstructor - public LongStreamLSL(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Initialized, null, 0, null, false, false); - } - - /** - * [SUBROUTINE] LongStreamAutomaton::_actionApply(LongConsumer) -> void - * Source: java/util/stream/LongStream.main.lsl:117 - */ - private void _actionApply(LongConsumer _action) { - /* body */ { - if (_action == null) { - throw new NullPointerException(); - } - int i = 0; - for (i = 0; i < this.length; i += 1) { - _action.accept(storage[i]); - } - ; - } - } - - /** - * [SUBROUTINE] LongStreamAutomaton::_findFirst() -> OptionalLong - * Source: java/util/stream/LongStream.main.lsl:136 - */ - private OptionalLong _findFirst() { - OptionalLong result = null; - /* body */ { - if (this.length == 0) { - result = OptionalLong.empty(); - } else { - final long first = storage[0]; - result = OptionalLong.of(first); - } - } - return result; - } - - /** - * [SUBROUTINE] LongStreamAutomaton::_sum() -> long - * Source: java/util/stream/LongStream.main.lsl:150 - */ - private long _sum() { - long result = 0L; - /* body */ { - result = 0; - if (this.length != 0) { - int i = 0; - for (i = 0; i < this.length; i += 1) { - result += storage[i]; - } - ; - } - } - return result; - } - - /** - * [FUNCTION] LongStreamAutomaton::filter(LongStream, LongPredicate) -> LongStream - * Source: java/util/stream/LongStream.main.lsl:172 - */ - public LongStream filter(LongPredicate predicate) { - LongStream result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (predicate == null) { - throw new NullPointerException(); - } - long[] filteredStorage = new long[this.length]; - int filteredLength = 0; - int i = 0; - for (i = 0; i < this.length; i += 1) { - if (predicate.test(storage[i])) { - filteredStorage[filteredLength] = storage[i]; - filteredLength += 1; - } - } - ; - Engine.assume(filteredLength <= this.length); - long[] resultStorage = new long[filteredLength]; - LibSLRuntime.ArrayActions.copy(filteredStorage, 0, resultStorage, 0, filteredLength); - result = (stub.java.util.stream.LongStreamLSL) ((Object) new LongStreamLSL((Void) null, - /* state = */ LongStreamLSL.__$lsl_States.Initialized, - /* storage = */ resultStorage, - /* length = */ filteredLength, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] LongStreamAutomaton::map(LongStream, LongUnaryOperator) -> LongStream - * Source: java/util/stream/LongStream.main.lsl:213 - */ - public LongStream map(LongUnaryOperator mapper) { - LongStream result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (mapper == null) { - throw new NullPointerException(); - } - long[] mappedStorage = new long[this.length]; - int i = 0; - for (i = 0; i < this.length; i += 1) { - mappedStorage[i] = mapper.applyAsLong(storage[i]); - } - ; - result = (stub.java.util.stream.LongStreamLSL) ((Object) new LongStreamLSL((Void) null, - /* state = */ LongStreamLSL.__$lsl_States.Initialized, - /* storage = */ mappedStorage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] LongStreamAutomaton::mapToObj(LongStream, LongFunction) -> Stream - * Source: java/util/stream/LongStream.main.lsl:244 - */ - public Stream mapToObj(LongFunction mapper) { - Stream result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - final Object[] objStorage = new Object[this.length]; - int i = 0; - for (i = 0; i < this.length; i += 1) { - objStorage[i] = mapper.apply(storage[i]); - } - ; - result = (stub.java.util.stream.StreamLSL) ((Object) new StreamLSL((Void) null, - /* state = */ StreamLSL.__$lsl_States.Initialized, - /* storage = */ objStorage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] LongStreamAutomaton::mapToInt(LongStream, LongToIntFunction) -> IntStream - * Source: java/util/stream/LongStream.main.lsl:273 - */ - public IntStream mapToInt(LongToIntFunction mapper) { - IntStream result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (mapper == null) { - throw new NullPointerException(); - } - int[] mappedStorage = new int[this.length]; - int i = 0; - for (i = 0; i < this.length; i += 1) { - mappedStorage[i] = mapper.applyAsInt(storage[i]); - } - ; - result = (stub.java.util.stream.IntStreamLSL) ((Object) new IntStreamLSL((Void) null, - /* state = */ IntStreamLSL.__$lsl_States.Initialized, - /* storage = */ mappedStorage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] LongStreamAutomaton::mapToDouble(LongStream, LongToDoubleFunction) -> DoubleStream - * Source: java/util/stream/LongStream.main.lsl:304 - */ - public DoubleStream mapToDouble(LongToDoubleFunction mapper) { - DoubleStream result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (mapper == null) { - throw new NullPointerException(); - } - double[] mappedStorage = new double[this.length]; - int i = 0; - for (i = 0; i < this.length; i += 1) { - mappedStorage[i] = mapper.applyAsDouble(storage[i]); - } - ; - result = (stub.java.util.stream.DoubleStreamLSL) ((Object) new DoubleStreamLSL((Void) null, - /* state = */ DoubleStreamLSL.__$lsl_States.Initialized, - /* storage = */ mappedStorage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] LongStreamAutomaton::flatMap(LongStream, LongFunction) -> LongStream - * Source: java/util/stream/LongStream.main.lsl:335 - */ - public LongStream flatMap(LongFunction mapper) { - LongStream result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (mapper == null) { - throw new NullPointerException(); - } - result = Engine.makeSymbolic(LongStream.class); - Engine.assume(result != null); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] LongStreamAutomaton::sorted(LongStream) -> LongStream - * Source: java/util/stream/LongStream.main.lsl:351 - */ - public LongStream sorted() { - LongStream result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (this.length == 0) { - result = (stub.java.util.stream.LongStreamLSL) ((Object) new LongStreamLSL((Void) null, - /* state = */ LongStreamLSL.__$lsl_States.Initialized, - /* storage = */ this.storage, - /* length = */ 0, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } else { - Engine.assume(this.length > 0); - final int outerLimit = this.length - 1; - int innerLimit = 0; - int i = 0; - int j = 0; - for (i = 0; i < outerLimit; i += 1) { - innerLimit = (this.length - i) - 1; - for (j = 0; j < innerLimit; j += 1) { - final int idxA = j; - final int idxB = j + 1; - final long a = storage[idxA]; - final long b = storage[idxB]; - if (a > b) { - storage[idxA] = b; - storage[idxB] = a; - } - } - ; - } - ; - result = (stub.java.util.stream.LongStreamLSL) ((Object) new LongStreamLSL((Void) null, - /* state = */ LongStreamLSL.__$lsl_States.Initialized, - /* storage = */ this.storage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] LongStreamAutomaton::distinct(LongStream) -> LongStream - * Source: java/util/stream/LongStream.main.lsl:414 - */ - public LongStream distinct() { - LongStream result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - long[] distinctStorage = null; - int distinctLength = 0; - final int size = this.length; - if (size == 0) { - distinctStorage = new long[0]; - distinctLength = 0; - } else { - final long[] items = this.storage; - Engine.assume(items != null); - Engine.assume(items.length != 0); - Engine.assume(size == items.length); - int i = 0; - int j = 0; - final SymbolicList uniqueItems = Engine.makeSymbolicList(); - final LibSLRuntime.Map visited = new LibSLRuntime.Map<>(new LibSLRuntime.HashMapContainer<>()); - for (i = 0; i < size; i += 1) { - final long item = items[i]; - if (!visited.hasKey(item)) { - visited.set(item, LibSLGlobals.SOMETHING); - uniqueItems.insert(j, item); - j += 1; - } - } - ; - distinctLength = j; - Engine.assume(distinctLength > 0); - Engine.assume(distinctLength <= size); - distinctStorage = new long[distinctLength]; - for (i = 0; i < distinctLength; i += 1) { - final Long item = uniqueItems.get(i); - Engine.assume(item != null); - distinctStorage[i] = ((long) item); - } - ; - } - result = (stub.java.util.stream.LongStreamLSL) ((Object) new LongStreamLSL((Void) null, - /* state = */ LongStreamLSL.__$lsl_States.Initialized, - /* storage = */ distinctStorage, - /* length = */ distinctLength, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] LongStreamAutomaton::peek(Stream, LongConsumer) -> LongStream - * Source: java/util/stream/LongStream.main.lsl:486 - */ - public LongStream peek(LongConsumer _action) { - LongStream result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - _actionApply(_action); - result = (stub.java.util.stream.LongStreamLSL) ((Object) new LongStreamLSL((Void) null, - /* state = */ LongStreamLSL.__$lsl_States.Initialized, - /* storage = */ this.storage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] LongStreamAutomaton::limit(LongStream, long) -> LongStream - * Source: java/util/stream/LongStream.main.lsl:502 - */ - public LongStream limit(long maxSize) { - LongStream result = null; - /* body */ { - final int maxSizeInt = ((int) maxSize); - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (maxSizeInt < 0) { - throw new IllegalArgumentException(); - } - if (maxSizeInt == 0) { - result = (stub.java.util.stream.LongStreamLSL) ((Object) new LongStreamLSL((Void) null, - /* state = */ LongStreamLSL.__$lsl_States.Initialized, - /* storage = */ this.storage, - /* length = */ 0, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } else { - if (maxSizeInt > this.length) { - result = (stub.java.util.stream.LongStreamLSL) ((Object) new LongStreamLSL((Void) null, - /* state = */ LongStreamLSL.__$lsl_States.Initialized, - /* storage = */ this.storage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } else { - final long[] limitStorage = new long[maxSizeInt]; - LibSLRuntime.ArrayActions.copy(this.storage, 0, limitStorage, 0, maxSizeInt); - result = (stub.java.util.stream.LongStreamLSL) ((Object) new LongStreamLSL((Void) null, - /* state = */ LongStreamLSL.__$lsl_States.Initialized, - /* storage = */ limitStorage, - /* length = */ maxSizeInt, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] LongStreamAutomaton::skip(LongStream, long) -> LongStream - * Source: java/util/stream/LongStream.main.lsl:544 - */ - public LongStream skip(long n) { - LongStream result = null; - /* body */ { - final int offset = ((int) n); - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (offset < 0) { - throw new IllegalArgumentException(); - } - if (offset == 0) { - result = (stub.java.util.stream.LongStreamLSL) ((Object) new LongStreamLSL((Void) null, - /* state = */ LongStreamLSL.__$lsl_States.Initialized, - /* storage = */ this.storage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } else { - if (offset >= this.length) { - long[] newArray = {}; - result = (stub.java.util.stream.LongStreamLSL) ((Object) new LongStreamLSL((Void) null, - /* state = */ LongStreamLSL.__$lsl_States.Initialized, - /* storage = */ newArray, - /* length = */ 0, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } else { - final int newLength = this.length - offset; - final long[] skipStorage = new long[newLength]; - int i = 0; - int skipIndex = 0; - for (i = offset; i < this.length; i += 1) { - skipStorage[skipIndex] = storage[i]; - skipIndex += 1; - } - ; - result = (stub.java.util.stream.LongStreamLSL) ((Object) new LongStreamLSL((Void) null, - /* state = */ LongStreamLSL.__$lsl_States.Initialized, - /* storage = */ skipStorage, - /* length = */ newLength, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] LongStreamAutomaton::forEach(LongStream, LongConsumer) -> void - * Source: java/util/stream/LongStream.main.lsl:600 - */ - public void forEach(LongConsumer _action) { - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - _actionApply(_action); - this.linkedOrConsumed = true; - } - } - - /** - * [FUNCTION] LongStreamAutomaton::forEachOrdered(LongStream, LongConsumer) -> void - * Source: java/util/stream/LongStream.main.lsl:609 - */ - public void forEachOrdered(LongConsumer _action) { - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - _actionApply(_action); - this.linkedOrConsumed = true; - } - } - - /** - * [FUNCTION] LongStreamAutomaton::toArray(LongStream) -> array - * Source: java/util/stream/LongStream.main.lsl:618 - */ - public long[] toArray() { - long[] result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - result = this.storage; - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] LongStreamAutomaton::reduce(LongStream, long, LongBinaryOperator) -> long - * Source: java/util/stream/LongStream.main.lsl:627 - */ - public long reduce(long identity, LongBinaryOperator accumulator) { - long result = 0L; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (accumulator == null) { - throw new NullPointerException(); - } - result = identity; - if (this.length != 0) { - Engine.assume(this.length > 0); - int i = 0; - for (i = 0; i < this.length; i += 1) { - result = accumulator.applyAsLong(result, storage[i]); - } - ; - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] LongStreamAutomaton::reduce(LongStream, LongBinaryOperator) -> OptionalLong - * Source: java/util/stream/LongStream.main.lsl:656 - */ - public OptionalLong reduce(LongBinaryOperator accumulator) { - OptionalLong result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (accumulator == null) { - throw new NullPointerException(); - } - if (this.length == 0) { - result = OptionalLong.empty(); - } else { - if (this.length > 0) { - long value = storage[0]; - int i = 0; - for (i = 1; i < this.length; i += 1) { - value = accumulator.applyAsLong(value, storage[i]); - } - ; - result = OptionalLong.of(value); - } - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] LongStreamAutomaton::collect(LongStream, Supplier, ObjLongConsumer, BiConsumer) -> Object - * Source: java/util/stream/LongStream.main.lsl:690 - */ - public Object collect(Supplier supplier, ObjLongConsumer accumulator, BiConsumer combiner) { - Object result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (supplier == null) { - throw new NullPointerException(); - } - if (accumulator == null) { - throw new NullPointerException(); - } - if (combiner == null) { - throw new NullPointerException(); - } - result = supplier.get(); - int i = 0; - for (i = 0; i < this.length; i += 1) { - accumulator.accept(result, storage[i]); - } - ; - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] LongStreamAutomaton::min(LongStream) -> OptionalLong - * Source: java/util/stream/LongStream.main.lsl:722 - */ - public OptionalLong min() { - OptionalLong result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (this.length == 0) { - result = OptionalLong.empty(); - } else { - long min = storage[0]; - int i = 0; - for (i = 1; i < this.length; i += 1) { - if (min > storage[i]) { - min = storage[i]; - } - } - ; - result = OptionalLong.of(min); - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] LongStreamAutomaton::max(IntStream) -> OptionalLong - * Source: java/util/stream/LongStream.main.lsl:754 - */ - public OptionalLong max() { - OptionalLong result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (this.length == 0) { - result = OptionalLong.empty(); - } else { - long max = storage[0]; - int i = 0; - for (i = 1; i < this.length; i += 1) { - if (max < storage[i]) { - max = storage[i]; - } - } - ; - result = OptionalLong.of(max); - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] LongStreamAutomaton::count(LongStream) -> long - * Source: java/util/stream/LongStream.main.lsl:786 - */ - public long count() { - long result = 0L; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - result = this.length; - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] LongStreamAutomaton::anyMatch(LongStream, LongPredicate) -> boolean - * Source: java/util/stream/LongStream.main.lsl:795 - */ - public boolean anyMatch(LongPredicate predicate) { - boolean result = false; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (predicate == null) { - throw new NullPointerException(); - } - result = false; - int i = 0; - while ((i < this.length) && !predicate.test(storage[i])) { - i += 1; - } - ; - if (i < this.length) { - result = true; - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] LongStreamAutomaton::allMatch(LongStream, LongPredicate) -> boolean - * Source: java/util/stream/LongStream.main.lsl:823 - */ - public boolean allMatch(LongPredicate predicate) { - boolean result = false; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (predicate == null) { - throw new NullPointerException(); - } - result = true; - if (this.length > 0) { - result = false; - int i = 0; - while ((i < this.length) && predicate.test(storage[i])) { - i += 1; - } - ; - if (i == this.length) { - result = true; - } - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] LongStreamAutomaton::noneMatch(LongStream, LongPredicate) -> boolean - * Source: java/util/stream/LongStream.main.lsl:849 - */ - public boolean noneMatch(LongPredicate predicate) { - boolean result = false; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (predicate == null) { - throw new NullPointerException(); - } - result = true; - if (this.length > 0) { - result = false; - int i = 0; - while ((i < this.length) && !predicate.test(storage[i])) { - i += 1; - } - ; - if (i == this.length) { - result = true; - } - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] LongStreamAutomaton::findFirst(LongStream) -> OptionalLong - * Source: java/util/stream/LongStream.main.lsl:875 - */ - public OptionalLong findFirst() { - OptionalLong result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - result = _findFirst(); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] LongStreamAutomaton::findAny(LongStream) -> OptionalLong - * Source: java/util/stream/LongStream.main.lsl:884 - */ - public OptionalLong findAny() { - OptionalLong result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - result = _findFirst(); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] LongStreamAutomaton::iterator(LongStream) -> PrimitiveIterator_OfLong - * Source: java/util/stream/LongStream.main.lsl:893 - */ - public PrimitiveIterator.OfLong iterator() { - PrimitiveIterator.OfLong result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - result = (stub.java.util.stream.LongStreamLSLIterator) ((Object) new LongStreamLSLIterator((Void) null, - /* state = */ LongStreamLSLIterator.__$lsl_States.Initialized, - /* parent = */ this, - /* cursor = */ 0 - )); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] LongStreamAutomaton::spliterator(LongStream) -> Spliterator_OfLong - * Source: java/util/stream/LongStream.main.lsl:907 - */ - public Spliterator.OfLong spliterator() { - Spliterator.OfLong result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - result = (Spliterators_LongArraySpliterator) ((Object) new generated.java.util.Spliterators_LongArraySpliterator((Void) null, - /* state = */ generated.java.util.Spliterators_LongArraySpliterator.__$lsl_States.Initialized, - /* array = */ this.storage, - /* index = */ 0, - /* fence = */ this.length, - /* characteristics = */ LibSLGlobals.SPLITERATOR_ORDERED | LibSLGlobals.SPLITERATOR_IMMUTABLE | LibSLGlobals.SPLITERATOR_SIZED | LibSLGlobals.SPLITERATOR_SUBSIZED - )); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] LongStreamAutomaton::isParallel(LongStream) -> boolean - * Source: java/util/stream/LongStream.main.lsl:923 - */ - public boolean isParallel() { - boolean result = false; - /* body */ { - result = this.isParallel; - } - return result; - } - - /** - * [FUNCTION] LongStreamAutomaton::sequential(LongStream) -> LongStream - * Source: java/util/stream/LongStream.main.lsl:929 - */ - public LongStream sequential() { - LongStream result = null; - /* body */ { - this.isParallel = false; - result = this; - } - return result; - } - - /** - * [FUNCTION] LongStreamAutomaton::parallel(LongStream) -> LongStream - * Source: java/util/stream/LongStream.main.lsl:936 - */ - public LongStream parallel() { - LongStream result = null; - /* body */ { - this.isParallel = true; - result = this; - } - return result; - } - - /** - * [FUNCTION] LongStreamAutomaton::unordered(LongStream) -> LongStream - * Source: java/util/stream/LongStream.main.lsl:943 - */ - public LongStream unordered() { - LongStream result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - result = (stub.java.util.stream.LongStreamLSL) ((Object) new LongStreamLSL((Void) null, - /* state = */ LongStreamLSL.__$lsl_States.Initialized, - /* storage = */ this.storage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] LongStreamAutomaton::onClose(LongStream, Runnable) -> LongStream - * Source: java/util/stream/LongStream.main.lsl:956 - */ - public LongStream onClose(Runnable closeHandler) { - LongStream result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - final int listLength = this.closeHandlers.size(); - this.closeHandlers.insert(listLength, closeHandler); - result = this; - } - return result; - } - - /** - * [FUNCTION] LongStreamAutomaton::close(LongStream) -> void - * Source: java/util/stream/LongStream.main.lsl:968 - */ - public void close() { - /* body */ { - final int listLength = this.closeHandlers.size(); - int i = 0; - for (i = 0; i < listLength; i += 1) { - final Runnable currentHandler = ((Runnable) this.closeHandlers.get(i)); - currentHandler.run(); - } - ; - this.closeHandlers = Engine.makeSymbolicList(); - this.linkedOrConsumed = true; - } - } - - /** - * [FUNCTION] LongStreamAutomaton::dropWhile(LongStream, LongPredicate) -> LongStream - * Source: java/util/stream/LongStream.main.lsl:992 - */ - public LongStream dropWhile(LongPredicate predicate) { - LongStream result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (predicate == null) { - throw new NullPointerException(); - } - if (this.length == 0) { - final long[] emptyStorage = new long[0]; - result = (stub.java.util.stream.LongStreamLSL) ((Object) new LongStreamLSL((Void) null, - /* state = */ LongStreamLSL.__$lsl_States.Initialized, - /* storage = */ emptyStorage, - /* length = */ 0, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } else { - Engine.assume(this.length > 0); - int dropLength = 0; - int i = 0; - while ((i < this.length) && predicate.test(storage[i])) { - dropLength += 1; - i += 1; - } - ; - if (dropLength == 0) { - result = (stub.java.util.stream.LongStreamLSL) ((Object) new LongStreamLSL((Void) null, - /* state = */ LongStreamLSL.__$lsl_States.Initialized, - /* storage = */ this.storage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } else { - final int newLength = this.length - dropLength; - final long[] newStorage = new long[newLength]; - int j = dropLength; - i = dropLength; - while (i < this.length) { - newStorage[j] = storage[i]; - j += 1; - i += 1; - } - ; - result = (stub.java.util.stream.LongStreamLSL) ((Object) new LongStreamLSL((Void) null, - /* state = */ LongStreamLSL.__$lsl_States.Initialized, - /* storage = */ newStorage, - /* length = */ newLength, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] LongStreamAutomaton::takeWhile(LongStream, LongPredicate) -> LongStream - * Source: java/util/stream/LongStream.main.lsl:1067 - */ - public LongStream takeWhile(LongPredicate predicate) { - LongStream result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (predicate == null) { - throw new NullPointerException(); - } - if (this.length == 0) { - final long[] emptyStorage = new long[0]; - result = (stub.java.util.stream.LongStreamLSL) ((Object) new LongStreamLSL((Void) null, - /* state = */ LongStreamLSL.__$lsl_States.Initialized, - /* storage = */ emptyStorage, - /* length = */ 0, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } else { - Engine.assume(this.length > 0); - int takeLength = 0; - int i = 0; - while ((i < this.length) && predicate.test(storage[i])) { - takeLength += 1; - i += 1; - } - ; - if (takeLength == this.length) { - result = (stub.java.util.stream.LongStreamLSL) ((Object) new LongStreamLSL((Void) null, - /* state = */ LongStreamLSL.__$lsl_States.Initialized, - /* storage = */ this.storage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } else { - final int newLength = takeLength; - final long[] newStorage = new long[newLength]; - int j = 0; - i = 0; - while (i < takeLength) { - newStorage[j] = storage[i]; - j += 1; - i += 1; - } - ; - result = (stub.java.util.stream.LongStreamLSL) ((Object) new LongStreamLSL((Void) null, - /* state = */ LongStreamLSL.__$lsl_States.Initialized, - /* storage = */ newStorage, - /* length = */ newLength, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] LongStreamAutomaton::asDoubleStream(LongStream) -> DoubleStream - * Source: java/util/stream/LongStream.main.lsl:1142 - */ - public DoubleStream asDoubleStream() { - DoubleStream result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (this.length == 0) { - final double[] emptyArray = {}; - result = (stub.java.util.stream.DoubleStreamLSL) ((Object) new DoubleStreamLSL((Void) null, - /* state = */ DoubleStreamLSL.__$lsl_States.Initialized, - /* storage = */ emptyArray, - /* length = */ 0, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } else { - Engine.assume(this.length > 0); - final double[] newStorage = new double[this.length]; - int i = 0; - for (i = 0; i < this.length; i += 1) { - newStorage[i] = ((double) storage[i]); - } - ; - result = (stub.java.util.stream.DoubleStreamLSL) ((Object) new DoubleStreamLSL((Void) null, - /* state = */ DoubleStreamLSL.__$lsl_States.Initialized, - /* storage = */ newStorage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] LongStreamAutomaton::sum(LongStream) -> long - * Source: java/util/stream/LongStream.main.lsl:1184 - */ - public long sum() { - long result = 0L; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - result = _sum(); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] LongStreamAutomaton::average(LongStream) -> OptionalDouble - * Source: java/util/stream/LongStream.main.lsl:1194 - */ - public OptionalDouble average() { - OptionalDouble result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (this.length == 0) { - result = OptionalDouble.empty(); - } else { - double curSum = _sum(); - double divisionResult = curSum / this.length; - result = OptionalDouble.of(divisionResult); - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] LongStreamAutomaton::summaryStatistics(LongStream) -> LongSummaryStatistics - * Source: java/util/stream/LongStream.main.lsl:1213 - */ - public LongSummaryStatistics summaryStatistics() { - LongSummaryStatistics result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - result = new LongSummaryStatistics(); - int i = 0; - for (i = 0; i < this.length; i += 1) { - result.accept(storage[i]); - } - ; - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] LongStreamAutomaton::boxed(LongStream) -> Stream - * Source: java/util/stream/LongStream.main.lsl:1234 - */ - public Stream boxed() { - Stream result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - final Long[] longArray = new Long[this.length]; - int i = 0; - for (i = 0; i < this.length; i += 1) { - longArray[i] = storage[i]; - } - ; - result = (stub.java.util.stream.StreamLSL) ((Object) new StreamLSL((Void) null, - /* state = */ StreamLSL.__$lsl_States.Initialized, - /* storage = */ longArray, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - this.linkedOrConsumed = true; - } - return result; - } - - public static final class __$lsl_States { - public static final byte Initialized = (byte) 0; - } - - @Approximate(LongStreamLSL.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/stream/LongStreamLSLIterator.java b/approximations/src/main/java/generated/java/util/stream/LongStreamLSLIterator.java deleted file mode 100644 index 7720db40..00000000 --- a/approximations/src/main/java/generated/java/util/stream/LongStreamLSLIterator.java +++ /dev/null @@ -1,169 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/stream/LongStream.lsl:35 -// - java/util/stream/LongStream.Iterator.lsl:18 -// -package generated.java.util.stream; - -import java.lang.Long; -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.SuppressWarnings; -import java.lang.UnsupportedOperationException; -import java.lang.Void; -import java.util.NoSuchElementException; -import java.util.PrimitiveIterator; -import java.util.function.Consumer; -import java.util.function.LongConsumer; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; - -/** - * LongStreamIteratorAutomaton for LongStreamLSLIterator ~> java.util.stream.LongStreamLSLIterator - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(stub.java.util.stream.LongStreamLSLIterator.class) -public class LongStreamLSLIterator implements LibSLRuntime.Automaton, PrimitiveIterator.OfLong { - static { - Engine.assume(true); - } - - public LongStreamLSL parent; - - public int cursor; - - @LibSLRuntime.AutomatonConstructor - public LongStreamLSLIterator(Void __$lsl_token, final byte p0, final LongStreamLSL p1, - final int p2) { - this.parent = p1; - this.cursor = p2; - } - - @LibSLRuntime.AutomatonConstructor - public LongStreamLSLIterator(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Initialized, null, 0); - } - - /** - * [FUNCTION] LongStreamIteratorAutomaton::hasNext(LongStreamLSLIterator) -> boolean - * Source: java/util/stream/LongStream.Iterator.lsl:41 - */ - public boolean hasNext() { - boolean result = false; - /* body */ { - Engine.assume(this.parent != null); - result = this.cursor != ((LongStreamLSL) ((Object) this.parent)).length; - } - return result; - } - - /** - * [FUNCTION] LongStreamIteratorAutomaton::next(LongStreamLSLIterator) -> Long - * Source: java/util/stream/LongStream.Iterator.lsl:50 - */ - public Long next() { - Long result = null; - /* body */ { - Engine.assume(this.parent != null); - final long[] parentStorage = ((LongStreamLSL) ((Object) this.parent)).storage; - final int i = this.cursor; - if (i >= ((LongStreamLSL) ((Object) this.parent)).length) { - throw new NoSuchElementException(); - } - this.cursor = i + 1; - result = parentStorage[i]; - } - return result; - } - - /** - * [FUNCTION] LongStreamIteratorAutomaton::nextLong(LongStreamLSLIterator) -> long - * Source: java/util/stream/LongStream.Iterator.lsl:66 - */ - public long nextLong() { - long result = 0L; - /* body */ { - Engine.assume(this.parent != null); - final long[] parentStorage = ((LongStreamLSL) ((Object) this.parent)).storage; - final int i = this.cursor; - if (i >= ((LongStreamLSL) ((Object) this.parent)).length) { - throw new NoSuchElementException(); - } - this.cursor = i + 1; - result = parentStorage[i]; - } - return result; - } - - /** - * [FUNCTION] LongStreamIteratorAutomaton::remove(LongStreamLSLIterator) -> void - * Source: java/util/stream/LongStream.Iterator.lsl:82 - */ - public void remove() { - /* body */ { - throw new UnsupportedOperationException(); - } - } - - /** - * [FUNCTION] LongStreamIteratorAutomaton::forEachRemaining(LongStreamLSLIterator, Consumer) -> void - * Source: java/util/stream/LongStream.Iterator.lsl:88 - */ - public void forEachRemaining(Consumer userAction) { - /* body */ { - Engine.assume(this.parent != null); - if (userAction == null) { - throw new NullPointerException(); - } - int i = this.cursor; - final int size = ((LongStreamLSL) ((Object) this.parent)).length; - if (i != size) { - final long[] pStorage = ((LongStreamLSL) ((Object) this.parent)).storage; - while (i < size) { - final long item = pStorage[i]; - userAction.accept(item); - i += 1; - } - ; - this.cursor = i; - } - } - } - - /** - * [FUNCTION] LongStreamIteratorAutomaton::forEachRemaining(LongStreamLSLIterator, LongConsumer) -> void - * Source: java/util/stream/LongStream.Iterator.lsl:113 - */ - public void forEachRemaining(LongConsumer userAction) { - /* body */ { - Engine.assume(this.parent != null); - if (userAction == null) { - throw new NullPointerException(); - } - int i = this.cursor; - final int size = ((LongStreamLSL) ((Object) this.parent)).length; - if (i != size) { - final long[] pStorage = ((LongStreamLSL) ((Object) this.parent)).storage; - while (i < size) { - final long item = pStorage[i]; - userAction.accept(item); - i += 1; - } - ; - this.cursor = i; - } - } - } - - public static final class __$lsl_States { - public static final byte Initialized = (byte) 0; - } - - @Approximate(LongStreamLSLIterator.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/stream/StreamLSL.java b/approximations/src/main/java/generated/java/util/stream/StreamLSL.java deleted file mode 100644 index 1f888c3e..00000000 --- a/approximations/src/main/java/generated/java/util/stream/StreamLSL.java +++ /dev/null @@ -1,1369 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/stream/Stream.lsl:34 -// - java/util/stream/Stream.main.lsl:40 -// -package generated.java.util.stream; - -import generated.runtime.LibSLGlobals; -import java.lang.Comparable; -import java.lang.IllegalArgumentException; -import java.lang.IllegalStateException; -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.Runnable; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.Comparator; -import java.util.Iterator; -import java.util.Optional; -import java.util.Spliterator; -import java.util.function.BiConsumer; -import java.util.function.BiFunction; -import java.util.function.BinaryOperator; -import java.util.function.Consumer; -import java.util.function.Function; -import java.util.function.IntFunction; -import java.util.function.Predicate; -import java.util.function.Supplier; -import java.util.function.ToDoubleFunction; -import java.util.function.ToIntFunction; -import java.util.function.ToLongFunction; -import java.util.stream.BaseStream; -import java.util.stream.Collector; -import java.util.stream.DoubleStream; -import java.util.stream.IntStream; -import java.util.stream.LongStream; -import java.util.stream.Stream; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import org.usvm.api.SymbolicList; -import runtime.LibSLRuntime; -import stub.java.util.Spliterators_ArraySpliterator; - -/** - * StreamAutomaton for StreamLSL ~> java.util.stream.StreamLSL - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(stub.java.util.stream.StreamLSL.class) -public class StreamLSL implements LibSLRuntime.Automaton, Stream { - static { - Engine.assume(true); - } - - private byte __$lsl_state = __$lsl_States.Allocated; - - public Object[] storage; - - public transient int length; - - public SymbolicList closeHandlers; - - public boolean isParallel; - - public boolean linkedOrConsumed; - - @LibSLRuntime.AutomatonConstructor - public StreamLSL(Void __$lsl_token, final byte p0, final Object[] p1, final int p2, - final SymbolicList p3, final boolean p4, final boolean p5) { - this.__$lsl_state = p0; - this.storage = p1; - this.length = p2; - this.closeHandlers = p3; - this.isParallel = p4; - this.linkedOrConsumed = p5; - } - - @LibSLRuntime.AutomatonConstructor - public StreamLSL(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Allocated, null, 0, null, false, false); - } - - /** - * [SUBROUTINE] StreamAutomaton::_actionApply(Consumer) -> void - * Source: java/util/stream/Stream.main.lsl:134 - */ - private void _actionApply(Consumer _action) { - /* body */ { - if (_action == null) { - throw new NullPointerException(); - } - int i = 0; - for (i = 0; i < this.length; i += 1) { - _action.accept(storage[i]); - } - ; - } - } - - /** - * [SUBROUTINE] StreamAutomaton::_findFirst() -> Optional - * Source: java/util/stream/Stream.main.lsl:153 - */ - private Optional _findFirst() { - Optional result = null; - /* body */ { - if (this.length == 0) { - result = Optional.empty(); - } else { - final Object first = storage[0]; - result = Optional.ofNullable(first); - } - } - return result; - } - - /** - * [FUNCTION] StreamAutomaton::filter(Stream, Predicate) -> Stream - * Source: java/util/stream/Stream.main.lsl:169 - */ - public Stream filter(Predicate predicate) { - Stream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (predicate == null) { - throw new NullPointerException(); - } - Object[] filteredStorage = new Object[this.length]; - int filteredLength = 0; - int i = 0; - for (i = 0; i < this.length; i += 1) { - if (predicate.test(storage[i])) { - filteredStorage[filteredLength] = storage[i]; - filteredLength += 1; - } - } - ; - Engine.assume(filteredLength <= this.length); - Object[] resultStorage = new Object[filteredLength]; - LibSLRuntime.ArrayActions.copy(filteredStorage, 0, resultStorage, 0, filteredLength); - result = (stub.java.util.stream.StreamLSL) ((Object) new StreamLSL((Void) null, - /* state = */ StreamLSL.__$lsl_States.Initialized, - /* storage = */ resultStorage, - /* length = */ filteredLength, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] StreamAutomaton::map(Stream, Function) -> Stream - * Source: java/util/stream/Stream.main.lsl:210 - */ - public Stream map(Function mapper) { - Stream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (mapper == null) { - throw new NullPointerException(); - } - Object[] mappedStorage = new Object[this.length]; - int i = 0; - for (i = 0; i < this.length; i += 1) { - mappedStorage[i] = mapper.apply(storage[i]); - } - ; - result = (stub.java.util.stream.StreamLSL) ((Object) new StreamLSL((Void) null, - /* state = */ StreamLSL.__$lsl_States.Initialized, - /* storage = */ mappedStorage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] StreamAutomaton::mapToInt(Stream, ToIntFunction) -> IntStream - * Source: java/util/stream/Stream.main.lsl:241 - */ - public IntStream mapToInt(ToIntFunction mapper) { - IntStream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (mapper == null) { - throw new NullPointerException(); - } - final int[] mappedStorage = new int[this.length]; - int i = 0; - for (i = 0; i < this.length; i += 1) { - mappedStorage[i] = mapper.applyAsInt(storage[i]); - } - ; - result = (stub.java.util.stream.IntStreamLSL) ((Object) new IntStreamLSL((Void) null, - /* state = */ IntStreamLSL.__$lsl_States.Initialized, - /* storage = */ mappedStorage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] StreamAutomaton::mapToLong(Stream, ToLongFunction) -> LongStream - * Source: java/util/stream/Stream.main.lsl:272 - */ - public LongStream mapToLong(ToLongFunction mapper) { - LongStream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (mapper == null) { - throw new NullPointerException(); - } - long[] mappedStorage = new long[this.length]; - int i = 0; - for (i = 0; i < this.length; i += 1) { - mappedStorage[i] = mapper.applyAsLong(storage[i]); - } - ; - result = (stub.java.util.stream.LongStreamLSL) ((Object) new LongStreamLSL((Void) null, - /* state = */ LongStreamLSL.__$lsl_States.Initialized, - /* storage = */ mappedStorage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] StreamAutomaton::mapToDouble(Stream, ToDoubleFunction) -> DoubleStream - * Source: java/util/stream/Stream.main.lsl:303 - */ - public DoubleStream mapToDouble(ToDoubleFunction mapper) { - DoubleStream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (mapper == null) { - throw new NullPointerException(); - } - double[] mappedStorage = new double[this.length]; - int i = 0; - for (i = 0; i < this.length; i += 1) { - mappedStorage[i] = mapper.applyAsDouble(storage[i]); - } - ; - result = (stub.java.util.stream.DoubleStreamLSL) ((Object) new DoubleStreamLSL((Void) null, - /* state = */ DoubleStreamLSL.__$lsl_States.Initialized, - /* storage = */ mappedStorage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] StreamAutomaton::flatMap(Stream, Function) -> Stream - * Source: java/util/stream/Stream.main.lsl:334 - */ - public Stream flatMap(Function mapper) { - Stream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (mapper == null) { - throw new NullPointerException(); - } - result = Engine.makeSymbolic(Stream.class); - Engine.assume(result != null); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] StreamAutomaton::flatMapToInt(Stream, Function) -> IntStream - * Source: java/util/stream/Stream.main.lsl:350 - */ - public IntStream flatMapToInt(Function mapper) { - IntStream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (mapper == null) { - throw new NullPointerException(); - } - result = Engine.makeSymbolic(IntStream.class); - Engine.assume(result != null); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] StreamAutomaton::flatMapToLong(Stream, Function) -> LongStream - * Source: java/util/stream/Stream.main.lsl:366 - */ - public LongStream flatMapToLong(Function mapper) { - LongStream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (mapper == null) { - throw new NullPointerException(); - } - result = Engine.makeSymbolic(LongStream.class); - Engine.assume(result != null); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] StreamAutomaton::flatMapToDouble(Stream, Function) -> DoubleStream - * Source: java/util/stream/Stream.main.lsl:382 - */ - public DoubleStream flatMapToDouble(Function mapper) { - DoubleStream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (mapper == null) { - throw new NullPointerException(); - } - result = Engine.makeSymbolic(DoubleStream.class); - Engine.assume(result != null); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] StreamAutomaton::distinct(Stream) -> Stream - * Source: java/util/stream/Stream.main.lsl:398 - */ - public Stream distinct() { - Stream result = null; - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - Object[] distinctStorage = null; - int distinctLength = 0; - final int size = this.length; - if (size == 0) { - distinctStorage = new Object[0]; - distinctLength = 0; - } else { - final Object[] items = this.storage; - Engine.assume(items != null); - Engine.assume(items.length != 0); - Engine.assume(size == items.length); - int i = 0; - int j = 0; - final SymbolicList uniqueItems = Engine.makeSymbolicList(); - final LibSLRuntime.Map visited = new LibSLRuntime.Map<>(new LibSLRuntime.HashMapContainer<>()); - for (i = 0; i < size; i += 1) { - final Object item = items[i]; - if (!visited.hasKey(item)) { - visited.set(item, LibSLGlobals.SOMETHING); - uniqueItems.insert(j, item); - j += 1; - } - } - ; - distinctLength = j; - Engine.assume(distinctLength > 0); - Engine.assume(distinctLength <= size); - distinctStorage = new Object[distinctLength]; - for (i = 0; i < distinctLength; i += 1) { - distinctStorage[i] = uniqueItems.get(i); - } - ; - } - result = (stub.java.util.stream.StreamLSL) ((Object) new StreamLSL((Void) null, - /* state = */ StreamLSL.__$lsl_States.Initialized, - /* storage = */ distinctStorage, - /* length = */ distinctLength, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] StreamAutomaton::sorted(Stream) -> Stream - * Source: java/util/stream/Stream.main.lsl:468 - */ - public Stream sorted() { - Stream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (this.length == 0) { - result = (stub.java.util.stream.StreamLSL) ((Object) new StreamLSL((Void) null, - /* state = */ StreamLSL.__$lsl_States.Initialized, - /* storage = */ this.storage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } else { - Engine.assume(this.length > 0); - final int outerLimit = this.length - 1; - int innerLimit = 0; - int i = 0; - int j = 0; - for (i = 0; i < outerLimit; i += 1) { - innerLimit = (this.length - i) - 1; - for (j = 0; j < innerLimit; j += 1) { - final int idxA = j; - final int idxB = j + 1; - final Object a = storage[idxA]; - final Object b = storage[idxB]; - if (((Comparable) a).compareTo(b) > 0) { - storage[idxA] = b; - storage[idxB] = a; - } - } - ; - } - ; - result = (stub.java.util.stream.StreamLSL) ((Object) new StreamLSL((Void) null, - /* state = */ StreamLSL.__$lsl_States.Initialized, - /* storage = */ this.storage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] StreamAutomaton::sorted(Stream, Comparator) -> Stream - * Source: java/util/stream/Stream.main.lsl:531 - */ - public Stream sorted(Comparator comparator) { - Stream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (this.length == 0) { - result = (stub.java.util.stream.StreamLSL) ((Object) new StreamLSL((Void) null, - /* state = */ StreamLSL.__$lsl_States.Initialized, - /* storage = */ this.storage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } else { - final int outerLimit = this.length - 1; - int innerLimit = 0; - int i = 0; - int j = 0; - for (i = 0; i < outerLimit; i += 1) { - innerLimit = (this.length - i) - 1; - for (j = 0; j < innerLimit; j += 1) { - final int idxA = j; - final int idxB = j + 1; - final Object a = storage[idxA]; - final Object b = storage[idxB]; - if (comparator.compare(a, b) > 0) { - storage[idxA] = b; - storage[idxB] = a; - } - } - ; - } - ; - result = (stub.java.util.stream.StreamLSL) ((Object) new StreamLSL((Void) null, - /* state = */ StreamLSL.__$lsl_States.Initialized, - /* storage = */ this.storage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] StreamAutomaton::peek(Stream, Consumer) -> Stream - * Source: java/util/stream/Stream.main.lsl:591 - */ - public Stream peek(Consumer _action) { - Stream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - _actionApply(_action); - result = (stub.java.util.stream.StreamLSL) ((Object) new StreamLSL((Void) null, - /* state = */ StreamLSL.__$lsl_States.Initialized, - /* storage = */ this.storage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] StreamAutomaton::limit(Stream, long) -> Stream - * Source: java/util/stream/Stream.main.lsl:608 - */ - public Stream limit(long maxSize) { - Stream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (maxSize < 0) { - throw new IllegalArgumentException(); - } - if (maxSize == 0) { - result = (stub.java.util.stream.StreamLSL) ((Object) new StreamLSL((Void) null, - /* state = */ StreamLSL.__$lsl_States.Initialized, - /* storage = */ this.storage, - /* length = */ 0, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } else { - if (maxSize > this.length) { - result = (stub.java.util.stream.StreamLSL) ((Object) new StreamLSL((Void) null, - /* state = */ StreamLSL.__$lsl_States.Initialized, - /* storage = */ this.storage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } else { - final int maxSizeInt = ((int) maxSize); - final Object[] limitStorage = new Object[maxSizeInt]; - int i = 0; - for (i = 0; i < maxSizeInt; i += 1) { - limitStorage[i] = storage[i]; - } - ; - result = (stub.java.util.stream.StreamLSL) ((Object) new StreamLSL((Void) null, - /* state = */ StreamLSL.__$lsl_States.Initialized, - /* storage = */ limitStorage, - /* length = */ maxSizeInt, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] StreamAutomaton::skip(Stream, long) -> Stream - * Source: java/util/stream/Stream.main.lsl:661 - */ - public Stream skip(long n) { - Stream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final int offset = ((int) n); - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (offset < 0) { - throw new IllegalArgumentException(); - } - if (offset == 0) { - result = (stub.java.util.stream.StreamLSL) ((Object) new StreamLSL((Void) null, - /* state = */ StreamLSL.__$lsl_States.Initialized, - /* storage = */ this.storage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } else { - if (offset >= this.length) { - Object[] newArray = {}; - result = (stub.java.util.stream.StreamLSL) ((Object) new StreamLSL((Void) null, - /* state = */ StreamLSL.__$lsl_States.Initialized, - /* storage = */ newArray, - /* length = */ 0, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } else { - final int newLength = this.length - offset; - final Object[] skipStorage = new Object[newLength]; - int i = 0; - int skipIndex = 0; - for (i = offset; i < this.length; i += 1) { - skipStorage[skipIndex] = storage[i]; - skipIndex += 1; - } - ; - result = (stub.java.util.stream.StreamLSL) ((Object) new StreamLSL((Void) null, - /* state = */ StreamLSL.__$lsl_States.Initialized, - /* storage = */ skipStorage, - /* length = */ newLength, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] StreamAutomaton::forEach(Stream, Consumer) -> void - * Source: java/util/stream/Stream.main.lsl:717 - */ - public void forEach(Consumer _action) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - _actionApply(_action); - this.linkedOrConsumed = true; - } - } - - /** - * [FUNCTION] StreamAutomaton::forEachOrdered(Stream, Consumer) -> void - * Source: java/util/stream/Stream.main.lsl:726 - */ - public void forEachOrdered(Consumer _action) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - _actionApply(_action); - this.linkedOrConsumed = true; - } - } - - /** - * [FUNCTION] StreamAutomaton::toArray(Stream) -> array - * Source: java/util/stream/Stream.main.lsl:735 - */ - public Object[] toArray() { - Object[] result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - result = this.storage; - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] StreamAutomaton::toArray(Stream, IntFunction) -> array - * Source: java/util/stream/Stream.main.lsl:744 - */ - public Object[] toArray(IntFunction generator) { - Object[] result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - final Object[] generatedArray = ((Object[]) generator.apply(this.length)); - LibSLRuntime.ArrayActions.copy(this.storage, 0, generatedArray, 0, this.length); - result = generatedArray; - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] StreamAutomaton::reduce(Stream, Object, BinaryOperator) -> Object - * Source: java/util/stream/Stream.main.lsl:757 - */ - public Object reduce(Object identity, BinaryOperator accumulator) { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (accumulator == null) { - throw new NullPointerException(); - } - result = identity; - if (this.length != 0) { - Engine.assume(this.length > 0); - int i = 0; - for (i = 0; i < this.length; i += 1) { - result = accumulator.apply(result, storage[i]); - } - ; - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] StreamAutomaton::reduce(Stream, BinaryOperator) -> Optional - * Source: java/util/stream/Stream.main.lsl:786 - */ - public Optional reduce(BinaryOperator accumulator) { - Optional result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (accumulator == null) { - throw new NullPointerException(); - } - Object value = null; - if (this.length == 0) { - result = Optional.empty(); - } else { - if (this.length > 0) { - value = storage[0]; - int i = 0; - for (i = 1; i < this.length; i += 1) { - value = accumulator.apply(value, storage[i]); - } - ; - result = Optional.ofNullable(value); - } - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] StreamAutomaton::reduce(Stream, Object, BiFunction, BinaryOperator) -> Object - * Source: java/util/stream/Stream.main.lsl:822 - */ - public Object reduce(Object identity, BiFunction accumulator, BinaryOperator combiner) { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (accumulator == null) { - throw new NullPointerException(); - } - if (combiner == null) { - throw new NullPointerException(); - } - result = identity; - if (this.length != 0) { - Engine.assume(this.length > 0); - int i = 0; - for (i = 0; i < this.length; i += 1) { - result = accumulator.apply(result, storage[i]); - } - ; - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] StreamAutomaton::collect(Stream, Supplier, BiConsumer, BiConsumer) -> Object - * Source: java/util/stream/Stream.main.lsl:855 - */ - public Object collect(Supplier supplier, BiConsumer accumulator, BiConsumer combiner) { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (supplier == null) { - throw new NullPointerException(); - } - if (accumulator == null) { - throw new NullPointerException(); - } - if (combiner == null) { - throw new NullPointerException(); - } - result = supplier.get(); - int i = 0; - for (i = 0; i < this.length; i += 1) { - accumulator.accept(result, storage[i]); - } - ; - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] StreamAutomaton::collect(Stream, Collector) -> Object - * Source: java/util/stream/Stream.main.lsl:887 - */ - public Object collect(Collector collector) { - Object result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (collector == null) { - throw new NullPointerException(); - } - int i = 0; - final BiConsumer accumulator = collector.accumulator(); - for (i = 0; i < this.length; i += 1) { - accumulator.accept(result, storage[i]); - } - ; - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] StreamAutomaton::min(Stream, Comparator) -> Optional - * Source: java/util/stream/Stream.main.lsl:905 - */ - public Optional min(Comparator comparator) { - Optional result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (comparator == null) { - throw new NullPointerException(); - } - if (this.length == 0) { - result = Optional.empty(); - } else { - Object min = storage[0]; - int i = 0; - for (i = 1; i < this.length; i += 1) { - if (comparator.compare(min, storage[i]) > 0) { - min = storage[i]; - } - } - ; - result = Optional.ofNullable(min); - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] StreamAutomaton::max(Stream, Comparator) -> Optional - * Source: java/util/stream/Stream.main.lsl:940 - */ - public Optional max(Comparator comparator) { - Optional result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (comparator == null) { - throw new NullPointerException(); - } - if (this.length == 0) { - result = Optional.empty(); - } else { - Object max = storage[0]; - int i = 0; - for (i = 1; i < this.length; i += 1) { - if (comparator.compare(max, storage[i]) < 0) { - max = storage[i]; - } - } - ; - result = Optional.ofNullable(max); - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] StreamAutomaton::count(Stream) -> long - * Source: java/util/stream/Stream.main.lsl:975 - */ - public long count() { - long result = 0L; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - result = this.length; - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] StreamAutomaton::anyMatch(Stream, Predicate) -> boolean - * Source: java/util/stream/Stream.main.lsl:984 - */ - public boolean anyMatch(Predicate predicate) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (predicate == null) { - throw new NullPointerException(); - } - result = false; - int i = 0; - while ((i < this.length) && !predicate.test(storage[i])) { - i += 1; - } - ; - if (i < this.length) { - result = true; - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] StreamAutomaton::allMatch(Stream, Predicate) -> boolean - * Source: java/util/stream/Stream.main.lsl:1012 - */ - public boolean allMatch(Predicate predicate) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (predicate == null) { - throw new NullPointerException(); - } - result = true; - if (this.length > 0) { - result = false; - int i = 0; - while ((i < this.length) && predicate.test(storage[i])) { - i += 1; - } - ; - if (i == this.length) { - result = true; - } - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] StreamAutomaton::noneMatch(Stream, Predicate) -> boolean - * Source: java/util/stream/Stream.main.lsl:1038 - */ - public boolean noneMatch(Predicate predicate) { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (predicate == null) { - throw new NullPointerException(); - } - result = true; - if (this.length > 0) { - result = false; - int i = 0; - while ((i < this.length) && !predicate.test(storage[i])) { - i += 1; - } - ; - if (i == this.length) { - result = true; - } - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] StreamAutomaton::findFirst(Stream) -> Optional - * Source: java/util/stream/Stream.main.lsl:1064 - */ - public Optional findFirst() { - Optional result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - result = _findFirst(); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] StreamAutomaton::findAny(Stream) -> Optional - * Source: java/util/stream/Stream.main.lsl:1073 - */ - public Optional findAny() { - Optional result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - result = _findFirst(); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] StreamAutomaton::iterator(Stream) -> Iterator - * Source: java/util/stream/Stream.main.lsl:1083 - */ - public Iterator iterator() { - Iterator result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - result = (stub.java.util.stream.StreamLSLIterator) ((Object) new StreamLSLIterator((Void) null, - /* state = */ StreamLSLIterator.__$lsl_States.Initialized, - /* parent = */ this, - /* cursor = */ 0 - )); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] StreamAutomaton::spliterator(Stream) -> Spliterator - * Source: java/util/stream/Stream.main.lsl:1097 - */ - public Spliterator spliterator() { - Spliterator result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - result = (Spliterators_ArraySpliterator) ((Object) new generated.java.util.Spliterators_ArraySpliterator((Void) null, - /* state = */ generated.java.util.Spliterators_ArraySpliterator.__$lsl_States.Initialized, - /* array = */ this.storage, - /* index = */ 0, - /* fence = */ this.length, - /* characteristics = */ LibSLGlobals.SPLITERATOR_ORDERED | LibSLGlobals.SPLITERATOR_SIZED | LibSLGlobals.SPLITERATOR_SUBSIZED - )); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] StreamAutomaton::isParallel(Stream) -> boolean - * Source: java/util/stream/Stream.main.lsl:1113 - */ - public boolean isParallel() { - boolean result = false; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = this.isParallel; - } - return result; - } - - /** - * [FUNCTION] StreamAutomaton::sequential(Stream) -> BaseStream - * Source: java/util/stream/Stream.main.lsl:1120 - */ - public BaseStream sequential() { - BaseStream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - this.isParallel = false; - result = this; - } - return result; - } - - /** - * [FUNCTION] StreamAutomaton::parallel(Stream) -> BaseStream - * Source: java/util/stream/Stream.main.lsl:1128 - */ - public BaseStream parallel() { - BaseStream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - this.isParallel = true; - result = this; - } - return result; - } - - /** - * [FUNCTION] StreamAutomaton::unordered(Stream) -> BaseStream - * Source: java/util/stream/Stream.main.lsl:1136 - */ - public BaseStream unordered() { - BaseStream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - result = (stub.java.util.stream.StreamLSL) ((Object) new StreamLSL((Void) null, - /* state = */ StreamLSL.__$lsl_States.Initialized, - /* storage = */ this.storage, - /* length = */ this.length, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] StreamAutomaton::onClose(Stream, Runnable) -> BaseStream - * Source: java/util/stream/Stream.main.lsl:1149 - */ - public BaseStream onClose(Runnable arg0) { - BaseStream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - final int listLength = this.closeHandlers.size(); - this.closeHandlers.insert(listLength, arg0); - result = this; - } - return result; - } - - /** - * [FUNCTION] StreamAutomaton::close(Stream) -> void - * Source: java/util/stream/Stream.main.lsl:1161 - */ - public void close() { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final int listLength = this.closeHandlers.size(); - int i = 0; - for (i = 0; i < listLength; i += 1) { - final Runnable currentHandler = ((Runnable) this.closeHandlers.get(i)); - currentHandler.run(); - } - ; - this.closeHandlers = Engine.makeSymbolicList(); - this.linkedOrConsumed = true; - } - } - - /** - * [FUNCTION] StreamAutomaton::dropWhile(Stream, Predicate) -> Stream - * Source: java/util/stream/Stream.main.lsl:1185 - */ - public Stream dropWhile(Predicate predicate) { - Stream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (predicate == null) { - throw new NullPointerException(); - } - if (this.length == 0) { - final Object[] emptyStorage = new Object[0]; - result = (stub.java.util.stream.StreamLSL) ((Object) new StreamLSL((Void) null, - /* state = */ StreamLSL.__$lsl_States.Initialized, - /* storage = */ emptyStorage, - /* length = */ 0, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } else { - int dropLength = 0; - int i = 0; - for (i = 0; i < this.length; i += 1) { - if (predicate.test(storage[i])) { - dropLength += 1; - } else { - break; - } - } - ; - final int newLength = this.length - dropLength; - final Object[] newStorage = new Object[newLength]; - int j = 0; - for (i = dropLength; i < this.length; i += 1) { - newStorage[j] = storage[i]; - j += 1; - } - ; - result = (stub.java.util.stream.StreamLSL) ((Object) new StreamLSL((Void) null, - /* state = */ StreamLSL.__$lsl_States.Initialized, - /* storage = */ newStorage, - /* length = */ newLength, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - this.linkedOrConsumed = true; - } - return result; - } - - /** - * [FUNCTION] StreamAutomaton::takeWhile(Stream, Predicate) -> Stream - * Source: java/util/stream/Stream.main.lsl:1247 - */ - public Stream takeWhile(Predicate predicate) { - Stream result = null; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - if (this.linkedOrConsumed) { - throw new IllegalStateException(); - } - if (predicate == null) { - throw new NullPointerException(); - } - if (this.length == 0) { - final Object[] emptyStorage = new Object[0]; - result = (stub.java.util.stream.StreamLSL) ((Object) new StreamLSL((Void) null, - /* state = */ StreamLSL.__$lsl_States.Initialized, - /* storage = */ emptyStorage, - /* length = */ 0, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } else { - int takeLength = 0; - int i = 0; - for (i = 0; i < this.length; i += 1) { - if (predicate.test(storage[i])) { - takeLength += 1; - } else { - break; - } - } - ; - final int newLength = takeLength; - final Object[] newStorage = new Object[newLength]; - int j = 0; - for (i = 0; i < takeLength; i += 1) { - newStorage[j] = storage[i]; - j += 1; - } - ; - result = (stub.java.util.stream.StreamLSL) ((Object) new StreamLSL((Void) null, - /* state = */ StreamLSL.__$lsl_States.Initialized, - /* storage = */ newStorage, - /* length = */ newLength, - /* closeHandlers = */ this.closeHandlers, - /* isParallel = */ false, - /* linkedOrConsumed = */ false - )); - } - this.linkedOrConsumed = true; - } - return result; - } - - public static final class __$lsl_States { - public static final byte Allocated = (byte) 0; - - public static final byte Initialized = (byte) 1; - } - - @Approximate(StreamLSL.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/stream/StreamLSLIterator.java b/approximations/src/main/java/generated/java/util/stream/StreamLSLIterator.java deleted file mode 100644 index c42944e1..00000000 --- a/approximations/src/main/java/generated/java/util/stream/StreamLSLIterator.java +++ /dev/null @@ -1,122 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/stream/Stream.lsl:43 -// - java/util/stream/Stream.Iterator.lsl:16 -// -package generated.java.util.stream; - -import java.lang.NullPointerException; -import java.lang.Object; -import java.lang.SuppressWarnings; -import java.lang.UnsupportedOperationException; -import java.lang.Void; -import java.util.Iterator; -import java.util.NoSuchElementException; -import java.util.function.Consumer; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; - -/** - * StreamIteratorAutomaton for StreamLSLIterator ~> java.util.stream.StreamLSLIterator - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(stub.java.util.stream.StreamLSLIterator.class) -public class StreamLSLIterator implements LibSLRuntime.Automaton, Iterator { - static { - Engine.assume(true); - } - - public StreamLSL parent; - - public int cursor; - - @LibSLRuntime.AutomatonConstructor - public StreamLSLIterator(Void __$lsl_token, final byte p0, final StreamLSL p1, final int p2) { - this.parent = p1; - this.cursor = p2; - } - - @LibSLRuntime.AutomatonConstructor - public StreamLSLIterator(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Initialized, null, 0); - } - - /** - * [FUNCTION] StreamIteratorAutomaton::hasNext(StreamLSLIterator) -> boolean - * Source: java/util/stream/Stream.Iterator.lsl:37 - */ - public boolean hasNext() { - boolean result = false; - /* body */ { - Engine.assume(this.parent != null); - result = this.cursor != ((StreamLSL) ((Object) this.parent)).length; - } - return result; - } - - /** - * [FUNCTION] StreamIteratorAutomaton::next(StreamLSLIterator) -> Object - * Source: java/util/stream/Stream.Iterator.lsl:46 - */ - public Object next() { - Object result = null; - /* body */ { - Engine.assume(this.parent != null); - final Object[] parentStorage = ((StreamLSL) ((Object) this.parent)).storage; - final int i = this.cursor; - if (i >= ((StreamLSL) ((Object) this.parent)).length) { - throw new NoSuchElementException(); - } - this.cursor = i + 1; - result = parentStorage[i]; - } - return result; - } - - /** - * [FUNCTION] StreamIteratorAutomaton::remove(StreamLSLIterator) -> void - * Source: java/util/stream/Stream.Iterator.lsl:62 - */ - public void remove() { - /* body */ { - throw new UnsupportedOperationException(); - } - } - - /** - * [FUNCTION] StreamIteratorAutomaton::forEachRemaining(StreamLSLIterator, Consumer) -> void - * Source: java/util/stream/Stream.Iterator.lsl:68 - */ - public void forEachRemaining(Consumer userAction) { - /* body */ { - Engine.assume(this.parent != null); - if (userAction == null) { - throw new NullPointerException(); - } - int i = this.cursor; - final int size = ((StreamLSL) ((Object) this.parent)).length; - if (i != size) { - final Object[] pStorage = ((StreamLSL) ((Object) this.parent)).storage; - while (i < size) { - final Object item = pStorage[i]; - userAction.accept(item); - i += 1; - } - ; - this.cursor = i; - } - } - } - - public static final class __$lsl_States { - public static final byte Initialized = (byte) 0; - } - - @Approximate(StreamLSLIterator.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/java/util/stream/StreamStubImpl.java b/approximations/src/main/java/generated/java/util/stream/StreamStubImpl.java new file mode 100644 index 00000000..c404dd87 --- /dev/null +++ b/approximations/src/main/java/generated/java/util/stream/StreamStubImpl.java @@ -0,0 +1,699 @@ +package generated.java.util.stream; + +import generated.java.util.array.ArrayIteratorImpl; +import generated.java.util.array.ArraySpliteratorImpl; +import generated.runtime.LibSLGlobals; + +import java.lang.Comparable; +import java.lang.IllegalArgumentException; +import java.lang.NullPointerException; +import java.lang.Object; +import java.lang.Runnable; +import java.util.*; +import java.util.function.BiConsumer; +import java.util.function.BiFunction; +import java.util.function.BinaryOperator; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.function.IntFunction; +import java.util.function.Predicate; +import java.util.function.Supplier; +import java.util.function.ToDoubleFunction; +import java.util.function.ToIntFunction; +import java.util.function.ToLongFunction; +import java.util.stream.Collector; +import java.util.stream.DoubleStream; +import java.util.stream.IntStream; +import java.util.stream.LongStream; +import java.util.stream.Stream; + +import org.jacodb.approximation.annotation.Approximate; +import org.jetbrains.annotations.NotNull; +import org.usvm.api.Engine; +import org.usvm.api.SymbolicList; +import runtime.LibSLRuntime; +import stub.java.util.stream.StreamStub; + +@Approximate(StreamStub.class) +public class StreamStubImpl extends BaseStreamImpl implements Stream { + + private final E[] storage; + + public StreamStubImpl( + E[] storage, + SymbolicList handlers, + boolean isParallel, + boolean linkedOrConsumed + ) { + super(handlers, isParallel, linkedOrConsumed); + this.storage = storage; + } + + public StreamStubImpl(E[] storage, SymbolicList handlers, boolean isParallel) { + this(storage, handlers, isParallel, false); + } + + public StreamStubImpl(E[] storage, boolean isParallel) { + this(storage, Engine.makeSymbolicList(), isParallel); + } + + public StreamStubImpl(E[] storage, SymbolicList handlers) { + this(storage, handlers, false); + } + + public StreamStubImpl(E[] storage) { + this(storage, Engine.makeSymbolicList()); + } + + @SuppressWarnings({"ConstantValue", "DataFlowIssue"}) + private E[] _getStorage() { + E[] storage = this.storage; + Engine.assume(storage != null); + Engine.assume(storage.length >= 0); + return storage; + } + + protected int _getLength() { + return _getStorage().length; + } + + private StreamStubImpl _copy(T[] storage) { + return new StreamStubImpl<>(storage, _getCloseHandlers(), isParallel, linkedOrConsumed); + } + + private StreamStubImpl _copy() { + return _copy(_getStorage()); + } + + private void _actionApply(Consumer _action) { + if (_action == null) + throw new NullPointerException(); + + E[] storage = _getStorage(); + for (E e : storage) { + _action.accept(e); + } + } + + private Optional _findFirst() { + E[] storage = _getStorage(); + + if (storage.length == 0) + return Optional.empty(); + + E first = storage[0]; + return Optional.ofNullable(first); + } + + public Stream filter(Predicate predicate) { + super.evaluate(); + + if (predicate == null) + throw new NullPointerException(); + + E[] storage = _getStorage(); + int length = storage.length; + E[] filteredStorage = Arrays.copyOf(storage, length); + int filteredLength = 0; + for (E e : storage) { + if (predicate.test(e)) { + filteredStorage[filteredLength] = e; + filteredLength++; + } + } + + Engine.assume(filteredLength <= length); + E[] resultStorage = Arrays.copyOf(filteredStorage, filteredLength); + return _copy(resultStorage); + } + + @SuppressWarnings("unchecked") + public Stream map(Function mapper) { + super.evaluate(); + + if (mapper == null) + throw new NullPointerException(); + + E[] storage = _getStorage(); + int length = storage.length; + T[] mappedStorage = (T[]) new Object[length]; + for (int i = 0; i < length; i++) { + mappedStorage[i] = mapper.apply(storage[i]); + } + + return _copy(mappedStorage); + } + + public IntStream mapToInt(ToIntFunction mapper) { + super.evaluate(); + + if (mapper == null) + throw new NullPointerException(); + + E[] storage = _getStorage(); + int length = storage.length; + int[] mappedStorage = new int[length]; + for (int i = 0; i < length; i++) { + mappedStorage[i] = mapper.applyAsInt(storage[i]); + } + + return _copyToIntStream(mappedStorage); + } + + public LongStream mapToLong(ToLongFunction mapper) { + super.evaluate(); + + if (mapper == null) + throw new NullPointerException(); + + E[] storage = _getStorage(); + int length = storage.length; + long[] mappedStorage = new long[length]; + for (int i = 0; i < length; i++) { + mappedStorage[i] = mapper.applyAsLong(storage[i]); + } + + return _copyToLongStream(mappedStorage); + } + + public DoubleStream mapToDouble(ToDoubleFunction mapper) { + super.evaluate(); + + if (mapper == null) + throw new NullPointerException(); + + E[] storage = _getStorage(); + int length = storage.length; + double[] mappedStorage = new double[length]; + for (int i = 0; i < length; i++) { + mappedStorage[i] = mapper.applyAsDouble(storage[i]); + } + + return _copyToDoubleStream(mappedStorage); + } + + @SuppressWarnings({"unchecked", "ConstantValue"}) + public Stream flatMap(Function> mapper) { + super.evaluate(); + + if (mapper == null) + throw new NullPointerException(); + + // TODO: approximate + Stream result = Engine.makeSymbolic(Stream.class); + Engine.assume(result != null); + return result; + } + + @SuppressWarnings("ConstantValue") + public IntStream flatMapToInt(Function mapper) { + super.evaluate(); + + if (mapper == null) + throw new NullPointerException(); + + // TODO: approximate + IntStream result = Engine.makeSymbolic(IntStream.class); + Engine.assume(result != null); + return result; + } + + @SuppressWarnings("ConstantValue") + public LongStream flatMapToLong(Function mapper) { + super.evaluate(); + + if (mapper == null) + throw new NullPointerException(); + + // TODO: approximate + LongStream result = Engine.makeSymbolic(LongStream.class); + Engine.assume(result != null); + return result; + } + + @SuppressWarnings("ConstantValue") + public DoubleStream flatMapToDouble(Function mapper) { + super.evaluate(); + + if (mapper == null) + throw new NullPointerException(); + + // TODO: approximate + DoubleStream result = Engine.makeSymbolic(DoubleStream.class); + Engine.assume(result != null); + return result; + } + + public StreamStubImpl distinct() { + super.evaluate(); + + E[] storage = _getStorage(); + E[] distinctStorage; + int length = storage.length; + if (length == 0) { + distinctStorage = Arrays.copyOf(storage, 0); + return _copy(distinctStorage); + } + + int distinctLength = 0; + distinctStorage = Arrays.copyOf(storage, length); + LibSLRuntime.Map visited = new LibSLRuntime.Map<>(new LibSLRuntime.HashMapContainer<>()); + for (E item : storage) { + if (!visited.hasKey(item)) { + Engine.assume(item != null); + visited.set(item, LibSLGlobals.SOMETHING); + distinctStorage[distinctLength] = item; + distinctLength++; + } + } + + Engine.assume(distinctLength <= length); + E[] resultStorage = Arrays.copyOf(distinctStorage, distinctLength); + return _copy(resultStorage); + } + + @SuppressWarnings("unchecked") + public StreamStubImpl sorted() { + super.evaluate(); + + E[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return _copy(); + + int outerLimit = length - 1; + for (int i = 0; i < outerLimit; i++) { + int innerLimit = length - i - 1; + for (int j = 0; j < innerLimit; j++) { + int idxB = j + 1; + Comparable a = (Comparable) storage[j]; + E b = storage[idxB]; + if (a.compareTo(b) > 0) { + storage[j] = b; + storage[idxB] = (E) a; + } + } + } + + return _copy(); + } + + public StreamStubImpl sorted(Comparator comparator) { + super.evaluate(); + + E[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return _copy(); + + int outerLimit = length - 1; + for (int i = 0; i < outerLimit; i++) { + int innerLimit = length - i - 1; + for (int j = 0; j < innerLimit; j++) { + int idxB = j + 1; + E a = storage[j]; + E b = storage[idxB]; + if (comparator.compare(a, b) > 0) { + storage[j] = b; + storage[idxB] = a; + } + } + } + + return _copy(); + } + + public StreamStubImpl peek(Consumer _action) { + super.evaluate(); + _actionApply(_action); + return _copy(); + } + + public StreamStubImpl limit(long maxSize) { + super.evaluate(); + + int maxSizeInt = (int) maxSize; + + if (maxSizeInt < 0) + throw new IllegalArgumentException(); + + if (maxSizeInt == 0) + return _copy(Arrays.copyOf(_getStorage(), 0)); + + E[] storage = _getStorage(); + int length = storage.length; + if (maxSizeInt > length) + return _copy(); + + E[] limitStorage = Arrays.copyOf(storage, maxSizeInt); + return _copy(limitStorage); + } + + public StreamStubImpl skip(long n) { + super.evaluate(); + + int offset = (int) n; + + if (offset < 0) + throw new IllegalArgumentException(); + + if (offset == 0) + return _copy(); + + E[] storage = _getStorage(); + int length = storage.length; + if (offset >= length) + return _copy(Arrays.copyOf(_getStorage(), 0)); + + E[] skipStorage = Arrays.copyOfRange(storage, offset, length); + return _copy(skipStorage); + } + + public void forEach(Consumer _action) { + super.evaluate(); + _actionApply(_action); + } + + public void forEachOrdered(Consumer _action) { + forEach(_action); + } + + @NotNull + public Object[] toArray() { + super.evaluate(); + return _getStorage(); + } + + @NotNull + @SuppressWarnings("unchecked") + public T[] toArray(IntFunction generator) { + super.evaluate(); + E[] storage = _getStorage(); + int length = storage.length; + + T[] array = generator.apply(length); + if (array.length < length) + return (T[]) Arrays.copyOf(storage, length, array.getClass()); + + LibSLRuntime.ArrayActions.copy(storage, 0, array, 0, length); + return array; + } + + public E reduce(E identity, BinaryOperator accumulator) { + super.evaluate(); + + if (accumulator == null) + throw new NullPointerException(); + + E result = identity; + E[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return result; + + for (E item : storage) { + result = accumulator.apply(result, item); + } + + return result; + } + + @NotNull + public Optional reduce(BinaryOperator accumulator) { + super.evaluate(); + + if (accumulator == null) + throw new NullPointerException(); + + E[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return Optional.empty(); + + E value = storage[0]; + for (int i = 1; i < length; i++) { + value = accumulator.apply(value, storage[i]); + } + + return Optional.of(value); + } + + public T reduce(T identity, BiFunction accumulator, BinaryOperator combiner) { + super.evaluate(); + + if (accumulator == null) + throw new NullPointerException(); + + if (combiner == null) + throw new NullPointerException(); + + T result = identity; + E[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return result; + + for (E item : storage) { + result = accumulator.apply(result, item); + } + + return result; + } + + private R _collect(Supplier supplier, BiConsumer accumulator) { + R result = supplier.get(); + E[] storage = _getStorage(); + for (E item : storage) { + accumulator.accept(result, item); + } + + return result; + } + + public R collect(Supplier supplier, BiConsumer accumulator, BiConsumer combiner) { + super.evaluate(); + + if (supplier == null) + throw new NullPointerException(); + + if (accumulator == null) + throw new NullPointerException(); + + if (combiner == null) + throw new NullPointerException(); + + return _collect(supplier, accumulator); + } + + public R collect(Collector collector) { + super.evaluate(); + + if (collector == null) + throw new NullPointerException(); + + return collector.finisher().apply(_collect(collector.supplier(), collector.accumulator())); + } + + @NotNull + public Optional min(Comparator comparator) { + super.evaluate(); + + if (comparator == null) + throw new NullPointerException(); + + E[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return Optional.empty(); + + E min = storage[0]; + for (int i = 1; i < length; i++) { + E item = storage[i]; + if (comparator.compare(min, item) > 0) + min = item; + } + + return Optional.ofNullable(min); + } + + @NotNull + public Optional max(Comparator comparator) { + super.evaluate(); + + if (comparator == null) + throw new NullPointerException(); + + E[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return Optional.empty(); + + E max = storage[0]; + for (int i = 1; i < length; i++) { + E item = storage[i]; + if (comparator.compare(max, item) < 0) + max = item; + } + + return Optional.ofNullable(max); + } + + public long count() { + super.evaluate(); + return _getStorage().length; + } + + public boolean anyMatch(Predicate predicate) { + super.evaluate(); + + if (predicate == null) + throw new NullPointerException(); + + E[] storage = _getStorage(); + for (E item : storage) { + if (predicate.test(item)) + return true; + } + + return false; + } + + public boolean allMatch(Predicate predicate) { + super.evaluate(); + + if (predicate == null) + throw new NullPointerException(); + + E[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return true; + + for (E item : storage) { + if (!predicate.test(item)) + return false; + } + + return true; + } + + public boolean noneMatch(Predicate predicate) { + super.evaluate(); + + if (predicate == null) + throw new NullPointerException(); + + E[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return true; + + for (E item : storage) { + if (predicate.test(item)) + return false; + } + + return true; + } + + @NotNull + public Optional findFirst() { + super.evaluate(); + return _findFirst(); + } + + @NotNull + public Optional findAny() { + return findFirst(); + } + + @NotNull + public Iterator iterator() { + super.evaluate(); + return new ArrayIteratorImpl<>(_getStorage()); + } + + @NotNull + public Spliterator spliterator() { + super.evaluate(); + E[] storage = _getStorage(); + int characteristics = LibSLGlobals.SPLITERATOR_ORDERED | LibSLGlobals.SPLITERATOR_SIZED | LibSLGlobals.SPLITERATOR_SUBSIZED; + return new ArraySpliteratorImpl<>(storage, characteristics); + } + + public boolean isParallel() { + return this.isParallel; + } + + @NotNull + public StreamStubImpl sequential() { + return (StreamStubImpl) super.sequential(); + } + + @NotNull + public StreamStubImpl parallel() { + return (StreamStubImpl) super.parallel(); + } + + @NotNull + public StreamStubImpl unordered() { + super.evaluate(); + return _copy(); + } + + @NotNull + public StreamStubImpl onClose(@NotNull Runnable handler) { + return (StreamStubImpl) super.onClose(handler); + } + + public void close() { + super.close(); + } + + public StreamStubImpl dropWhile(Predicate predicate) { + super.evaluate(); + + if (predicate == null) + throw new NullPointerException(); + + E[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return _copy(Arrays.copyOf(storage, 0)); + + int dropLength = 0; + while (dropLength < length && predicate.test(storage[dropLength])) { + dropLength++; + } + + if (dropLength == 0) + return _copy(); + + int newLength = length - dropLength; + E[] newStorage = Arrays.copyOf(storage, newLength); + return _copy(newStorage); + } + + public StreamStubImpl takeWhile(Predicate predicate) { + super.evaluate(); + + if (predicate == null) + throw new NullPointerException(); + + E[] storage = _getStorage(); + int length = storage.length; + if (length == 0) + return _copy(Arrays.copyOf(storage, 0)); + + int takeLength = 0; + while (takeLength < length && predicate.test(storage[takeLength])) { + takeLength++; + } + + if (takeLength == length) + return _copy(); + + E[] newStorage = Arrays.copyOf(storage, takeLength); + return _copy(newStorage); + } +} diff --git a/approximations/src/main/java/generated/java/util/zip/CRC32.java b/approximations/src/main/java/generated/java/util/zip/CRC32.java index dfd4c667..39dc5ff9 100644 --- a/approximations/src/main/java/generated/java/util/zip/CRC32.java +++ b/approximations/src/main/java/generated/java/util/zip/CRC32.java @@ -1,238 +1,136 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/zip/CRC32.lsl:23 -// - java/util/zip/CRC32.automaton.lsl:18 -// package generated.java.util.zip; import java.lang.ArrayIndexOutOfBoundsException; import java.lang.AssertionError; import java.lang.NullPointerException; import java.lang.SuppressWarnings; -import java.lang.Void; import java.nio.ByteBuffer; import java.util.zip.Checksum; import org.jacodb.approximation.annotation.Approximate; import org.usvm.api.Engine; -import runtime.LibSLRuntime; import sun.nio.ch.DirectBuffer; -/** - * CRC32Automaton for LSLCRC32 ~> java.util.zip.CRC32 - */ -@SuppressWarnings({"all", "unchecked"}) +@SuppressWarnings("unused") @Approximate(java.util.zip.CRC32.class) -public class CRC32 implements LibSLRuntime.Automaton, Checksum { +public class CRC32 implements Checksum { static { Engine.assume(true); } - private byte __$lsl_state = __$lsl_States.Allocated; - public int crc; - @LibSLRuntime.AutomatonConstructor - public CRC32(Void __$lsl_token, final byte p0, final int p1) { - this.__$lsl_state = p0; - this.crc = p1; - } - - @LibSLRuntime.AutomatonConstructor - public CRC32(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Allocated, 0); + public CRC32(int value) { + this.crc = value; } - /** - * [CONSTRUCTOR] CRC32Automaton::(CRC32) -> void - * Source: java/util/zip/CRC32.automaton.lsl:99 - */ public CRC32() { - this((Void) null); - Engine.assume(this.__$lsl_state == __$lsl_States.Allocated); - /* body */ { - } - this.__$lsl_state = __$lsl_States.Initialized; + this(0); } - /** - * [SUBROUTINE] CRC32Automaton::_updateCheck(array, int, int) -> void - * Source: java/util/zip/CRC32.automaton.lsl:50 - */ private void _updateCheck(byte[] b, int off, int len) { - /* body */ { - if (b == null) { - throw new NullPointerException(); - } - final int b_size = b.length; - if ((off < 0) || (len < 0) || (off > (b_size - len))) { - throw new ArrayIndexOutOfBoundsException(); - } - } + if (b == null) + throw new NullPointerException(); + + if (off < 0 || len < 0 || off > b.length - len) + throw new ArrayIndexOutOfBoundsException(); } - /** - * [SUBROUTINE] CRC32Automaton::_updateByteBuffer(long) -> int - * Source: java/util/zip/CRC32.automaton.lsl:61 - */ private int _updateByteBuffer(long addr) { - int result = 0; - /* body */ { - if (addr == 0L) { - throw new NullPointerException(); - } - result = Engine.makeSymbolicInt(); - } - return result; + if (addr == 0L) + throw new NullPointerException(); + + return Engine.makeSymbolicInt(); } - /** - * [SUBROUTINE] CRC32Automaton::_updateBytesCheck(array, int, int) -> void - * Source: java/util/zip/CRC32.automaton.lsl:75 - */ + @SuppressWarnings("ConstantValue") private void _updateBytesCheck(byte[] b, int off, int len) { - /* body */ { - if (len != 0) { - if (b != null) { - final int b_size = b.length; - Engine.assume(b_size >= 0); - if ((off < 0) || (off >= b_size)) { - throw new ArrayIndexOutOfBoundsException(off); - } - final int endIndex = (off + len) - 1; - if ((endIndex < 0) || (endIndex >= b_size)) { - throw new ArrayIndexOutOfBoundsException(endIndex); - } - } else { - throw new NullPointerException(); - } - } - } + if (len == 0) + return; + + if (b == null) + throw new NullPointerException(); + + int b_size = b.length; + Engine.assume(b_size >= 0); + if (off < 0 || off >= b_size) + throw new ArrayIndexOutOfBoundsException(off); + + int endIndex = off + len - 1; + if (endIndex < 0 || endIndex >= b_size) + throw new ArrayIndexOutOfBoundsException(endIndex); } - /** - * [FUNCTION] CRC32Automaton::getValue(CRC32) -> long - * Source: java/util/zip/CRC32.automaton.lsl:109 - */ public long getValue() { - long result = 0L; - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - result = ((long) this.crc) & 4294967295L; - } - return result; + return ((long) this.crc) & 4294967295L; } - /** - * [FUNCTION] CRC32Automaton::reset(CRC32) -> void - * Source: java/util/zip/CRC32.automaton.lsl:115 - */ public void reset() { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - this.crc = 0; - } + this.crc = 0; } - /** - * [FUNCTION] CRC32Automaton::update(CRC32, ByteBuffer) -> void - * Source: java/util/zip/CRC32.automaton.lsl:121 - */ + @SuppressWarnings({"ConstantValue", "PatternVariableCanBeUsed"}) public void update(ByteBuffer buffer) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final int pos = buffer.position(); - final int limit = buffer.limit(); - if (pos > limit) { - throw new AssertionError(); - } - final int rem = limit - pos; - if (rem > 0) { - if ((buffer instanceof DirectBuffer)) { - final DirectBuffer directBuffer = ((DirectBuffer) buffer); - final long address = directBuffer.address(); - this.crc = _updateByteBuffer(address); - } else { - if (buffer.hasArray()) { - final int off = buffer.arrayOffset() + pos; - final byte[] bufferArray = buffer.array(); - _updateBytesCheck(bufferArray, off, rem); - this.crc = Engine.makeSymbolicInt(); - } else { - int len = 4096; - final int b_rem = buffer.remaining(); - if (b_rem < len) { - len = b_rem; - } - final byte[] b = new byte[len]; - final int b_size = b.length; - Engine.assume(b_size >= 0); - while (buffer.hasRemaining()) { - int length = buffer.remaining(); - if (b_size < length) { - length = b_size; - } - buffer.get(b, 0, length); - _updateCheck(b, 0, length); - _updateBytesCheck(b, 0, length); - } - ; - this.crc = Engine.makeSymbolicInt(); - } - } - buffer.position(limit); - } + int pos = buffer.position(); + int limit = buffer.limit(); + if (pos > limit) + throw new AssertionError(); + + int rem = limit - pos; + if (rem <= 0) + return; + + if (buffer instanceof DirectBuffer) { + DirectBuffer directBuffer = (DirectBuffer) buffer; + long address = directBuffer.address(); + this.crc = _updateByteBuffer(address); + buffer.position(limit); + return; } - } - /** - * [FUNCTION] CRC32Automaton::update(CRC32, array) -> void - * Source: java/util/zip/CRC32.automaton.lsl:178 - */ - public void update(byte[] b) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - final int len = b.length; - Engine.assume(len >= 0); - _updateCheck(b, 0, len); - _updateBytesCheck(b, 0, len); + if (buffer.hasArray()) { + int off = buffer.arrayOffset() + pos; + byte[] bufferArray = buffer.array(); + _updateBytesCheck(bufferArray, off, rem); this.crc = Engine.makeSymbolicInt(); + buffer.position(limit); + return; } - } - /** - * [FUNCTION] CRC32Automaton::update(CRC32, array, int, int) -> void - * Source: java/util/zip/CRC32.automaton.lsl:188 - */ - public void update(byte[] b, int off, int len) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - _updateCheck(b, off, len); - _updateBytesCheck(b, off, len); - this.crc = Engine.makeSymbolicInt(); + int len = 4096; + int b_rem = buffer.remaining(); + if (b_rem < len) + len = b_rem; + byte[] b = new byte[len]; + int b_size = b.length; + Engine.assume(b_size >= 0); + while (buffer.hasRemaining()) { + int length = buffer.remaining(); + if (b_size < length) + length = b_size; + buffer.get(b, 0, length); + _updateCheck(b, 0, length); + _updateBytesCheck(b, 0, length); } + this.crc = Engine.makeSymbolicInt(); + buffer.position(limit); } - /** - * [FUNCTION] CRC32Automaton::update(CRC32, int) -> void - * Source: java/util/zip/CRC32.automaton.lsl:196 - */ - public void update(int b) { - Engine.assume(this.__$lsl_state == __$lsl_States.Initialized); - /* body */ { - this.crc = Engine.makeSymbolicInt(); - } + @SuppressWarnings("ConstantValue") + public void update(byte[] b) { + int len = b.length; + Engine.assume(len >= 0); + _updateCheck(b, 0, len); + _updateBytesCheck(b, 0, len); + this.crc = Engine.makeSymbolicInt(); } - public static final class __$lsl_States { - public static final byte Allocated = (byte) 0; - - public static final byte Initialized = (byte) 1; + public void update(byte[] b, int off, int len) { + _updateCheck(b, off, len); + _updateBytesCheck(b, off, len); + this.crc = Engine.makeSymbolicInt(); } - @Approximate(CRC32.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } + public void update(int b) { + this.crc = Engine.makeSymbolicInt(); } } diff --git a/approximations/src/main/java/generated/libsl/utils/SymbolicInputStream.java b/approximations/src/main/java/generated/libsl/utils/SymbolicInputStream.java deleted file mode 100644 index 596b7801..00000000 --- a/approximations/src/main/java/generated/libsl/utils/SymbolicInputStream.java +++ /dev/null @@ -1,415 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - libsl/utils/SymbolicInputStream.lsl:15 -// - libsl/utils/SymbolicInputStream.main.lsl:16 -// -package generated.libsl.utils; - -import java.io.IOException; -import java.io.OutputStream; -import java.lang.IllegalArgumentException; -import java.lang.IndexOutOfBoundsException; -import java.lang.NullPointerException; -import java.lang.SuppressWarnings; -import java.lang.Void; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; - -/** - * SymbolicInputStreamAutomaton for SymbolicInputStream ~> libsl.utils.SymbolicInputStream - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(stub.libsl.utils.SymbolicInputStream.class) -public final class SymbolicInputStream implements LibSLRuntime.Automaton { - static { - Engine.assume(true); - } - - public final int maxSize; - - public final boolean supportMarks; - - public volatile int dataSize; - - public volatile byte[] data; - - public volatile boolean closed; - - public volatile int pos; - - public int markPos; - - public int markLimit; - - @LibSLRuntime.AutomatonConstructor - public SymbolicInputStream(Void __$lsl_token, final byte p0, final int p1, final boolean p2, - final int p3, final byte[] p4, final boolean p5, final int p6, final int p7, - final int p8) { - this.maxSize = p1; - this.supportMarks = p2; - this.dataSize = p3; - this.data = p4; - this.closed = p5; - this.pos = p6; - this.markPos = p7; - this.markLimit = p8; - } - - @LibSLRuntime.AutomatonConstructor - public SymbolicInputStream(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Initialized, 0, false, -1, null, false, 0, -1, 0); - } - - /** - * [SUBROUTINE] SymbolicInputStreamAutomaton::_initBuffer() -> void - * Source: libsl/utils/SymbolicInputStream.main.lsl:57 - */ - private void _initBuffer() { - /* body */ { - if (this.data == null) { - Engine.assume(this.maxSize > 0); - final int newSize = Engine.makeSymbolicInt(); - Engine.assume(0 <= newSize); - Engine.assume(newSize < this.maxSize); - this.dataSize = newSize; - if (newSize == 0) { - this.data = new byte[0]; - } else { - this.data = Engine.makeSymbolicByteArray(newSize); - } - Engine.assume(this.data != null); - Engine.assume(this.dataSize == this.data.length); - } - } - } - - /** - * [SUBROUTINE] SymbolicInputStreamAutomaton::_checkFromIndexSize(int, int, int) -> void - * Source: libsl/utils/SymbolicInputStream.main.lsl:99 - */ - private void _checkFromIndexSize(int fromIndex, int size, int length) { - /* body */ { - if (((length | fromIndex | size) < 0) || (size > (length - fromIndex))) { - throw new IndexOutOfBoundsException("Range [%s, % void - * Source: libsl/utils/SymbolicInputStream.main.lsl:107 - */ - private void _updatePosition(int delta) { - /* body */ { - this.pos += delta; - if (this.markPos != -1) { - if (this.pos >= this.markLimit) { - this.markPos = -1; - } - } - } - } - - /** - * [SUBROUTINE] SymbolicInputStreamAutomaton::_moveDataTo(array, int, int) -> int - * Source: libsl/utils/SymbolicInputStream.main.lsl:117 - */ - private int _moveDataTo(byte[] dest, int offset, int count) { - int result = 0; - /* body */ { - result = 0; - final int available = this.dataSize - this.pos; - if (available != 0) { - Engine.assume(available > 0); - if (available < count) { - count = available; - } - LibSLRuntime.ArrayActions.copy(this.data, this.pos, dest, offset, count); - _updatePosition(count); - result = count; - } - } - return result; - } - - /** - * [FUNCTION] SymbolicInputStreamAutomaton::available(SymbolicInputStream) -> int - * Source: libsl/utils/SymbolicInputStream.main.lsl:143 - */ - public int available() throws java.io.IOException { - int result = 0; - /* body */ { - if (this.closed) { - throw new IOException("Stream closed"); - } - if (this.data == null) { - _initBuffer(); - } - Engine.assume(this.dataSize >= 0); - result = this.dataSize - this.pos; - } - return result; - } - - /** - * [FUNCTION] SymbolicInputStreamAutomaton::close(SymbolicInputStream) -> void - * Source: libsl/utils/SymbolicInputStream.main.lsl:151 - */ - public void close() throws java.io.IOException { - /* body */ { - this.closed = true; - } - } - - /** - * [FUNCTION] SymbolicInputStreamAutomaton::mark(SymbolicInputStream, int) -> void - * Source: libsl/utils/SymbolicInputStream.main.lsl:159 - */ - public void mark(int readlimit) { - /* body */ { - if (this.supportMarks) { - this.markPos = this.pos; - this.markLimit = readlimit; - } - } - } - - /** - * [FUNCTION] SymbolicInputStreamAutomaton::markSupported(SymbolicInputStream) -> boolean - * Source: libsl/utils/SymbolicInputStream.main.lsl:170 - */ - public boolean markSupported() { - boolean result = false; - /* body */ { - result = this.supportMarks; - } - return result; - } - - /** - * [FUNCTION] SymbolicInputStreamAutomaton::read(SymbolicInputStream) -> int - * Source: libsl/utils/SymbolicInputStream.main.lsl:176 - */ - public int read() throws java.io.IOException { - int result = 0; - /* body */ { - if (this.closed) { - throw new IOException("Stream closed"); - } - if (this.data == null) { - _initBuffer(); - } - Engine.assume(this.dataSize >= 0); - result = -1; - } - return result; - } - - /** - * [FUNCTION] SymbolicInputStreamAutomaton::read(SymbolicInputStream, array) -> int - * Source: libsl/utils/SymbolicInputStream.main.lsl:184 - */ - public int read(byte[] b) throws java.io.IOException { - int result = 0; - /* body */ { - final int len = b.length; - if (len == 0) { - result = 0; - } else { - Engine.assume(len > 0); - if (this.closed) { - throw new IOException("Stream closed"); - } - if (this.data == null) { - _initBuffer(); - } - Engine.assume(this.dataSize >= 0); - result = _moveDataTo(b, 0, len); - } - } - return result; - } - - /** - * [FUNCTION] SymbolicInputStreamAutomaton::read(SymbolicInputStream, array, int, int) -> int - * Source: libsl/utils/SymbolicInputStream.main.lsl:202 - */ - public int read(byte[] b, int off, int len) throws java.io.IOException { - int result = 0; - /* body */ { - _checkFromIndexSize(off, len, b.length); - if (len == 0) { - result = 0; - } else { - if (this.closed) { - throw new IOException("Stream closed"); - } - if (this.data == null) { - _initBuffer(); - } - Engine.assume(this.dataSize >= 0); - result = _moveDataTo(b, off, len); - } - } - return result; - } - - /** - * [FUNCTION] SymbolicInputStreamAutomaton::readAllBytes(SymbolicInputStream) -> array - * Source: libsl/utils/SymbolicInputStream.main.lsl:218 - */ - public byte[] readAllBytes() throws java.io.IOException { - byte[] result = null; - /* body */ { - if (this.closed) { - throw new IOException("Stream closed"); - } - if (this.data == null) { - _initBuffer(); - } - Engine.assume(this.dataSize >= 0); - if (this.pos == 0) { - result = this.data; - _updatePosition(this.dataSize); - } else { - if (this.pos == this.dataSize) { - result = new byte[0]; - } else { - final int len = this.dataSize - this.pos; - Engine.assume(len > 0); - result = new byte[len]; - _moveDataTo(result, 0, len); - } - } - } - return result; - } - - /** - * [FUNCTION] SymbolicInputStreamAutomaton::readNBytes(SymbolicInputStream, array, int, int) -> int - * Source: libsl/utils/SymbolicInputStream.main.lsl:243 - */ - public int readNBytes(byte[] b, int off, int len) throws java.io.IOException { - int result = 0; - /* body */ { - _checkFromIndexSize(off, len, b.length); - if (this.closed) { - throw new IOException("Stream closed"); - } - if (this.data == null) { - _initBuffer(); - } - Engine.assume(this.dataSize >= 0); - if (len == 0) { - result = 0; - } else { - result = _moveDataTo(b, off, len); - } - } - return result; - } - - /** - * [FUNCTION] SymbolicInputStreamAutomaton::readNBytes(SymbolicInputStream, int) -> array - * Source: libsl/utils/SymbolicInputStream.main.lsl:256 - */ - public byte[] readNBytes(int len) throws java.io.IOException { - byte[] result = null; - /* body */ { - if (len < 0) { - throw new IllegalArgumentException("len < 0"); - } - if (this.closed) { - throw new IOException("Stream closed"); - } - if (this.data == null) { - _initBuffer(); - } - Engine.assume(this.dataSize >= 0); - if (len == 0) { - result = new byte[0]; - } else { - result = new byte[len]; - _moveDataTo(result, 0, len); - } - } - return result; - } - - /** - * [FUNCTION] SymbolicInputStreamAutomaton::reset(SymbolicInputStream) -> void - * Source: libsl/utils/SymbolicInputStream.main.lsl:275 - */ - public void reset() throws java.io.IOException { - /* body */ { - if (this.supportMarks) { - if (this.closed) { - throw new IOException("Stream closed"); - } - if (this.data == null) { - _initBuffer(); - } - Engine.assume(this.dataSize >= 0); - if (this.markPos < 0) { - throw new IOException("Resetting to invalid mark"); - } - this.pos = this.markPos; - } else { - throw new IOException("mark/reset not supported"); - } - } - } - - /** - * [FUNCTION] SymbolicInputStreamAutomaton::skip(SymbolicInputStream, long) -> long - * Source: libsl/utils/SymbolicInputStream.main.lsl:294 - */ - public long skip(long n) throws java.io.IOException { - long result = 0L; - /* body */ { - if (this.closed) { - throw new IOException("Stream closed"); - } - if (this.data == null) { - _initBuffer(); - } - Engine.assume(this.dataSize >= 0); - result = 0L; - } - return result; - } - - /** - * [FUNCTION] SymbolicInputStreamAutomaton::transferTo(SymbolicInputStream, OutputStream) -> long - * Source: libsl/utils/SymbolicInputStream.main.lsl:302 - */ - public long transferTo(OutputStream output) throws java.io.IOException { - long result = 0L; - /* body */ { - if (output == null) { - throw new NullPointerException(); - } - if (this.closed) { - throw new IOException("Stream closed"); - } - if (this.data == null) { - _initBuffer(); - } - Engine.assume(this.dataSize >= 0); - result = 0L; - } - return result; - } - - public static final class __$lsl_States { - public static final byte Initialized = (byte) 0; - } - - @Approximate(SymbolicInputStream.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/libsl/utils/SymbolicInputStreamImpl.java b/approximations/src/main/java/generated/libsl/utils/SymbolicInputStreamImpl.java new file mode 100644 index 00000000..82d1ad8e --- /dev/null +++ b/approximations/src/main/java/generated/libsl/utils/SymbolicInputStreamImpl.java @@ -0,0 +1,232 @@ +package generated.libsl.utils; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.lang.IllegalArgumentException; +import java.lang.IndexOutOfBoundsException; +import java.lang.NullPointerException; +import java.lang.SuppressWarnings; + +import org.jacodb.approximation.annotation.Approximate; +import org.jetbrains.annotations.NotNull; +import org.usvm.api.Engine; +import runtime.LibSLRuntime; +import stub.libsl.utils.SymbolicInputStream; + +@Approximate(SymbolicInputStream.class) +public final class SymbolicInputStreamImpl extends InputStream { + + public final int maxSize; + + public final boolean supportMarks; + + public volatile int dataSize; + + public volatile byte[] data; + + public volatile boolean closed; + + public volatile int pos; + + public int markPos; + + public int markLimit; + + public SymbolicInputStreamImpl( + int maxSize, + boolean supportMarks, + int dataSize, + byte[] data, + boolean closed, + int pos, + int markPos, + int markLimit8 + ) { + this.maxSize = maxSize; + this.supportMarks = supportMarks; + this.dataSize = dataSize; + this.data = data; + this.closed = closed; + this.pos = pos; + this.markPos = markPos; + this.markLimit = markLimit8; + } + + private void _initBuffer() { + if (this.data != null) + return; + + Engine.assume(this.maxSize > 0); + int newSize = Engine.makeSymbolicInt(); + Engine.assume(0 <= newSize); + Engine.assume(newSize < this.maxSize); + this.dataSize = newSize; + if (newSize == 0) { + this.data = new byte[0]; + } else { + this.data = Engine.makeSymbolicByteArray(newSize); + } + Engine.assume(this.data != null); + Engine.assume(this.dataSize == this.data.length); + } + + public static void _checkFromIndexSize(int fromIndex, int size, int length) { + if (length < 0 || fromIndex < 0 || size < 0 || size > length - fromIndex) { + throw new IndexOutOfBoundsException("Range [%s, %= this.markLimit) + this.markPos = -1; + } + + private int _moveDataTo(byte[] dest, int offset, int count) { + int available = this.dataSize - this.pos; + if (available != 0) { + Engine.assume(available > 0); + if (available < count) + count = available; + LibSLRuntime.ArrayActions.copy(this.data, this.pos, dest, offset, count); + _updatePosition(count); + return count; + } + + return 0; + } + + public int available() throws java.io.IOException { + _checkClosed(); + _initBuffer(); + + Engine.assume(this.dataSize >= 0); + return this.dataSize - this.pos; + } + + public void close() throws java.io.IOException { + this.closed = true; + } + + public void mark(int readLimit) { + if (this.supportMarks) { + this.markPos = this.pos; + this.markLimit = readLimit; + } + } + + public boolean markSupported() { + return this.supportMarks; + } + + public int read() throws java.io.IOException { + _checkClosed(); + _initBuffer(); + + Engine.assume(this.dataSize >= 0); + return -1; + } + + @SuppressWarnings("ConstantValue") + public int read(@NotNull byte[] b) throws java.io.IOException { + int len = b.length; + if (len == 0) + return 0; + + Engine.assume(len > 0); + _checkClosed(); + _initBuffer(); + Engine.assume(this.dataSize >= 0); + return _moveDataTo(b, 0, len); + } + + public int read(@NotNull byte[] b, int off, int len) throws java.io.IOException { + _checkFromIndexSize(off, len, b.length); + if (len == 0) + return 0; + + _checkClosed(); + _initBuffer(); + Engine.assume(this.dataSize >= 0); + return _moveDataTo(b, off, len); + } + + public byte[] readAllBytes() throws java.io.IOException { + _checkClosed(); + _initBuffer(); + Engine.assume(this.dataSize >= 0); + if (this.pos == 0) { + _updatePosition(this.dataSize); + return this.data; + } + + if (this.pos == this.dataSize) + return new byte[0]; + + int len = this.dataSize - this.pos; + Engine.assume(len > 0); + byte[] result = new byte[len]; + _moveDataTo(result, 0, len); + return result; + } + + public int readNBytes(byte[] b, int off, int len) throws java.io.IOException { + _checkFromIndexSize(off, len, b.length); + _checkClosed(); + _initBuffer(); + Engine.assume(this.dataSize >= 0); + if (len == 0) + return 0; + + return _moveDataTo(b, off, len); + } + + public byte[] readNBytes(int len) throws java.io.IOException { + if (len < 0) + throw new IllegalArgumentException("len < 0"); + _checkClosed(); + _initBuffer(); + Engine.assume(this.dataSize >= 0); + if (len == 0) + return new byte[0]; + + byte[] result = new byte[len]; + _moveDataTo(result, 0, len); + return result; + } + + public void reset() throws java.io.IOException { + if (!this.supportMarks) + throw new IOException("mark/reset not supported"); + + _checkClosed(); + _initBuffer(); + Engine.assume(this.dataSize >= 0); + if (this.markPos < 0) + throw new IOException("Resetting to invalid mark"); + this.pos = this.markPos; + } + + public long skip(long n) throws java.io.IOException { + _checkClosed(); + _initBuffer(); + Engine.assume(this.dataSize >= 0); + return 0L; + } + + public long transferTo(OutputStream output) throws java.io.IOException { + if (output == null) + throw new NullPointerException(); + _checkClosed(); + _initBuffer(); + Engine.assume(this.dataSize >= 0); + return 0L; + } +} diff --git a/approximations/src/main/java/generated/libsl/utils/VoidInputStream.java b/approximations/src/main/java/generated/libsl/utils/VoidInputStream.java deleted file mode 100644 index 605d3fbe..00000000 --- a/approximations/src/main/java/generated/libsl/utils/VoidInputStream.java +++ /dev/null @@ -1,256 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - libsl/utils/VoidInputStream.lsl:15 -// - libsl/utils/VoidInputStream.main.lsl:16 -// -package generated.libsl.utils; - -import java.io.IOException; -import java.io.OutputStream; -import java.lang.IllegalArgumentException; -import java.lang.IndexOutOfBoundsException; -import java.lang.NullPointerException; -import java.lang.SuppressWarnings; -import java.lang.Void; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; - -/** - * VoidInputStreamAutomaton for VoidInputStream ~> libsl.utils.VoidInputStream - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(stub.libsl.utils.VoidInputStream.class) -public final class VoidInputStream implements LibSLRuntime.Automaton { - static { - Engine.assume(true); - } - - public volatile boolean closed; - - @LibSLRuntime.AutomatonConstructor - public VoidInputStream(Void __$lsl_token, final byte p0, final boolean p1) { - this.closed = p1; - } - - @LibSLRuntime.AutomatonConstructor - public VoidInputStream(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Initialized, false); - } - - /** - * [SUBROUTINE] VoidInputStreamAutomaton::_checkFromIndexSize(int, int, int) -> void - * Source: libsl/utils/VoidInputStream.main.lsl:55 - */ - private void _checkFromIndexSize(int fromIndex, int size, int length) { - /* body */ { - if (((length | fromIndex | size) < 0) || (size > (length - fromIndex))) { - throw new IndexOutOfBoundsException("Range [%s, % int - * Source: libsl/utils/VoidInputStream.main.lsl:69 - */ - public int available() throws java.io.IOException { - int result = 0; - /* body */ { - if (this.closed) { - throw new IOException("Stream closed"); - } - result = 0; - } - return result; - } - - /** - * [FUNCTION] VoidInputStreamAutomaton::close(VoidInputStream) -> void - * Source: libsl/utils/VoidInputStream.main.lsl:77 - */ - public void close() throws java.io.IOException { - /* body */ { - this.closed = true; - } - } - - /** - * [FUNCTION] VoidInputStreamAutomaton::mark(VoidInputStream, int) -> void - * Source: libsl/utils/VoidInputStream.main.lsl:85 - */ - public synchronized void mark(int readlimit) { - /* body */ { - } - } - - /** - * [FUNCTION] VoidInputStreamAutomaton::markSupported(VoidInputStream) -> boolean - * Source: libsl/utils/VoidInputStream.main.lsl:92 - */ - public boolean markSupported() { - boolean result = false; - /* body */ { - result = false; - } - return result; - } - - /** - * [FUNCTION] VoidInputStreamAutomaton::read(VoidInputStream) -> int - * Source: libsl/utils/VoidInputStream.main.lsl:98 - */ - public int read() throws java.io.IOException { - int result = 0; - /* body */ { - if (this.closed) { - throw new IOException("Stream closed"); - } - result = -1; - } - return result; - } - - /** - * [FUNCTION] VoidInputStreamAutomaton::read(VoidInputStream, array) -> int - * Source: libsl/utils/VoidInputStream.main.lsl:106 - */ - public int read(byte[] b) throws java.io.IOException { - int result = 0; - /* body */ { - if (b.length == 0) { - result = 0; - } else { - if (this.closed) { - throw new IOException("Stream closed"); - } - result = -1; - } - } - return result; - } - - /** - * [FUNCTION] VoidInputStreamAutomaton::read(VoidInputStream, array, int, int) -> int - * Source: libsl/utils/VoidInputStream.main.lsl:122 - */ - public int read(byte[] b, int off, int len) throws java.io.IOException { - int result = 0; - /* body */ { - _checkFromIndexSize(off, len, b.length); - if (len == 0) { - result = 0; - } else { - if (this.closed) { - throw new IOException("Stream closed"); - } - result = -1; - } - } - return result; - } - - /** - * [FUNCTION] VoidInputStreamAutomaton::readAllBytes(VoidInputStream) -> array - * Source: libsl/utils/VoidInputStream.main.lsl:138 - */ - public byte[] readAllBytes() throws java.io.IOException { - byte[] result = null; - /* body */ { - if (this.closed) { - throw new IOException("Stream closed"); - } - result = new byte[0]; - } - return result; - } - - /** - * [FUNCTION] VoidInputStreamAutomaton::readNBytes(VoidInputStream, array, int, int) -> int - * Source: libsl/utils/VoidInputStream.main.lsl:146 - */ - public int readNBytes(byte[] b, int off, int len) throws java.io.IOException { - int result = 0; - /* body */ { - _checkFromIndexSize(off, len, b.length); - if (this.closed) { - throw new IOException("Stream closed"); - } - result = 0; - } - return result; - } - - /** - * [FUNCTION] VoidInputStreamAutomaton::readNBytes(VoidInputStream, int) -> array - * Source: libsl/utils/VoidInputStream.main.lsl:155 - */ - public byte[] readNBytes(int len) throws java.io.IOException { - byte[] result = null; - /* body */ { - if (len < 0) { - throw new IllegalArgumentException("len < 0"); - } else { - if (this.closed) { - throw new IOException("Stream closed"); - } - result = new byte[0]; - } - } - return result; - } - - /** - * [FUNCTION] VoidInputStreamAutomaton::reset(VoidInputStream) -> void - * Source: libsl/utils/VoidInputStream.main.lsl:170 - */ - public synchronized void reset() throws java.io.IOException { - /* body */ { - throw new IOException("mark/reset not supported"); - } - } - - /** - * [FUNCTION] VoidInputStreamAutomaton::skip(VoidInputStream, long) -> long - * Source: libsl/utils/VoidInputStream.main.lsl:178 - */ - public long skip(long n) throws java.io.IOException { - long result = 0L; - /* body */ { - if (this.closed) { - throw new IOException("Stream closed"); - } - result = 0L; - } - return result; - } - - /** - * [FUNCTION] VoidInputStreamAutomaton::transferTo(VoidInputStream, OutputStream) -> long - * Source: libsl/utils/VoidInputStream.main.lsl:186 - */ - public long transferTo(OutputStream output) throws java.io.IOException { - long result = 0L; - /* body */ { - if (output == null) { - throw new NullPointerException(); - } - if (this.closed) { - throw new IOException("Stream closed"); - } - result = 0L; - } - return result; - } - - public static final class __$lsl_States { - public static final byte Initialized = (byte) 0; - } - - @Approximate(VoidInputStream.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/libsl/utils/VoidInputStreamImpl.java b/approximations/src/main/java/generated/libsl/utils/VoidInputStreamImpl.java new file mode 100644 index 00000000..9e768177 --- /dev/null +++ b/approximations/src/main/java/generated/libsl/utils/VoidInputStreamImpl.java @@ -0,0 +1,116 @@ +package generated.libsl.utils; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.lang.IllegalArgumentException; +import java.lang.NullPointerException; +import java.lang.SuppressWarnings; + +import org.jacodb.approximation.annotation.Approximate; +import org.jetbrains.annotations.NotNull; +import stub.libsl.utils.VoidInputStream; + +@SuppressWarnings("unused") +@Approximate(VoidInputStream.class) +public final class VoidInputStreamImpl extends InputStream { + + public volatile boolean closed; + + public VoidInputStreamImpl(boolean p1) { + this.closed = p1; + } + + public int available() throws java.io.IOException { + if (this.closed) + throw new IOException("Stream closed"); + + return 0; + } + + public void close() throws java.io.IOException { + this.closed = true; + } + + public synchronized void mark(int readLimit) { + } + + @SuppressWarnings("RedundantMethodOverride") + public boolean markSupported() { + return false; + } + + public int read() throws java.io.IOException { + if (this.closed) + throw new IOException("Stream closed"); + + return -1; + } + + public int read(@NotNull byte[] b) throws java.io.IOException { + if (b.length == 0) + return 0; + + if (this.closed) + throw new IOException("Stream closed"); + + return -1; + } + + public int read(@NotNull byte[] b, int off, int len) throws java.io.IOException { + SymbolicInputStreamImpl._checkFromIndexSize(off, len, b.length); + if (len == 0) + return 0; + + if (this.closed) + throw new IOException("Stream closed"); + + return -1; + } + + public byte[] readAllBytes() throws java.io.IOException { + if (this.closed) + throw new IOException("Stream closed"); + + return new byte[0]; + } + + public int readNBytes(byte[] b, int off, int len) throws java.io.IOException { + SymbolicInputStreamImpl._checkFromIndexSize(off, len, b.length); + if (this.closed) + throw new IOException("Stream closed"); + + return 0; + } + + public byte[] readNBytes(int len) throws java.io.IOException { + if (len < 0) + throw new IllegalArgumentException("len < 0"); + + if (this.closed) + throw new IOException("Stream closed"); + + return new byte[0]; + } + + public synchronized void reset() throws java.io.IOException { + throw new IOException("mark/reset not supported"); + } + + public long skip(long n) throws java.io.IOException { + if (this.closed) + throw new IOException("Stream closed"); + + return 0L; + } + + public long transferTo(OutputStream output) throws java.io.IOException { + if (output == null) + throw new NullPointerException(); + + if (this.closed) + throw new IOException("Stream closed"); + + return 0L; + } +} diff --git a/approximations/src/main/java/generated/libsl/utils/VoidOutputStream.java b/approximations/src/main/java/generated/libsl/utils/VoidOutputStream.java deleted file mode 100644 index 77997694..00000000 --- a/approximations/src/main/java/generated/libsl/utils/VoidOutputStream.java +++ /dev/null @@ -1,120 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - libsl/utils/VoidOutputStream.lsl:15 -// - libsl/utils/VoidOutputStream.main.lsl:16 -// -package generated.libsl.utils; - -import java.io.IOException; -import java.lang.IndexOutOfBoundsException; -import java.lang.NullPointerException; -import java.lang.SuppressWarnings; -import java.lang.Void; -import org.jacodb.approximation.annotation.Approximate; -import org.usvm.api.Engine; -import runtime.LibSLRuntime; - -/** - * VoidOutputStreamAutomaton for VoidOutputStream ~> libsl.utils.VoidOutputStream - */ -@SuppressWarnings({"all", "unchecked"}) -@Approximate(stub.libsl.utils.VoidOutputStream.class) -public final class VoidOutputStream implements LibSLRuntime.Automaton { - static { - Engine.assume(true); - } - - public volatile boolean closed; - - @LibSLRuntime.AutomatonConstructor - public VoidOutputStream(Void __$lsl_token, final byte p0, final boolean p1) { - this.closed = p1; - } - - @LibSLRuntime.AutomatonConstructor - public VoidOutputStream(final Void __$lsl_token) { - this(__$lsl_token, __$lsl_States.Initialized, false); - } - - /** - * [SUBROUTINE] VoidOutputStreamAutomaton::_checkFromIndexSize(int, int, int) -> void - * Source: libsl/utils/VoidOutputStream.main.lsl:47 - */ - private void _checkFromIndexSize(int fromIndex, int size, int length) { - /* body */ { - if (((length | fromIndex | size) < 0) || (size > (length - fromIndex))) { - throw new IndexOutOfBoundsException("Range [%s, % void - * Source: libsl/utils/VoidOutputStream.main.lsl:61 - */ - public void close() { - /* body */ { - this.closed = true; - } - } - - /** - * [FUNCTION] VoidOutputStreamAutomaton::flush(VoidOutputStream) -> void - * Source: libsl/utils/VoidOutputStream.main.lsl:67 - */ - public void flush() throws java.io.IOException { - /* body */ { - } - } - - /** - * [FUNCTION] VoidOutputStreamAutomaton::write(VoidOutputStream, array) -> void - * Source: libsl/utils/VoidOutputStream.main.lsl:75 - */ - public void write(byte[] b) throws java.io.IOException { - /* body */ { - if (b == null) { - throw new NullPointerException(); - } - if (this.closed) { - throw new IOException("Stream closed"); - } - } - } - - /** - * [FUNCTION] VoidOutputStreamAutomaton::write(VoidOutputStream, array, int, int) -> void - * Source: libsl/utils/VoidOutputStream.main.lsl:86 - */ - public void write(byte[] b, int off, int len) throws java.io.IOException { - /* body */ { - _checkFromIndexSize(off, len, b.length); - if (this.closed) { - throw new IOException("Stream closed"); - } - } - } - - /** - * [FUNCTION] VoidOutputStreamAutomaton::write(VoidOutputStream, int) -> void - * Source: libsl/utils/VoidOutputStream.main.lsl:94 - */ - public void write(int b) throws java.io.IOException { - /* body */ { - if (this.closed) { - throw new IOException("Stream closed"); - } - } - } - - public static final class __$lsl_States { - public static final byte Initialized = (byte) 0; - } - - @Approximate(VoidOutputStream.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } -} diff --git a/approximations/src/main/java/generated/libsl/utils/VoidOutputStreamImpl.java b/approximations/src/main/java/generated/libsl/utils/VoidOutputStreamImpl.java new file mode 100644 index 00000000..76c54f31 --- /dev/null +++ b/approximations/src/main/java/generated/libsl/utils/VoidOutputStreamImpl.java @@ -0,0 +1,47 @@ +package generated.libsl.utils; + +import java.io.IOException; +import java.io.OutputStream; +import java.lang.NullPointerException; +import java.lang.SuppressWarnings; + +import org.jacodb.approximation.annotation.Approximate; +import org.jetbrains.annotations.NotNull; +import stub.libsl.utils.VoidOutputStream; + +@SuppressWarnings("unused") +@Approximate(VoidOutputStream.class) +public final class VoidOutputStreamImpl extends OutputStream { + + public volatile boolean closed; + + public VoidOutputStreamImpl(boolean p1) { + this.closed = p1; + } + + public void close() { + this.closed = true; + } + + @SuppressWarnings({"RedundantMethodOverride", "RedundantThrows"}) + public void flush() throws java.io.IOException { } + + @SuppressWarnings("ConstantValue") + public void write(@NotNull byte[] b) throws java.io.IOException { + if (b == null) + throw new NullPointerException(); + if (this.closed) + throw new IOException("Stream closed"); + } + + public void write(@NotNull byte[] b, int off, int len) throws java.io.IOException { + SymbolicInputStreamImpl._checkFromIndexSize(off, len, b.length); + if (this.closed) + throw new IOException("Stream closed"); + } + + public void write(int b) throws java.io.IOException { + if (this.closed) + throw new IOException("Stream closed"); + } +} diff --git a/approximations/src/main/java/generated/org/apache/commons/logging/LogImpl.java b/approximations/src/main/java/generated/org/apache/commons/logging/LogImpl.java new file mode 100644 index 00000000..10629579 --- /dev/null +++ b/approximations/src/main/java/generated/org/apache/commons/logging/LogImpl.java @@ -0,0 +1,56 @@ +package generated.org.apache.commons.logging; + +import org.jacodb.approximation.annotation.Approximate; + +@SuppressWarnings("unused") +@Approximate(org.apache.commons.logging.Log.class) +public class LogImpl { + + final boolean isFatalEnabled() { + return false; + } + + final boolean isErrorEnabled() { + return false; + } + + final boolean isWarnEnabled() { + return false; + } + + final boolean isInfoEnabled() { + return false; + } + + final boolean isDebugEnabled() { + return false; + } + + final boolean isTraceEnabled() { + return false; + } + + final void fatal(Object message) { } + + final void fatal(Object message, Throwable t) { } + + final void error(Object message) { } + + final void error(Object message, Throwable t) { } + + final void warn(Object message) { } + + final void warn(Object message, Throwable t) { } + + final void info(Object message) { } + + final void info(Object message, Throwable t) { } + + final void debug(Object message) { } + + final void debug(Object message, Throwable t) { } + + final void trace(Object message) { } + + final void trace(Object message, Throwable t) { } +} diff --git a/approximations/src/main/java/generated/org/springframework/boot/ClassUtilsImpl.java b/approximations/src/main/java/generated/org/springframework/boot/ClassUtilsImpl.java new file mode 100644 index 00000000..2828168e --- /dev/null +++ b/approximations/src/main/java/generated/org/springframework/boot/ClassUtilsImpl.java @@ -0,0 +1,19 @@ +package generated.org.springframework.boot; + +import org.jacodb.approximation.annotation.Approximate; +import org.springframework.util.ClassUtils; + +@Approximate(ClassUtils.class) +public abstract class ClassUtilsImpl { + + private static String getMainPackageName() { + throw new IllegalStateException("'getMainPackageName' should be approximated"); + } + + public static String getPackageName(Class clazz) { + if (clazz.getName().equals("StartSpringTestClass")) + return ClassUtilsImpl.getMainPackageName(); + + return clazz.getPackageName(); + } +} diff --git a/approximations/src/main/java/generated/org/springframework/boot/ErrorsMethodArgumentResolverImpl.java b/approximations/src/main/java/generated/org/springframework/boot/ErrorsMethodArgumentResolverImpl.java new file mode 100644 index 00000000..475effc1 --- /dev/null +++ b/approximations/src/main/java/generated/org/springframework/boot/ErrorsMethodArgumentResolverImpl.java @@ -0,0 +1,28 @@ +package generated.org.springframework.boot; + +import org.jacodb.approximation.annotation.Approximate; +import org.springframework.core.MethodParameter; +import org.springframework.lang.Nullable; +import org.springframework.ui.ModelMap; +import org.springframework.util.Assert; +import org.springframework.util.CollectionUtils; +import org.springframework.web.bind.support.WebDataBinderFactory; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.method.support.ModelAndViewContainer; + +@SuppressWarnings("unused") +@Approximate(org.springframework.web.method.annotation.ErrorsMethodArgumentResolver.class) +public class ErrorsMethodArgumentResolverImpl { + + @SuppressWarnings("RedundantThrows") + public Object resolveArgument(MethodParameter parameter, @Nullable ModelAndViewContainer mavContainer, NativeWebRequest webRequest, @Nullable WebDataBinderFactory binderFactory) throws Exception { + Assert.state(mavContainer != null, "Errors/BindingResult argument only supported on regular handler methods"); + ModelMap model = mavContainer.getModel(); + String lastKey = CollectionUtils.lastElement(model.keySet()); + if (lastKey != null) { + return model.get(lastKey); + } else { + throw new IllegalStateException("An Errors/BindingResult argument is expected to be declared immediately after the model attribute, the @RequestBody or the @RequestPart arguments to which they apply: " + parameter.getMethod()); + } + } +} diff --git a/approximations/src/main/java/generated/org/springframework/boot/LogFactoryImpl.java b/approximations/src/main/java/generated/org/springframework/boot/LogFactoryImpl.java new file mode 100644 index 00000000..28c01808 --- /dev/null +++ b/approximations/src/main/java/generated/org/springframework/boot/LogFactoryImpl.java @@ -0,0 +1,17 @@ +package generated.org.springframework.boot; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.impl.NoOpLog; +import org.jacodb.approximation.annotation.Approximate; + +@Approximate(org.apache.commons.logging.LogFactory.class) +public abstract class LogFactoryImpl { + + public static Log getLog(Class clazz) { + return new NoOpLog(); + } + + public static Log getLog(String name) { + return new NoOpLog(); + } +} diff --git a/approximations/src/main/java/generated/org/springframework/boot/MergedContextConfigurationImpl.java b/approximations/src/main/java/generated/org/springframework/boot/MergedContextConfigurationImpl.java new file mode 100644 index 00000000..5a183dac --- /dev/null +++ b/approximations/src/main/java/generated/org/springframework/boot/MergedContextConfigurationImpl.java @@ -0,0 +1,26 @@ +package generated.org.springframework.boot; + +import org.jacodb.approximation.annotation.Approximate; +import org.springframework.lang.Nullable; +import org.springframework.test.context.ContextCustomizer; +import org.springframework.test.context.MergedContextConfiguration; + +import java.util.Collections; +import java.util.Set; + +@Approximate(MergedContextConfiguration.class) +public class MergedContextConfigurationImpl { + + private static final Set EMPTY_CONTEXT_CUSTOMIZERS = Collections.emptySet(); + + private static Set processContextCustomizers( + @Nullable Set contextCustomizers + ) { + if (contextCustomizers == null) + return EMPTY_CONTEXT_CUSTOMIZERS; + + contextCustomizers.removeIf(it -> it.getClass().getName().contains("TypeExcludeFiltersContextCustomizer")); + + return contextCustomizers; + } +} diff --git a/approximations/src/main/java/generated/org/springframework/boot/PathVariableMethodArgumentResolverImpl.java b/approximations/src/main/java/generated/org/springframework/boot/PathVariableMethodArgumentResolverImpl.java new file mode 100644 index 00000000..91da2d61 --- /dev/null +++ b/approximations/src/main/java/generated/org/springframework/boot/PathVariableMethodArgumentResolverImpl.java @@ -0,0 +1,20 @@ +package generated.org.springframework.boot; + +import org.jacodb.approximation.annotation.Approximate; +import org.springframework.core.MethodParameter; +import org.springframework.lang.Nullable; +import org.springframework.web.bind.support.WebDataBinderFactory; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.method.support.ModelAndViewContainer; + +import static generated.org.springframework.boot.SymbolicValueFactory.createSymbolic; + +@Approximate(org.springframework.web.servlet.mvc.method.annotation.PathVariableMethodArgumentResolver.class) +public class PathVariableMethodArgumentResolverImpl { + + public final Object resolveArgument(MethodParameter parameter, @Nullable ModelAndViewContainer mavContainer, + NativeWebRequest webRequest, @Nullable WebDataBinderFactory binderFactory) throws Exception { + Class paramType = parameter.getParameterType(); + return createSymbolic(paramType); + } +} diff --git a/approximations/src/main/java/generated/org/springframework/boot/RequestParamMethodArgumentResolverImpl.java b/approximations/src/main/java/generated/org/springframework/boot/RequestParamMethodArgumentResolverImpl.java new file mode 100644 index 00000000..6751c96a --- /dev/null +++ b/approximations/src/main/java/generated/org/springframework/boot/RequestParamMethodArgumentResolverImpl.java @@ -0,0 +1,20 @@ +package generated.org.springframework.boot; + +import org.jacodb.approximation.annotation.Approximate; +import org.springframework.core.MethodParameter; +import org.springframework.lang.Nullable; +import org.springframework.web.bind.support.WebDataBinderFactory; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.method.support.ModelAndViewContainer; + +import static generated.org.springframework.boot.SymbolicValueFactory.createSymbolic; + +@Approximate(org.springframework.web.method.annotation.RequestParamMethodArgumentResolver.class) +public class RequestParamMethodArgumentResolverImpl { + + public final Object resolveArgument(MethodParameter parameter, @Nullable ModelAndViewContainer mavContainer, + NativeWebRequest webRequest, @Nullable WebDataBinderFactory binderFactory) throws Exception { + Class paramType = parameter.getParameterType(); + return createSymbolic(paramType); + } +} diff --git a/approximations/src/main/java/generated/org/springframework/boot/SpringApplicationImpl.java b/approximations/src/main/java/generated/org/springframework/boot/SpringApplicationImpl.java new file mode 100644 index 00000000..1c26d62f --- /dev/null +++ b/approximations/src/main/java/generated/org/springframework/boot/SpringApplicationImpl.java @@ -0,0 +1,74 @@ +package generated.org.springframework.boot; + +import jakarta.servlet.Filter; +import org.jacodb.approximation.annotation.Approximate; +import org.springframework.boot.ApplicationArguments; +import org.springframework.boot.ApplicationContextFactory; +import org.springframework.boot.context.logging.LoggingApplicationListener; +import org.springframework.context.ApplicationListener; +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.setup.DefaultMockMvcBuilder; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.web.context.WebApplicationContext; + +import java.util.*; + +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; + +@Approximate(org.springframework.boot.SpringApplication.class) +public class SpringApplicationImpl { + + private List> listeners; + + private ApplicationContextFactory applicationContextFactory = ApplicationContextFactory.DEFAULT; + + private boolean registerShutdownHook = true; + + private Map>> allControllerPaths() { + return new HashMap<>(); + } + + protected void afterRefresh(ConfigurableApplicationContext context, ApplicationArguments args) { + startAnalysis(); + Object[] beans = context.getBeansOfType(Filter.class).values().toArray(); + Filter[] filters = Arrays.copyOf(beans, beans.length, Filter[].class); + DefaultMockMvcBuilder builder = MockMvcBuilders.webAppContextSetup((WebApplicationContext) context); + for (Filter filter : filters) { + builder.addFilter(filter); + } + MockMvc mockMvc = builder.build(); + Map>> allPaths = allControllerPaths(); + try { + for (String controllerName : allPaths.keySet()) { + Map> paths = allPaths.get(controllerName); + for (String path : paths.keySet()) { + List properties = paths.get(path); + String kind = (String) properties.get(0); + Integer paramCount = (Integer) properties.get(1); + Object[] pathArgs = new Object[paramCount]; + if (kind.equals("get")) + mockMvc.perform(get(path, pathArgs)); + if (kind.equals("post")) + mockMvc.perform(post(path, pathArgs)); + if (kind.equals("put")) + mockMvc.perform(put(path, pathArgs)); + if (kind.equals("delete")) + mockMvc.perform(delete(path, pathArgs)); + if (kind.equals("patch")) + mockMvc.perform(patch(path, pathArgs)); + } + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + private void startAnalysis() { } + + public void setListeners(Collection> listeners) { + registerShutdownHook = false; + listeners.removeIf(it -> it instanceof LoggingApplicationListener); + this.listeners = new ArrayList<>(listeners); + } +} diff --git a/approximations/src/main/java/generated/org/springframework/boot/StartSpring.java b/approximations/src/main/java/generated/org/springframework/boot/StartSpring.java new file mode 100644 index 00000000..41c9969a --- /dev/null +++ b/approximations/src/main/java/generated/org/springframework/boot/StartSpring.java @@ -0,0 +1,11 @@ +package generated.org.springframework.boot; + +import org.springframework.test.context.TestContextManager; + +public class StartSpring { + + public static void startSpring() { + TestContextManager b = new TestContextManager(TestClass.class); + b.getTestContext().getApplicationContext(); + } +} diff --git a/approximations/src/main/java/generated/org/springframework/boot/SymbolicValueFactory.java b/approximations/src/main/java/generated/org/springframework/boot/SymbolicValueFactory.java new file mode 100644 index 00000000..57055eff --- /dev/null +++ b/approximations/src/main/java/generated/org/springframework/boot/SymbolicValueFactory.java @@ -0,0 +1,24 @@ +package generated.org.springframework.boot; + +import org.usvm.api.Engine; + +public class SymbolicValueFactory { + public static Object createSymbolic(Class type) { + if (type == boolean.class) + return Engine.makeSymbolicBoolean(); + if (type == int.class) + return Engine.makeSymbolicInt(); + if (type == long.class) + return Engine.makeSymbolicLong(); + if (type == float.class) + return Engine.makeSymbolicFloat(); + if (type == byte.class) + return Engine.makeSymbolicByte(); + if (type == char.class) + return Engine.makeSymbolicChar(); + if (type == short.class) + return Engine.makeSymbolicShort(); + + return Engine.makeNullableSymbolic(type); + } +} diff --git a/approximations/src/main/java/generated/org/springframework/boot/TestClass.java b/approximations/src/main/java/generated/org/springframework/boot/TestClass.java new file mode 100644 index 00000000..d66f59e8 --- /dev/null +++ b/approximations/src/main/java/generated/org/springframework/boot/TestClass.java @@ -0,0 +1,12 @@ +package generated.org.springframework.boot; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.test.web.servlet.MockMvc; + +@WebMvcTest +public class TestClass { + + @Autowired + private MockMvc mockMvc; +} diff --git a/approximations/src/main/java/generated/org/springframework/boot/TestContextManagerImpl.java b/approximations/src/main/java/generated/org/springframework/boot/TestContextManagerImpl.java new file mode 100644 index 00000000..f50b2741 --- /dev/null +++ b/approximations/src/main/java/generated/org/springframework/boot/TestContextManagerImpl.java @@ -0,0 +1,57 @@ +package generated.org.springframework.boot; + +import org.jacodb.approximation.annotation.Approximate; +import org.springframework.test.context.TestContext; +import org.springframework.test.context.TestContextBootstrapper; +import org.springframework.test.context.TestContextManager; +import org.springframework.test.context.TestExecutionListener; +import org.springframework.util.ClassUtils; +import org.springframework.util.ReflectionUtils; + +import java.lang.reflect.Constructor; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +@Approximate(TestContextManager.class) +public class TestContextManagerImpl { + + private final TestContext testContext; + + private final List testExecutionListeners = new ArrayList<>(8); + + private static TestContext copyTestContext(TestContext testContext) { + Constructor constructor = + ClassUtils.getConstructorIfAvailable(testContext.getClass(), testContext.getClass()); + + if (constructor != null) { + try { + ReflectionUtils.makeAccessible(constructor); + return constructor.newInstance(testContext); + } + catch (Exception ignored) { + } + } + + // Fallback to original instance + return testContext; + } + + public TestContextManagerImpl(TestContextBootstrapper testContextBootstrapper) { + this.testContext = testContextBootstrapper.buildTestContext(); + registerTestExecutionListeners(testContextBootstrapper.getTestExecutionListeners()); + } + + public final TestContext getTestContext() { + return this.testContext; + } + + public void registerTestExecutionListeners(List testExecutionListeners) { + registerTestExecutionListeners(testExecutionListeners.toArray(new TestExecutionListener[0])); + } + + public void registerTestExecutionListeners(TestExecutionListener... testExecutionListeners) { + Collections.addAll(this.testExecutionListeners, testExecutionListeners); + } + +} diff --git a/approximations/src/main/java/generated/runtime/LibSLGlobals.java b/approximations/src/main/java/generated/runtime/LibSLGlobals.java index ab17ae0d..455cabc3 100644 --- a/approximations/src/main/java/generated/runtime/LibSLGlobals.java +++ b/approximations/src/main/java/generated/runtime/LibSLGlobals.java @@ -1,129 +1,57 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - *global variables* -// package generated.runtime; import java.lang.Object; -import java.lang.Void; + import org.jacodb.approximation.annotation.Approximate; import org.usvm.api.Engine; @Approximate(runtime.LibSLGlobals.class) public final class LibSLGlobals { - /** - * Source: java/io/Console.lsl:22 - */ + public static final boolean CONSOLE_IS_TTY; - /** - * Source: java/lang/Character.lsl:53 - */ public static final int MAX_CODE_POINT; - /** - * Source: java/lang/Character.lsl:54 - */ public static final int MIN_CODE_POINT; - /** - * Source: java/lang/Character.lsl:56 - */ public static final int MIN_HIGH_SURROGATE; - /** - * Source: java/lang/Character.lsl:55 - */ public static final int MIN_LOW_SURROGATE; - /** - * Source: java/lang/Character.lsl:57 - */ public static final int MIN_SUPPLEMENTARY_CODE_POINT; - /** - * Source: java/util/Random.lsl:26 - */ public static final int RANDOM_STREAM_SIZE_MAX; - /** - * Source: java/lang/Object.lsl:25 - */ public static final Object SOMETHING; - /** - * Source: java/util/Spliterator.lsl:42 - */ public static final int SPLITERATOR_CONCURRENT; - /** - * Source: java/util/Spliterator.lsl:36 - */ public static final int SPLITERATOR_DISTINCT; - /** - * Source: java/util/Spliterator.lsl:41 - */ public static final int SPLITERATOR_IMMUTABLE; - /** - * Source: java/util/Spliterator.lsl:40 - */ public static final int SPLITERATOR_NONNULL; - /** - * Source: java/util/Spliterator.lsl:38 - */ public static final int SPLITERATOR_ORDERED; - /** - * Source: java/util/Spliterator.lsl:39 - */ public static final int SPLITERATOR_SIZED; - /** - * Source: java/util/Spliterator.lsl:37 - */ public static final int SPLITERATOR_SORTED; - /** - * Source: java/util/Spliterator.lsl:43 - */ public static final int SPLITERATOR_SUBSIZED; - /** - * Source: java/lang/System.lsl:79 - */ public static final boolean SYSTEM_IS_MAC; - /** - * Source: java/lang/System.lsl:80 - */ public static final boolean SYSTEM_IS_WINDOWS; - /** - * Source: jdk/internal/misc/VM.lsl:42 - */ public static final int VM_JAVA_LANG_SYSTEM_INITED; - /** - * Source: jdk/internal/misc/VM.lsl:43 - */ public static final int VM_MODULE_SYSTEM_INITED; - /** - * Source: jdk/internal/misc/VM.lsl:45 - */ public static final int VM_SYSTEM_BOOTED; - /** - * Source: jdk/internal/misc/VM.lsl:44 - */ public static final int VM_SYSTEM_LOADER_INITIALIZING; - /** - * Source: jdk/internal/misc/VM.lsl:46 - */ public static final int VM_SYSTEM_SHUTDOWN; static { @@ -144,6 +72,7 @@ public final class LibSLGlobals { SPLITERATOR_SORTED = 4; SPLITERATOR_SUBSIZED = 16384; SYSTEM_IS_MAC = Engine.makeSymbolicBoolean(); + //noinspection ConstantValue SYSTEM_IS_WINDOWS = !LibSLGlobals.SYSTEM_IS_MAC && Engine.makeSymbolicBoolean(); VM_JAVA_LANG_SYSTEM_INITED = 1; VM_MODULE_SYSTEM_INITED = 2; @@ -151,11 +80,4 @@ public final class LibSLGlobals { VM_SYSTEM_LOADER_INITIALIZING = 3; VM_SYSTEM_SHUTDOWN = 5; } - - @Approximate(LibSLGlobals.class) - public static final class __hook { - private __hook(Void o1, Void o2) { - Engine.assume(false); - } - } } diff --git a/approximations/src/main/java/runtime/LibSLRuntime.java b/approximations/src/main/java/runtime/LibSLRuntime.java index 2f69e534..fb03400d 100644 --- a/approximations/src/main/java/runtime/LibSLRuntime.java +++ b/approximations/src/main/java/runtime/LibSLRuntime.java @@ -10,53 +10,51 @@ import org.usvm.api.SymbolicList; import org.usvm.api.SymbolicMap; -@SuppressWarnings({"unused", "ManualMinMaxCalculation", "ExplicitArrayFilling"}) +@SuppressWarnings("unused") public final class LibSLRuntime { - /* - public static final class Token { - public static final Token INSTANCE = new Token(); - - private Token() {} - } - */ private static final Object SOMETHING = LibSLRuntime.class; - public interface HasAutomaton { - } - @Target(ElementType.CONSTRUCTOR) @Retention(RetentionPolicy.RUNTIME) public @interface DirectCallOnly { } - public interface Automaton { - } + public static abstract class LibSLException extends Error { - @Target(ElementType.CONSTRUCTOR) - @Retention(RetentionPolicy.RUNTIME) - public @interface AutomatonConstructor { - } + @java.io.Serial + private static final long serialVersionUID = 4980196508277280341L; - public static abstract class LibSLException extends Error { private LibSLException(final String msg) { super(msg); } } public static final class StateCheckException extends LibSLException { + + @java.io.Serial + private static final long serialVersionUID = 4980196508277280343L; + private StateCheckException(final String msg) { super(msg); } } public static final class SemanticViolationException extends LibSLException { + + @java.io.Serial + private static final long serialVersionUID = 4980196508277280344L; + private SemanticViolationException(final String msg) { super(msg); } } public static final class IncompleteSpecificationException extends LibSLException { + + @java.io.Serial + private static final long serialVersionUID = 4980196508277280345L; + private IncompleteSpecificationException(final String msg) { // #question: can we pass class and method names here? (counterargument: string bloat) super(msg); @@ -81,6 +79,7 @@ public static void not_implemented() { private static volatile int guid = 0; private static final Object guidLock = new Object(); + @SuppressWarnings("NonAtomicOperationOnVolatileField") public static int getUniqueId() { // TODO: enable synchronization when parallel execution is allowed //synchronized (guidLock) { @@ -117,15 +116,15 @@ public static String toString(byte v) { int len = 0; int pos = BUFF_SIZE_BYTE; while (v != 0) { - pos -= 1; - len += 1; + pos--; + len++; chars[pos] = (char) ('0' + (v % 10)); v /= 10; } if (isNegative) { - pos -= 1; - len += 1; + pos--; + len++; chars[pos] = '-'; } @@ -151,15 +150,15 @@ public static String toString(short v) { int len = 0; int pos = BUFF_SIZE_SHORT; while (v != 0) { - pos -= 1; - len += 1; + pos--; + len++; chars[pos] = (char) ('0' + (v % 10)); v /= 10; } if (isNegative) { - pos -= 1; - len += 1; + pos--; + len++; chars[pos] = '-'; } @@ -185,15 +184,15 @@ public static String toString(int v) { int len = 0; int pos = BUFF_SIZE_INT; while (v != 0) { - pos -= 1; - len += 1; + pos--; + len++; chars[pos] = (char) ('0' + (v % 10)); v /= 10; } if (isNegative) { - pos -= 1; - len += 1; + pos--; + len++; chars[pos] = '-'; } @@ -219,15 +218,15 @@ public static String toString(long v) { int len = 0; int pos = BUFF_SIZE_LONG; while (v != 0) { - pos -= 1; - len += 1; + pos--; + len++; chars[pos] = (char) ('0' + (v % 10)); v /= 10; } if (isNegative) { - pos -= 1; - len += 1; + pos--; + len++; chars[pos] = '-'; } @@ -252,6 +251,7 @@ public static String toString(final char[] v) { private static final int FLOAT_MULTIPLIER_SCIENTIFIC_count = 6; private static final int FLOAT_MULTIPLIER_SCIENTIFIC_int = (int) FLOAT_MULTIPLIER_SCIENTIFIC; + @SuppressWarnings("ManualMinMaxCalculation") public static String toString(float v) { if (v != v) return "NaN"; @@ -283,12 +283,12 @@ public static String toString(float v) { // corrections if (remainder - (float) fraction >= 0.5f) { // rounding of last decimal digit - fraction += 1; + fraction++; // overflow? if (fraction >= FLOAT_MULTIPLIER_REGULAR_int) { fraction = 0; - integral += 1; + integral++; // overflow? if (integral >= 10) @@ -334,7 +334,7 @@ public static String toString(float v) { } if (v >= 1E+1f) { v *= 1E-1f; - exp += 1; + exp++; } } if (v > 0.0f && v <= 1.0f) { @@ -360,7 +360,7 @@ public static String toString(float v) { } if (v < 1E-0f) { v *= 1E1f; - exp -= 1; + exp--; } } @@ -372,17 +372,17 @@ public static String toString(float v) { // corrections if (remainder - (float) fraction >= 0.5f) { // rounding of last decimal digit - fraction += 1; + fraction++; // overflow? if (fraction >= FLOAT_MULTIPLIER_SCIENTIFIC_int) { fraction = 0; - integral += 1; + integral++; // overflow? if (integral >= 10) { integral = 1; - exp += 1; + exp++; } } } @@ -400,6 +400,7 @@ public static String toString(float v) { return (isNegative ? "-" : "").concat(result); } + @SuppressWarnings("ExplicitArrayFilling") private static String prepareFloatFraction(int decimal, final int expectedFractionLength) { if (decimal == 0) return "0"; @@ -408,7 +409,7 @@ private static String prepareFloatFraction(int decimal, final int expectedFracti int cutZeroes = 0; while (decimal % 10 == 0) { decimal /= 10; - cutZeroes += 1; + cutZeroes++; } final String decimals = toString(decimal); @@ -435,6 +436,7 @@ private static String prepareFloatFraction(int decimal, final int expectedFracti private static final int DOUBLE_MULTIPLIER_SCIENTIFIC_count = 15; private static final long DOUBLE_MULTIPLIER_SCIENTIFIC_long = (long) DOUBLE_MULTIPLIER_SCIENTIFIC; + @SuppressWarnings("ManualMinMaxCalculation") public static String toString(double v) { if (v != v) return "NaN"; @@ -466,12 +468,12 @@ public static String toString(double v) { // corrections if (remainder - (double) fraction >= 0.5d) { // rounding of last decimal digit - fraction += 1; + fraction++; // overflow? if (fraction >= DOUBLE_MULTIPLIER_REGULAR_long) { fraction = 0; - integral += 1; + integral++; // overflow? if (integral >= 10) @@ -529,7 +531,7 @@ public static String toString(double v) { } if (v >= 1E+1) { v *= 1E-1; - exp += 1; + exp++; } } if (v > 0.0 && v <= 1.0) { @@ -567,7 +569,7 @@ public static String toString(double v) { } if (v < 1E-0) { v *= 1E1; - exp -= 1; + exp--; } } @@ -579,17 +581,17 @@ public static String toString(double v) { // corrections if (remainder - (double) fraction >= 0.5d) { // rounding of last decimal digit - fraction += 1; + fraction++; // overflow? if (fraction >= DOUBLE_MULTIPLIER_SCIENTIFIC_long) { fraction = 0; - integral += 1; + integral++; // overflow? if (integral >= 10) { integral = 1; - exp += 1; + exp++; } } } @@ -607,6 +609,7 @@ public static String toString(double v) { return (isNegative ? "-" : "").concat(result); } + @SuppressWarnings("ExplicitArrayFilling") private static String prepareDoubleFraction(long decimal, final int expectedFractionLength) { if (decimal == 0) return "0"; @@ -615,7 +618,7 @@ private static String prepareDoubleFraction(long decimal, final int expectedFrac int cutZeroes = 0; while (decimal % 10 == 0) { decimal /= 10; - cutZeroes += 1; + cutZeroes++; } final String decimals = toString(decimal); @@ -726,6 +729,7 @@ public static int hashCode(final int v) { return v; } + @SuppressWarnings("UseHashCodeMethodInspection") public static int hashCode(final long v) { return (int) (v ^ (v >>> 32)); } @@ -744,24 +748,23 @@ public static int hashCode(final double v) { return Double.hashCode(v); } - public static int hashCode(final SymbolicList v) { + public static int hashCode(SymbolicList v, int start, int end) { if (v == null) return 0; - final int count = v.size(); - if (count == 0) - return 1; - Engine.assume(count > 0); - - // FIXME: use less complex approach + Engine.assume(start >= 0); + Engine.assume(end >= 0 && end <= v.size()); int res = 1; - - for (int i = 0; i < count; i++) + for (int i = start; i < end; i++) res = 31 * res + hashCode(v.get(i)); return res; } + public static int hashCode(SymbolicList v) { + return hashCode(v, 0, v.size()); + } + public static int hashCode(final Map v) { if (v == null) return 0; @@ -781,7 +784,7 @@ public static int hashCode(final Map v) { res += hashCode(key) ^ hashCode(unseen.get(key)); unseen.remove(key); - count -= 1; + count--; } return res; @@ -886,7 +889,7 @@ public static boolean equals(final Map a, final Map b) { return false; unseen.remove(key); - length -= 1; + length--; } return true; } @@ -929,6 +932,7 @@ public static final class UnknownAction { // a helper class for complex "array"-related actions public static final class ArrayActions { + @SuppressWarnings({"DataFlowIssue", "SuspiciousSystemArraycopy"}) public static void copy(final Object src, final int srcPos, final Object dst, final int dstPos, final int count) { @@ -941,6 +945,7 @@ public static void copy(final Object src, final int srcPos, System.arraycopy(src, srcPos, dst, dstPos, count); } + @SuppressWarnings({"DataFlowIssue", "ConstantValue"}) public static void fill(final byte[] arr, final byte value) { Engine.assume(arr != null); @@ -951,6 +956,7 @@ public static void fill(final byte[] arr, final byte value) { arr[i] = value; } + @SuppressWarnings({"DataFlowIssue", "ConstantValue"}) public static void fill(final short[] arr, final short value) { Engine.assume(arr != null); @@ -961,6 +967,7 @@ public static void fill(final short[] arr, final short value) { arr[i] = value; } + @SuppressWarnings({"DataFlowIssue", "ConstantValue"}) public static void fill(final int[] arr, final int value) { Engine.assume(arr != null); @@ -971,6 +978,7 @@ public static void fill(final int[] arr, final int value) { arr[i] = value; } + @SuppressWarnings({"DataFlowIssue", "ConstantValue"}) public static void fill(final long[] arr, final long value) { Engine.assume(arr != null); @@ -981,6 +989,7 @@ public static void fill(final long[] arr, final long value) { arr[i] = value; } + @SuppressWarnings({"DataFlowIssue", "ConstantValue"}) public static void fill(final float[] arr, final float value) { Engine.assume(arr != null); @@ -991,6 +1000,7 @@ public static void fill(final float[] arr, final float value) { arr[i] = value; } + @SuppressWarnings({"DataFlowIssue", "ConstantValue"}) public static void fill(final double[] arr, final double value) { Engine.assume(arr != null); @@ -1001,6 +1011,7 @@ public static void fill(final double[] arr, final double value) { arr[i] = value; } + @SuppressWarnings({"DataFlowIssue", "ConstantValue"}) public static void fill(final char[] arr, final char value) { Engine.assume(arr != null); @@ -1011,6 +1022,7 @@ public static void fill(final char[] arr, final char value) { arr[i] = value; } + @SuppressWarnings({"DataFlowIssue", "ConstantValue"}) public static void fill(final T[] arr, final T value) { Engine.assume(arr != null); @@ -1021,6 +1033,7 @@ public static void fill(final T[] arr, final T value) { arr[i] = value; } + @SuppressWarnings({"DataFlowIssue", "ConstantValue"}) public static void fillRange(final byte[] arr, final int fromIndex, final int toIndex, final byte value) { @@ -1037,6 +1050,7 @@ public static void fillRange(final byte[] arr, arr[i] = value; } + @SuppressWarnings({"DataFlowIssue", "ConstantValue"}) public static void fillRange(final short[] arr, final int fromIndex, final int toIndex, final short value) { @@ -1053,6 +1067,7 @@ public static void fillRange(final short[] arr, arr[i] = value; } + @SuppressWarnings({"DataFlowIssue", "ConstantValue"}) public static void fillRange(final int[] arr, final int fromIndex, final int toIndex, final int value) { @@ -1069,6 +1084,7 @@ public static void fillRange(final int[] arr, arr[i] = value; } + @SuppressWarnings({"DataFlowIssue", "ConstantValue"}) public static void fillRange(final long[] arr, final int fromIndex, final int toIndex, final long value) { @@ -1085,6 +1101,7 @@ public static void fillRange(final long[] arr, arr[i] = value; } + @SuppressWarnings({"DataFlowIssue", "ConstantValue"}) public static void fillRange(final float[] arr, final int fromIndex, final int toIndex, final float value) { @@ -1101,6 +1118,7 @@ public static void fillRange(final float[] arr, arr[i] = value; } + @SuppressWarnings({"DataFlowIssue", "ConstantValue"}) public static void fillRange(final double[] arr, final int fromIndex, final int toIndex, final double value) { @@ -1117,6 +1135,7 @@ public static void fillRange(final double[] arr, arr[i] = value; } + @SuppressWarnings({"DataFlowIssue", "ConstantValue"}) public static void fillRange(final char[] arr, final int fromIndex, final int toIndex, final char value) { @@ -1133,6 +1152,7 @@ public static void fillRange(final char[] arr, arr[i] = value; } + @SuppressWarnings({"DataFlowIssue", "ConstantValue"}) public static void fillRange(final T[] arr, final int fromIndex, final int toIndex, final T value) { @@ -1148,20 +1168,21 @@ public static void fillRange(final T[] arr, for (int i = fromIndex; i < toIndex; i++) arr[i] = value; } - } - // a helper class for complex "list"-related actions public static final class ListActions { private static final int INDEX_NOT_FOUND = -1; - public static int find(final SymbolicList list, final Object value, - final int from, final int to) { + private static void addAssumptions(SymbolicList list, int from, int to) { // general assumptions for this function to do something useful Engine.assume(list != null); Engine.assume(0 <= from); Engine.assume(from <= to); + } + + public static int find(SymbolicList list, Object value, int from, int to) { + addAssumptions(list, from, to); // TODO: is there a more efficient solution? if (value == null) { @@ -1169,20 +1190,42 @@ public static int find(final SymbolicList list, final Object value, if (list.get(i) == null) return i; } - } else { - for (int i = from; i < to; i++) { - final Object item = list.get(i); - if (value == item || value.equals(item)) + return INDEX_NOT_FOUND; + } + + for (int i = from; i < to; i++) { + final Object item = list.get(i); + if (value == item || value.equals(item)) + return i; + } + + return INDEX_NOT_FOUND; + } + + public static int findBack(SymbolicList list, Object value, int from, int to) { + addAssumptions(list, from, to); + + // TODO: is there a more efficient solution? + if (value == null) { + for (int i = to - 1; i >= from; i--) { + if (list.get(i) == null) return i; } + return INDEX_NOT_FOUND; + } + + for (int i = to - 1; i >= from; i--) { + final Object item = list.get(i); + if (value == item || value.equals(item)) + return i; } return INDEX_NOT_FOUND; } - } + @SuppressWarnings("DataFlowIssue") public static final class Map { Container map; @@ -1272,7 +1315,7 @@ public void union(final Map other) { map.set(key, unseen.get(key)); unseen.remove(key); - count -= 1; + count--; } } } @@ -1301,7 +1344,7 @@ public void intersection(final Map other) { map.set(key, unseen.get(key)); unseen.remove(key); - count -= 1; + count--; } } } @@ -1340,6 +1383,7 @@ public HashMapContainer() { super(KIND_HASHMAP); } + @SuppressWarnings("DataFlowIssue") @Override public void merge(Map.Container container) { Engine.assume(container instanceof HashMapContainer); @@ -1398,6 +1442,7 @@ public IdentityMapContainer() { super(KIND_IDENTITY_MAP); } + @SuppressWarnings("DataFlowIssue") @Override public void merge(Map.Container container) { Engine.assume(container instanceof IdentityMapContainer); diff --git a/approximations/src/main/java/stub/java/lang/System_PrintStream.java b/approximations/src/main/java/stub/java/lang/System_PrintStream.java index 35d11039..f432a9ea 100644 --- a/approximations/src/main/java/stub/java/lang/System_PrintStream.java +++ b/approximations/src/main/java/stub/java/lang/System_PrintStream.java @@ -1,35 +1,32 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/lang/System.lsl:83 -// package stub.java.lang; +import org.jetbrains.annotations.NotNull; + import java.io.OutputStream; import java.io.PrintStream; import java.lang.CharSequence; import java.lang.LinkageError; import java.lang.Object; import java.lang.String; -import java.lang.SuppressWarnings; -import java.lang.Void; import java.util.Locale; -import runtime.LibSLRuntime; -@SuppressWarnings({"all", "unchecked"}) -public final class System_PrintStream extends PrintStream implements LibSLRuntime.HasAutomaton { - private System_PrintStream(Void a, Void b) { +public final class System_PrintStream extends PrintStream { + + @SuppressWarnings({"DataFlowIssue", "unused"}) + public System_PrintStream(boolean closed, boolean error) { super((OutputStream) null); + throw new LinkageError(); } - public PrintStream append(CharSequence csq) { + public System_PrintStream append(CharSequence csq) { throw new LinkageError(); } - public PrintStream append(CharSequence csq, int start, int end) { + public System_PrintStream append(CharSequence csq, int start, int end) { throw new LinkageError(); } - public PrintStream append(char c) { + public System_PrintStream append(char c) { throw new LinkageError(); } @@ -45,11 +42,11 @@ public void flush() { throw new LinkageError(); } - public PrintStream format(Locale l, String format, Object[] args) { + public System_PrintStream format(Locale l, @NotNull String format, Object... args) { throw new LinkageError(); } - public PrintStream format(String format, Object[] args) { + public System_PrintStream format(@NotNull String format, Object... args) { throw new LinkageError(); } @@ -69,7 +66,7 @@ public void print(char c) { throw new LinkageError(); } - public void print(char[] s) { + public void print(@NotNull char[] s) { throw new LinkageError(); } @@ -89,11 +86,11 @@ public void print(long l) { throw new LinkageError(); } - public PrintStream printf(Locale l, String format, Object[] args) { + public System_PrintStream printf(Locale l, @NotNull String format, Object... args) { throw new LinkageError(); } - public PrintStream printf(String format, Object[] args) { + public System_PrintStream printf(@NotNull String format, Object... args) { throw new LinkageError(); } @@ -117,7 +114,7 @@ public void println(char x) { throw new LinkageError(); } - public void println(char[] x) { + public void println(@NotNull char[] x) { throw new LinkageError(); } @@ -141,7 +138,7 @@ public void write(byte[] b) throws java.io.IOException { throw new LinkageError(); } - public void write(byte[] buf, int off, int len) { + public void write(@NotNull byte[] buf, int off, int len) { throw new LinkageError(); } diff --git a/approximations/src/main/java/stub/java/util/AbstractIterator.java b/approximations/src/main/java/stub/java/util/AbstractIterator.java new file mode 100644 index 00000000..785a601e --- /dev/null +++ b/approximations/src/main/java/stub/java/util/AbstractIterator.java @@ -0,0 +1,17 @@ +package stub.java.util; + +import java.util.Iterator; + +public abstract class AbstractIterator implements Iterator { + + @SuppressWarnings("unused") + public AbstractIterator(int expectedModCount) { + throw new LinkageError(); + } + + abstract protected int _parentModCount(); + + protected void _checkForModification() { + throw new LinkageError(); + } +} diff --git a/approximations/src/main/java/stub/java/util/AbstractMap_SimpleEntry.java b/approximations/src/main/java/stub/java/util/AbstractMap_SimpleEntry.java deleted file mode 100644 index bc4d0b1d..00000000 --- a/approximations/src/main/java/stub/java/util/AbstractMap_SimpleEntry.java +++ /dev/null @@ -1,53 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/AbstractMap.lsl:23 -// -package stub.java.util; - -import java.io.Serializable; -import java.lang.LinkageError; -import java.lang.Object; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.Map; -import runtime.LibSLRuntime; - -@SuppressWarnings({"all", "unchecked"}) -public class AbstractMap_SimpleEntry implements LibSLRuntime.HasAutomaton, Serializable, Map.Entry { - private AbstractMap_SimpleEntry(Void a, Void b) { - super(); - } - - public AbstractMap_SimpleEntry(Map.Entry entry) { - throw new LinkageError(); - } - - public AbstractMap_SimpleEntry(Object key, Object value) { - throw new LinkageError(); - } - - public boolean equals(Object other) { - throw new LinkageError(); - } - - public Object getKey() { - throw new LinkageError(); - } - - public Object getValue() { - throw new LinkageError(); - } - - public int hashCode() { - throw new LinkageError(); - } - - public Object setValue(Object value) { - throw new LinkageError(); - } - - public String toString() { - throw new LinkageError(); - } -} diff --git a/approximations/src/main/java/stub/java/util/ArrayList_ListItr.java b/approximations/src/main/java/stub/java/util/ArrayList_ListItr.java deleted file mode 100644 index 070b82fd..00000000 --- a/approximations/src/main/java/stub/java/util/ArrayList_ListItr.java +++ /dev/null @@ -1,60 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/ArrayList.lsl:36 -// -package stub.java.util; - -import java.lang.LinkageError; -import java.lang.Object; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.ListIterator; -import java.util.function.Consumer; -import runtime.LibSLRuntime; - -@SuppressWarnings({"all", "unchecked"}) -public final class ArrayList_ListItr implements LibSLRuntime.HasAutomaton, ListIterator { - private ArrayList_ListItr(Void a, Void b) { - super(); - } - - public boolean hasPrevious() { - throw new LinkageError(); - } - - public int nextIndex() { - throw new LinkageError(); - } - - public int previousIndex() { - throw new LinkageError(); - } - - public boolean hasNext() { - throw new LinkageError(); - } - - public Object next() { - throw new LinkageError(); - } - - public Object previous() { - throw new LinkageError(); - } - - public void remove() { - throw new LinkageError(); - } - - public void set(Object e) { - throw new LinkageError(); - } - - public void add(Object e) { - throw new LinkageError(); - } - - public void forEachRemaining(Consumer userAction) { - throw new LinkageError(); - } -} diff --git a/approximations/src/main/java/stub/java/util/ArrayList_Spliterator.java b/approximations/src/main/java/stub/java/util/ArrayList_Spliterator.java deleted file mode 100644 index 186a94a2..00000000 --- a/approximations/src/main/java/stub/java/util/ArrayList_Spliterator.java +++ /dev/null @@ -1,48 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/ArrayList.lsl:45 -// -package stub.java.util; - -import java.lang.LinkageError; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.ArrayList; -import java.util.Spliterator; -import java.util.function.Consumer; -import runtime.LibSLRuntime; - -@SuppressWarnings({"all", "unchecked"}) -public final class ArrayList_Spliterator implements LibSLRuntime.HasAutomaton, Spliterator { - private ArrayList_Spliterator(Void a, Void b) { - super(); - } - - private ArrayList_Spliterator(ArrayList _this, int origin, int fence, int expectedModCount) { - throw new LinkageError(); - } - - public int characteristics() { - throw new LinkageError(); - } - - public long estimateSize() { - throw new LinkageError(); - } - - public void forEachRemaining(Consumer _action) { - throw new LinkageError(); - } - - public long getExactSizeIfKnown() { - throw new LinkageError(); - } - - public boolean tryAdvance(Consumer _action) { - throw new LinkageError(); - } - - public Spliterator trySplit() { - throw new LinkageError(); - } -} diff --git a/approximations/src/main/java/stub/java/util/ArrayList_SubList$ListIterator.java b/approximations/src/main/java/stub/java/util/ArrayList_SubList$ListIterator.java deleted file mode 100644 index ee24c0e1..00000000 --- a/approximations/src/main/java/stub/java/util/ArrayList_SubList$ListIterator.java +++ /dev/null @@ -1,60 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/ArrayList.lsl:75 -// -package stub.java.util; - -import java.lang.LinkageError; -import java.lang.Object; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.ListIterator; -import java.util.function.Consumer; -import runtime.LibSLRuntime; - -@SuppressWarnings({"all", "unchecked"}) -public final class ArrayList_SubList$ListIterator implements LibSLRuntime.HasAutomaton, ListIterator { - private ArrayList_SubList$ListIterator(Void a, Void b) { - super(); - } - - public boolean hasPrevious() { - throw new LinkageError(); - } - - public int nextIndex() { - throw new LinkageError(); - } - - public int previousIndex() { - throw new LinkageError(); - } - - public boolean hasNext() { - throw new LinkageError(); - } - - public Object next() { - throw new LinkageError(); - } - - public Object previous() { - throw new LinkageError(); - } - - public void remove() { - throw new LinkageError(); - } - - public void set(Object e) { - throw new LinkageError(); - } - - public void add(Object e) { - throw new LinkageError(); - } - - public void forEachRemaining(Consumer userAction) { - throw new LinkageError(); - } -} diff --git a/approximations/src/main/java/stub/java/util/ArrayList_SubList$Spliterator.java b/approximations/src/main/java/stub/java/util/ArrayList_SubList$Spliterator.java deleted file mode 100644 index e64e7a39..00000000 --- a/approximations/src/main/java/stub/java/util/ArrayList_SubList$Spliterator.java +++ /dev/null @@ -1,43 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/ArrayList.lsl:65 -// -package stub.java.util; - -import java.lang.LinkageError; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.Spliterator; -import java.util.function.Consumer; -import runtime.LibSLRuntime; - -@SuppressWarnings({"all", "unchecked"}) -public final class ArrayList_SubList$Spliterator implements LibSLRuntime.HasAutomaton, Spliterator { - private ArrayList_SubList$Spliterator(Void a, Void b) { - super(); - } - - public int characteristics() { - throw new LinkageError(); - } - - public long estimateSize() { - throw new LinkageError(); - } - - public void forEachRemaining(Consumer _action) { - throw new LinkageError(); - } - - public long getExactSizeIfKnown() { - throw new LinkageError(); - } - - public boolean tryAdvance(Consumer _action) { - throw new LinkageError(); - } - - public Spliterator trySplit() { - throw new LinkageError(); - } -} diff --git a/approximations/src/main/java/stub/java/util/ArrayList_SubList.java b/approximations/src/main/java/stub/java/util/ArrayList_SubList.java deleted file mode 100644 index dc8c7db0..00000000 --- a/approximations/src/main/java/stub/java/util/ArrayList_SubList.java +++ /dev/null @@ -1,177 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/ArrayList.lsl:54 -// -package stub.java.util; - -import java.lang.LinkageError; -import java.lang.Object; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.AbstractList; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Comparator; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; -import java.util.RandomAccess; -import java.util.Spliterator; -import java.util.function.Consumer; -import java.util.function.IntFunction; -import java.util.function.Predicate; -import java.util.function.UnaryOperator; -import java.util.stream.Stream; -import runtime.LibSLRuntime; - -@SuppressWarnings({"all", "unchecked"}) -public final class ArrayList_SubList extends AbstractList implements LibSLRuntime.HasAutomaton, List, RandomAccess { - private ArrayList_SubList(Void a, Void b) { - super(); - } - - public ArrayList_SubList(ArrayList root, int fromIndex, int toIndex) { - throw new LinkageError(); - } - - private ArrayList_SubList(ArrayList_SubList parent, int fromIndex, int toIndex) { - throw new LinkageError(); - } - - public boolean add(Object e) { - throw new LinkageError(); - } - - public void add(int index, Object element) { - throw new LinkageError(); - } - - public boolean addAll(Collection c) { - throw new LinkageError(); - } - - public boolean addAll(int index, Collection c) { - throw new LinkageError(); - } - - public void clear() { - throw new LinkageError(); - } - - public boolean contains(Object o) { - throw new LinkageError(); - } - - public boolean containsAll(Collection c) { - throw new LinkageError(); - } - - public boolean equals(Object o) { - throw new LinkageError(); - } - - public void forEach(Consumer _action) { - throw new LinkageError(); - } - - public Object get(int index) { - throw new LinkageError(); - } - - public int hashCode() { - throw new LinkageError(); - } - - public int indexOf(Object o) { - throw new LinkageError(); - } - - public boolean isEmpty() { - throw new LinkageError(); - } - - public Iterator iterator() { - throw new LinkageError(); - } - - public int lastIndexOf(Object o) { - throw new LinkageError(); - } - - public ListIterator listIterator() { - throw new LinkageError(); - } - - public ListIterator listIterator(int index) { - throw new LinkageError(); - } - - public Stream parallelStream() { - throw new LinkageError(); - } - - public boolean remove(Object o) { - throw new LinkageError(); - } - - public Object remove(int index) { - throw new LinkageError(); - } - - public boolean removeAll(Collection c) { - throw new LinkageError(); - } - - public boolean removeIf(Predicate filter) { - throw new LinkageError(); - } - - public void replaceAll(UnaryOperator operator) { - throw new LinkageError(); - } - - public boolean retainAll(Collection c) { - throw new LinkageError(); - } - - public Object set(int index, Object element) { - throw new LinkageError(); - } - - public int size() { - throw new LinkageError(); - } - - public void sort(Comparator c) { - throw new LinkageError(); - } - - public Spliterator spliterator() { - throw new LinkageError(); - } - - public Stream stream() { - throw new LinkageError(); - } - - public List subList(int fromIndex, int toIndex) { - throw new LinkageError(); - } - - public Object[] toArray() { - throw new LinkageError(); - } - - public Object[] toArray(IntFunction generator) { - throw new LinkageError(); - } - - public Object[] toArray(Object[] a) { - throw new LinkageError(); - } - - public String toString() { - throw new LinkageError(); - } -} diff --git a/approximations/src/main/java/stub/java/util/HashMap_EntryIterator.java b/approximations/src/main/java/stub/java/util/HashMap_EntryIterator.java deleted file mode 100644 index d8b96c6c..00000000 --- a/approximations/src/main/java/stub/java/util/HashMap_EntryIterator.java +++ /dev/null @@ -1,36 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/HashMap.lsl:99 -// -package stub.java.util; - -import java.lang.LinkageError; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.Iterator; -import java.util.Map; -import java.util.function.Consumer; -import runtime.LibSLRuntime; - -@SuppressWarnings({"all", "unchecked"}) -public final class HashMap_EntryIterator implements LibSLRuntime.HasAutomaton, Iterator { - private HashMap_EntryIterator(Void a, Void b) { - super(); - } - - public void forEachRemaining(Consumer userAction) { - throw new LinkageError(); - } - - public final boolean hasNext() { - throw new LinkageError(); - } - - public final Map.Entry next() { - throw new LinkageError(); - } - - public final void remove() { - throw new LinkageError(); - } -} diff --git a/approximations/src/main/java/stub/java/util/HashMap_EntrySet.java b/approximations/src/main/java/stub/java/util/HashMap_EntrySet.java deleted file mode 100644 index b76074f4..00000000 --- a/approximations/src/main/java/stub/java/util/HashMap_EntrySet.java +++ /dev/null @@ -1,115 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/HashMap.lsl:90 -// -package stub.java.util; - -import java.lang.LinkageError; -import java.lang.Object; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.AbstractSet; -import java.util.Collection; -import java.util.Iterator; -import java.util.Spliterator; -import java.util.function.Consumer; -import java.util.function.IntFunction; -import java.util.function.Predicate; -import java.util.stream.Stream; -import runtime.LibSLRuntime; - -@SuppressWarnings({"all", "unchecked"}) -public final class HashMap_EntrySet extends AbstractSet implements LibSLRuntime.HasAutomaton { - private HashMap_EntrySet(Void a, Void b) { - super(); - } - - public boolean add(Object e) { - throw new LinkageError(); - } - - public boolean addAll(Collection c) { - throw new LinkageError(); - } - - public final void clear() { - throw new LinkageError(); - } - - public final boolean contains(Object o) { - throw new LinkageError(); - } - - public boolean containsAll(Collection c) { - throw new LinkageError(); - } - - public boolean equals(Object other) { - throw new LinkageError(); - } - - public final void forEach(Consumer userAction) { - throw new LinkageError(); - } - - public int hashCode() { - throw new LinkageError(); - } - - public boolean isEmpty() { - throw new LinkageError(); - } - - public final Iterator iterator() { - throw new LinkageError(); - } - - public Stream parallelStream() { - throw new LinkageError(); - } - - public final boolean remove(Object o) { - throw new LinkageError(); - } - - public boolean removeAll(Collection c) { - throw new LinkageError(); - } - - public boolean removeIf(Predicate filter) { - throw new LinkageError(); - } - - public boolean retainAll(Collection c) { - throw new LinkageError(); - } - - public final int size() { - throw new LinkageError(); - } - - public final Spliterator spliterator() { - throw new LinkageError(); - } - - public Stream stream() { - throw new LinkageError(); - } - - public Object[] toArray() { - throw new LinkageError(); - } - - public Object[] toArray(IntFunction generator) { - throw new LinkageError(); - } - - public Object[] toArray(Object[] a) { - throw new LinkageError(); - } - - public String toString() { - throw new LinkageError(); - } -} diff --git a/approximations/src/main/java/stub/java/util/HashMap_EntrySpliterator.java b/approximations/src/main/java/stub/java/util/HashMap_EntrySpliterator.java deleted file mode 100644 index 39eea530..00000000 --- a/approximations/src/main/java/stub/java/util/HashMap_EntrySpliterator.java +++ /dev/null @@ -1,43 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/HashMap.lsl:108 -// -package stub.java.util; - -import java.lang.LinkageError; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.Spliterator; -import java.util.function.Consumer; -import runtime.LibSLRuntime; - -@SuppressWarnings({"all", "unchecked"}) -public final class HashMap_EntrySpliterator implements LibSLRuntime.HasAutomaton, Spliterator { - private HashMap_EntrySpliterator(Void a, Void b) { - super(); - } - - public int characteristics() { - throw new LinkageError(); - } - - public final long estimateSize() { - throw new LinkageError(); - } - - public void forEachRemaining(Consumer userAction) { - throw new LinkageError(); - } - - public long getExactSizeIfKnown() { - throw new LinkageError(); - } - - public boolean tryAdvance(Consumer userAction) { - throw new LinkageError(); - } - - public Spliterator trySplit() { - throw new LinkageError(); - } -} diff --git a/approximations/src/main/java/stub/java/util/HashMap_KeyIterator.java b/approximations/src/main/java/stub/java/util/HashMap_KeyIterator.java deleted file mode 100644 index 96a73a06..00000000 --- a/approximations/src/main/java/stub/java/util/HashMap_KeyIterator.java +++ /dev/null @@ -1,36 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/HashMap.lsl:72 -// -package stub.java.util; - -import java.lang.LinkageError; -import java.lang.Object; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.Iterator; -import java.util.function.Consumer; -import runtime.LibSLRuntime; - -@SuppressWarnings({"all", "unchecked"}) -public final class HashMap_KeyIterator implements LibSLRuntime.HasAutomaton, Iterator { - private HashMap_KeyIterator(Void a, Void b) { - super(); - } - - public void forEachRemaining(Consumer userAction) { - throw new LinkageError(); - } - - public final boolean hasNext() { - throw new LinkageError(); - } - - public final Object next() { - throw new LinkageError(); - } - - public final void remove() { - throw new LinkageError(); - } -} diff --git a/approximations/src/main/java/stub/java/util/HashMap_KeySpliterator.java b/approximations/src/main/java/stub/java/util/HashMap_KeySpliterator.java deleted file mode 100644 index f1109b43..00000000 --- a/approximations/src/main/java/stub/java/util/HashMap_KeySpliterator.java +++ /dev/null @@ -1,43 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/HashMap.lsl:81 -// -package stub.java.util; - -import java.lang.LinkageError; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.Spliterator; -import java.util.function.Consumer; -import runtime.LibSLRuntime; - -@SuppressWarnings({"all", "unchecked"}) -public final class HashMap_KeySpliterator implements LibSLRuntime.HasAutomaton, Spliterator { - private HashMap_KeySpliterator(Void a, Void b) { - super(); - } - - public int characteristics() { - throw new LinkageError(); - } - - public final long estimateSize() { - throw new LinkageError(); - } - - public void forEachRemaining(Consumer userAction) { - throw new LinkageError(); - } - - public long getExactSizeIfKnown() { - throw new LinkageError(); - } - - public boolean tryAdvance(Consumer userAction) { - throw new LinkageError(); - } - - public Spliterator trySplit() { - throw new LinkageError(); - } -} diff --git a/approximations/src/main/java/stub/java/util/HashMap_ValueIterator.java b/approximations/src/main/java/stub/java/util/HashMap_ValueIterator.java deleted file mode 100644 index 3ebaa49f..00000000 --- a/approximations/src/main/java/stub/java/util/HashMap_ValueIterator.java +++ /dev/null @@ -1,36 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/HashMap.lsl:45 -// -package stub.java.util; - -import java.lang.LinkageError; -import java.lang.Object; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.Iterator; -import java.util.function.Consumer; -import runtime.LibSLRuntime; - -@SuppressWarnings({"all", "unchecked"}) -public class HashMap_ValueIterator implements LibSLRuntime.HasAutomaton, Iterator { - private HashMap_ValueIterator(Void a, Void b) { - super(); - } - - public void forEachRemaining(Consumer userAction) { - throw new LinkageError(); - } - - public final boolean hasNext() { - throw new LinkageError(); - } - - public final Object next() { - throw new LinkageError(); - } - - public final void remove() { - throw new LinkageError(); - } -} diff --git a/approximations/src/main/java/stub/java/util/HashMap_ValueSpliterator.java b/approximations/src/main/java/stub/java/util/HashMap_ValueSpliterator.java deleted file mode 100644 index d89797c1..00000000 --- a/approximations/src/main/java/stub/java/util/HashMap_ValueSpliterator.java +++ /dev/null @@ -1,43 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/HashMap.lsl:54 -// -package stub.java.util; - -import java.lang.LinkageError; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.Spliterator; -import java.util.function.Consumer; -import runtime.LibSLRuntime; - -@SuppressWarnings({"all", "unchecked"}) -public final class HashMap_ValueSpliterator implements LibSLRuntime.HasAutomaton, Spliterator { - private HashMap_ValueSpliterator(Void a, Void b) { - super(); - } - - public int characteristics() { - throw new LinkageError(); - } - - public final long estimateSize() { - throw new LinkageError(); - } - - public void forEachRemaining(Consumer userAction) { - throw new LinkageError(); - } - - public long getExactSizeIfKnown() { - throw new LinkageError(); - } - - public boolean tryAdvance(Consumer userAction) { - throw new LinkageError(); - } - - public Spliterator trySplit() { - throw new LinkageError(); - } -} diff --git a/approximations/src/main/java/stub/java/util/HashMap_Values.java b/approximations/src/main/java/stub/java/util/HashMap_Values.java deleted file mode 100644 index 24ef048d..00000000 --- a/approximations/src/main/java/stub/java/util/HashMap_Values.java +++ /dev/null @@ -1,107 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/HashMap.lsl:36 -// -package stub.java.util; - -import java.lang.LinkageError; -import java.lang.Object; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.AbstractCollection; -import java.util.Collection; -import java.util.Iterator; -import java.util.Spliterator; -import java.util.function.Consumer; -import java.util.function.IntFunction; -import java.util.function.Predicate; -import java.util.stream.Stream; -import runtime.LibSLRuntime; - -@SuppressWarnings({"all", "unchecked"}) -public class HashMap_Values extends AbstractCollection implements LibSLRuntime.HasAutomaton { - private HashMap_Values(Void a, Void b) { - super(); - } - - public boolean add(Object e) { - throw new LinkageError(); - } - - public boolean addAll(Collection c) { - throw new LinkageError(); - } - - public final void clear() { - throw new LinkageError(); - } - - public final boolean contains(Object value) { - throw new LinkageError(); - } - - public boolean containsAll(Collection c) { - throw new LinkageError(); - } - - public final void forEach(Consumer userAction) { - throw new LinkageError(); - } - - public boolean isEmpty() { - throw new LinkageError(); - } - - public final Iterator iterator() { - throw new LinkageError(); - } - - public Stream parallelStream() { - throw new LinkageError(); - } - - public boolean remove(Object value) { - throw new LinkageError(); - } - - public boolean removeAll(Collection c) { - throw new LinkageError(); - } - - public boolean removeIf(Predicate filter) { - throw new LinkageError(); - } - - public boolean retainAll(Collection c) { - throw new LinkageError(); - } - - public final int size() { - throw new LinkageError(); - } - - public final Spliterator spliterator() { - throw new LinkageError(); - } - - public Stream stream() { - throw new LinkageError(); - } - - public Object[] toArray() { - throw new LinkageError(); - } - - public Object[] toArray(IntFunction generator) { - throw new LinkageError(); - } - - public Object[] toArray(Object[] a) { - throw new LinkageError(); - } - - public String toString() { - throw new LinkageError(); - } -} diff --git a/approximations/src/main/java/stub/java/util/HashSet_KeyIterator.java b/approximations/src/main/java/stub/java/util/HashSet_KeyIterator.java deleted file mode 100644 index e3c17984..00000000 --- a/approximations/src/main/java/stub/java/util/HashSet_KeyIterator.java +++ /dev/null @@ -1,41 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/HashSet.lsl:41 -// -package stub.java.util; - -import java.lang.LinkageError; -import java.lang.Object; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.HashMap; -import java.util.Iterator; -import java.util.function.Consumer; -import runtime.LibSLRuntime; - -@SuppressWarnings({"all", "unchecked"}) -public final class HashSet_KeyIterator implements LibSLRuntime.HasAutomaton, Iterator { - private HashSet_KeyIterator(Void a, Void b) { - super(); - } - - private HashSet_KeyIterator(HashMap source) { - throw new LinkageError(); - } - - public boolean hasNext() { - throw new LinkageError(); - } - - public final Object next() { - throw new LinkageError(); - } - - public void remove() { - throw new LinkageError(); - } - - public void forEachRemaining(Consumer userAction) { - throw new LinkageError(); - } -} diff --git a/approximations/src/main/java/stub/java/util/HashSet_KeySpliterator.java b/approximations/src/main/java/stub/java/util/HashSet_KeySpliterator.java deleted file mode 100644 index 609d2b94..00000000 --- a/approximations/src/main/java/stub/java/util/HashSet_KeySpliterator.java +++ /dev/null @@ -1,45 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/HashSet.lsl:32 -// -package stub.java.util; - -import java.lang.LinkageError; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.HashMap; -import java.util.Spliterator; -import java.util.function.Consumer; -import runtime.LibSLRuntime; - -@SuppressWarnings({"all", "unchecked"}) -public final class HashSet_KeySpliterator implements LibSLRuntime.HasAutomaton, Spliterator { - private HashSet_KeySpliterator(Void a, Void b) { - super(); - } - - private HashSet_KeySpliterator(HashMap source, int origin, int fence, int est, - int expectedModCount) { - throw new LinkageError(); - } - - public long estimateSize() { - throw new LinkageError(); - } - - public int characteristics() { - throw new LinkageError(); - } - - public void forEachRemaining(Consumer userAction) { - throw new LinkageError(); - } - - public boolean tryAdvance(Consumer userAction) { - throw new LinkageError(); - } - - public Spliterator trySplit() { - throw new LinkageError(); - } -} diff --git a/approximations/src/main/java/stub/java/util/LinkedHashSet_KeyIterator.java b/approximations/src/main/java/stub/java/util/LinkedHashSet_KeyIterator.java deleted file mode 100644 index 287bb47f..00000000 --- a/approximations/src/main/java/stub/java/util/LinkedHashSet_KeyIterator.java +++ /dev/null @@ -1,41 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/LinkedHashSet.lsl:39 -// -package stub.java.util; - -import java.lang.LinkageError; -import java.lang.Object; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.HashMap; -import java.util.Iterator; -import java.util.function.Consumer; -import runtime.LibSLRuntime; - -@SuppressWarnings({"all", "unchecked"}) -public final class LinkedHashSet_KeyIterator implements LibSLRuntime.HasAutomaton, Iterator { - private LinkedHashSet_KeyIterator(Void a, Void b) { - super(); - } - - private LinkedHashSet_KeyIterator(HashMap source) { - throw new LinkageError(); - } - - public boolean hasNext() { - throw new LinkageError(); - } - - public final Object next() { - throw new LinkageError(); - } - - public void remove() { - throw new LinkageError(); - } - - public void forEachRemaining(Consumer userAction) { - throw new LinkageError(); - } -} diff --git a/approximations/src/main/java/stub/java/util/LinkedHashSet_KeySpliterator.java b/approximations/src/main/java/stub/java/util/LinkedHashSet_KeySpliterator.java deleted file mode 100644 index dc299af5..00000000 --- a/approximations/src/main/java/stub/java/util/LinkedHashSet_KeySpliterator.java +++ /dev/null @@ -1,45 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/LinkedHashSet.lsl:31 -// -package stub.java.util; - -import java.lang.LinkageError; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.HashMap; -import java.util.Spliterator; -import java.util.function.Consumer; -import runtime.LibSLRuntime; - -@SuppressWarnings({"all", "unchecked"}) -public final class LinkedHashSet_KeySpliterator implements LibSLRuntime.HasAutomaton, Spliterator { - private LinkedHashSet_KeySpliterator(Void a, Void b) { - super(); - } - - private LinkedHashSet_KeySpliterator(HashMap source, int origin, int fence, int est, - int expectedModCount) { - throw new LinkageError(); - } - - public long estimateSize() { - throw new LinkageError(); - } - - public int characteristics() { - throw new LinkageError(); - } - - public void forEachRemaining(Consumer userAction) { - throw new LinkageError(); - } - - public boolean tryAdvance(Consumer userAction) { - throw new LinkageError(); - } - - public Spliterator trySplit() { - throw new LinkageError(); - } -} diff --git a/approximations/src/main/java/stub/java/util/LinkedList_DescendingIterator.java b/approximations/src/main/java/stub/java/util/LinkedList_DescendingIterator.java deleted file mode 100644 index 37a2b9e2..00000000 --- a/approximations/src/main/java/stub/java/util/LinkedList_DescendingIterator.java +++ /dev/null @@ -1,36 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/LinkedList.lsl:43 -// -package stub.java.util; - -import java.lang.LinkageError; -import java.lang.Object; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.Iterator; -import java.util.function.Consumer; -import runtime.LibSLRuntime; - -@SuppressWarnings({"all", "unchecked"}) -public final class LinkedList_DescendingIterator implements LibSLRuntime.HasAutomaton, Iterator { - private LinkedList_DescendingIterator(Void a, Void b) { - super(); - } - - public boolean hasNext() { - throw new LinkageError(); - } - - public Object next() { - throw new LinkageError(); - } - - public void remove() { - throw new LinkageError(); - } - - public void forEachRemaining(Consumer userAction) { - throw new LinkageError(); - } -} diff --git a/approximations/src/main/java/stub/java/util/LinkedList_ListItr.java b/approximations/src/main/java/stub/java/util/LinkedList_ListItr.java deleted file mode 100644 index 2df0b3b3..00000000 --- a/approximations/src/main/java/stub/java/util/LinkedList_ListItr.java +++ /dev/null @@ -1,60 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/LinkedList.lsl:34 -// -package stub.java.util; - -import java.lang.LinkageError; -import java.lang.Object; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.ListIterator; -import java.util.function.Consumer; -import runtime.LibSLRuntime; - -@SuppressWarnings({"all", "unchecked"}) -public final class LinkedList_ListItr implements LibSLRuntime.HasAutomaton, ListIterator { - private LinkedList_ListItr(Void a, Void b) { - super(); - } - - public boolean hasPrevious() { - throw new LinkageError(); - } - - public int nextIndex() { - throw new LinkageError(); - } - - public int previousIndex() { - throw new LinkageError(); - } - - public boolean hasNext() { - throw new LinkageError(); - } - - public Object next() { - throw new LinkageError(); - } - - public Object previous() { - throw new LinkageError(); - } - - public void remove() { - throw new LinkageError(); - } - - public void set(Object e) { - throw new LinkageError(); - } - - public void add(Object e) { - throw new LinkageError(); - } - - public void forEachRemaining(Consumer userAction) { - throw new LinkageError(); - } -} diff --git a/approximations/src/main/java/stub/java/util/LinkedList_Spliterator.java b/approximations/src/main/java/stub/java/util/LinkedList_Spliterator.java deleted file mode 100644 index 3fb5d733..00000000 --- a/approximations/src/main/java/stub/java/util/LinkedList_Spliterator.java +++ /dev/null @@ -1,48 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/LinkedList.lsl:52 -// -package stub.java.util; - -import java.lang.LinkageError; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.LinkedList; -import java.util.Spliterator; -import java.util.function.Consumer; -import runtime.LibSLRuntime; - -@SuppressWarnings({"all", "unchecked"}) -public final class LinkedList_Spliterator implements LibSLRuntime.HasAutomaton, Spliterator { - private LinkedList_Spliterator(Void a, Void b) { - super(); - } - - private LinkedList_Spliterator(LinkedList _this, int origin, int fence, int expectedModCount) { - throw new LinkageError(); - } - - public int characteristics() { - throw new LinkageError(); - } - - public long estimateSize() { - throw new LinkageError(); - } - - public void forEachRemaining(Consumer _action) { - throw new LinkageError(); - } - - public long getExactSizeIfKnown() { - throw new LinkageError(); - } - - public boolean tryAdvance(Consumer _action) { - throw new LinkageError(); - } - - public Spliterator trySplit() { - throw new LinkageError(); - } -} diff --git a/approximations/src/main/java/stub/java/util/LinkedList_SubList$ListIterator.java b/approximations/src/main/java/stub/java/util/LinkedList_SubList$ListIterator.java deleted file mode 100644 index a9332419..00000000 --- a/approximations/src/main/java/stub/java/util/LinkedList_SubList$ListIterator.java +++ /dev/null @@ -1,60 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/LinkedList.lsl:82 -// -package stub.java.util; - -import java.lang.LinkageError; -import java.lang.Object; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.ListIterator; -import java.util.function.Consumer; -import runtime.LibSLRuntime; - -@SuppressWarnings({"all", "unchecked"}) -public final class LinkedList_SubList$ListIterator implements LibSLRuntime.HasAutomaton, ListIterator { - private LinkedList_SubList$ListIterator(Void a, Void b) { - super(); - } - - public boolean hasPrevious() { - throw new LinkageError(); - } - - public int nextIndex() { - throw new LinkageError(); - } - - public int previousIndex() { - throw new LinkageError(); - } - - public boolean hasNext() { - throw new LinkageError(); - } - - public Object next() { - throw new LinkageError(); - } - - public Object previous() { - throw new LinkageError(); - } - - public void remove() { - throw new LinkageError(); - } - - public void set(Object e) { - throw new LinkageError(); - } - - public void add(Object e) { - throw new LinkageError(); - } - - public void forEachRemaining(Consumer userAction) { - throw new LinkageError(); - } -} diff --git a/approximations/src/main/java/stub/java/util/LinkedList_SubList$Spliterator.java b/approximations/src/main/java/stub/java/util/LinkedList_SubList$Spliterator.java deleted file mode 100644 index defcd7d6..00000000 --- a/approximations/src/main/java/stub/java/util/LinkedList_SubList$Spliterator.java +++ /dev/null @@ -1,43 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/LinkedList.lsl:72 -// -package stub.java.util; - -import java.lang.LinkageError; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.Spliterator; -import java.util.function.Consumer; -import runtime.LibSLRuntime; - -@SuppressWarnings({"all", "unchecked"}) -public final class LinkedList_SubList$Spliterator implements LibSLRuntime.HasAutomaton, Spliterator { - private LinkedList_SubList$Spliterator(Void a, Void b) { - super(); - } - - public int characteristics() { - throw new LinkageError(); - } - - public long estimateSize() { - throw new LinkageError(); - } - - public void forEachRemaining(Consumer _action) { - throw new LinkageError(); - } - - public long getExactSizeIfKnown() { - throw new LinkageError(); - } - - public boolean tryAdvance(Consumer _action) { - throw new LinkageError(); - } - - public Spliterator trySplit() { - throw new LinkageError(); - } -} diff --git a/approximations/src/main/java/stub/java/util/LinkedList_SubList.java b/approximations/src/main/java/stub/java/util/LinkedList_SubList.java deleted file mode 100644 index 8947d0c9..00000000 --- a/approximations/src/main/java/stub/java/util/LinkedList_SubList.java +++ /dev/null @@ -1,177 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/LinkedList.lsl:61 -// -package stub.java.util; - -import java.lang.LinkageError; -import java.lang.Object; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.AbstractList; -import java.util.Collection; -import java.util.Comparator; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.ListIterator; -import java.util.RandomAccess; -import java.util.Spliterator; -import java.util.function.Consumer; -import java.util.function.IntFunction; -import java.util.function.Predicate; -import java.util.function.UnaryOperator; -import java.util.stream.Stream; -import runtime.LibSLRuntime; - -@SuppressWarnings({"all", "unchecked"}) -public final class LinkedList_SubList extends AbstractList implements LibSLRuntime.HasAutomaton, List, RandomAccess { - private LinkedList_SubList(Void a, Void b) { - super(); - } - - public LinkedList_SubList(LinkedList root, int fromIndex, int toIndex) { - throw new LinkageError(); - } - - private LinkedList_SubList(LinkedList_SubList parent, int fromIndex, int toIndex) { - throw new LinkageError(); - } - - public boolean add(Object e) { - throw new LinkageError(); - } - - public void add(int index, Object element) { - throw new LinkageError(); - } - - public boolean addAll(Collection c) { - throw new LinkageError(); - } - - public boolean addAll(int index, Collection c) { - throw new LinkageError(); - } - - public void clear() { - throw new LinkageError(); - } - - public boolean contains(Object o) { - throw new LinkageError(); - } - - public boolean containsAll(Collection c) { - throw new LinkageError(); - } - - public boolean equals(Object o) { - throw new LinkageError(); - } - - public void forEach(Consumer _action) { - throw new LinkageError(); - } - - public Object get(int index) { - throw new LinkageError(); - } - - public int hashCode() { - throw new LinkageError(); - } - - public int indexOf(Object o) { - throw new LinkageError(); - } - - public boolean isEmpty() { - throw new LinkageError(); - } - - public Iterator iterator() { - throw new LinkageError(); - } - - public int lastIndexOf(Object o) { - throw new LinkageError(); - } - - public ListIterator listIterator() { - throw new LinkageError(); - } - - public ListIterator listIterator(int index) { - throw new LinkageError(); - } - - public Stream parallelStream() { - throw new LinkageError(); - } - - public boolean remove(Object o) { - throw new LinkageError(); - } - - public Object remove(int index) { - throw new LinkageError(); - } - - public boolean removeAll(Collection c) { - throw new LinkageError(); - } - - public boolean removeIf(Predicate filter) { - throw new LinkageError(); - } - - public void replaceAll(UnaryOperator operator) { - throw new LinkageError(); - } - - public boolean retainAll(Collection c) { - throw new LinkageError(); - } - - public Object set(int index, Object element) { - throw new LinkageError(); - } - - public int size() { - throw new LinkageError(); - } - - public void sort(Comparator c) { - throw new LinkageError(); - } - - public Spliterator spliterator() { - throw new LinkageError(); - } - - public Stream stream() { - throw new LinkageError(); - } - - public List subList(int fromIndex, int toIndex) { - throw new LinkageError(); - } - - public Object[] toArray() { - throw new LinkageError(); - } - - public Object[] toArray(IntFunction generator) { - throw new LinkageError(); - } - - public Object[] toArray(Object[] a) { - throw new LinkageError(); - } - - public String toString() { - throw new LinkageError(); - } -} diff --git a/approximations/src/main/java/stub/java/util/Spliterators_ArraySpliterator.java b/approximations/src/main/java/stub/java/util/Spliterators_ArraySpliterator.java deleted file mode 100644 index 6f779567..00000000 --- a/approximations/src/main/java/stub/java/util/Spliterators_ArraySpliterator.java +++ /dev/null @@ -1,62 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/Spliterators.lsl:44 -// -package stub.java.util; - -import java.lang.LinkageError; -import java.lang.Object; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.Comparator; -import java.util.Spliterator; -import java.util.function.Consumer; -import runtime.LibSLRuntime; - -@SuppressWarnings({"all", "unchecked"}) -public final class Spliterators_ArraySpliterator implements LibSLRuntime.HasAutomaton, Spliterator { - private Spliterators_ArraySpliterator(Void a, Void b) { - super(); - } - - public Spliterators_ArraySpliterator(Object[] arr, int additionalCharacteristics) { - throw new LinkageError(); - } - - public Spliterators_ArraySpliterator(Object[] arr, int origin, int pFence, - int additionalCharacteristics) { - throw new LinkageError(); - } - - public int characteristics() { - throw new LinkageError(); - } - - public long estimateSize() { - throw new LinkageError(); - } - - public void forEachRemaining(Consumer _action) { - throw new LinkageError(); - } - - public Comparator getComparator() { - throw new LinkageError(); - } - - public long getExactSizeIfKnown() { - throw new LinkageError(); - } - - public boolean hasCharacteristics(int _characteristics) { - throw new LinkageError(); - } - - public boolean tryAdvance(Consumer _action) { - throw new LinkageError(); - } - - public Spliterator trySplit() { - throw new LinkageError(); - } -} diff --git a/approximations/src/main/java/stub/java/util/Spliterators_DoubleArraySpliterator.java b/approximations/src/main/java/stub/java/util/Spliterators_DoubleArraySpliterator.java deleted file mode 100644 index 66522e36..00000000 --- a/approximations/src/main/java/stub/java/util/Spliterators_DoubleArraySpliterator.java +++ /dev/null @@ -1,70 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/Spliterators.lsl:53 -// -package stub.java.util; - -import java.lang.LinkageError; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.Comparator; -import java.util.Spliterator; -import java.util.function.Consumer; -import java.util.function.DoubleConsumer; -import runtime.LibSLRuntime; - -@SuppressWarnings({"all", "unchecked"}) -public final class Spliterators_DoubleArraySpliterator implements LibSLRuntime.HasAutomaton, Spliterator.OfDouble { - private Spliterators_DoubleArraySpliterator(Void a, Void b) { - super(); - } - - public Spliterators_DoubleArraySpliterator(double[] arr, int additionalCharacteristics) { - throw new LinkageError(); - } - - public Spliterators_DoubleArraySpliterator(double[] arr, int origin, int pFence, - int additionalCharacteristics) { - throw new LinkageError(); - } - - public int characteristics() { - throw new LinkageError(); - } - - public long estimateSize() { - throw new LinkageError(); - } - - public void forEachRemaining(DoubleConsumer _action) { - throw new LinkageError(); - } - - public void forEachRemaining(Consumer _action) { - throw new LinkageError(); - } - - public Comparator getComparator() { - throw new LinkageError(); - } - - public long getExactSizeIfKnown() { - throw new LinkageError(); - } - - public boolean hasCharacteristics(int _characteristics) { - throw new LinkageError(); - } - - public boolean tryAdvance(DoubleConsumer _action) { - throw new LinkageError(); - } - - public boolean tryAdvance(Consumer _action) { - throw new LinkageError(); - } - - public Spliterator.OfDouble trySplit() { - throw new LinkageError(); - } -} diff --git a/approximations/src/main/java/stub/java/util/Spliterators_IntArraySpliterator.java b/approximations/src/main/java/stub/java/util/Spliterators_IntArraySpliterator.java deleted file mode 100644 index 45a90c3f..00000000 --- a/approximations/src/main/java/stub/java/util/Spliterators_IntArraySpliterator.java +++ /dev/null @@ -1,70 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/Spliterators.lsl:62 -// -package stub.java.util; - -import java.lang.LinkageError; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.Comparator; -import java.util.Spliterator; -import java.util.function.Consumer; -import java.util.function.IntConsumer; -import runtime.LibSLRuntime; - -@SuppressWarnings({"all", "unchecked"}) -public final class Spliterators_IntArraySpliterator implements LibSLRuntime.HasAutomaton, Spliterator.OfInt { - private Spliterators_IntArraySpliterator(Void a, Void b) { - super(); - } - - public Spliterators_IntArraySpliterator(int[] arr, int additionalCharacteristics) { - throw new LinkageError(); - } - - public Spliterators_IntArraySpliterator(int[] arr, int origin, int pFence, - int additionalCharacteristics) { - throw new LinkageError(); - } - - public int characteristics() { - throw new LinkageError(); - } - - public long estimateSize() { - throw new LinkageError(); - } - - public void forEachRemaining(Consumer _action) { - throw new LinkageError(); - } - - public void forEachRemaining(IntConsumer _action) { - throw new LinkageError(); - } - - public Comparator getComparator() { - throw new LinkageError(); - } - - public long getExactSizeIfKnown() { - throw new LinkageError(); - } - - public boolean hasCharacteristics(int _characteristics) { - throw new LinkageError(); - } - - public boolean tryAdvance(IntConsumer _action) { - throw new LinkageError(); - } - - public boolean tryAdvance(Consumer _action) { - throw new LinkageError(); - } - - public Spliterator.OfInt trySplit() { - throw new LinkageError(); - } -} diff --git a/approximations/src/main/java/stub/java/util/Spliterators_LongArraySpliterator.java b/approximations/src/main/java/stub/java/util/Spliterators_LongArraySpliterator.java deleted file mode 100644 index 8bde7189..00000000 --- a/approximations/src/main/java/stub/java/util/Spliterators_LongArraySpliterator.java +++ /dev/null @@ -1,70 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/Spliterators.lsl:71 -// -package stub.java.util; - -import java.lang.LinkageError; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.Comparator; -import java.util.Spliterator; -import java.util.function.Consumer; -import java.util.function.LongConsumer; -import runtime.LibSLRuntime; - -@SuppressWarnings({"all", "unchecked"}) -public final class Spliterators_LongArraySpliterator implements LibSLRuntime.HasAutomaton, Spliterator.OfLong { - private Spliterators_LongArraySpliterator(Void a, Void b) { - super(); - } - - public Spliterators_LongArraySpliterator(long[] arr, int additionalCharacteristics) { - throw new LinkageError(); - } - - public Spliterators_LongArraySpliterator(long[] arr, int origin, int pFence, - int additionalCharacteristics) { - throw new LinkageError(); - } - - public int characteristics() { - throw new LinkageError(); - } - - public long estimateSize() { - throw new LinkageError(); - } - - public void forEachRemaining(Consumer _action) { - throw new LinkageError(); - } - - public void forEachRemaining(LongConsumer _action) { - throw new LinkageError(); - } - - public Comparator getComparator() { - throw new LinkageError(); - } - - public long getExactSizeIfKnown() { - throw new LinkageError(); - } - - public boolean hasCharacteristics(int _characteristics) { - throw new LinkageError(); - } - - public boolean tryAdvance(LongConsumer _action) { - throw new LinkageError(); - } - - public boolean tryAdvance(Consumer _action) { - throw new LinkageError(); - } - - public Spliterator.OfLong trySplit() { - throw new LinkageError(); - } -} diff --git a/approximations/src/main/java/stub/java/util/array/AbstractArrayIterator.java b/approximations/src/main/java/stub/java/util/array/AbstractArrayIterator.java new file mode 100644 index 00000000..04add8c0 --- /dev/null +++ b/approximations/src/main/java/stub/java/util/array/AbstractArrayIterator.java @@ -0,0 +1,43 @@ +package stub.java.util.array; + +import stub.java.util.AbstractIterator; + +import java.util.function.Consumer; + +public abstract class AbstractArrayIterator extends AbstractIterator { + + @SuppressWarnings("unused") + AbstractArrayIterator(int cursor) { + super(0); + throw new LinkageError(); + } + + protected final int _parentModCount() { + throw new LinkageError(); + } + + abstract protected int _getLength(); + + abstract protected E _getItem(int index); + + @SuppressWarnings("unused") + protected boolean _isEmpty() { + throw new LinkageError(); + } + + public boolean hasNext() { + throw new LinkageError(); + } + + public E next() { + throw new LinkageError(); + } + + public void remove() { + throw new LinkageError(); + } + + public void forEachRemaining(Consumer userAction) { + throw new LinkageError(); + } +} diff --git a/approximations/src/main/java/stub/java/util/array/AbstractArraySpliterator.java b/approximations/src/main/java/stub/java/util/array/AbstractArraySpliterator.java new file mode 100644 index 00000000..659d9058 --- /dev/null +++ b/approximations/src/main/java/stub/java/util/array/AbstractArraySpliterator.java @@ -0,0 +1,64 @@ +package stub.java.util.array; + +import java.util.Comparator; +import java.util.Spliterators; +import java.util.function.Consumer; + +@SuppressWarnings("unused") +public abstract class AbstractArraySpliterator extends Spliterators.AbstractSpliterator { + + public AbstractArraySpliterator(int index, int fence, int characteristics) { + super(fence - index, characteristics); + throw new LinkageError(); + } + + protected int _parentModCount() { + throw new LinkageError(); + } + + protected int _storageSize() { + throw new LinkageError(); + } + + protected int _getFence() { + throw new LinkageError(); + } + + protected void _checkForModification() { + throw new LinkageError(); + } + + public boolean hasCharacteristics(int _characteristics) { + throw new LinkageError(); + } + + public int characteristics() { + throw new LinkageError(); + } + + public long estimateSize() { + throw new LinkageError(); + } + + abstract protected E _getItem(int index); + + public void forEachRemaining(Consumer _action) { + throw new LinkageError(); + } + + public Comparator getComparator() { + throw new LinkageError(); + } + + public long getExactSizeIfKnown() { + throw new LinkageError(); + } + + public boolean tryAdvance(Consumer _action) { + throw new LinkageError(); + } + + public AbstractArraySpliterator trySplit() { + throw new LinkageError(); + } +} diff --git a/approximations/src/main/java/stub/java/util/array/ArrayIterator.java b/approximations/src/main/java/stub/java/util/array/ArrayIterator.java new file mode 100644 index 00000000..aef2b49f --- /dev/null +++ b/approximations/src/main/java/stub/java/util/array/ArrayIterator.java @@ -0,0 +1,46 @@ +package stub.java.util.array; + +import java.util.function.Consumer; + +public class ArrayIterator extends AbstractArrayIterator { + + @SuppressWarnings("unused") + public ArrayIterator(E[] storage, int cursor) { + super(cursor); + throw new LinkageError(); + } + + @SuppressWarnings("unused") + public ArrayIterator(E[] storage) { + this(storage, 0); + throw new LinkageError(); + } + + protected int _getLength() { + throw new LinkageError(); + } + + protected E _getItem(int index) { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public boolean hasNext() { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public E next() { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public void remove() { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public void forEachRemaining(Consumer userAction) { + throw new LinkageError(); + } +} diff --git a/approximations/src/main/java/stub/java/util/array/ArraySpliterator.java b/approximations/src/main/java/stub/java/util/array/ArraySpliterator.java new file mode 100644 index 00000000..2fae85be --- /dev/null +++ b/approximations/src/main/java/stub/java/util/array/ArraySpliterator.java @@ -0,0 +1,69 @@ +package stub.java.util.array; + +import java.lang.LinkageError; +import java.lang.Object; +import java.lang.SuppressWarnings; +import java.util.Comparator; +import java.util.function.Consumer; + +public final class ArraySpliterator extends AbstractArraySpliterator { + + @SuppressWarnings("unused") + public ArraySpliterator(E[] array, int index, int fence, int characteristics) { + super(index, fence, characteristics); + throw new LinkageError(); + } + + @SuppressWarnings("unused") + public ArraySpliterator(E[] arr, int additionalCharacteristics) { + this(arr, 0, -1, additionalCharacteristics); + throw new LinkageError(); + } + + @SuppressWarnings({"ProtectedMemberInFinalClass", "unused"}) + protected ArraySpliterator _create(int index, int fence) { + throw new LinkageError(); + } + + protected E _getItem(int index) { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public int characteristics() { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public long estimateSize() { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public void forEachRemaining(Consumer action) { + throw new LinkageError(); + } + + public Comparator getComparator() { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public long getExactSizeIfKnown() { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public boolean hasCharacteristics(int _characteristics) { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public boolean tryAdvance(Consumer action) { + throw new LinkageError(); + } + + public ArraySpliterator trySplit() { + throw new LinkageError(); + } +} diff --git a/approximations/src/main/java/stub/java/util/array/DoubleArrayIterator.java b/approximations/src/main/java/stub/java/util/array/DoubleArrayIterator.java new file mode 100644 index 00000000..4d720e01 --- /dev/null +++ b/approximations/src/main/java/stub/java/util/array/DoubleArrayIterator.java @@ -0,0 +1,54 @@ +package stub.java.util.array; + +import java.util.PrimitiveIterator; +import java.util.function.Consumer; +import java.util.function.DoubleConsumer; + +public class DoubleArrayIterator extends AbstractArrayIterator implements PrimitiveIterator.OfDouble { + + @SuppressWarnings("unused") + public DoubleArrayIterator(double[] storage, int cursor) { + super(cursor); + throw new LinkageError(); + } + + @SuppressWarnings("unused") + public DoubleArrayIterator(double[] storage) { + this(storage, 0); + throw new LinkageError(); + } + + protected int _getLength() { + throw new LinkageError(); + } + + protected Double _getItem(int index) { + throw new LinkageError(); + } + + public boolean hasNext() { + throw new LinkageError(); + } + + public Double next() { + throw new LinkageError(); + } + + public double nextDouble() { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public void remove() { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public void forEachRemaining(Consumer userAction) { + throw new LinkageError(); + } + + public void forEachRemaining(DoubleConsumer action) { + throw new LinkageError(); + } +} diff --git a/approximations/src/main/java/stub/java/util/array/DoubleArraySpliterator.java b/approximations/src/main/java/stub/java/util/array/DoubleArraySpliterator.java new file mode 100644 index 00000000..48b6919f --- /dev/null +++ b/approximations/src/main/java/stub/java/util/array/DoubleArraySpliterator.java @@ -0,0 +1,74 @@ +package stub.java.util.array; + +import java.lang.LinkageError; +import java.util.Comparator; +import java.util.Spliterator; +import java.util.function.Consumer; +import java.util.function.DoubleConsumer; + +@SuppressWarnings("unused") +public final class DoubleArraySpliterator extends AbstractArraySpliterator implements Spliterator.OfDouble { + + public DoubleArraySpliterator(double[] array, int index, int fence, int characteristics) { + super(index, fence, characteristics); + throw new LinkageError(); + } + + public DoubleArraySpliterator(double[] arr, int additionalCharacteristics) { + this(arr, 0, -1, additionalCharacteristics); + throw new LinkageError(); + } + + @SuppressWarnings("ProtectedMemberInFinalClass") + protected DoubleArraySpliterator _create(int index, int fence) { + throw new LinkageError(); + } + + protected Double _getItem(int index) { + throw new LinkageError(); + } + + public int characteristics() { + throw new LinkageError(); + } + + public long estimateSize() { + throw new LinkageError(); + } + + public void forEachRemaining(DoubleConsumer _action) { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public void forEachRemaining(Consumer action) { + throw new LinkageError(); + } + + public Comparator getComparator() { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public long getExactSizeIfKnown() { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public boolean hasCharacteristics(int _characteristics) { + throw new LinkageError(); + } + + public boolean tryAdvance(DoubleConsumer _action) { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public boolean tryAdvance(Consumer action) { + throw new LinkageError(); + } + + public DoubleArraySpliterator trySplit() { + throw new LinkageError(); + } +} diff --git a/approximations/src/main/java/stub/java/util/array/IntArrayIterator.java b/approximations/src/main/java/stub/java/util/array/IntArrayIterator.java new file mode 100644 index 00000000..4806b1e1 --- /dev/null +++ b/approximations/src/main/java/stub/java/util/array/IntArrayIterator.java @@ -0,0 +1,54 @@ +package stub.java.util.array; + +import java.util.PrimitiveIterator; +import java.util.function.Consumer; +import java.util.function.IntConsumer; + +public class IntArrayIterator extends AbstractArrayIterator implements PrimitiveIterator.OfInt { + + @SuppressWarnings("unused") + public IntArrayIterator(int[] storage, int cursor) { + super(cursor); + throw new LinkageError(); + } + + @SuppressWarnings("unused") + public IntArrayIterator(int[] storage) { + this(storage, 0); + throw new LinkageError(); + } + + protected int _getLength() { + throw new LinkageError(); + } + + protected Integer _getItem(int index) { + throw new LinkageError(); + } + + public boolean hasNext() { + throw new LinkageError(); + } + + public Integer next() { + throw new LinkageError(); + } + + public int nextInt() { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public void remove() { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public void forEachRemaining(Consumer action) { + throw new LinkageError(); + } + + public void forEachRemaining(IntConsumer action) { + throw new LinkageError(); + } +} diff --git a/approximations/src/main/java/stub/java/util/array/IntArraySpliterator.java b/approximations/src/main/java/stub/java/util/array/IntArraySpliterator.java new file mode 100644 index 00000000..ba985e8a --- /dev/null +++ b/approximations/src/main/java/stub/java/util/array/IntArraySpliterator.java @@ -0,0 +1,77 @@ +package stub.java.util.array; + +import generated.java.util.array.IntArraySpliteratorImpl; + +import java.lang.LinkageError; +import java.util.Comparator; +import java.util.Spliterator; +import java.util.function.Consumer; +import java.util.function.IntConsumer; + +public final class IntArraySpliterator extends AbstractArraySpliterator implements Spliterator.OfInt { + + @SuppressWarnings("unused") + public IntArraySpliterator(int[] array, int index, int fence, int characteristics) { + super(index, fence, characteristics); + throw new LinkageError(); + } + + @SuppressWarnings("unused") + public IntArraySpliterator(int[] arr, int additionalCharacteristics) { + this(arr, 0, arr.length, additionalCharacteristics); + throw new LinkageError(); + } + + @SuppressWarnings({"ProtectedMemberInFinalClass", "unused"}) + protected IntArraySpliteratorImpl _create(int index, int fence) { + throw new LinkageError(); + } + + protected Integer _getItem(int index) { + throw new LinkageError(); + } + + public int characteristics() { + throw new LinkageError(); + } + + public long estimateSize() { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public void forEachRemaining(Consumer action) { + throw new LinkageError(); + } + + public void forEachRemaining(IntConsumer action) { + throw new LinkageError(); + } + + public Comparator getComparator() { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public long getExactSizeIfKnown() { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public boolean hasCharacteristics(int characteristics) { + throw new LinkageError(); + } + + public boolean tryAdvance(IntConsumer action) { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public boolean tryAdvance(Consumer action) { + throw new LinkageError(); + } + + public IntArraySpliterator trySplit() { + throw new LinkageError(); + } +} diff --git a/approximations/src/main/java/stub/java/util/array/LongArrayIterator.java b/approximations/src/main/java/stub/java/util/array/LongArrayIterator.java new file mode 100644 index 00000000..8930acad --- /dev/null +++ b/approximations/src/main/java/stub/java/util/array/LongArrayIterator.java @@ -0,0 +1,54 @@ +package stub.java.util.array; + +import java.util.PrimitiveIterator; +import java.util.function.Consumer; +import java.util.function.LongConsumer; + +public class LongArrayIterator extends AbstractArrayIterator implements PrimitiveIterator.OfLong { + + @SuppressWarnings("unused") + public LongArrayIterator(long[] storage, int cursor) { + super(cursor); + throw new LinkageError(); + } + + @SuppressWarnings("unused") + public LongArrayIterator(long[] storage) { + this(storage, 0); + throw new LinkageError(); + } + + protected int _getLength() { + throw new LinkageError(); + } + + protected Long _getItem(int index) { + throw new LinkageError(); + } + + public boolean hasNext() { + throw new LinkageError(); + } + + public Long next() { + throw new LinkageError(); + } + + public long nextLong() { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public void remove() { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public void forEachRemaining(Consumer action) { + throw new LinkageError(); + } + + public void forEachRemaining(LongConsumer action) { + throw new LinkageError(); + } +} diff --git a/approximations/src/main/java/stub/java/util/array/LongArraySpliterator.java b/approximations/src/main/java/stub/java/util/array/LongArraySpliterator.java new file mode 100644 index 00000000..466536d0 --- /dev/null +++ b/approximations/src/main/java/stub/java/util/array/LongArraySpliterator.java @@ -0,0 +1,75 @@ +package stub.java.util.array; + +import java.lang.LinkageError; +import java.util.Comparator; +import java.util.Spliterator; +import java.util.function.Consumer; +import java.util.function.LongConsumer; + +public final class LongArraySpliterator extends AbstractArraySpliterator implements Spliterator.OfLong { + + @SuppressWarnings("unused") + public LongArraySpliterator(long[] array, int index, int fence, int characteristics) { + super(index, fence, characteristics); + throw new LinkageError(); + } + + @SuppressWarnings("unused") + public LongArraySpliterator(long[] arr, int additionalCharacteristics) { + this(arr, 0, arr.length, additionalCharacteristics); + throw new LinkageError(); + } + + @SuppressWarnings({"unused", "ProtectedMemberInFinalClass"}) + protected LongArraySpliterator _create(int index, int fence) { + throw new LinkageError(); + } + + protected Long _getItem(int index) { + throw new LinkageError(); + } + + public int characteristics() { + throw new LinkageError(); + } + + public long estimateSize() { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public void forEachRemaining(Consumer action) { + throw new LinkageError(); + } + + public void forEachRemaining(LongConsumer action) { + throw new LinkageError(); + } + + public Comparator getComparator() { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public long getExactSizeIfKnown() { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public boolean hasCharacteristics(int characteristics) { + throw new LinkageError(); + } + + public boolean tryAdvance(LongConsumer action) { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public boolean tryAdvance(Consumer action) { + throw new LinkageError(); + } + + public LongArraySpliterator trySplit() { + throw new LinkageError(); + } +} diff --git a/approximations/src/main/java/stub/java/util/list/LinkedList_DescendingIterator.java b/approximations/src/main/java/stub/java/util/list/LinkedList_DescendingIterator.java new file mode 100644 index 00000000..6e4f3e0f --- /dev/null +++ b/approximations/src/main/java/stub/java/util/list/LinkedList_DescendingIterator.java @@ -0,0 +1,34 @@ +package stub.java.util.list; + +import generated.java.util.list.LinkedListImpl; + +import java.lang.LinkageError; +import java.util.function.Consumer; + +public final class LinkedList_DescendingIterator extends ListIteratorStub { + + public LinkedList_DescendingIterator(LinkedListImpl list) { + super(list); + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public boolean hasNext() { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public E next() { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public void remove() { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public void forEachRemaining(Consumer userAction) { + throw new LinkageError(); + } +} diff --git a/approximations/src/main/java/stub/java/util/list/ListIteratorStub.java b/approximations/src/main/java/stub/java/util/list/ListIteratorStub.java new file mode 100644 index 00000000..79bb2ea1 --- /dev/null +++ b/approximations/src/main/java/stub/java/util/list/ListIteratorStub.java @@ -0,0 +1,88 @@ +package stub.java.util.list; + +import generated.java.util.list.AbstractListImpl; +import org.usvm.api.SymbolicList; +import stub.java.util.AbstractIterator; + +import java.lang.LinkageError; +import java.util.ListIterator; +import java.util.function.Consumer; + +public class ListIteratorStub extends AbstractIterator implements ListIterator { + + @SuppressWarnings("unused") + public ListIteratorStub(AbstractListImpl list, int index, int expectedModCount) { + super(expectedModCount); + throw new LinkageError(); + } + + public ListIteratorStub(AbstractListImpl list, int index) { + this(list, index, list.modCount); + throw new LinkageError(); + } + + @SuppressWarnings("unused") + public ListIteratorStub(AbstractListImpl list) { + this(list, 0); + throw new LinkageError(); + } + + @SuppressWarnings("unused") + protected AbstractListImpl _getList() { + throw new LinkageError(); + } + + protected int _parentModCount() { + throw new LinkageError(); + } + + @SuppressWarnings("unused") + protected int _getSize(SymbolicList storage) { + throw new LinkageError(); + } + + public boolean hasPrevious() { + throw new LinkageError(); + } + + public int nextIndex() { + throw new LinkageError(); + } + + public int previousIndex() { + throw new LinkageError(); + } + + @SuppressWarnings("unused") + protected boolean _hasNext(int size) { + throw new LinkageError(); + } + + public boolean hasNext() { + throw new LinkageError(); + } + + public E next() { + throw new LinkageError(); + } + + public E previous() { + throw new LinkageError(); + } + + public void remove() { + throw new LinkageError(); + } + + public void set(E e) { + throw new LinkageError(); + } + + public void add(E e) { + throw new LinkageError(); + } + + public void forEachRemaining(Consumer userAction) { + throw new LinkageError(); + } +} diff --git a/approximations/src/main/java/stub/java/util/list/ListSpliteratorStub.java b/approximations/src/main/java/stub/java/util/list/ListSpliteratorStub.java new file mode 100644 index 00000000..d7cec2cb --- /dev/null +++ b/approximations/src/main/java/stub/java/util/list/ListSpliteratorStub.java @@ -0,0 +1,60 @@ +package stub.java.util.list; + +import generated.java.util.list.AbstractListImpl; + +import java.lang.LinkageError; +import java.util.Spliterators; +import java.util.function.Consumer; + +public class ListSpliteratorStub extends Spliterators.AbstractSpliterator { + + @SuppressWarnings("unused") + protected ListSpliteratorStub(AbstractListImpl list, int index, int fence, int expectedModCount) { + super(fence - index, expectedModCount); + throw new LinkageError(); + } + + @SuppressWarnings("unused") + public ListSpliteratorStub(AbstractListImpl list) { + this(list, 0, -1, 0); + throw new LinkageError(); + } + + @SuppressWarnings("unused") + protected ListSpliteratorStub _create(int index, int fence) { + throw new LinkageError(); + } + + protected int _parentModCount() { + throw new LinkageError(); + } + + @SuppressWarnings("unused") + protected int _storageSize() { + throw new LinkageError(); + } + + public int characteristics() { + throw new LinkageError(); + } + + public long estimateSize() { + throw new LinkageError(); + } + + public void forEachRemaining(Consumer _action) { + throw new LinkageError(); + } + + public long getExactSizeIfKnown() { + throw new LinkageError(); + } + + public boolean tryAdvance(Consumer _action) { + throw new LinkageError(); + } + + public ListSpliteratorStub trySplit() { + throw new LinkageError(); + } +} diff --git a/approximations/src/main/java/stub/java/util/list/SubList.java b/approximations/src/main/java/stub/java/util/list/SubList.java new file mode 100644 index 00000000..cef9261f --- /dev/null +++ b/approximations/src/main/java/stub/java/util/list/SubList.java @@ -0,0 +1,207 @@ +package stub.java.util.list; + +import generated.java.util.list.AbstractListImpl; +import generated.java.util.list.SubListImpl; +import org.jetbrains.annotations.NotNull; + +import java.io.Serial; +import java.io.Serializable; +import java.lang.LinkageError; +import java.lang.Object; +import java.lang.String; +import java.util.AbstractList; +import java.util.Collection; +import java.util.Comparator; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.RandomAccess; +import java.util.Spliterator; +import java.util.function.Consumer; +import java.util.function.IntFunction; +import java.util.function.Predicate; +import java.util.function.UnaryOperator; +import java.util.stream.Stream; + +public final class SubList extends AbstractList implements RandomAccess, Cloneable, Serializable { + + @Serial + private static final long serialVersionUID = 8683452581122892189L; + + @SuppressWarnings("unused") + private SubList(AbstractListImpl list, SubListImpl parent, int offset, int length, int modCount) { + throw new LinkageError(); + } + + @SuppressWarnings("unused") + public SubList(AbstractListImpl list, int fromIndex, int toIndex) { + throw new LinkageError(); + } + + @SuppressWarnings("unused") + public AbstractListImpl _getList() { + throw new LinkageError(); + } + + @SuppressWarnings("unused") + public int _endIndex() { + throw new LinkageError(); + } + + @SuppressWarnings("unused") + public boolean _addAllElements(int index, Collection c) { + throw new LinkageError(); + } + + @SuppressWarnings("unused") + public void _updateSizeAndModCount(int sizeChange) { + throw new LinkageError(); + } + + @SuppressWarnings({"unused", "ProtectedMemberInFinalClass"}) + protected Object[] _mapToArray() { + throw new LinkageError(); + } + + public void add(int index, E element) { + throw new LinkageError(); + } + + public boolean add(E e) { + throw new LinkageError(); + } + + public boolean addAll(@NotNull Collection c) { + throw new LinkageError(); + } + + public boolean addAll(int index, @NotNull Collection c) { + throw new LinkageError(); + } + + public void clear() { + throw new LinkageError(); + } + + public Object clone() throws CloneNotSupportedException { + throw new LinkageError(); + } + + public boolean contains(Object o) { + throw new LinkageError(); + } + + public boolean containsAll(@NotNull Collection c) { + throw new LinkageError(); + } + + public boolean equals(Object o) { + throw new LinkageError(); + } + + public void forEach(Consumer _action) { + throw new LinkageError(); + } + + public E get(int index) { + throw new LinkageError(); + } + + public int hashCode() { + throw new LinkageError(); + } + + public int indexOf(Object o) { + throw new LinkageError(); + } + + public boolean isEmpty() { + throw new LinkageError(); + } + + @NotNull + public Iterator iterator() { + throw new LinkageError(); + } + + public int lastIndexOf(Object o) { + throw new LinkageError(); + } + + @NotNull + public ListIterator listIterator() { + throw new LinkageError(); + } + + @NotNull + public ListIterator listIterator(int index) { + throw new LinkageError(); + } + + public Stream parallelStream() { + throw new LinkageError(); + } + + public boolean remove(Object o) { + throw new LinkageError(); + } + + public E remove(int index) { + throw new LinkageError(); + } + + public boolean removeAll(@NotNull Collection c) { + throw new LinkageError(); + } + + public boolean removeIf(Predicate filter) { + throw new LinkageError(); + } + + public void replaceAll(UnaryOperator operator) { + throw new LinkageError(); + } + + public boolean retainAll(@NotNull Collection c) { + throw new LinkageError(); + } + + public int size() { + throw new LinkageError(); + } + + public void sort(Comparator c) { + throw new LinkageError(); + } + + public Spliterator spliterator() { + throw new LinkageError(); + } + + public Stream stream() { + throw new LinkageError(); + } + + @NotNull + public List subList(int fromIndex, int toIndex) { + throw new LinkageError(); + } + + @NotNull + public Object[] toArray() { + throw new LinkageError(); + } + + public T[] toArray(IntFunction generator) { + throw new LinkageError(); + } + + @NotNull + public T[] toArray(@NotNull T[] array) { + throw new LinkageError(); + } + + public String toString() { + throw new LinkageError(); + } +} diff --git a/approximations/src/main/java/stub/java/util/list/SubListIteratorStub.java b/approximations/src/main/java/stub/java/util/list/SubListIteratorStub.java new file mode 100644 index 00000000..a16879ab --- /dev/null +++ b/approximations/src/main/java/stub/java/util/list/SubListIteratorStub.java @@ -0,0 +1,91 @@ +package stub.java.util.list; + +import generated.java.util.list.AbstractListImpl; +import generated.java.util.list.SubListImpl; +import org.usvm.api.SymbolicList; + +import java.lang.LinkageError; +import java.util.function.Consumer; + +public final class SubListIteratorStub extends ListIteratorStub { + + @SuppressWarnings("unused") + public SubListIteratorStub( + AbstractListImpl list, + SubListImpl subList, + int cursor, + int expectedModCount, + int offset, + int length + ) { + super(list); + throw new LinkageError(); + } + + @SuppressWarnings("unused") + public SubListIteratorStub(SubListImpl subList, int index) { + super(subList, index); + throw new LinkageError(); + } + + @SuppressWarnings("unused") + public SubListIteratorStub(SubListImpl subList) { + super(subList); + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + protected int _getSize(SymbolicList storage) { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public boolean hasPrevious() { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public int nextIndex() { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public int previousIndex() { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public boolean hasNext() { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public E next() { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public E previous() { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public void remove() { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public void set(E e) { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public void add(E e) { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public void forEachRemaining(Consumer userAction) { + throw new LinkageError(); + } +} diff --git a/approximations/src/main/java/stub/java/util/list/SubListSpliteratorStub.java b/approximations/src/main/java/stub/java/util/list/SubListSpliteratorStub.java new file mode 100644 index 00000000..8fafac04 --- /dev/null +++ b/approximations/src/main/java/stub/java/util/list/SubListSpliteratorStub.java @@ -0,0 +1,76 @@ +package stub.java.util.list; + +import generated.java.util.list.AbstractListImpl; +import generated.java.util.list.SubListImpl; + +import java.lang.LinkageError; +import java.util.function.Consumer; + +public final class SubListSpliteratorStub extends ListSpliteratorStub { + + @SuppressWarnings("unused") + public SubListSpliteratorStub( + AbstractListImpl list, + SubListImpl subList, + int index, + int fence, + int expectedModCount + ) { + super(list, index, fence, expectedModCount); + throw new LinkageError(); + } + + public SubListSpliteratorStub(SubListImpl subList, int index) { + this(subList._getList(), subList, index, -1, 0); + throw new LinkageError(); + } + + @SuppressWarnings("unused") + public SubListSpliteratorStub(SubListImpl subList) { + this(subList, 0); + throw new LinkageError(); + } + + protected SubListSpliteratorStub _create(int index, int fence) { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + protected int _parentModCount() { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + protected int _storageSize() { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public int characteristics() { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public long estimateSize() { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public void forEachRemaining(Consumer _action) { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public long getExactSizeIfKnown() { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public boolean tryAdvance(Consumer _action) { + throw new LinkageError(); + } + + public SubListSpliteratorStub trySplit() { + throw new LinkageError(); + } +} diff --git a/approximations/src/main/java/stub/java/util/map/AbstractMap_Entry.java b/approximations/src/main/java/stub/java/util/map/AbstractMap_Entry.java new file mode 100644 index 00000000..f166fa04 --- /dev/null +++ b/approximations/src/main/java/stub/java/util/map/AbstractMap_Entry.java @@ -0,0 +1,40 @@ +package stub.java.util.map; + +import java.util.Map; + +public class AbstractMap_Entry implements Map.Entry { + + @SuppressWarnings("unused") + public AbstractMap_Entry(Map.Entry entry) { + throw new LinkageError(); + } + + @SuppressWarnings("unused") + public AbstractMap_Entry(K key, V value) { + throw new LinkageError(); + } + + public boolean equals(Object other) { + throw new LinkageError(); + } + + public K getKey() { + throw new LinkageError(); + } + + public V getValue() { + throw new LinkageError(); + } + + public int hashCode() { + throw new LinkageError(); + } + + public V setValue(V value) { + throw new LinkageError(); + } + + public String toString() { + throw new LinkageError(); + } +} diff --git a/approximations/src/main/java/stub/java/util/map/Map_Contents.java b/approximations/src/main/java/stub/java/util/map/Map_Contents.java new file mode 100644 index 00000000..e59fe8b9 --- /dev/null +++ b/approximations/src/main/java/stub/java/util/map/Map_Contents.java @@ -0,0 +1,123 @@ +package stub.java.util.map; + +import generated.java.util.map.AbstractMapImpl; +import org.jetbrains.annotations.NotNull; +import runtime.LibSLRuntime; + +import java.util.*; +import java.util.function.Consumer; +import java.util.function.IntFunction; +import java.util.function.Predicate; +import java.util.stream.Stream; + +public abstract class Map_Contents extends AbstractCollection { + + public Map_Contents(AbstractMapImpl map) { + throw new LinkageError(); + } + + LibSLRuntime.Map> getStorage() { + throw new LinkageError(); + } + + abstract Content _contentByKey(LibSLRuntime.Map> storage, K key); + + protected Object[] _mapToArray() { + throw new LinkageError(); + } + + public boolean add(Content e) { + throw new LinkageError(); + } + + public boolean addAll(@NotNull Collection c) { + throw new LinkageError(); + } + + public void clear() { + throw new LinkageError(); + } + + abstract boolean _containsInStorage(LibSLRuntime.Map> storage, Object o); + + public boolean contains(Object obj) { + throw new LinkageError(); + } + + public boolean containsAll(@NotNull Collection c) { + throw new LinkageError(); + } + + Collection _equalsTypeCheck(Object other) { + throw new LinkageError(); + } + + public boolean equals(Object other) { + throw new LinkageError(); + } + + public void forEach(Consumer userAction) { + throw new LinkageError(); + } + + public int hashCode() { + throw new LinkageError(); + } + + public boolean isEmpty() { + throw new LinkageError(); + } + + @NotNull + public Iterator iterator() { + throw new LinkageError(); + } + + public Stream parallelStream() { + throw new LinkageError(); + } + + public abstract boolean remove(Object o); + + public boolean removeAll(@NotNull Collection c) { + throw new LinkageError(); + } + + public boolean removeIf(Predicate filter) { + throw new LinkageError(); + } + + public boolean retainAll(@NotNull Collection c) { + throw new LinkageError(); + } + + public int size() { + throw new LinkageError(); + } + + public Spliterator spliterator() { + throw new LinkageError(); + } + + public Stream stream() { + throw new LinkageError(); + } + + @NotNull + public Object[] toArray() { + throw new LinkageError(); + } + + public T[] toArray(IntFunction generator) { + throw new LinkageError(); + } + + @NotNull + public T[] toArray(@NotNull T[] array) { + throw new LinkageError(); + } + + public String toString() { + throw new LinkageError(); + } +} diff --git a/approximations/src/main/java/stub/java/util/map/Map_ContentsSet.java b/approximations/src/main/java/stub/java/util/map/Map_ContentsSet.java new file mode 100644 index 00000000..11ec514a --- /dev/null +++ b/approximations/src/main/java/stub/java/util/map/Map_ContentsSet.java @@ -0,0 +1,110 @@ +package stub.java.util.map; + +import generated.java.util.map.AbstractMapImpl; +import org.jetbrains.annotations.NotNull; + +import java.util.*; +import java.util.function.Consumer; +import java.util.function.IntFunction; +import java.util.function.Predicate; +import java.util.stream.Stream; + +@SuppressWarnings("RedundantMethodOverride") +public abstract class Map_ContentsSet extends Map_Contents implements Set { + + public Map_ContentsSet(AbstractMapImpl map) { + super(map); + throw new LinkageError(); + } + + public boolean add(Content e) { + throw new LinkageError(); + } + + public boolean addAll(@NotNull Collection c) { + throw new LinkageError(); + } + + public void clear() { + throw new LinkageError(); + } + + public boolean contains(Object obj) { + throw new LinkageError(); + } + + public boolean containsAll(@NotNull Collection c) { + throw new LinkageError(); + } + + Set _equalsTypeCheck(Object other) { + throw new LinkageError(); + } + + public boolean equals(Object other) { + throw new LinkageError(); + } + + public void forEach(Consumer userAction) { + throw new LinkageError(); + } + + public int hashCode() { + throw new LinkageError(); + } + + public boolean isEmpty() { + throw new LinkageError(); + } + + @NotNull + public Iterator iterator() { + throw new LinkageError(); + } + + public Stream parallelStream() { + throw new LinkageError(); + } + + public boolean removeAll(@NotNull Collection c) { + throw new LinkageError(); + } + + public boolean removeIf(Predicate filter) { + throw new LinkageError(); + } + + public boolean retainAll(@NotNull Collection c) { + throw new LinkageError(); + } + + public int size() { + throw new LinkageError(); + } + + public Spliterator spliterator() { + throw new LinkageError(); + } + + public Stream stream() { + throw new LinkageError(); + } + + @NotNull + public Object[] toArray() { + throw new LinkageError(); + } + + public T[] toArray(IntFunction generator) { + throw new LinkageError(); + } + + @NotNull + public T[] toArray(@NotNull T[] array) { + throw new LinkageError(); + } + + public String toString() { + throw new LinkageError(); + } +} diff --git a/approximations/src/main/java/stub/java/util/map/Map_ContentsSet_Spliterator.java b/approximations/src/main/java/stub/java/util/map/Map_ContentsSet_Spliterator.java new file mode 100644 index 00000000..73396e05 --- /dev/null +++ b/approximations/src/main/java/stub/java/util/map/Map_ContentsSet_Spliterator.java @@ -0,0 +1,71 @@ +package stub.java.util.map; + +import generated.java.util.map.Map_ContentsSetImpl; +import org.usvm.api.SymbolicList; + +import java.util.function.Consumer; + +@SuppressWarnings("unused") +public class Map_ContentsSet_Spliterator extends Map_Contents_Spliterator { + + private Map_ContentsSet_Spliterator( + Map_ContentsSetImpl set, + SymbolicList seenKeys, + SymbolicList unseenKeys, + int index, + int fence, + int expectedModCount + ) { + super(set, seenKeys, unseenKeys, index, fence, expectedModCount); + throw new LinkageError(); + } + + public Map_ContentsSet_Spliterator(Map_ContentsSetImpl set) { + super(set); + throw new LinkageError(); + } + + Map_ContentsSet_Spliterator _createSpliterator( + SymbolicList seenKeys, + SymbolicList unseenKeys, + int index, + int fence, + int expectedModCount + ) { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + protected int _defaultCharacteristics() { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public int characteristics() { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public long estimateSize() { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public void forEachRemaining(Consumer userAction) { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public long getExactSizeIfKnown() { + throw new LinkageError(); + } + + @SuppressWarnings("RedundantMethodOverride") + public boolean tryAdvance(Consumer userAction) { + throw new LinkageError(); + } + + public Map_ContentsSet_Spliterator trySplit() { + throw new LinkageError(); + } +} diff --git a/approximations/src/main/java/stub/java/util/map/Map_Contents_Iterator.java b/approximations/src/main/java/stub/java/util/map/Map_Contents_Iterator.java new file mode 100644 index 00000000..6d5d0f9b --- /dev/null +++ b/approximations/src/main/java/stub/java/util/map/Map_Contents_Iterator.java @@ -0,0 +1,41 @@ +package stub.java.util.map; + +import generated.java.util.map.Map_ContentsSetImpl; +import runtime.LibSLRuntime; +import stub.java.util.AbstractIterator; + +import java.util.Map; +import java.util.function.Consumer; + +public class Map_Contents_Iterator extends AbstractIterator { + + @SuppressWarnings("unused") + public Map_Contents_Iterator( + Map_ContentsSetImpl parent, + LibSLRuntime.Map> unseen, + int expectedModCount + ) { + super(expectedModCount); + throw new LinkageError(); + } + + protected int _parentModCount() { + throw new LinkageError(); + } + + public void forEachRemaining(Consumer userAction) { + throw new LinkageError(); + } + + public boolean hasNext() { + throw new LinkageError(); + } + + public Content next() { + throw new LinkageError(); + } + + public void remove() { + throw new LinkageError(); + } +} diff --git a/approximations/src/main/java/stub/java/util/map/Map_Contents_Spliterator.java b/approximations/src/main/java/stub/java/util/map/Map_Contents_Spliterator.java new file mode 100644 index 00000000..95f810a1 --- /dev/null +++ b/approximations/src/main/java/stub/java/util/map/Map_Contents_Spliterator.java @@ -0,0 +1,83 @@ +package stub.java.util.map; + +import generated.java.util.map.Map_ContentsImpl; +import org.usvm.api.Engine; +import org.usvm.api.SymbolicList; + +import java.util.Spliterators; +import java.util.function.Consumer; + +public class Map_Contents_Spliterator extends Spliterators.AbstractSpliterator { + + @SuppressWarnings("unused") + Map_Contents_Spliterator( + Map_ContentsImpl contents, + SymbolicList seenKeys, + SymbolicList unseenKeys, + int index, + int fence, + int expectedModCount + ) { + super(fence - index, expectedModCount); + throw new LinkageError(); + } + + @SuppressWarnings("unused") + public Map_Contents_Spliterator(Map_ContentsImpl contents) { + this(contents, Engine.makeSymbolicList(), null, 0, -1, 0); + throw new LinkageError(); + } + + @SuppressWarnings("unused") + protected Spliterators.AbstractSpliterator _create(int index, int fence) { + throw new LinkageError(); + } + + @SuppressWarnings("unused") + Map_Contents_Spliterator _createSpliterator( + SymbolicList seenKeys, + SymbolicList unseenKeys, + int index, + int fence, + int expectedModCount + ) { + throw new LinkageError(); + } + + protected int _parentModCount() { + throw new LinkageError(); + } + + protected int _storageSize() { + throw new LinkageError(); + } + + @SuppressWarnings("unused") + protected int _defaultCharacteristics() { + throw new LinkageError(); + } + + public int characteristics() { + throw new LinkageError(); + } + + public long estimateSize() { + throw new LinkageError(); + } + + public void forEachRemaining(Consumer userAction) { + throw new LinkageError(); + } + + public long getExactSizeIfKnown() { + throw new LinkageError(); + } + + public boolean tryAdvance(Consumer userAction) { + throw new LinkageError(); + } + + public Map_Contents_Spliterator trySplit() { + throw new LinkageError(); + } +} diff --git a/approximations/src/main/java/stub/java/util/map/Map_EntrySet.java b/approximations/src/main/java/stub/java/util/map/Map_EntrySet.java new file mode 100644 index 00000000..6633b826 --- /dev/null +++ b/approximations/src/main/java/stub/java/util/map/Map_EntrySet.java @@ -0,0 +1,118 @@ +package stub.java.util.map; + +import generated.java.util.map.AbstractMapImpl; +import org.jetbrains.annotations.NotNull; +import runtime.LibSLRuntime; + +import java.util.*; +import java.util.function.Consumer; +import java.util.function.IntFunction; +import java.util.function.Predicate; +import java.util.stream.Stream; + +@SuppressWarnings("RedundantMethodOverride") +public final class Map_EntrySet extends Map_ContentsSet> { + + public Map_EntrySet(AbstractMapImpl parent) { + super(parent); + } + + Map.Entry _contentByKey(LibSLRuntime.Map> storage, K key) { + throw new LinkageError(); + } + + public boolean add(Map.Entry e) { + throw new LinkageError(); + } + + public boolean addAll(@NotNull Collection> c) { + throw new LinkageError(); + } + + public void clear() { + throw new LinkageError(); + } + + boolean _containsInStorage(LibSLRuntime.Map> storage, Object o) { + throw new LinkageError(); + } + + public boolean contains(Object o) { + throw new LinkageError(); + } + + public boolean containsAll(@NotNull Collection c) { + throw new LinkageError(); + } + + public boolean equals(Object other) { + throw new LinkageError(); + } + + public void forEach(Consumer> userAction) { + throw new LinkageError(); + } + + public int hashCode() { + throw new LinkageError(); + } + + public boolean isEmpty() { + throw new LinkageError(); + } + + @NotNull + public Iterator> iterator() { + throw new LinkageError(); + } + + public Stream> parallelStream() { + throw new LinkageError(); + } + + public boolean remove(Object o) { + throw new LinkageError(); + } + + public boolean removeAll(@NotNull Collection c) { + throw new LinkageError(); + } + + public boolean removeIf(Predicate> filter) { + throw new LinkageError(); + } + + public boolean retainAll(@NotNull Collection c) { + throw new LinkageError(); + } + + public int size() { + throw new LinkageError(); + } + + public Spliterator> spliterator() { + throw new LinkageError(); + } + + public Stream> stream() { + throw new LinkageError(); + } + + @NotNull + public Object[] toArray() { + throw new LinkageError(); + } + + public T[] toArray(IntFunction generator) { + throw new LinkageError(); + } + + @NotNull + public T[] toArray(@NotNull T[] array) { + throw new LinkageError(); + } + + public String toString() { + throw new LinkageError(); + } +} diff --git a/approximations/src/main/java/stub/java/util/map/Map_KeySet.java b/approximations/src/main/java/stub/java/util/map/Map_KeySet.java new file mode 100644 index 00000000..3a56d12b --- /dev/null +++ b/approximations/src/main/java/stub/java/util/map/Map_KeySet.java @@ -0,0 +1,122 @@ +package stub.java.util.map; + +import generated.java.util.map.AbstractMapImpl; +import org.jetbrains.annotations.NotNull; +import runtime.LibSLRuntime; + +import java.lang.LinkageError; +import java.lang.Object; +import java.lang.String; +import java.util.*; +import java.util.function.Consumer; +import java.util.function.IntFunction; +import java.util.function.Predicate; +import java.util.stream.Stream; + +@SuppressWarnings("RedundantMethodOverride") +public final class Map_KeySet extends Map_ContentsSet { + + public Map_KeySet(AbstractMapImpl parent) { + super(parent); + throw new LinkageError(); + } + + K _contentByKey(LibSLRuntime.Map> storage, K key) { + throw new LinkageError(); + } + + public boolean add(K e) { + throw new LinkageError(); + } + + public boolean addAll(@NotNull Collection c) { + throw new LinkageError(); + } + + public void clear() { + throw new LinkageError(); + } + + boolean _containsInStorage(LibSLRuntime.Map> storage, Object o) { + throw new LinkageError(); + } + + public boolean contains(Object key) { + throw new LinkageError(); + } + + public boolean containsAll(@NotNull Collection c) { + throw new LinkageError(); + } + + public boolean equals(Object other) { + throw new LinkageError(); + } + + public void forEach(Consumer userAction) { + throw new LinkageError(); + } + + public int hashCode() { + throw new LinkageError(); + } + + public boolean isEmpty() { + throw new LinkageError(); + } + + @NotNull + public Iterator iterator() { + throw new LinkageError(); + } + + public Stream parallelStream() { + throw new LinkageError(); + } + + public boolean remove(Object key) { + throw new LinkageError(); + } + + public boolean removeAll(@NotNull Collection c) { + throw new LinkageError(); + } + + public boolean removeIf(Predicate filter) { + throw new LinkageError(); + } + + public boolean retainAll(@NotNull Collection c) { + throw new LinkageError(); + } + + public int size() { + throw new LinkageError(); + } + + public Spliterator spliterator() { + throw new LinkageError(); + } + + public Stream stream() { + throw new LinkageError(); + } + + @NotNull + public Object[] toArray() { + throw new LinkageError(); + } + + public T[] toArray(IntFunction generator) { + throw new LinkageError(); + } + + @NotNull + public T[] toArray(@NotNull T[] array) { + throw new LinkageError(); + } + + public String toString() { + throw new LinkageError(); + } +} diff --git a/approximations/src/main/java/stub/java/util/HashMap_KeySet.java b/approximations/src/main/java/stub/java/util/map/Map_Values.java similarity index 50% rename from approximations/src/main/java/stub/java/util/HashMap_KeySet.java rename to approximations/src/main/java/stub/java/util/map/Map_Values.java index 3e0aa775..49eb2a49 100644 --- a/approximations/src/main/java/stub/java/util/HashMap_KeySet.java +++ b/approximations/src/main/java/stub/java/util/map/Map_Values.java @@ -1,64 +1,56 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/HashMap.lsl:63 -// -package stub.java.util; +package stub.java.util.map; + +import generated.java.util.map.AbstractMapImpl; +import org.jetbrains.annotations.NotNull; +import runtime.LibSLRuntime; import java.lang.LinkageError; import java.lang.Object; import java.lang.String; import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.AbstractSet; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Spliterator; +import java.util.*; import java.util.function.Consumer; import java.util.function.IntFunction; import java.util.function.Predicate; import java.util.stream.Stream; -import runtime.LibSLRuntime; -@SuppressWarnings({"all", "unchecked"}) -public final class HashMap_KeySet extends AbstractSet implements LibSLRuntime.HasAutomaton { - private HashMap_KeySet(Void a, Void b) { - super(); - } +@SuppressWarnings("RedundantMethodOverride") +public class Map_Values extends Map_Contents { - private HashMap_KeySet(HashMap _this) { + public Map_Values(AbstractMapImpl parent) { + super(parent); throw new LinkageError(); } - public boolean add(Object e) { + V _contentByKey(LibSLRuntime.Map> storage, K key) { throw new LinkageError(); } - public boolean addAll(Collection c) { + public boolean add(V e) { throw new LinkageError(); } - public final void clear() { + public boolean addAll(@NotNull Collection c) { throw new LinkageError(); } - public final boolean contains(Object key) { + public void clear() { throw new LinkageError(); } - public boolean containsAll(Collection c) { + boolean _containsInStorage(LibSLRuntime.Map> storage, Object value) { throw new LinkageError(); } - public boolean equals(Object other) { + public boolean contains(Object value) { throw new LinkageError(); } - public final void forEach(Consumer userAction) { + public boolean containsAll(@NotNull Collection c) { throw new LinkageError(); } - public int hashCode() { + public void forEach(Consumer userAction) { throw new LinkageError(); } @@ -66,51 +58,54 @@ public boolean isEmpty() { throw new LinkageError(); } - public final Iterator iterator() { + @NotNull + public Iterator iterator() { throw new LinkageError(); } - public Stream parallelStream() { + public Stream parallelStream() { throw new LinkageError(); } - public final boolean remove(Object key) { + public boolean remove(Object value) { throw new LinkageError(); } - public boolean removeAll(Collection c) { + public boolean removeAll(@NotNull Collection c) { throw new LinkageError(); } - public boolean removeIf(Predicate filter) { + public boolean removeIf(Predicate filter) { throw new LinkageError(); } - public boolean retainAll(Collection c) { + public boolean retainAll(@NotNull Collection c) { throw new LinkageError(); } - public final int size() { + public int size() { throw new LinkageError(); } - public final Spliterator spliterator() { + public Spliterator spliterator() { throw new LinkageError(); } - public Stream stream() { + public Stream stream() { throw new LinkageError(); } + @NotNull public Object[] toArray() { throw new LinkageError(); } - public Object[] toArray(IntFunction generator) { + public T[] toArray(IntFunction generator) { throw new LinkageError(); } - public Object[] toArray(Object[] a) { + @NotNull + public T[] toArray(@NotNull T[] array) { throw new LinkageError(); } diff --git a/approximations/src/main/java/stub/java/util/set/Set_Iterator.java b/approximations/src/main/java/stub/java/util/set/Set_Iterator.java new file mode 100644 index 00000000..07ba9ed7 --- /dev/null +++ b/approximations/src/main/java/stub/java/util/set/Set_Iterator.java @@ -0,0 +1,43 @@ +package stub.java.util.set; + +import generated.java.util.set.AbstractSetImpl; +import runtime.LibSLRuntime; +import stub.java.util.AbstractIterator; + +import java.lang.LinkageError; +import java.lang.Object; +import java.util.function.Consumer; + +public final class Set_Iterator extends AbstractIterator { + + @SuppressWarnings("unused") + public Set_Iterator( + int expectedModCount, + LibSLRuntime.Map unseen, + AbstractSetImpl set, + E currentKey + ) { + super(expectedModCount); + throw new LinkageError(); + } + + protected int _parentModCount() { + throw new LinkageError(); + } + + public void forEachRemaining(Consumer userAction) { + throw new LinkageError(); + } + + public boolean hasNext() { + throw new LinkageError(); + } + + public E next() { + throw new LinkageError(); + } + + public void remove() { + throw new LinkageError(); + } +} diff --git a/approximations/src/main/java/stub/java/util/set/Set_Spliterator.java b/approximations/src/main/java/stub/java/util/set/Set_Spliterator.java new file mode 100644 index 00000000..ecf044e6 --- /dev/null +++ b/approximations/src/main/java/stub/java/util/set/Set_Spliterator.java @@ -0,0 +1,72 @@ +package stub.java.util.set; + +import java.lang.LinkageError; +import java.lang.SuppressWarnings; +import java.util.Spliterator; +import java.util.Spliterators; +import java.util.function.Consumer; + +import generated.java.util.AbstractSpliteratorImpl; +import generated.java.util.set.AbstractSetImpl; +import generated.java.util.set.Set_SpliteratorImpl; +import org.usvm.api.SymbolicList; + +public final class Set_Spliterator extends Spliterators.AbstractSpliterator { + + @SuppressWarnings("unused") + Set_Spliterator( + AbstractSetImpl set, + SymbolicList seenKeys, + SymbolicList unseenKeys, + int index, + int fence, + int expectedModCount + ) { + super(fence - index, 0); + throw new LinkageError(); + } + + public Set_Spliterator(AbstractSetImpl set) { + super(0, 0); + throw new LinkageError(); + } + + @SuppressWarnings("ProtectedMemberInFinalClass") + protected AbstractSpliteratorImpl _create(int index, int fence) { + throw new LinkageError(); + } + + @SuppressWarnings("ProtectedMemberInFinalClass") + protected int _parentModCount() { + throw new LinkageError(); + } + + @SuppressWarnings("ProtectedMemberInFinalClass") + protected int _storageSize() { + throw new LinkageError(); + } + + public int characteristics() { + throw new LinkageError(); + } + + public long estimateSize() { + throw new LinkageError(); + } + + public void forEachRemaining(Consumer userAction) { + throw new LinkageError(); + } + + public long getExactSizeIfKnown() { + throw new LinkageError(); + } + + public boolean tryAdvance(Consumer userAction) { + throw new LinkageError(); + } + + public Set_SpliteratorImpl trySplit() { + throw new LinkageError(); + } +} diff --git a/approximations/src/main/java/stub/java/util/stream/BaseStreamStub.java b/approximations/src/main/java/stub/java/util/stream/BaseStreamStub.java new file mode 100644 index 00000000..2bae8a33 --- /dev/null +++ b/approximations/src/main/java/stub/java/util/stream/BaseStreamStub.java @@ -0,0 +1,69 @@ +package stub.java.util.stream; + +import org.jetbrains.annotations.NotNull; +import org.usvm.api.SymbolicList; + +@SuppressWarnings("unused") +public abstract class BaseStreamStub { + + public BaseStreamStub( + SymbolicList closeHandlers, + boolean isParallel, + boolean linkedOrConsumed + ) { + throw new LinkageError(); + } + + protected SymbolicList _getCloseHandlers() { + throw new LinkageError(); + } + + protected StreamStub _copyToObjStream(T[] storage) { + throw new LinkageError(); + } + + protected IntStreamStub _copyToIntStream(int[] storage) { + throw new LinkageError(); + } + + protected LongStreamStub _copyToLongStream(long[] storage) { + throw new LinkageError(); + } + + protected DoubleStreamStub _copyToDoubleStream(double[] storage) { + throw new LinkageError(); + } + + public void evaluate() { + throw new LinkageError(); + } + + public boolean isParallel() { + throw new LinkageError(); + } + + @NotNull + public BaseStreamStub sequential() { + throw new LinkageError(); + } + + @NotNull + public BaseStreamStub parallel() { + throw new LinkageError(); + } + + abstract protected int _getLength(); + + public long count() { + throw new LinkageError(); + } + + @NotNull + public BaseStreamStub onClose(@NotNull Runnable closeHandler) { + throw new LinkageError(); + } + + public void close() { + throw new LinkageError(); + } +} diff --git a/approximations/src/main/java/stub/java/util/stream/DoubleStreamLSLIterator.java b/approximations/src/main/java/stub/java/util/stream/DoubleStreamLSLIterator.java deleted file mode 100644 index 130d39c5..00000000 --- a/approximations/src/main/java/stub/java/util/stream/DoubleStreamLSLIterator.java +++ /dev/null @@ -1,45 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/stream/DoubleStream.lsl:39 -// -package stub.java.util.stream; - -import java.lang.Double; -import java.lang.LinkageError; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.PrimitiveIterator; -import java.util.function.Consumer; -import java.util.function.DoubleConsumer; -import runtime.LibSLRuntime; - -@SuppressWarnings({"all", "unchecked"}) -public class DoubleStreamLSLIterator implements LibSLRuntime.HasAutomaton, PrimitiveIterator.OfDouble { - private DoubleStreamLSLIterator(Void a, Void b) { - super(); - } - - public boolean hasNext() { - throw new LinkageError(); - } - - public Double next() { - throw new LinkageError(); - } - - public double nextDouble() { - throw new LinkageError(); - } - - public void remove() { - throw new LinkageError(); - } - - public void forEachRemaining(Consumer userAction) { - throw new LinkageError(); - } - - public void forEachRemaining(DoubleConsumer userAction) { - throw new LinkageError(); - } -} diff --git a/approximations/src/main/java/stub/java/util/stream/DoubleStreamLSL.java b/approximations/src/main/java/stub/java/util/stream/DoubleStreamStub.java similarity index 55% rename from approximations/src/main/java/stub/java/util/stream/DoubleStreamLSL.java rename to approximations/src/main/java/stub/java/util/stream/DoubleStreamStub.java index 5dd85f00..b02a5245 100644 --- a/approximations/src/main/java/stub/java/util/stream/DoubleStreamLSL.java +++ b/approximations/src/main/java/stub/java/util/stream/DoubleStreamStub.java @@ -1,14 +1,7 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/stream/DoubleStream.lsl:26 -// package stub.java.util.stream; import java.lang.LinkageError; -import java.lang.Object; import java.lang.Runnable; -import java.lang.SuppressWarnings; -import java.lang.Void; import java.util.DoubleSummaryStatistics; import java.util.OptionalDouble; import java.util.PrimitiveIterator; @@ -24,58 +17,98 @@ import java.util.function.ObjDoubleConsumer; import java.util.function.Supplier; import java.util.stream.DoubleStream; -import java.util.stream.IntStream; -import java.util.stream.LongStream; import java.util.stream.Stream; -import runtime.LibSLRuntime; -@SuppressWarnings({"all", "unchecked"}) -public class DoubleStreamLSL implements LibSLRuntime.HasAutomaton, DoubleStream { - private DoubleStreamLSL(Void a, Void b) { - super(); +import org.jetbrains.annotations.NotNull; +import org.usvm.api.Engine; +import org.usvm.api.SymbolicList; + +public class DoubleStreamStub extends BaseStreamStub implements DoubleStream { + + @SuppressWarnings("unused") + public DoubleStreamStub( + double[] storage, + SymbolicList closeHandlers, + boolean isParallel, + boolean linkedOrConsumed + ) { + super(closeHandlers, isParallel, linkedOrConsumed); + throw new LinkageError(); + } + + @SuppressWarnings("unused") + public DoubleStreamStub(double[] storage, SymbolicList closeHandlers, boolean isParallel) { + super(closeHandlers, isParallel, false); + throw new LinkageError(); + } + + @SuppressWarnings("unused") + public DoubleStreamStub(double[] storage, SymbolicList closeHandlers) { + super(closeHandlers, false, false); + throw new LinkageError(); + } + + @SuppressWarnings("unused") + public DoubleStreamStub(double[] storage) { + super(Engine.makeSymbolicList(), false, false); + throw new LinkageError(); + } + + protected int _getLength() { + throw new LinkageError(); } - public DoubleStream filter(DoublePredicate predicate) { + @NotNull + public DoubleStreamStub filter(@NotNull DoublePredicate predicate) { throw new LinkageError(); } - public DoubleStream map(DoubleUnaryOperator mapper) { + @NotNull + public DoubleStreamStub map(@NotNull DoubleUnaryOperator mapper) { throw new LinkageError(); } - public Stream mapToObj(DoubleFunction mapper) { + @NotNull + public StreamStub mapToObj(@NotNull DoubleFunction mapper) { throw new LinkageError(); } - public LongStream mapToLong(DoubleToLongFunction mapper) { + @NotNull + public LongStreamStub mapToLong(@NotNull DoubleToLongFunction mapper) { throw new LinkageError(); } - public IntStream mapToInt(DoubleToIntFunction mapper) { + @NotNull + public IntStreamStub mapToInt(@NotNull DoubleToIntFunction mapper) { throw new LinkageError(); } - public DoubleStream flatMap(DoubleFunction mapper) { + public DoubleStream flatMap(@NotNull DoubleFunction mapper) { throw new LinkageError(); } - public DoubleStream sorted() { + @NotNull + public DoubleStreamStub sorted() { throw new LinkageError(); } - public DoubleStream distinct() { + @NotNull + public DoubleStreamStub distinct() { throw new LinkageError(); } - public DoubleStream peek(DoubleConsumer _action) { + @NotNull + public DoubleStreamStub peek(@NotNull DoubleConsumer _action) { throw new LinkageError(); } - public DoubleStream limit(long maxSize) { + @NotNull + public DoubleStreamStub limit(long maxSize) { throw new LinkageError(); } - public DoubleStream skip(long n) { + @NotNull + public DoubleStreamStub skip(long n) { throw new LinkageError(); } @@ -99,7 +132,7 @@ public OptionalDouble reduce(DoubleBinaryOperator accumulator) { throw new LinkageError(); } - public Object collect(Supplier supplier, ObjDoubleConsumer accumulator, BiConsumer combiner) { + public R collect(Supplier supplier, ObjDoubleConsumer accumulator, BiConsumer combiner) { throw new LinkageError(); } @@ -135,10 +168,12 @@ public OptionalDouble findAny() { throw new LinkageError(); } + @NotNull public PrimitiveIterator.OfDouble iterator() { throw new LinkageError(); } + @NotNull public Spliterator.OfDouble spliterator() { throw new LinkageError(); } @@ -147,19 +182,23 @@ public boolean isParallel() { throw new LinkageError(); } - public DoubleStream sequential() { + @NotNull + public DoubleStreamStub sequential() { throw new LinkageError(); } - public DoubleStream parallel() { + @NotNull + public DoubleStreamStub parallel() { throw new LinkageError(); } - public DoubleStream unordered() { + @NotNull + public DoubleStreamStub unordered() { throw new LinkageError(); } - public DoubleStream onClose(Runnable closeHandler) { + @NotNull + public DoubleStreamStub onClose(@NotNull Runnable closeHandler) { throw new LinkageError(); } @@ -167,11 +206,13 @@ public void close() { throw new LinkageError(); } - public DoubleStream dropWhile(DoublePredicate predicate) { + @NotNull + public DoubleStreamStub dropWhile(@NotNull DoublePredicate predicate) { throw new LinkageError(); } - public DoubleStream takeWhile(DoublePredicate predicate) { + @NotNull + public DoubleStreamStub takeWhile(@NotNull DoublePredicate predicate) { throw new LinkageError(); } @@ -187,7 +228,7 @@ public DoubleSummaryStatistics summaryStatistics() { throw new LinkageError(); } - public Stream boxed() { + public Stream boxed() { throw new LinkageError(); } } diff --git a/approximations/src/main/java/stub/java/util/stream/IntStreamLSLIterator.java b/approximations/src/main/java/stub/java/util/stream/IntStreamLSLIterator.java deleted file mode 100644 index 3b0d8e79..00000000 --- a/approximations/src/main/java/stub/java/util/stream/IntStreamLSLIterator.java +++ /dev/null @@ -1,45 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/stream/IntStream.lsl:35 -// -package stub.java.util.stream; - -import java.lang.Integer; -import java.lang.LinkageError; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.PrimitiveIterator; -import java.util.function.Consumer; -import java.util.function.IntConsumer; -import runtime.LibSLRuntime; - -@SuppressWarnings({"all", "unchecked"}) -public class IntStreamLSLIterator implements LibSLRuntime.HasAutomaton, PrimitiveIterator.OfInt { - private IntStreamLSLIterator(Void a, Void b) { - super(); - } - - public boolean hasNext() { - throw new LinkageError(); - } - - public Integer next() { - throw new LinkageError(); - } - - public int nextInt() { - throw new LinkageError(); - } - - public void remove() { - throw new LinkageError(); - } - - public void forEachRemaining(Consumer userAction) { - throw new LinkageError(); - } - - public void forEachRemaining(IntConsumer userAction) { - throw new LinkageError(); - } -} diff --git a/approximations/src/main/java/stub/java/util/stream/IntStreamLSL.java b/approximations/src/main/java/stub/java/util/stream/IntStreamStub.java similarity index 55% rename from approximations/src/main/java/stub/java/util/stream/IntStreamLSL.java rename to approximations/src/main/java/stub/java/util/stream/IntStreamStub.java index 0ab69db1..814c41d2 100644 --- a/approximations/src/main/java/stub/java/util/stream/IntStreamLSL.java +++ b/approximations/src/main/java/stub/java/util/stream/IntStreamStub.java @@ -1,14 +1,7 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/stream/IntStream.lsl:26 -// package stub.java.util.stream; import java.lang.LinkageError; -import java.lang.Object; import java.lang.Runnable; -import java.lang.SuppressWarnings; -import java.lang.Void; import java.util.IntSummaryStatistics; import java.util.OptionalDouble; import java.util.OptionalInt; @@ -24,59 +17,100 @@ import java.util.function.IntUnaryOperator; import java.util.function.ObjIntConsumer; import java.util.function.Supplier; -import java.util.stream.DoubleStream; import java.util.stream.IntStream; -import java.util.stream.LongStream; import java.util.stream.Stream; -import runtime.LibSLRuntime; -@SuppressWarnings({"all", "unchecked"}) -public class IntStreamLSL implements LibSLRuntime.HasAutomaton, IntStream { - private IntStreamLSL(Void a, Void b) { - super(); +import org.jetbrains.annotations.NotNull; +import org.usvm.api.Engine; +import org.usvm.api.SymbolicList; + +public class IntStreamStub extends BaseStreamStub implements IntStream { + + @SuppressWarnings("unused") + public IntStreamStub( + int[] storage, + SymbolicList closeHandlers, + boolean isParallel, + boolean linkedOrConsumed + ) { + super(closeHandlers, isParallel, linkedOrConsumed); + throw new LinkageError(); + } + + @SuppressWarnings("unused") + public IntStreamStub(int[] storage, SymbolicList closeHandlers, boolean isParallel) { + super(closeHandlers, isParallel, false); + throw new LinkageError(); + } + + @SuppressWarnings("unused") + public IntStreamStub(int[] storage, SymbolicList closeHandlers) { + super(closeHandlers, false, false); + throw new LinkageError(); + } + + @SuppressWarnings("unused") + public IntStreamStub(int[] storage) { + super(Engine.makeSymbolicList(), false, false); + throw new LinkageError(); + } + + protected int _getLength() { + throw new LinkageError(); } - public IntStream filter(IntPredicate predicate) { + @NotNull + public IntStreamStub filter(@NotNull IntPredicate predicate) { throw new LinkageError(); } - public IntStream map(IntUnaryOperator mapper) { + @NotNull + public IntStreamStub map(@NotNull IntUnaryOperator mapper) { throw new LinkageError(); } - public Stream mapToObj(IntFunction mapper) { + @NotNull + public StreamStub mapToObj(@NotNull IntFunction mapper) { throw new LinkageError(); } - public LongStream mapToLong(IntToLongFunction mapper) { + @NotNull + public LongStreamStub mapToLong(@NotNull IntToLongFunction mapper) { throw new LinkageError(); } - public DoubleStream mapToDouble(IntToDoubleFunction mapper) { + @NotNull + public DoubleStreamStub mapToDouble(@NotNull IntToDoubleFunction mapper) { throw new LinkageError(); } - public IntStream flatMap(IntFunction mapper) { + @NotNull + public IntStream flatMap(@NotNull IntFunction mapper) { throw new LinkageError(); } - public IntStream sorted() { + @NotNull + public IntStreamStub sorted() { throw new LinkageError(); } - public IntStream distinct() { + @NotNull + public IntStreamStub distinct() { throw new LinkageError(); } - public IntStream peek(IntConsumer _action) { + @NotNull + public IntStreamStub peek(@NotNull IntConsumer _action) { throw new LinkageError(); } - public IntStream limit(long maxSize) { + @NotNull + public IntStreamStub limit(long maxSize) { throw new LinkageError(); } - public IntStream skip(long n) { + @NotNull + public IntStreamStub skip(long n) { throw new LinkageError(); } @@ -100,7 +134,7 @@ public OptionalInt reduce(IntBinaryOperator accumulator) { throw new LinkageError(); } - public Object collect(Supplier supplier, ObjIntConsumer accumulator, BiConsumer combiner) { + public R collect(Supplier supplier, ObjIntConsumer accumulator, BiConsumer combiner) { throw new LinkageError(); } @@ -136,10 +170,12 @@ public OptionalInt findAny() { throw new LinkageError(); } + @NotNull public PrimitiveIterator.OfInt iterator() { throw new LinkageError(); } + @NotNull public Spliterator.OfInt spliterator() { throw new LinkageError(); } @@ -148,19 +184,23 @@ public boolean isParallel() { throw new LinkageError(); } - public IntStream sequential() { + @NotNull + public IntStreamStub sequential() { throw new LinkageError(); } - public IntStream parallel() { + @NotNull + public IntStreamStub parallel() { throw new LinkageError(); } - public IntStream unordered() { + @NotNull + public IntStreamStub unordered() { throw new LinkageError(); } - public IntStream onClose(Runnable closeHandler) { + @NotNull + public IntStreamStub onClose(@NotNull Runnable closeHandler) { throw new LinkageError(); } @@ -168,19 +208,21 @@ public void close() { throw new LinkageError(); } - public IntStream dropWhile(IntPredicate predicate) { + @NotNull + public IntStreamStub dropWhile(@NotNull IntPredicate predicate) { throw new LinkageError(); } - public IntStream takeWhile(IntPredicate predicate) { + @NotNull + public IntStreamStub takeWhile(@NotNull IntPredicate predicate) { throw new LinkageError(); } - public LongStream asLongStream() { + public LongStreamStub asLongStream() { throw new LinkageError(); } - public DoubleStream asDoubleStream() { + public DoubleStreamStub asDoubleStream() { throw new LinkageError(); } @@ -196,7 +238,7 @@ public IntSummaryStatistics summaryStatistics() { throw new LinkageError(); } - public Stream boxed() { + public Stream boxed() { throw new LinkageError(); } } diff --git a/approximations/src/main/java/stub/java/util/stream/LongStreamLSLIterator.java b/approximations/src/main/java/stub/java/util/stream/LongStreamLSLIterator.java deleted file mode 100644 index f05ce279..00000000 --- a/approximations/src/main/java/stub/java/util/stream/LongStreamLSLIterator.java +++ /dev/null @@ -1,45 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/stream/LongStream.lsl:35 -// -package stub.java.util.stream; - -import java.lang.LinkageError; -import java.lang.Long; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.PrimitiveIterator; -import java.util.function.Consumer; -import java.util.function.LongConsumer; -import runtime.LibSLRuntime; - -@SuppressWarnings({"all", "unchecked"}) -public class LongStreamLSLIterator implements LibSLRuntime.HasAutomaton, PrimitiveIterator.OfLong { - private LongStreamLSLIterator(Void a, Void b) { - super(); - } - - public boolean hasNext() { - throw new LinkageError(); - } - - public Long next() { - throw new LinkageError(); - } - - public long nextLong() { - throw new LinkageError(); - } - - public void remove() { - throw new LinkageError(); - } - - public void forEachRemaining(Consumer userAction) { - throw new LinkageError(); - } - - public void forEachRemaining(LongConsumer userAction) { - throw new LinkageError(); - } -} diff --git a/approximations/src/main/java/stub/java/util/stream/LongStreamLSL.java b/approximations/src/main/java/stub/java/util/stream/LongStreamStub.java similarity index 55% rename from approximations/src/main/java/stub/java/util/stream/LongStreamLSL.java rename to approximations/src/main/java/stub/java/util/stream/LongStreamStub.java index 83146f8a..ea41ae70 100644 --- a/approximations/src/main/java/stub/java/util/stream/LongStreamLSL.java +++ b/approximations/src/main/java/stub/java/util/stream/LongStreamStub.java @@ -1,14 +1,11 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/stream/LongStream.lsl:26 -// package stub.java.util.stream; +import org.jetbrains.annotations.NotNull; +import org.usvm.api.Engine; +import org.usvm.api.SymbolicList; + import java.lang.LinkageError; -import java.lang.Object; import java.lang.Runnable; -import java.lang.SuppressWarnings; -import java.lang.Void; import java.util.LongSummaryStatistics; import java.util.OptionalDouble; import java.util.OptionalLong; @@ -24,59 +21,96 @@ import java.util.function.LongUnaryOperator; import java.util.function.ObjLongConsumer; import java.util.function.Supplier; -import java.util.stream.DoubleStream; -import java.util.stream.IntStream; import java.util.stream.LongStream; import java.util.stream.Stream; -import runtime.LibSLRuntime; -@SuppressWarnings({"all", "unchecked"}) -public class LongStreamLSL implements LibSLRuntime.HasAutomaton, LongStream { - private LongStreamLSL(Void a, Void b) { - super(); +public class LongStreamStub extends BaseStreamStub implements LongStream { + + @SuppressWarnings("unused") + public LongStreamStub( + long[] storage, + SymbolicList closeHandlers, + boolean isParallel, + boolean linkedOrConsumed + ) { + super(closeHandlers, isParallel, linkedOrConsumed); + throw new LinkageError(); + } + + @SuppressWarnings("unused") + public LongStreamStub(long[] storage, SymbolicList closeHandlers, boolean isParallel) { + super(closeHandlers, isParallel, false); + throw new LinkageError(); + } + + @SuppressWarnings("unused") + public LongStreamStub(long[] storage, SymbolicList closeHandlers) { + super(closeHandlers, false, false); + throw new LinkageError(); + } + + @SuppressWarnings("unused") + public LongStreamStub(long[] storage) { + super(Engine.makeSymbolicList(), false, false); + throw new LinkageError(); + } + + protected int _getLength() { + throw new LinkageError(); } - public LongStream filter(LongPredicate predicate) { + @NotNull + public LongStreamStub filter(@NotNull LongPredicate predicate) { throw new LinkageError(); } - public LongStream map(LongUnaryOperator mapper) { + @NotNull + public LongStreamStub map(@NotNull LongUnaryOperator mapper) { throw new LinkageError(); } - public Stream mapToObj(LongFunction mapper) { + @NotNull + public StreamStub mapToObj(@NotNull LongFunction mapper) { throw new LinkageError(); } - public IntStream mapToInt(LongToIntFunction mapper) { + @NotNull + public IntStreamStub mapToInt(@NotNull LongToIntFunction mapper) { throw new LinkageError(); } - public DoubleStream mapToDouble(LongToDoubleFunction mapper) { + @NotNull + public DoubleStreamStub mapToDouble(@NotNull LongToDoubleFunction mapper) { throw new LinkageError(); } - public LongStream flatMap(LongFunction mapper) { + @NotNull + public LongStream flatMap(@NotNull LongFunction mapper) { throw new LinkageError(); } - public LongStream sorted() { + @NotNull + public LongStreamStub sorted() { throw new LinkageError(); } - public LongStream distinct() { + @NotNull + public LongStreamStub distinct() { throw new LinkageError(); } - public LongStream peek(LongConsumer _action) { + @NotNull + public LongStreamStub peek(@NotNull LongConsumer _action) { throw new LinkageError(); } - public LongStream limit(long maxSize) { + @NotNull + public LongStreamStub limit(long maxSize) { throw new LinkageError(); } - public LongStream skip(long n) { + @NotNull + public LongStreamStub skip(long n) { throw new LinkageError(); } @@ -100,7 +134,7 @@ public OptionalLong reduce(LongBinaryOperator accumulator) { throw new LinkageError(); } - public Object collect(Supplier supplier, ObjLongConsumer accumulator, BiConsumer combiner) { + public R collect(Supplier supplier, ObjLongConsumer accumulator, BiConsumer combiner) { throw new LinkageError(); } @@ -136,10 +170,12 @@ public OptionalLong findAny() { throw new LinkageError(); } + @NotNull public PrimitiveIterator.OfLong iterator() { throw new LinkageError(); } + @NotNull public Spliterator.OfLong spliterator() { throw new LinkageError(); } @@ -148,19 +184,23 @@ public boolean isParallel() { throw new LinkageError(); } - public LongStream sequential() { + @NotNull + public LongStreamStub sequential() { throw new LinkageError(); } - public LongStream parallel() { + @NotNull + public LongStreamStub parallel() { throw new LinkageError(); } - public LongStream unordered() { + @NotNull + public LongStreamStub unordered() { throw new LinkageError(); } - public LongStream onClose(Runnable closeHandler) { + @NotNull + public LongStreamStub onClose(@NotNull Runnable closeHandler) { throw new LinkageError(); } @@ -168,15 +208,17 @@ public void close() { throw new LinkageError(); } - public LongStream dropWhile(LongPredicate predicate) { + @NotNull + public LongStreamStub dropWhile(@NotNull LongPredicate predicate) { throw new LinkageError(); } - public LongStream takeWhile(LongPredicate predicate) { + @NotNull + public LongStreamStub takeWhile(@NotNull LongPredicate predicate) { throw new LinkageError(); } - public DoubleStream asDoubleStream() { + public DoubleStreamStub asDoubleStream() { throw new LinkageError(); } @@ -192,7 +234,7 @@ public LongSummaryStatistics summaryStatistics() { throw new LinkageError(); } - public Stream boxed() { + public Stream boxed() { throw new LinkageError(); } } diff --git a/approximations/src/main/java/stub/java/util/stream/StreamLSL.java b/approximations/src/main/java/stub/java/util/stream/StreamLSL.java deleted file mode 100644 index 455b4cea..00000000 --- a/approximations/src/main/java/stub/java/util/stream/StreamLSL.java +++ /dev/null @@ -1,208 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/stream/Stream.lsl:34 -// -package stub.java.util.stream; - -import java.lang.LinkageError; -import java.lang.Object; -import java.lang.Runnable; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.Comparator; -import java.util.Iterator; -import java.util.Optional; -import java.util.Spliterator; -import java.util.function.BiConsumer; -import java.util.function.BiFunction; -import java.util.function.BinaryOperator; -import java.util.function.Consumer; -import java.util.function.Function; -import java.util.function.IntFunction; -import java.util.function.Predicate; -import java.util.function.Supplier; -import java.util.function.ToDoubleFunction; -import java.util.function.ToIntFunction; -import java.util.function.ToLongFunction; -import java.util.stream.BaseStream; -import java.util.stream.Collector; -import java.util.stream.DoubleStream; -import java.util.stream.IntStream; -import java.util.stream.LongStream; -import java.util.stream.Stream; -import runtime.LibSLRuntime; - -@SuppressWarnings({"all", "unchecked"}) -public class StreamLSL implements LibSLRuntime.HasAutomaton, Stream { - private StreamLSL(Void a, Void b) { - super(); - } - - public Stream filter(Predicate predicate) { - throw new LinkageError(); - } - - public Stream map(Function mapper) { - throw new LinkageError(); - } - - public IntStream mapToInt(ToIntFunction mapper) { - throw new LinkageError(); - } - - public LongStream mapToLong(ToLongFunction mapper) { - throw new LinkageError(); - } - - public DoubleStream mapToDouble(ToDoubleFunction mapper) { - throw new LinkageError(); - } - - public Stream flatMap(Function mapper) { - throw new LinkageError(); - } - - public IntStream flatMapToInt(Function mapper) { - throw new LinkageError(); - } - - public LongStream flatMapToLong(Function mapper) { - throw new LinkageError(); - } - - public DoubleStream flatMapToDouble(Function mapper) { - throw new LinkageError(); - } - - public Stream distinct() { - throw new LinkageError(); - } - - public Stream sorted() { - throw new LinkageError(); - } - - public Stream sorted(Comparator comparator) { - throw new LinkageError(); - } - - public Stream peek(Consumer _action) { - throw new LinkageError(); - } - - public Stream limit(long maxSize) { - throw new LinkageError(); - } - - public Stream skip(long n) { - throw new LinkageError(); - } - - public void forEach(Consumer _action) { - throw new LinkageError(); - } - - public void forEachOrdered(Consumer _action) { - throw new LinkageError(); - } - - public Object[] toArray() { - throw new LinkageError(); - } - - public Object[] toArray(IntFunction generator) { - throw new LinkageError(); - } - - public Object reduce(Object identity, BinaryOperator accumulator) { - throw new LinkageError(); - } - - public Optional reduce(BinaryOperator accumulator) { - throw new LinkageError(); - } - - public Object reduce(Object identity, BiFunction accumulator, BinaryOperator combiner) { - throw new LinkageError(); - } - - public Object collect(Supplier supplier, BiConsumer accumulator, BiConsumer combiner) { - throw new LinkageError(); - } - - public Object collect(Collector collector) { - throw new LinkageError(); - } - - public Optional min(Comparator comparator) { - throw new LinkageError(); - } - - public Optional max(Comparator comparator) { - throw new LinkageError(); - } - - public long count() { - throw new LinkageError(); - } - - public boolean anyMatch(Predicate predicate) { - throw new LinkageError(); - } - - public boolean allMatch(Predicate predicate) { - throw new LinkageError(); - } - - public boolean noneMatch(Predicate predicate) { - throw new LinkageError(); - } - - public Optional findFirst() { - throw new LinkageError(); - } - - public Optional findAny() { - throw new LinkageError(); - } - - public Iterator iterator() { - throw new LinkageError(); - } - - public Spliterator spliterator() { - throw new LinkageError(); - } - - public boolean isParallel() { - throw new LinkageError(); - } - - public BaseStream sequential() { - throw new LinkageError(); - } - - public BaseStream parallel() { - throw new LinkageError(); - } - - public BaseStream unordered() { - throw new LinkageError(); - } - - public BaseStream onClose(Runnable arg0) { - throw new LinkageError(); - } - - public void close() { - throw new LinkageError(); - } - - public Stream dropWhile(Predicate predicate) { - throw new LinkageError(); - } - - public Stream takeWhile(Predicate predicate) { - throw new LinkageError(); - } -} diff --git a/approximations/src/main/java/stub/java/util/stream/StreamLSLIterator.java b/approximations/src/main/java/stub/java/util/stream/StreamLSLIterator.java deleted file mode 100644 index f22e89e5..00000000 --- a/approximations/src/main/java/stub/java/util/stream/StreamLSLIterator.java +++ /dev/null @@ -1,36 +0,0 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - java/util/stream/Stream.lsl:43 -// -package stub.java.util.stream; - -import java.lang.LinkageError; -import java.lang.Object; -import java.lang.SuppressWarnings; -import java.lang.Void; -import java.util.Iterator; -import java.util.function.Consumer; -import runtime.LibSLRuntime; - -@SuppressWarnings({"all", "unchecked"}) -public class StreamLSLIterator implements LibSLRuntime.HasAutomaton, Iterator { - private StreamLSLIterator(Void a, Void b) { - super(); - } - - public boolean hasNext() { - throw new LinkageError(); - } - - public Object next() { - throw new LinkageError(); - } - - public void remove() { - throw new LinkageError(); - } - - public void forEachRemaining(Consumer userAction) { - throw new LinkageError(); - } -} diff --git a/approximations/src/main/java/stub/java/util/stream/StreamStub.java b/approximations/src/main/java/stub/java/util/stream/StreamStub.java new file mode 100644 index 00000000..cc683375 --- /dev/null +++ b/approximations/src/main/java/stub/java/util/stream/StreamStub.java @@ -0,0 +1,252 @@ +package stub.java.util.stream; + +import org.jetbrains.annotations.NotNull; +import org.usvm.api.Engine; +import org.usvm.api.SymbolicList; + +import java.lang.LinkageError; +import java.lang.Object; +import java.lang.Runnable; +import java.util.Comparator; +import java.util.Iterator; +import java.util.Optional; +import java.util.Spliterator; +import java.util.function.BiConsumer; +import java.util.function.BiFunction; +import java.util.function.BinaryOperator; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.function.IntFunction; +import java.util.function.Predicate; +import java.util.function.Supplier; +import java.util.function.ToDoubleFunction; +import java.util.function.ToIntFunction; +import java.util.function.ToLongFunction; +import java.util.stream.Collector; +import java.util.stream.DoubleStream; +import java.util.stream.IntStream; +import java.util.stream.LongStream; +import java.util.stream.Stream; + +public class StreamStub extends BaseStreamStub implements Stream { + + @SuppressWarnings("unused") + public StreamStub( + E[] storage, + SymbolicList handlers, + boolean isParallel, + boolean linkedOrConsumed + ) { + super(handlers, isParallel, linkedOrConsumed); + throw new LinkageError(); + } + + @SuppressWarnings("unused") + public StreamStub(E[] storage, SymbolicList handlers, boolean isParallel) { + super(handlers, isParallel, false); + throw new LinkageError(); + } + + @SuppressWarnings("unused") + public StreamStub(E[] storage, boolean isParallel) { + super(Engine.makeSymbolicList(), isParallel, false); + throw new LinkageError(); + } + + @SuppressWarnings("unused") + public StreamStub(E[] storage, SymbolicList handlers) { + super(handlers, false, false); + throw new LinkageError(); + } + + @SuppressWarnings("unused") + public StreamStub(E[] storage) { + super(Engine.makeSymbolicList(), false, false); + throw new LinkageError(); + } + + protected int _getLength() { + throw new LinkageError(); + } + + public Stream filter(Predicate predicate) { + throw new LinkageError(); + } + + public Stream map(Function mapper) { + throw new LinkageError(); + } + + public IntStream mapToInt(ToIntFunction mapper) { + throw new LinkageError(); + } + + public LongStream mapToLong(ToLongFunction mapper) { + throw new LinkageError(); + } + + public DoubleStream mapToDouble(ToDoubleFunction mapper) { + throw new LinkageError(); + } + + public Stream flatMap(Function> mapper) { + throw new LinkageError(); + } + + public IntStream flatMapToInt(Function mapper) { + throw new LinkageError(); + } + + public LongStream flatMapToLong(Function mapper) { + throw new LinkageError(); + } + + public DoubleStream flatMapToDouble(Function mapper) { + throw new LinkageError(); + } + + public StreamStub distinct() { + throw new LinkageError(); + } + + public StreamStub sorted() { + throw new LinkageError(); + } + + public StreamStub sorted(Comparator comparator) { + throw new LinkageError(); + } + + public StreamStub peek(Consumer _action) { + throw new LinkageError(); + } + + public StreamStub limit(long maxSize) { + throw new LinkageError(); + } + + public StreamStub skip(long n) { + throw new LinkageError(); + } + + public void forEach(Consumer _action) { + throw new LinkageError(); + } + + public void forEachOrdered(Consumer _action) { + throw new LinkageError(); + } + + @NotNull + public Object[] toArray() { + throw new LinkageError(); + } + + @NotNull + public T[] toArray(IntFunction generator) { + throw new LinkageError(); + } + + public E reduce(E identity, BinaryOperator accumulator) { + throw new LinkageError(); + } + + @NotNull + public Optional reduce(BinaryOperator accumulator) { + throw new LinkageError(); + } + + public T reduce(T identity, BiFunction accumulator, BinaryOperator combiner) { + throw new LinkageError(); + } + + public R collect(Supplier supplier, BiConsumer accumulator, BiConsumer combiner) { + throw new LinkageError(); + } + + public R collect(Collector collector) { + throw new LinkageError(); + } + + @NotNull + public Optional min(Comparator comparator) { + throw new LinkageError(); + } + + @NotNull + public Optional max(Comparator comparator) { + throw new LinkageError(); + } + + public long count() { + throw new LinkageError(); + } + + public boolean anyMatch(Predicate predicate) { + throw new LinkageError(); + } + + public boolean allMatch(Predicate predicate) { + throw new LinkageError(); + } + + public boolean noneMatch(Predicate predicate) { + throw new LinkageError(); + } + + @NotNull + public Optional findFirst() { + throw new LinkageError(); + } + + @NotNull + public Optional findAny() { + throw new LinkageError(); + } + + @NotNull + public Iterator iterator() { + throw new LinkageError(); + } + + @NotNull + public Spliterator spliterator() { + throw new LinkageError(); + } + + public boolean isParallel() { + throw new LinkageError(); + } + + @NotNull + public StreamStub sequential() { + throw new LinkageError(); + } + + @NotNull + public StreamStub parallel() { + throw new LinkageError(); + } + + @NotNull + public StreamStub unordered() { + throw new LinkageError(); + } + + @NotNull + public StreamStub onClose(@NotNull Runnable handler) { + throw new LinkageError(); + } + + public void close() { + throw new LinkageError(); + } + + public StreamStub dropWhile(Predicate predicate) { + throw new LinkageError(); + } + + public StreamStub takeWhile(Predicate predicate) { + throw new LinkageError(); + } +} diff --git a/approximations/src/main/java/stub/libsl/utils/SymbolicInputStream.java b/approximations/src/main/java/stub/libsl/utils/SymbolicInputStream.java index 9737515c..4da755cb 100644 --- a/approximations/src/main/java/stub/libsl/utils/SymbolicInputStream.java +++ b/approximations/src/main/java/stub/libsl/utils/SymbolicInputStream.java @@ -1,20 +1,31 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - libsl/utils/SymbolicInputStream.lsl:15 -// package stub.libsl.utils; +import org.jetbrains.annotations.NotNull; + import java.io.InputStream; import java.io.OutputStream; import java.lang.LinkageError; -import java.lang.SuppressWarnings; -import java.lang.Void; -import runtime.LibSLRuntime; - -@SuppressWarnings({"all", "unchecked"}) -public final class SymbolicInputStream extends InputStream implements LibSLRuntime.HasAutomaton { - private SymbolicInputStream(Void a, Void b) { - super(); + +@SuppressWarnings("RedundantThrows") +public final class SymbolicInputStream extends InputStream { + + @SuppressWarnings("unused") + public SymbolicInputStream( + int maxSize, + boolean supportMarks, + int dataSize, + byte[] data, + boolean closed, + int pos, + int markPos, + int markLimit8 + ) { + throw new LinkageError(); + } + + @SuppressWarnings("unused") + public static void _checkFromIndexSize(int fromIndex, int size, int length) { + throw new LinkageError(); } public int available() throws java.io.IOException { @@ -25,7 +36,7 @@ public void close() throws java.io.IOException { throw new LinkageError(); } - public void mark(int readlimit) { + public void mark(int readLimit) { throw new LinkageError(); } @@ -37,11 +48,11 @@ public int read() throws java.io.IOException { throw new LinkageError(); } - public int read(byte[] b) throws java.io.IOException { + public int read(@NotNull byte[] b) throws java.io.IOException { throw new LinkageError(); } - public int read(byte[] b, int off, int len) throws java.io.IOException { + public int read(@NotNull byte[] b, int off, int len) throws java.io.IOException { throw new LinkageError(); } diff --git a/approximations/src/main/java/stub/libsl/utils/VoidInputStream.java b/approximations/src/main/java/stub/libsl/utils/VoidInputStream.java index 20bbf305..e8e139da 100644 --- a/approximations/src/main/java/stub/libsl/utils/VoidInputStream.java +++ b/approximations/src/main/java/stub/libsl/utils/VoidInputStream.java @@ -1,20 +1,18 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - libsl/utils/VoidInputStream.lsl:15 -// package stub.libsl.utils; +import org.jetbrains.annotations.NotNull; + import java.io.InputStream; import java.io.OutputStream; import java.lang.LinkageError; import java.lang.SuppressWarnings; -import java.lang.Void; -import runtime.LibSLRuntime; -@SuppressWarnings({"all", "unchecked"}) -public final class VoidInputStream extends InputStream implements LibSLRuntime.HasAutomaton { - private VoidInputStream(Void a, Void b) { - super(); +@SuppressWarnings("RedundantThrows") +public final class VoidInputStream extends InputStream { + + @SuppressWarnings("unused") + public VoidInputStream(boolean p1) { + throw new LinkageError(); } public int available() throws java.io.IOException { @@ -25,7 +23,7 @@ public void close() throws java.io.IOException { throw new LinkageError(); } - public synchronized void mark(int readlimit) { + public synchronized void mark(int readLimit) { throw new LinkageError(); } @@ -37,11 +35,11 @@ public int read() throws java.io.IOException { throw new LinkageError(); } - public int read(byte[] b) throws java.io.IOException { + public int read(@NotNull byte[] b) throws java.io.IOException { throw new LinkageError(); } - public int read(byte[] b, int off, int len) throws java.io.IOException { + public int read(@NotNull byte[] b, int off, int len) throws java.io.IOException { throw new LinkageError(); } diff --git a/approximations/src/main/java/stub/libsl/utils/VoidOutputStream.java b/approximations/src/main/java/stub/libsl/utils/VoidOutputStream.java index b0663416..ac85ebc0 100644 --- a/approximations/src/main/java/stub/libsl/utils/VoidOutputStream.java +++ b/approximations/src/main/java/stub/libsl/utils/VoidOutputStream.java @@ -1,19 +1,17 @@ -// Generated by the LibSL translator. DO NOT EDIT! -// sources: -// - libsl/utils/VoidOutputStream.lsl:15 -// package stub.libsl.utils; +import org.jetbrains.annotations.NotNull; + import java.io.OutputStream; import java.lang.LinkageError; import java.lang.SuppressWarnings; -import java.lang.Void; -import runtime.LibSLRuntime; -@SuppressWarnings({"all", "unchecked"}) -public final class VoidOutputStream extends OutputStream implements LibSLRuntime.HasAutomaton { - private VoidOutputStream(Void a, Void b) { - super(); +@SuppressWarnings("RedundantThrows") +public final class VoidOutputStream extends OutputStream { + + @SuppressWarnings("unused") + public VoidOutputStream(boolean p1) { + throw new LinkageError(); } public void close() { @@ -24,11 +22,11 @@ public void flush() throws java.io.IOException { throw new LinkageError(); } - public void write(byte[] b) throws java.io.IOException { + public void write(@NotNull byte[] b) throws java.io.IOException { throw new LinkageError(); } - public void write(byte[] b, int off, int len) throws java.io.IOException { + public void write(@NotNull byte[] b, int off, int len) throws java.io.IOException { throw new LinkageError(); } diff --git a/jitpack.yml b/jitpack.yml index f78f664d..bb8a4f69 100644 --- a/jitpack.yml +++ b/jitpack.yml @@ -1 +1 @@ -jdk: openjdk11 \ No newline at end of file +jdk: openjdk17 diff --git a/usvm-api/usvm-api.jar b/usvm-api/usvm-api.jar index f596e33f9f062bd54efda23291732f8be639f969..fb9607f8e8d57073af1a092cd5f130eea444d990 100644 GIT binary patch literal 11342 zcma)ibzD^4_BSm^Hz?hm(%nc&OT*CJoze(Hcc&mJ(k%!`gOs#1NHc`A{D#-7KJw_j z@1D;&bN*QCyJPLW_9{hLXc#OA2zYo1J|L_n1h_%ny}%6t{K!kFiZDJ^kYt92Q2a@l z`LbK1$`5M)F_-`!{D9ei5z31wJe8DCQDu^sJeD6EkdtL(8by|6q#GU_sa9s0U|(8a zS%5mCzY*S_0`flz0rnREB396anze(4fT%_N zK9!%Scf=C5W)`+4Oh(oKC#P5HR$iDASiaQqeXnw#Ygu+Y)X1S7>y;44plh|1(PBbS z3J;qzw!r0V22?|8-69AHzjGJyAv#1SKCKq&?_rO(;7vt_IT2%@<2mpcNj=M8Z}z)A zo+E}}TG`XPY0=#*??ys92xvVa;?}jfu!LYFd!Ju z7y~@V)=1UXua$9ZCF+)=GnEAKuGB!Sp%d=`7fVF-A&vSWHfZgLoMeDA*ZW-*%h6*U z=BU;$;YJXF=tz{6sGUeY%}XBX()eWRHlL1xjIqO71Xrw&I-&BNvGy5Ty@VbZuF)6%h*%cFZ}aXzw8%pgkR!VeH`&=&4k>DDQ8w(teep zc3hoULfFHNdk)_@`kb!}ZxZesOAoOL_l2c*oi%UUx*f+2Rf9LF992vgmY8$r$t!cQ z_`Y`k#<2rR`?vvqWlpOkv!ry`zN-*@>Yl?EZK~EwN7boGPm_g{hb?JHfjsrb(-NK4 z=eLgRyLMV@Pcp2=u`Mhq9%{d_pI_6el8(4&*k;{*W$^0C`C;GKJHyL#+l!KAeC+sP zIpE81hsAjwE(ClA{q${C=VWUmuXF$jL=kyCkwIybQy4m71})YY`x^Ry_G6U374$Ev zh4!R)4pcGEJGq{|L%KRARo|%_THPfwl@^%G*qJR{j)7-v)^4M{^ig0Rw0o4rGB{4E zCgwYS>J8{qIaQVYWU*_;QIfG^4c}QMS!>)Z*=h2!zd{RVzDW@%hnNOdE}+?lxppWg)39JC3UbA)WgyjEoGHtHI~Dc z*E)8SZDkr5ua;nZ@AgEu7EEf`bhk#a;6DgHC5D?C*Cfg$8PDo<3Z*4>2p z4?eZVH5!AK4=i*J#^)nH>nM3bLYDa@_z`~`hh+H%5P3I#q93j~T?RGIySR9qX) zlqBSAi)$2O2}>cOm7QCbX1_&_z8?7o*o%1*DIhX}xZ8R`;N$05!X$!?3&O-Jh<>Tt zMCwga#Y1gxjYfQg2XyraJ3bEszwuM`!vt*DIO85GPK!3Ycv7C4lo?SYGm97yZs#X= zlB^f#yY_B;#89JzkE*?9@s#k5zo?L81J9saS0tt_WCWpu6nuTqGv1Xb^nDd$zLi4w zdfSL`xws0Rf0u}A_s$?vPMh%Ge3liX9M+S>ayx}U<$|Cu`ZW1t4#C#rBV|4Xa%Qy%t-%Jk|CnZ4O8kgjDC@{Fa@V(%*dC`aT_ta zmtPQpD$vB9C8uqq%{GB8oB-HXl=!LUrexaI{n#m=X^}SwN4$kznq#G+dMG+uE^5Pb z5c0Di%#$-@vSmAToT)%hKJ^69BjH3i?3KQJYO0Xp$GL5?)@B(cHSVHOkGy&2-Ha>s z(B&er)X4-C$xb=RPxBPW%Td@CJsKYKjXr9Q%2e_dXYT45np)KK03ahtW-oVPrgk!i z!RQA+WbI61vAae5{j%|%H=1>agn$66ZwRXUDqY3H#?a2%!sw~7iLJARvxhvu{=3Q! zRvu7zFO1d7So3N{ThTjT(gt_7l|&X3N*og&Q8&^=Il?Dqi@Z2{<2~wOKF}@PkSzXV zLFN|EW|r5!vEaMULJ&(h!%t!;UxyC9jiWhbWOFF@-4F`RvZ|MQ61Kp-6Z;ZQ0^w5+ z1!a;HR8Ny1kqTc@4ql_3YCr&>4z!~f#01>;)9uU%{a7Kjnrwd}j0dui(+om+^CVvQ zpjkn9B`DXa56}70hC!HTB8+C}F}B#3B0MU~QHm8-CRkROju4Gx4CW4XUc2B-?n1Wh zP}%^s(I+}FoA2dkPy$mLL=vPh`-%P58zTy|la?&sHt`@Y_Ln{h zN|hxi>h;DTRIi?COzjDUDx;*+-ws8n-pbrrX5bLXu+l4#d4UPxC*$sirRcv%jx0kG z81*_pp&tE7q@wk}q^~=|~1z!zrqj^)5 zLZt~i9NMzUT)6wD#_fKW-DW;=ts_`=s9@O<{Y`d1W#*zh^Ic}nn7FEnI`)yXZPRWd zMDj>z@+ACU#uce+r-S8^VT6Vr2(?GEeWneU451ot6xf_+FN(hcU3^7>n6fYNXAogD ztjPSJX%PR`?2M{|4CFjCUv%L*?PD^BRn14tSRSbkv3NcVS;kuJn-kLZ-w1s6jA7LF;$dMu81skr< zj;YzG?q*$Z3J*pGqdG?sK)X>ZAMl?4(J{oQ{4b7aLtiKP1MqSKoNLtveh$Ze<-{Kp5HK}a~lw;3uf;*9UL;fx;uz-GAV%YbkWnyb&XKdp5 zn-O(q3)YoId^`pd--(&>Z%h*3nI-KUzn@N<7+D!;5wwuo@Rvp_hU_wbn zTJV@`{xtTt;J|+0z3EUGT~XetNOkpQ<%OXQoi3Q2v02kvC&6v=78Nc(rrarWZFa!H ziS^j~diCd%l(|A2ug2e^i0jxVn5Vn1UHYJ0j*G5#gM>9OPuH9%P@h(kD(UB;z~v1Q+ab;w zsub^r#hIZQg`M0}YBTLUjOpOjS_VHfe_OR@hL$Eq&i`4v?+eFwYBwba2M4DOXX^?_ zB?7I$?s$=eD41Vh!Utd~~LNaI6Rk{aXelA!=4;Lb|@* zb~vS>-kieaKqjm5m$WcXy0~g7$b~3L-qNswziMCOnM(^!JgHc^9?M%(tsf-Fc_~VR z@(~)p`$KPgZ~Gtw6j1oAlC2W*Vpo`mo*eptbc{cyG#jfu zj00AYbzW_zNm4RU90$6XsQAY7yGI(~Ocif$YSq(>=*bj%ro_B7;9@CSq3YrPyl-Sk z3}45nf{7er-J)*XZAZ={IolHX+OjBk4R9$PEvbAg~~r$$#? zxQXWBL$N_rKtl$B(q1!x+aXbH@g(WSS!m5x?c+1Z9^DyGPBBLsb=s4K)rRP3JhH?> z0K$U#=97}u{z|~Etap+THYzR5Tg^9^2O5sTFvW3QK7*i_8KW??Jqaptm=_7F=tL@= zWgATv5BZd~+p}f5;W~A)sY0b=NmVDTLMnNwis?q58M$yJFEE-+RZ%oc4V6%JmpqFPnl$=F5XHZrz_a}fptgPj@|eOw+SP`v`|Q^{*-Q|H6nN$K;+I8ihj%$ zrW2I+yd%k!kfW6EJr;80dkoM^3J+zh7p4@z3V~seaev5zS>@|`{b!<-yl!OMgdRqF z_PGU}a-Ja%gLXyun(JqZ@Q{bflz`fO*B;QdsBp8U!GLexEPY`)!&fvuOf5yF1Doui zk8!bdlx0>EbDfj((0&WANb71z8QUPb?cdI@($9u4owDRX6Keq!fX<48hY4uN%MRn(@_xa_;#1<_EM@vNv}(Z*P@ zthmou^OutSb6EMl0HK`%`xj8!C~jS|-z;5Z#l4Zfa*#x|zp9n}@TO9fFSYs0r+E8q zkN9OQyS{8Uyl=vuF;aO&4MA@jg3=eBs*=sId+*`QRJqxm1fXM+qVK0I^_~DG_1FSQRr>c`;*z=I+Ld&4>UZ1d@ zeV>8GOCay1PW+gTS=*IEkyNr$HdDT>Z@0WsXKd^C?Y&!ZazJ*T6ReXc!8(clf9fQ# zG4oGdw5ak}4eQ%JTor{TJVnApop}V*UME98fn&S>B#Ko zD?)35!>xt$k=p)h76uNbD%DtsW!qu^wdX9=Q^*k+D+b^ron? z1XFYx4wP6e3~Q>a+K92sY1hkr{wT9KBvT4d-I`FSUNFEbbx3EYKuj)M8=zzfOaRsd zXzBn`c0pssQK0;N^I7y>U_hyRVB3^STuTAY<#De`CzZotQ^4btA_o00o0JZ&l0$F_ zUYl4OCl)(*bP#Q#dXqbN@b zv&lj`Pd1M{o7O!{N|mL#)7|i7OEq!Z|wEfA?t=9DG5ZBTPC)()O_a9j#=iW&Rs-a zYM&g*7@TK(Q(ifJb&BY@NXah={CZL|zKNpw6+M@brS%BIdY!p9lo|bs5TxIS(~*2a z>x=dR0XW*nzlVhz4drUFu=5tn!eqtg>vX*ZcH4QsU6{T>+OkD+MT*Y#>OB0~OQ0?9z)Q3ZW3LC_$N%{oXg1$S zm)V!ol+4+{^bw8_#1>k?&wz7i`Ws$0|24MUH8wqGF2z*qXQ0SrSr zSzpiA;LwNoNNt-8geIRdtG(qb$Xp9*7033Oz$A7Nr-}8Ia~u;oNhHKvV`@81xLHcn z2ld~!Vc}4Hup|8l-HlrqQ@Qn)8Qy<-=%UubKf?KXfwz$TC+YFeMxL;d+76 z#Al~lYrauZpM3_rj#HgCom7AuIEV|;eEyAcAscL4-N`LzE*adVAm-nVa(+W0pF^dYr@8Jhv}0sQyu?+TcGmLW|Ic>VE1%zPpIUifu5n~%s;txVr|#(drW>@gINOcKhxYVF}Zk8Z9tSjDrPA-e9+#|H(0Owc3cEE>C4i){8pRdTTpf;l7Q2UP;*D ztDFimuA_RLDSo;cLS{%p8G@&HyvlIHOJ(gXtDlY+h5_t$b$cxfM-25QoJZhGK772g zl&yT)nhRzkZ7VgS#aWagFqmSPw0yP2zdiwA2) zgyS6PIMp=LMyp}u{lx^*dt&Q`y$`<3koD-K^0<~7H9E?&q%K-cS`Z@)qA*nGKg-oP z$!(gfOjD0&d{5;dkK=WOZ87+zVUlsmVvLNpvL>B=g0$g|h zF8kn3z24@)0|`&poR3f+aI%CMt|4#csKahUx|mOBHCD7gbGOr|b~z*_p)bYua6}Ch z@zWCo^Iwx*;Yi`jGF*puv3`K@4R_}dirZe5Lvo-ZQ_#a2jL$fGEk!3IGu&qc>^VG! zu$ZMLL^U8St`Tex1!jMw7Q2i-2f~M-t8ejks+1YBtcpd2Pi&7gxC7m=c9C(uK&{zO zZDu00kG2%s>sc(c_lPq~Z7b&nkhsPR7E=-(*UpEXl(DsG(BUPpcX!L5 z^|6xiNK*9R#Tkh^0;l>KgE+L56?m+}&^e8nICTgcNjEQ>*cdho=s(y$hw<~->DZQt zTBY&vdj3t+(Z$%XpuV<{eLGM}`U=GXct*Pls`g9V(UKf^9UT*YRLC|9?Ke=iEohsz zi0S!pl$Zl_J|m>uxJ{pZT$H+*)nC=jqZKjH5`f9lde zgrD`WCGhbeTes9;gi ze=#AYo-`$Ls!JrU0p$H}u)psL@D=j+Adj)hpMyM7s@HOx;H?w__lF?Q52o+o3UPol z;JYXODnZ+BoQ0q}8c}zqoDqq$f_`<@U)&vr^P#nxM3J1FO!n6eDk}NJ5Aiz++s{}1 zQQJdBuT>t@4&|XYwNUW%Y@VC(fZi+$`9htCO;KXuSt?(AGItlOJl8bvc%PW1_^IAj zzoDs*gL#=(tafCi5&Nk389|5|dkuEjMT*7dZI#tnzPD$td(OVmywSn? zPY;6V1<|x#lZt_wEwo*sgjPHYU^<7_hcZ#rZ18c+_`meC*zXy<#;iEIT}soww$9Re z9ASEfP$B}Geyq`R&5-L^FU{Uve0&@*nnK$#o7H3KMKgrmaqih2jz3?; zTytTL(emte+y@j`*uOFP=-a+sa4$*$5^OX^&Fp%25t5aIX_-V@J7gy>Y(|zUum1a7 zp?Hivn$7b%kt&n5O+*6x0(BaXVOlLy)O5!QWT%Q|i`OV#I_ro8Y}SfP5z5~DvDWAp zO+AW>2i^_tmrtrt3b3W35@dr&3HcJYT;ILyVPa*`5%W&m5@s+&fKB*P-fIu7#xQOK zNpDLClGzCAckn|t1pP%yyo1iZ!m7!LfgQ^db-v;U89;HWXS z;vh*_>2SgS3-8`$Q@q)z zh_FkuKh$V6$GJ9^VXvJB(}u1lJ}~9QA}~1tZC`#o3eX+YOJ-2y^YX>ZLW8%;i}H?I zBSqk(*p`_PeO7a^Y6H-=rb{GLI)XAhiS@m=Y%0JKZeH*K(*f)1f5iiTEZct$*!RWz ze#TmrM`fTyumtiymAopx5qWko)>cm?j*b`NKX&DkVV&gi+*B$zM=S=*v1;WkbyzZ#hwjq~)7~p~H~85jEy+g=Io$gx>gI`!l*KJy?d1E$ zP+zEyY-xC%esvQdvT9NO%JfJlJ~wtn@2&9g=V(n$RxNu(ZrW_&+|p3enU{cGr+l{- znc4XX=}5g1tBOpks1hff*ISC(^8UW(hM@5c2EA05)-5h5kJgVzN5oMMm-!Y971NPa zk|l_Ql`XSl7{rvK^{_Bi(h4DNo``e3?aL(z5=7Wo+~EX#2oTLkw7D6gC5^Dgb_nW# z;q6`ZE12K4Vv?xm?moEoffHO^@UJNLkM;l0wiU6r_`djwiB?Wy!dM~CXcTE$6|Kt8 z)V)|w$J`Hs>yjd9q|4b^d=KZKwBbVv;u(OaMHd~!OVN(}#+`7p$jYXo@FQ&p9?z

>#*bj8Oz(Y1Hk8d~#^AiOks2%KTKuTU$#YR5Wt(6rMiDI+ke^$&j-q-ZJ7- z3eO%fAtVdX>O>)`1E zdHh;J*gTsNA-P>Ry`BNjPKq)k71+8rs*dlJpAr^wg0%fL0;^gSkWYqSQX05jcwRkm zUrR{ub{+?Gl>r)RW7|^R%dUh`%+OQC8efGgHFbS4xH-L@JdkJyIdP<8NU|rH7&FSf zY0tZqpEbt1bz?uH+yp*+N+le(97mCyke)OYR7j9R>omkLg(au21h0q{5|GGHO-j)X z@zjAv<8x)0J{56JpVJWk)LNOsTP>@2BnLeYqevtkFg_(bFVBeZw13N=r_ShZ@0K~L=!5wU_zXaVCdN|x86*dNChGs^(IVFJcMIevg`!E}zzr}Te zj{2<>LgMUti}?2gBcxu`qj0CNz=wwTzFYbuK!4|rem^Qcu?yhT9$K)OtVOrJq6ml? z^daG~7jrKmg*;1|K?}2qN>Yt(m3G*YA)ZW_~}!r_j?MfSwQiR=)ARk#;OFDn2V9u6wU`;VnhW%IYvG1{0x=jLlmC6 z{;20W*ZXCiK0V|9yF%yv(H{MYAtEQ)_}EQka@Wpf5LE`g*13E|?CRYhb){PB-YPC* zV?Ls^>RL*SA#8%AmA4r$j00dgkk-umzl?2NU)i{fq}Og-K7!CL%_%nqKHTvzk>E!d zhs-bKNP&~I@O_&hxnt^bw4r}%Qcd4Ow`7A3*dBYf;_}Ic^}Tt50M0(iGaM5)z&ISf zYP&5Fd;w#S$Xtx8xf>}qFtw&WAtFY0XWfUl-G9-*no!wenI=_LgjbY+yhL^r!B8)A zY=$A*4@yxM5(*3Y?}b};HXZ~78pNK+-T%)ru79%qsf_E6_^uWB(}LeW+5S<~bsyo5 z`bWjsUG3KQcGs~h`17uw>c4T^RdRiAcN}Tp&z}`o|7819UDq$R&VRDq6>i;Uy(hxb|kS@ZQzn7hTgUxx4tCJAg5{~Y+;2!3q;e-$O%$Go2&|Anaxj`sW!^JlXB zKGq%Y4^iADZ@;(yw+Fz1>))_`q;l^=+)w5H04eb2_#4Fi#O{5_`+3e^kXDF)8Py-M zp7&AjP=3tyF1h%<-OW`F=^pCORO5Y&`>DnsCm-~?S4f$V? zUf^r;kC1;b>+hr9H&1_|UXlC-^}exsAM*YM{tJ?U;vVEbH_!L$Tu~Mltn?rtaKJx* L@K^nv%?$B>kQgEz literal 8926 zcmaia1z40@*EZeFNQZzkNQ-ngNOwp&3^mf-Al)e?-KcaUAdSQ*B_Sb=2-1i&e8ca5 z^vL_3^DeGuc;>p+y7!(nd*6FK_Zl@tWE21b0tNpUf_lazm#RPB-rFt zWI2!#)c$a+@kiRBggcPKFL?NGM`Z~Wd081vEp}zuL*@4{B}F#&QCvkf=Ark)wHgn` zxfa)!*N|?3!Q+38iUPm4ce4DC0sroEGqW2XS7$fde|5zDyCc{E`mfG+ZabTqL+s7W zo&FW}v&XT+hNFjt=n!GI^9$T=!?UimRRwQ@D!*?7~i z(V#td@ipX&6eHF6b8AP9ZKe?B#LhE^vV{vl6<7WUu7QC=A4zB$Q*6BmRjCGPo0E1U zt$jWXGVl1x6bl>LGP{7J3)BK0jFPiVh$TcY8df) z#49-r#4~gb-(56%YlgL;jvLwqJ@Rnr0pw%|LKWSRGKjpm-D)ns&Es2Jl9Lq^`YCcB z%|A);i2MZj5N;GPX#$V9~^$m>)ur1Uz_@fJQ21VnZ%8Iwo$O+*r z#o_!q3I@b1?`V*-we0 zp`j6@iMpYIWYLN)@?9>+mTL?zdjgd%lg3vslE&$MuM5k@SBXe5;<5rl5+v@jRI{p! zF>-QHGY|B4q#7or>m_c!&^1gv9N#+YQpu+nTjvuD}#ntr%7 zaXi1SXI0CZ)+Ys&a&K7;!8HydQCwe)-|SsRPR<|1_3@BMQ6cJ?-9{~Db(a=Ij*WCC zI9P9%&;=x&42m~1BN%)SV;xX>KTsx#RV}y~LKbR*83ra}kP;IK#C$|Rt|3n9h`OFi z0xW4Z|ANphhXJJ944@i(*Wc0K@g4z5sl#Ppumf$iHpl~qN?eo?nKW}4*KGgU40z$=2{XOiBks4h8o=?65`MWuk^R7UG;(xV43+;*>dZ$8RN`d^ zhI2{_GsBh8%{ogG7=2C}zlx=5iI4%a(H?mc)jLWW9@7R#Q87+ZfK|O+b4nL1JvPkq z=>@+4#rqhHyB$1at-SjiPRR8A>VH5IQ`~jK4Jj<@DfWipAc>6BUKHDl=lX7c} z5Bd(#f>awmemE_?SRnPX(Q4mbum`>;EnYZ&LQdeLObI`<;Rutv?U_pq@!=+P?V)@< z_6c!I)cfA6#QZ=}DN*zn{89GTv*`VvQ*qa~R&C-AmFsu--gkoYz(1Y_|9{oW+B^MR zwYKps3djL`qS`8#Uw>BA??ob^CT7F}Cgft40Z$R}#c z>YZ##`_6U?ZyZEL7v>QSP5C6E99E_BUe_4kf6M*!-J2XoHTQP6RjEK;x~y;dETu+y zJ0;FTkU&?cZOx1TttN!kyrKQX;toCympHQr7$P)uPRDQE@goP=hqRXht>gJ z#3mt`a__Jv?01?^iZRjSlA|m-Rg1YbVIK|>9r%qspA<`Vs>{+=R^YR7eCpkD9YCtD zT@PEr45$Ka_OCypNqi!eUm?x*T{=T-o}{6-SYw(H$Z=Pec7ya!>V#+P*O^apn>wL( zF6K^lV4MFqdNrRfj&~!&YZD9v1lE6y()6@7wYPynl%UQo^0p2(KXV?VrS43u4Y;y% zYncU6zU%~88$el7?$t>%)AQDce^TIP)&o)dnm*qOW|QZwopvc3z9KUA*q5+$N$ZMU zsTJ!GTWohA+i!8_Q%pxVh@Y!n_gfcQ5Lll-UvH1|LwCSTzDG2o^pynk1Vd?e7TvAd z+&#Uw()wIQgx~@1=U7S`Osh9O6Fr3;OsJdacBLL4j<>rbXR#9>dO0TU`l z*HPjIyjYjj0q)siTNVMj-DlrmR{>U6Z%FNwWT1B;pTkG>fR6XcZ@!d9I|_;Pr5;*7Xg_M6 z5&`H@yfWkWd}XMk_7N&zThgt!l-NWkBy^nkK=%8^S?q2-l#p6q7Pi41)RM;{+!e(E zA_rv6<8Gb3<=D0xuS-t-iVLA1<>PJSdv{*LvvcN;J783~JC#MPi`5?+yB=uPLuBuW zBusW;zN-91f6+Rj!_(M_juz{xa?F{Sg6&E39zp&d*_TFq&Lhgi_K^~B%=LjMA}9}n zMQZh!jz*>xcC^enET~Io@72@Rt-S-pZm0JQh6d!A8cS^#hVeg#WDcY~uS9ZvG-O~{ zl%KSkDb%HeBo-HM0oYK&hJHu^c1RlgLsV z!r~m2lk37%n=;fUUG>vzM2m{JzK}GKbLQ!*k$?_j<=WfTd6EW9U>v3X;bI(TNpXHkdu23c7a1HlHJfP^R zpgflw{*VrfpR2QheKuA5?xWp%ue%I=vstJ6e&kTC$mnFQq&yvNg=r*&Vx2riU*+>x zH8XOHd=R2wF7GR=>a**_MNdb8CjVW2p%a}F@1~6 zYslpjFM(|Zv)C1SMmAIU*iEG@Z>Glb>Yv0yq z8>`F(<9=hVfCciAJ#@tA&J@j`X%v|6Y`Le|qWEHgg8t*DuFs22Om|cTEoxm&6{gUs z8u#d=nkQ?Fz|&cY@~(ztlhINU91b?i4Eeb>4U|dlvb1DK0uHoXhSAX)3n-k0%sQV* z?56U-{W7ZdG)Y+K6J0t1#cOuoJ|%HkOnroF9e&JLKqR?K_I}mYDX&NrW z>sIhA!vvk3-dC)=qg%FWLaC(a3$t1mA!B9NaC_@;2gtpAZGEE>iygh1HD~0vpW~C7WZfZ1I0oNg z{pSgjLN3URRWb548wW+}jH{sbmbSS7v4{ESJoV9l3~%{@GfH!vU$)|oGn(hy~-7Z z`pWBcVS9%%hrZMZKZ{iJW3Cy@;K$JLqzHeHoUowS!<8V_@Tr6wpKFP;$dfEbF6kVnowj)62g3 z&RBM%)OdtT?RKXZGrQ5l-)i04R1aqkoe{$;XFM4)$hpG)lNL6o7ei;@v=9ZS1+M=| z3-V^>b}mpC&s+3h1g8gph;@;Ujs4iT9YjI%5wf!Rx|B~{-8dZ(pn)!=92GQM?4#wV zrCZMWlODu+kl!O@b>MV!iA65$C}^|7UT}8@)lVH~iyY6_>RMkP?$Y`rHeoTupaAYb zs7m6^(!A`pD4T8hm3^&`-%Rh3C9p#fW^|XRS2hZ64;0 zQK4W?0z6z~2JwR&)4{K{d5?_U+lwfv6&tCBU8uV!tuH6-W*aCf$*hiLOCem*+vM4u z4$WR^A*Mw*Lw8H*`y5Hu$w2h#GZXcG56ojIkzTBOAg^zDe=H>VQore7QY1MCy+6%3z@ErcxzeLB@ToW#cZ0kV*~_mSDHD2GSO(5Cx)auq+eyBbZS+SDwVTx87nLl zN$LuND(Gz7>BnTIXtztSUFphW+p+4TcSt1KtP!E9Bx{G(kIE>yhUTCB2`C`o2PNsyEu&p#<}}Lzoodv zc57yJKxY=WyMnR;*oHpDx%*b@qz3{NOPlrieu!zaL1e^*-AT>nK=1o978eHm7xi#r?0N}Lyf z1CY6y=`$|s6{WCD7h6s0z(daR{QT%eL;emIBr*I13*bf_KK7%K`T!0lKSm;!uxf?- z8p&nKtmv5562zYE5q#u$dnq2Rusxy3?tw#O>NN=UT2PW-e#`1?KGz=cQMepodjAj! zelCm010Mn|X&3e4w4+Y2Ke2>=SF@^)WU+{JvXmB3+E?a&J79E;#|FJf7*qO7KtC;L zIXRpzgHkO$EO{?&O!)mUgMz;@$t4+;V;wEf^zh-eSX_h3B(g9L(bfH{FC*y&CzLOg z6I|7^_dlTEwPYp5qk2I}pfxFIb;BX3t9uwi2fgWq?2`;L>s=Zsn;8V!c=gx3b#2|p zPQC}Ue^LdvJm&dBxZhq&~^B0piZ#%!9 z5g3oT))#%fV^BS@92GiK&-1ZK{4m;1Aj#|s$~3LM-7u}>b|xYOO>?WM0P(Dh`&95k z03}hv>oT&iR|f=!)odTE%s=wTE(K0Y^B$Tn;+VCWYDjJ z)8qwF5GUD)Q5^KohpfcLjurYJ?79idt=Och&q<^y-)t7_6E^l8IJH8lM&&(;gorxwDcvn(6 z^({~GicmH`M>&;T2r=YN3hMpuK-Ii8hk@?(qm-3%nzs8btl~!;ak?ftTV4jQk4Bm% zw7gvW2f%=xrC_J)ux~!d(X3^R3aO(L^1RYu{`b@;(c0cw`-p?u_%##h{Z9(%i;ACq zN*5t`F_(!FuZ1vv+QTbJ5Sk%FDMfIf363bur%!WV*z1H+cd1!OV zz7gNIR>oaNw(=!Ddg%-25VGsXosO99K^tZM8-o@pX-$+YLcCD zREZUS+y4YW!eVR;ACDD9OhXhwIU<~Laj(2lTX{Q*;Gc73@D&**w~6^JbPmXtkq@3+n(x8L>CBf z1I-Hrh&&Zp;aau&JT`qj*E7?A;UYr#j+H~hW+czq-SmTRohykhdnE?W%LBd`{WKYU z5Y!zjJ#d#ng+BhSwaA*f2EF@B3LUgf&#JHJ@|j$OmPd~UPiF0@u-TTO;l6z?4c5u7 zvl*WkvOc7J6kO-uS>YYi_0XKC@G{mYMD!;XMe9_S7vN`!Q9aW>2FNeY7U$I;HCV++$yWegRdlkX;qA)z) z1@L@>{wd#oEB$`vJwzR*(*1zIFcq{BBo{z3sJM)D54}HxIL1r*wMGw}Hs0La6PXH% zl0ikRoOc2Eiv-QHIl zVO6b?fMvd6u>QhOuBqN!c5j3)d6@g7BwKUQ*tW`2@!s*MihgcT*-@~JV?Z0SwjR^V zgD0c7rU~loW6X&fS3em0B%}0*OcyAfn{5lV&(F67EvdZ?H>mr3XQCHbnyR0=QF9DE zesPqWI9g%C@+`fzWSXGFrU9g%Hywx2gQs0q7;XI`omADw51PBgfHf|g;Y zJNF%9xGGq0g=_BHCKdbZ^MhOJUTLkL)=gt%7=F?IQ~qz{xu1#mjTcdcCqC4qu`_S2 z6ji^cKQJ?dRjF=M=bmB$S>UIS{gH-i1(DAmt(CYgqVE+DtlwoGM@q3-ci)_nGir4*woF^ei)^k~mErq#)jHmPz)}q z;dwbMo7P)25q9SEsutRe&ibb@U2>hH^}1YDnT%{TR-A#=Q>(qknUc9LUhEHzWd@`N z8)bq#5b%WLNy7?{A8qHVUJ=GNUSXb=2wjn*+0GHH8(aqdNOg@+_l9c+YKn+R0OWse z$HFrSHv)uhiJSkwnzOgVZZ~IdoNuf!fC>KkE9`Hr+S>>>-tevS|LmqC`_pa)c7xyE zlu7>zx^ZhuTJi5 zh})gqzd#BDfbfO;Um8Z)ebNb@KKAw;xk}53md8 zia%!l_lK6-Ft>}4-!OXcpK<&F^S96alc8^8-9BJ{WA#(~1J>U@>VL<)eQ5l~d_?sR an7@w@HAPgkn*bvCpAh_q88Os1@BR Date: Mon, 19 May 2025 19:00:07 +0300 Subject: [PATCH 04/10] Approximation fixes (#16) * [fix] fixed approximations * [fix] deleted spring dependencies --- approximations/build.gradle.kts | 10 +- .../decoders/java/lang/Integer_Decoder.java | 12 +- .../java/util/AbstractMap_Entry_Decoder.java | 42 ++ .../decoders/java/util/ArrayList_Decoder.java | 12 +- .../decoders/java/util/HashMap_Decoder.java | 154 +++++ .../decoders/java/util/HashSet_Decoder.java | 14 +- .../java/util/LinkedHashMap_Decoder.java | 155 +++++ .../java/util/LinkedHashSet_Decoder.java | 23 +- .../java/util/LinkedList_Decoder.java | 12 +- .../java/util/AbstractCollection_Encoder.java | 16 + .../java/util/AbstractMap_Entry_Encoder.java | 7 +- .../encoders/java/util/ArrayList_Encoder.java | 7 +- .../encoders/java/util/HashSet_Encoder.java | 6 +- .../java/util/LinkedHashSet_Encoder.java | 18 + .../java/util/LinkedList_Encoder.java | 17 + .../java/util/StringBuilder_Encoder.java | 15 + .../encoders/java/util/String_Encoder.java | 19 +- .../java/util/ThreadLocal_Encoder.java | 2 +- .../java/generated/java/lang/IntegerImpl.java | 6 - .../java/lang/StringBuilderImpl.java | 588 +++++++++++------- .../java/generated/java/lang/StringImpl.java | 278 +++++++-- .../java/lang/SystemHelpersImpl.java | 10 + .../java/generated/java/lang/SystemImpl.java | 183 +++--- .../generated/java/lang/ThreadLocalImpl.java | 8 +- .../java/util/AbstractCollectionImpl.java | 30 +- .../java/util/AbstractSpliteratorImpl.java | 60 +- .../generated/java/util/PropertiesImpl.java | 19 + .../array/AbstractArraySpliteratorImpl.java | 55 +- .../generated/java/util/array/ArraysImpl.java | 420 +++++++++++++ .../java/util/list/AbstractListImpl.java | 149 ++--- .../java/util/list/ArrayListImpl.java | 108 ++-- .../java/util/list/LinkedListImpl.java | 115 ++-- .../java/util/list/ListIteratorStubImpl.java | 13 +- .../util/list/ListSpliteratorStubImpl.java | 61 +- .../generated/java/util/list/SubListImpl.java | 42 +- .../java/util/map/AbstractMapImpl.java | 132 ++-- .../java/util/map/ConcurrentHashMapImpl.java | 85 ++- .../generated/java/util/map/HashMapImpl.java | 83 ++- .../java/util/map/LinkedHashMapImpl.java | 3 +- .../java/util/map/Map_ContentsImpl.java | 83 ++- .../java/util/map/Map_ContentsSetImpl.java | 7 +- .../util/map/Map_Contents_IteratorImpl.java | 7 +- .../map/Map_Contents_SpliteratorImpl.java | 69 +- .../java/util/map/Map_EntrySetImpl.java | 11 +- .../java/util/map/Map_KeySetImpl.java | 11 +- .../java/util/map/Map_ValuesImpl.java | 13 +- .../java/util/set/AbstractSetImpl.java | 136 ++-- .../generated/java/util/set/HashSetImpl.java | 82 ++- .../java/util/set/LinkedHashSetImpl.java | 10 +- .../java/util/set/Set_IteratorImpl.java | 6 +- .../java/util/set/Set_SpliteratorImpl.java | 67 +- .../java/util/stream/BaseStreamImpl.java | 8 +- .../java/util/stream/DoubleStreamImpl.java | 2 +- .../java/util/stream/IntStreamImpl.java | 2 +- .../java/util/stream/LongStreamImpl.java | 2 +- .../java/util/stream/StreamStubImpl.java | 2 +- .../org/apache/commons/logging/LogImpl.java | 56 -- .../springframework/boot/ClassUtilsImpl.java | 19 - .../ErrorsMethodArgumentResolverImpl.java | 28 - .../springframework/boot/LogFactoryImpl.java | 17 - .../boot/MergedContextConfigurationImpl.java | 26 - ...athVariableMethodArgumentResolverImpl.java | 20 - ...equestParamMethodArgumentResolverImpl.java | 20 - .../boot/SpringApplicationImpl.java | 74 --- .../org/springframework/boot/StartSpring.java | 11 - .../boot/SymbolicValueFactory.java | 24 - .../org/springframework/boot/TestClass.java | 12 - .../boot/TestContextManagerImpl.java | 57 -- .../src/main/java/runtime/LibSLRuntime.java | 124 +--- .../java/stub/java/lang/SystemHelpers.java | 8 + .../util/array/AbstractArraySpliterator.java | 6 +- .../stub/java/util/list/ListIteratorStub.java | 2 +- .../java/stub/java/util/map/Map_Contents.java | 4 +- usvm-api/usvm-api.jar | Bin 11342 -> 0 bytes usvm-api/usvm-jvm-api.jar | Bin 0 -> 13121 bytes 75 files changed, 2565 insertions(+), 1450 deletions(-) create mode 100644 approximations/src/main/java/decoders/java/util/AbstractMap_Entry_Decoder.java create mode 100644 approximations/src/main/java/decoders/java/util/HashMap_Decoder.java create mode 100644 approximations/src/main/java/decoders/java/util/LinkedHashMap_Decoder.java create mode 100644 approximations/src/main/java/encoders/java/util/AbstractCollection_Encoder.java create mode 100644 approximations/src/main/java/encoders/java/util/LinkedHashSet_Encoder.java create mode 100644 approximations/src/main/java/encoders/java/util/LinkedList_Encoder.java create mode 100644 approximations/src/main/java/encoders/java/util/StringBuilder_Encoder.java create mode 100644 approximations/src/main/java/generated/java/lang/SystemHelpersImpl.java create mode 100644 approximations/src/main/java/generated/java/util/PropertiesImpl.java create mode 100644 approximations/src/main/java/generated/java/util/array/ArraysImpl.java delete mode 100644 approximations/src/main/java/generated/org/apache/commons/logging/LogImpl.java delete mode 100644 approximations/src/main/java/generated/org/springframework/boot/ClassUtilsImpl.java delete mode 100644 approximations/src/main/java/generated/org/springframework/boot/ErrorsMethodArgumentResolverImpl.java delete mode 100644 approximations/src/main/java/generated/org/springframework/boot/LogFactoryImpl.java delete mode 100644 approximations/src/main/java/generated/org/springframework/boot/MergedContextConfigurationImpl.java delete mode 100644 approximations/src/main/java/generated/org/springframework/boot/PathVariableMethodArgumentResolverImpl.java delete mode 100644 approximations/src/main/java/generated/org/springframework/boot/RequestParamMethodArgumentResolverImpl.java delete mode 100644 approximations/src/main/java/generated/org/springframework/boot/SpringApplicationImpl.java delete mode 100644 approximations/src/main/java/generated/org/springframework/boot/StartSpring.java delete mode 100644 approximations/src/main/java/generated/org/springframework/boot/SymbolicValueFactory.java delete mode 100644 approximations/src/main/java/generated/org/springframework/boot/TestClass.java delete mode 100644 approximations/src/main/java/generated/org/springframework/boot/TestContextManagerImpl.java create mode 100644 approximations/src/main/java/stub/java/lang/SystemHelpers.java delete mode 100644 usvm-api/usvm-api.jar create mode 100644 usvm-api/usvm-jvm-api.jar diff --git a/approximations/build.gradle.kts b/approximations/build.gradle.kts index b22d5130..52cd63a8 100644 --- a/approximations/build.gradle.kts +++ b/approximations/build.gradle.kts @@ -1,7 +1,8 @@ +@file:Suppress("VulnerableLibrariesLocal") + plugins { java `maven-publish` - id("org.springframework.boot") version "3.2.0" apply false } repositories { @@ -10,15 +11,12 @@ repositories { } private val jacodbPackage = "com.github.UnitTestBot.jacodb" -private val jacodbVersion = "00164e304b" // jacodb neo branch +private val jacodbVersion = "453ec7c0b3" // jacodb neo branch dependencies { compileOnly("$jacodbPackage:jacodb-api-jvm:$jacodbVersion") compileOnly("$jacodbPackage:jacodb-approximations:$jacodbVersion") - compileOnly(files(rootDir.resolve("usvm-api/usvm-api.jar"))) - compileOnly("org.springframework.boot:spring-boot-starter-web:3.2.0") - compileOnly("org.springframework.boot:spring-boot-starter-test:3.2.0") - compileOnly("org.springframework.boot:spring-boot-starter-data-jpa:3.2.0") + compileOnly(files(rootDir.resolve("usvm-api/usvm-jvm-api.jar"))) // Fixes "unknown enum constant 'When.MAYBE'" warning compileOnly("com.google.code.findbugs:jsr305:3.0.2") } diff --git a/approximations/src/main/java/decoders/java/lang/Integer_Decoder.java b/approximations/src/main/java/decoders/java/lang/Integer_Decoder.java index 0c5f4a83..dee10d69 100644 --- a/approximations/src/main/java/decoders/java/lang/Integer_Decoder.java +++ b/approximations/src/main/java/decoders/java/lang/Integer_Decoder.java @@ -11,28 +11,28 @@ @DecoderFor(Integer.class) public final class Integer_Decoder implements ObjectDecoder { - private volatile JcMethod cached_Integer_ctor = null; + private volatile JcMethod cached_Integer_valueOf = null; private volatile JcField cached_Integer_value = null; @Override public T createInstance(final JcClassOrInterface approximation, final ObjectData approximationData, final DecoderApi decoder) { - JcMethod ctor = cached_Integer_ctor; + JcMethod valueOf = cached_Integer_valueOf; // TODO: add synchronization if needed - if (ctor == null) { + if (valueOf == null) { // looking for constructor and data field final List methods = approximation.getDeclaredMethods(); for (int i = 0, c = methods.size(); i != c; i++) { JcMethod m = methods.get(i); - if (!m.isConstructor()) continue; + if (!"valueOf".equals(m.getName())) continue; List params = m.getParameters(); if (params.size() != 1) continue; if (!"int".equals(params.get(0).getType().getTypeName())) continue; - cached_Integer_ctor = ctor = m; + cached_Integer_valueOf = valueOf = m; break; } @@ -51,7 +51,7 @@ public T createInstance(final JcClassOrInterface approximation, // assemble into a call final List args = Collections.singletonList(decoder.createIntConst(value)); - return decoder.invokeMethod(ctor, args); + return decoder.invokeMethod(valueOf, args); } @Override diff --git a/approximations/src/main/java/decoders/java/util/AbstractMap_Entry_Decoder.java b/approximations/src/main/java/decoders/java/util/AbstractMap_Entry_Decoder.java new file mode 100644 index 00000000..3735dcc1 --- /dev/null +++ b/approximations/src/main/java/decoders/java/util/AbstractMap_Entry_Decoder.java @@ -0,0 +1,42 @@ +package decoders.java.util; + +import org.jacodb.api.jvm.JcClassOrInterface; +import org.jacodb.api.jvm.JcField; +import org.usvm.api.decoder.*; +import stub.java.util.map.AbstractMap_Entry; + +import java.util.List; + +@DecoderFor(AbstractMap_Entry.class) +public class AbstractMap_Entry_Decoder implements ObjectDecoder { + private volatile JcField cached_Entry_value = null; + + @SuppressWarnings({"ForLoopReplaceableByForEach", "unchecked"}) + @Override + public T createInstance(final JcClassOrInterface approx, + final ObjectData approxData, + final DecoderApi decoder) { + JcField f_value = cached_Entry_value; + // TODO: add synchronization if needed + if (f_value == null) { + final List fields = approx.getDeclaredFields(); + for (int i = 0, c = fields.size(); i < c; i++) { + JcField f = fields.get(i); + if ("value".equals(f.getName())) { + cached_Entry_value = f_value = f; + break; + } + } + } + + T value = approxData.decodeField(f_value); + return (T) new InternalMapEntry(value); + } + + @Override + public void initializeInstance(final JcClassOrInterface approx, + final ObjectData approxData, + final T instance, + final DecoderApi decoder) { + } +} diff --git a/approximations/src/main/java/decoders/java/util/ArrayList_Decoder.java b/approximations/src/main/java/decoders/java/util/ArrayList_Decoder.java index 162bde35..a66f2d15 100644 --- a/approximations/src/main/java/decoders/java/util/ArrayList_Decoder.java +++ b/approximations/src/main/java/decoders/java/util/ArrayList_Decoder.java @@ -14,6 +14,8 @@ import java.util.Collections; import java.util.List; +import static org.usvm.api.decoder.DecoderUtils.findStorageField; + @SuppressWarnings("ForLoopReplaceableByForEach") @DecoderFor(ArrayList.class) public class ArrayList_Decoder implements ObjectDecoder { @@ -46,7 +48,6 @@ public T createInstance(final JcClassOrInterface approx, List params = m.getParameters(); if (params.size() != 1) continue; - if (!"java.lang.Object".equals(params.get(0).getType().getTypeName())) continue; cached_ArrayList_add = m_add = m; } @@ -68,14 +69,7 @@ public void initializeInstance(final JcClassOrInterface approx, JcField f_storage = cached_ArrayList_storage; // TODO: add synchronization if needed if (f_storage == null) { - final List fields = approx.getDeclaredFields(); - for (int i = 0, c = fields.size(); i < c; i++) { - JcField f = fields.get(i); - if ("storage".equals(f.getName())) { - cached_ArrayList_storage = f_storage = f; - break; - } - } + cached_ArrayList_storage = f_storage = findStorageField(approx); } if (approxData.getObjectField(f_storage) == null) diff --git a/approximations/src/main/java/decoders/java/util/HashMap_Decoder.java b/approximations/src/main/java/decoders/java/util/HashMap_Decoder.java new file mode 100644 index 00000000..37b87726 --- /dev/null +++ b/approximations/src/main/java/decoders/java/util/HashMap_Decoder.java @@ -0,0 +1,154 @@ +package decoders.java.util; + +import org.jacodb.api.jvm.*; +import org.usvm.api.SymbolicMap; +import org.usvm.api.decoder.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import static org.usvm.api.decoder.DecoderUtils.findStorageField; +import static org.usvm.api.decoder.DecoderUtils.getAllMethods; + +@DecoderFor(HashMap.class) +public class HashMap_Decoder implements ObjectDecoder { + private volatile JcMethod[] cachedMethods = null; + private volatile JcMethod cached_HashMap_ctor = null; + private volatile JcMethod cached_HashMap_put = null; + private volatile JcField cached_HashMap_storage = null; + private volatile JcField cached_Map_map = null; + private volatile JcField cached_HashMapContainer_map = null; + private volatile JcMethod cached_MapEntry_getValue = null; + + @Override + public T createInstance(final JcClassOrInterface approximation, + final ObjectData approximationData, + final DecoderApi decoder) { + JcMethod m_ctor = cached_HashMap_ctor; + // TODO: add synchronization if needed + if (m_ctor == null) { + final List methodList = approximation.getDeclaredMethods(); + final int methodCount = methodList.size(); + JcMethod[] methods = new JcMethod[methodCount]; + cachedMethods = methods = methodList.toArray(methods); + + for (int i = 0; i != methodCount; i++) { + JcMethod m = methods[i]; + + if (m.isConstructor()) { + List params = m.getParameters(); + + // example: looking for java.util.HashMap.HashMap() + if (!params.isEmpty()) continue; + + // update global "cache" and stop the search + cached_HashMap_ctor = m_ctor = m; + break; + } + } + } + + // prepare parameters "in-place" and construct a new call + final ArrayList args = new ArrayList<>(); + return decoder.invokeMethod(m_ctor, args); + } + + @SuppressWarnings("unchecked") + @Override + public void initializeInstance(final JcClassOrInterface approximation, + final ObjectData approximationData, + final T outputInstance, + final DecoderApi decoder) { + JcField f_hs_storage = cached_HashMap_storage; + // TODO: add synchronization if needed + if (f_hs_storage == null) { + cached_HashMap_storage = f_hs_storage = findStorageField(approximation); + } + + // skip empty or erroneous objects + final ObjectData storageData = approximationData.getObjectField(f_hs_storage); + if (storageData == null) + return; + + // get primary method + JcMethod m_put = cached_HashMap_put; + // TODO: add synchronization if needed + if (m_put == null) { + // TODO: add cache + List methodsList = getAllMethods(approximation); + final int methodCount = methodsList.size(); + JcMethod[] methods = new JcMethod[methodCount]; + methodsList.toArray(methods); + for (int i = 0, c = methods.length; i != c; i++) { + JcMethod m = methods[i]; + + if (!"put".equals(m.getName())) continue; + List params = m.getParameters(); + if (params.size() != 2) continue; + + m_put = m; + break; + } + cached_HashMap_put = m_put; + } + + // prepare field references (inlined) + JcField f_m_map = cached_Map_map; + // TODO: add synchronization if needed + if (f_m_map == null) { + JcClasspath cp = approximation.getClasspath(); + { + List fields = cp.findClassOrNull("runtime.LibSLRuntime$Map").getDeclaredFields(); + for (int i = 0, c = fields.size(); i != c; i++) { + JcField field = fields.get(i); + + if ("map".equals(field.getName())) { + cached_Map_map = f_m_map = field; + break; + } + } + } + { + List fields = cp.findClassOrNull("runtime.LibSLRuntime$HashMapContainer").getDeclaredFields(); + for (int i = 0, c = fields.size(); i != c; i++) { + JcField field = fields.get(i); + + if ("map".equals(field.getName())) { + cached_HashMapContainer_map = field; + break; + } + } + } + } + + // get and parse the underlying symbolic map + final ObjectData rtMapContainerData = storageData.getObjectField(f_m_map); + if (rtMapContainerData == null) + return; // ignore invalid container + + final SymbolicMap map = rtMapContainerData.decodeSymbolicMapField(cached_HashMapContainer_map); + if (map == null) + return; // ignore invalid container + + int length = map.size(); + if (length == Integer.MAX_VALUE) + return; // ignore invalid container + + while (length > 0) { + T key = map.anyKey(); + T value = map.get(key); + if (value instanceof InternalMapEntry) { + value = ((InternalMapEntry) value).getValue(); + } + + List args = new ArrayList<>(); + args.add(outputInstance); + args.add(key); + args.add(value); + decoder.invokeMethod(m_put, args); + + map.remove(key); + length--; + } + } +} diff --git a/approximations/src/main/java/decoders/java/util/HashSet_Decoder.java b/approximations/src/main/java/decoders/java/util/HashSet_Decoder.java index 4a7634ed..7fb92e71 100644 --- a/approximations/src/main/java/decoders/java/util/HashSet_Decoder.java +++ b/approximations/src/main/java/decoders/java/util/HashSet_Decoder.java @@ -11,6 +11,8 @@ import java.util.HashSet; import java.util.List; +import static org.usvm.api.decoder.DecoderUtils.findStorageField; + @DecoderFor(HashSet.class) public final class HashSet_Decoder implements ObjectDecoder { private volatile JcMethod[] cachedMethods = null; @@ -65,17 +67,7 @@ public void initializeInstance(final JcClassOrInterface approximation, JcField f_hs_storage = cached_HashSet_storage; // TODO: add synchronization if needed if (f_hs_storage == null) { - final List fields = approximation.getDeclaredFields(); - for (int i = 0, c = fields.size(); i != c; i++) { - JcField field = fields.get(i); - String fieldName = field.getName(); - - if (!"storage".equals(fieldName)) continue; - - // early termination - cached_HashSet_storage = f_hs_storage = field; - break; - } + cached_HashSet_storage = f_hs_storage = findStorageField(approximation); } // skip erroneous objects diff --git a/approximations/src/main/java/decoders/java/util/LinkedHashMap_Decoder.java b/approximations/src/main/java/decoders/java/util/LinkedHashMap_Decoder.java new file mode 100644 index 00000000..7e9db527 --- /dev/null +++ b/approximations/src/main/java/decoders/java/util/LinkedHashMap_Decoder.java @@ -0,0 +1,155 @@ +package decoders.java.util; + +import org.jacodb.api.jvm.*; +import org.usvm.api.SymbolicMap; +import org.usvm.api.decoder.*; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; + +import static org.usvm.api.decoder.DecoderUtils.findStorageField; +import static org.usvm.api.decoder.DecoderUtils.getAllMethods; + +@DecoderFor(LinkedHashMap.class) +public class LinkedHashMap_Decoder implements ObjectDecoder { + private volatile JcMethod[] cachedMethods = null; + private volatile JcMethod cached_LinkedHashMap_ctor = null; + private volatile JcMethod cached_LinkedHashMap_put = null; + private volatile JcField cached_LinkedHashMap_storage = null; + private volatile JcField cached_Map_map = null; + private volatile JcField cached_HashMapContainer_map = null; + private volatile JcMethod cached_MapEntry_getValue = null; + + @Override + public T createInstance(final JcClassOrInterface approximation, + final ObjectData approximationData, + final DecoderApi decoder) { + JcMethod m_ctor = cached_LinkedHashMap_ctor; + // TODO: add synchronization if needed + if (m_ctor == null) { + final List methodList = approximation.getDeclaredMethods(); + final int methodCount = methodList.size(); + JcMethod[] methods = new JcMethod[methodCount]; + cachedMethods = methods = methodList.toArray(methods); + + for (int i = 0; i != methodCount; i++) { + JcMethod m = methods[i]; + + if (m.isConstructor()) { + List params = m.getParameters(); + + // example: looking for java.util.LinkedHashMap.LinkedHashMap() + if (!params.isEmpty()) continue; + + // update global "cache" and stop the search + cached_LinkedHashMap_ctor = m_ctor = m; + break; + } + } + } + + // prepare parameters "in-place" and construct a new call + final ArrayList args = new ArrayList<>(); + return decoder.invokeMethod(m_ctor, args); + } + + @SuppressWarnings("unchecked") + @Override + public void initializeInstance(final JcClassOrInterface approximation, + final ObjectData approximationData, + final T outputInstance, + final DecoderApi decoder) { + JcField f_hs_storage = cached_LinkedHashMap_storage; + // TODO: add synchronization if needed + if (f_hs_storage == null) { + cached_LinkedHashMap_storage = f_hs_storage = findStorageField(approximation); + } + + // skip empty or erroneous objects + final ObjectData storageData = approximationData.getObjectField(f_hs_storage); + if (storageData == null) + return; + + // get primary method + JcMethod m_put = cached_LinkedHashMap_put; + // TODO: add synchronization if needed + if (m_put == null) { + // TODO: add cache + List methodsList = getAllMethods(approximation); + final int methodCount = methodsList.size(); + JcMethod[] methods = new JcMethod[methodCount]; + methodsList.toArray(methods); + for (int i = 0, c = methods.length; i != c; i++) { + JcMethod m = methods[i]; + + if (!"put".equals(m.getName())) continue; + List params = m.getParameters(); + if (params.size() != 2) continue; + + m_put = m; + break; + } + cached_LinkedHashMap_put = m_put; + } + + // prepare field references (inlined) + JcField f_m_map = cached_Map_map; + // TODO: add synchronization if needed + if (f_m_map == null) { + JcClasspath cp = approximation.getClasspath(); + { + List fields = cp.findClassOrNull("runtime.LibSLRuntime$Map").getDeclaredFields(); + for (int i = 0, c = fields.size(); i != c; i++) { + JcField field = fields.get(i); + + if ("map".equals(field.getName())) { + cached_Map_map = f_m_map = field; + break; + } + } + } + { + List fields = cp.findClassOrNull("runtime.LibSLRuntime$HashMapContainer").getDeclaredFields(); + for (int i = 0, c = fields.size(); i != c; i++) { + JcField field = fields.get(i); + + if ("map".equals(field.getName())) { + cached_HashMapContainer_map = field; + break; + } + } + } + } + + // get and parse the underlying symbolic map + final ObjectData rtMapContainerData = storageData.getObjectField(f_m_map); + if (rtMapContainerData == null) + return; // ignore invalid container + + final SymbolicMap map = rtMapContainerData.decodeSymbolicMapField(cached_HashMapContainer_map); + if (map == null) + return; // ignore invalid container + + int length = map.size(); + if (length == Integer.MAX_VALUE) + return; // ignore invalid container + + while (length > 0) { + T key = map.anyKey(); + T value = map.get(key); + if (value instanceof InternalMapEntry) { + value = ((InternalMapEntry) value).getValue(); + } + + List args = new ArrayList<>(); + args.add(outputInstance); + args.add(key); + args.add(value); + decoder.invokeMethod(m_put, args); + + map.remove(key); + length--; + } + } +} diff --git a/approximations/src/main/java/decoders/java/util/LinkedHashSet_Decoder.java b/approximations/src/main/java/decoders/java/util/LinkedHashSet_Decoder.java index 35c9f296..d30ae40d 100644 --- a/approximations/src/main/java/decoders/java/util/LinkedHashSet_Decoder.java +++ b/approximations/src/main/java/decoders/java/util/LinkedHashSet_Decoder.java @@ -11,8 +11,11 @@ import java.util.LinkedHashSet; import java.util.List; +import static org.usvm.api.decoder.DecoderUtils.findStorageField; + @DecoderFor(LinkedHashSet.class) public class LinkedHashSet_Decoder implements ObjectDecoder { + // TODO: unify with HashSet_Decoder private volatile JcMethod[] cachedMethods = null; private volatile JcMethod cached_LinkedHashSet_ctor = null; private volatile JcMethod cached_LinkedHashSet_add = null; @@ -38,10 +41,8 @@ public T createInstance(final JcClassOrInterface approximation, if (m.isConstructor()) { List params = m.getParameters(); - // example: looking for java.util.LinkedHashSet.LinkedHashSet(int, float) - if (params.size() != 2) continue; - if (!"int".equals(params.get(0).getType().getTypeName())) continue; - if (!"float".equals(params.get(1).getType().getTypeName())) continue; + // example: looking for java.util.LinkedHashSet.LinkedHashSet() + if (!params.isEmpty()) continue; // update global "cache" and stop the search cached_LinkedHashSet_ctor = m_ctor = m; @@ -52,8 +53,6 @@ public T createInstance(final JcClassOrInterface approximation, // prepare parameters "in-place" and construct a new call final ArrayList args = new ArrayList<>(); - args.add(decoder.createIntConst(123)); - args.add(decoder.createFloatConst(0.75f)); return decoder.invokeMethod(m_ctor, args); } @@ -65,17 +64,7 @@ public void initializeInstance(final JcClassOrInterface approximation, JcField f_hs_storage = cached_LinkedHashSet_storage; // TODO: add synchronization if needed if (f_hs_storage == null) { - final List fields = approximation.getDeclaredFields(); - for (int i = 0, c = fields.size(); i != c; i++) { - JcField field = fields.get(i); - String fieldName = field.getName(); - - if ("storage".equals(fieldName)) continue; - - // early termination - cached_LinkedHashSet_storage = f_hs_storage = field; - break; - } + cached_LinkedHashSet_storage = f_hs_storage = findStorageField(approximation); } // skip empty or erroneous objects diff --git a/approximations/src/main/java/decoders/java/util/LinkedList_Decoder.java b/approximations/src/main/java/decoders/java/util/LinkedList_Decoder.java index b2c3896f..429a251a 100644 --- a/approximations/src/main/java/decoders/java/util/LinkedList_Decoder.java +++ b/approximations/src/main/java/decoders/java/util/LinkedList_Decoder.java @@ -12,6 +12,8 @@ import java.util.*; +import static org.usvm.api.decoder.DecoderUtils.findStorageField; + @SuppressWarnings("ForLoopReplaceableByForEach") @DecoderFor(LinkedList.class) public class LinkedList_Decoder implements ObjectDecoder { @@ -66,14 +68,7 @@ public void initializeInstance(final JcClassOrInterface approximation, JcField f_storage = cached_LinkedList_storage; // TODO: add synchronization if needed if (f_storage == null) { - final List fields = approximation.getDeclaredFields(); - for (int i = 0, c = fields.size(); i < c; i++) { - JcField f = fields.get(i); - if ("storage".equals(f.getName())) { - cached_LinkedList_storage = f_storage = f; - break; - } - } + cached_LinkedList_storage = f_storage = findStorageField(approximation); } if (approximationData.getObjectField(f_storage) == null) @@ -91,4 +86,3 @@ public void initializeInstance(final JcClassOrInterface approximation, } } } - diff --git a/approximations/src/main/java/encoders/java/util/AbstractCollection_Encoder.java b/approximations/src/main/java/encoders/java/util/AbstractCollection_Encoder.java new file mode 100644 index 00000000..36077a79 --- /dev/null +++ b/approximations/src/main/java/encoders/java/util/AbstractCollection_Encoder.java @@ -0,0 +1,16 @@ +package encoders.java.util; + +import generated.java.util.list.ArrayListImpl; +import org.usvm.api.encoder.EncoderFor; +import org.usvm.api.encoder.ObjectEncoder; + +import java.util.AbstractCollection; + +@EncoderFor(AbstractCollection.class) +public class AbstractCollection_Encoder implements ObjectEncoder { + + @Override + public Object encode(Object object) { + return new ArrayListImpl<>(); + } +} diff --git a/approximations/src/main/java/encoders/java/util/AbstractMap_Entry_Encoder.java b/approximations/src/main/java/encoders/java/util/AbstractMap_Entry_Encoder.java index 2b79b6cd..0172b5d1 100644 --- a/approximations/src/main/java/encoders/java/util/AbstractMap_Entry_Encoder.java +++ b/approximations/src/main/java/encoders/java/util/AbstractMap_Entry_Encoder.java @@ -11,7 +11,10 @@ public class AbstractMap_Entry_Encoder implements ObjectEncoder { @Override - public Object encode(Object list) { - return new AbstractMap_EntryImpl<>((Map.Entry) list); + public Object encode(Object entry) { + if (entry instanceof AbstractMap_Entry) + return new AbstractMap_EntryImpl<>(null, null); + + return new AbstractMap_EntryImpl<>((Map.Entry) entry); } } diff --git a/approximations/src/main/java/encoders/java/util/ArrayList_Encoder.java b/approximations/src/main/java/encoders/java/util/ArrayList_Encoder.java index 09904b22..99127876 100644 --- a/approximations/src/main/java/encoders/java/util/ArrayList_Encoder.java +++ b/approximations/src/main/java/encoders/java/util/ArrayList_Encoder.java @@ -10,9 +10,8 @@ public class ArrayList_Encoder implements ObjectEncoder { @Override - public Object encode(Object list) { - ArrayListImpl result = new ArrayListImpl<>(); - result.addAll(((ArrayList) list).stream().toList()); - return result; + public Object encode(Object object) { + ArrayList list = (ArrayList) object; + return new ArrayListImpl<>(list); } } diff --git a/approximations/src/main/java/encoders/java/util/HashSet_Encoder.java b/approximations/src/main/java/encoders/java/util/HashSet_Encoder.java index 5c02fc20..8a567327 100644 --- a/approximations/src/main/java/encoders/java/util/HashSet_Encoder.java +++ b/approximations/src/main/java/encoders/java/util/HashSet_Encoder.java @@ -4,7 +4,6 @@ import org.usvm.api.encoder.EncoderFor; import org.usvm.api.encoder.ObjectEncoder; -import java.util.Arrays; import java.util.HashSet; import java.util.Set; @@ -13,8 +12,7 @@ public class HashSet_Encoder implements ObjectEncoder { @Override public Object encode(Object object) { - HashSetImpl result = new HashSetImpl<>(); - result.addAll(Arrays.asList(((Set) object).toArray())); - return result; + Set set = (Set) object; + return new HashSetImpl<>(set); } } diff --git a/approximations/src/main/java/encoders/java/util/LinkedHashSet_Encoder.java b/approximations/src/main/java/encoders/java/util/LinkedHashSet_Encoder.java new file mode 100644 index 00000000..b1df736e --- /dev/null +++ b/approximations/src/main/java/encoders/java/util/LinkedHashSet_Encoder.java @@ -0,0 +1,18 @@ +package encoders.java.util; + +import generated.java.util.set.LinkedHashSetImpl; +import org.usvm.api.encoder.EncoderFor; +import org.usvm.api.encoder.ObjectEncoder; + +import java.util.LinkedHashSet; + +@EncoderFor(LinkedHashSet.class) +public class LinkedHashSet_Encoder implements ObjectEncoder { + + @Override + @SuppressWarnings("unchecked") + public Object encode(Object object) { + LinkedHashSet set = (LinkedHashSet) object; + return new LinkedHashSetImpl<>(set); + } +} diff --git a/approximations/src/main/java/encoders/java/util/LinkedList_Encoder.java b/approximations/src/main/java/encoders/java/util/LinkedList_Encoder.java new file mode 100644 index 00000000..6eb4d251 --- /dev/null +++ b/approximations/src/main/java/encoders/java/util/LinkedList_Encoder.java @@ -0,0 +1,17 @@ +package encoders.java.util; + +import generated.java.util.list.LinkedListImpl; +import org.usvm.api.encoder.EncoderFor; +import org.usvm.api.encoder.ObjectEncoder; + +import java.util.LinkedList; + +@EncoderFor(LinkedList.class) +public class LinkedList_Encoder implements ObjectEncoder { + + @Override + public Object encode(Object object) { + LinkedList list = (LinkedList) object; + return new LinkedListImpl<>(list); + } +} diff --git a/approximations/src/main/java/encoders/java/util/StringBuilder_Encoder.java b/approximations/src/main/java/encoders/java/util/StringBuilder_Encoder.java new file mode 100644 index 00000000..65bd39c2 --- /dev/null +++ b/approximations/src/main/java/encoders/java/util/StringBuilder_Encoder.java @@ -0,0 +1,15 @@ +package encoders.java.util; + +import generated.java.lang.StringBuilderImpl; +import org.usvm.api.encoder.EncoderFor; +import org.usvm.api.encoder.ObjectEncoder; + +@EncoderFor(java.lang.StringBuilder.class) +public class StringBuilder_Encoder implements ObjectEncoder { + + @Override + public Object encode(Object object) { + StringBuilder sb = (StringBuilder) object; + return new StringBuilderImpl(sb.toString()); + } +} diff --git a/approximations/src/main/java/encoders/java/util/String_Encoder.java b/approximations/src/main/java/encoders/java/util/String_Encoder.java index d8c3b59c..3b5c67b6 100644 --- a/approximations/src/main/java/encoders/java/util/String_Encoder.java +++ b/approximations/src/main/java/encoders/java/util/String_Encoder.java @@ -4,11 +4,28 @@ import org.usvm.api.encoder.EncoderFor; import org.usvm.api.encoder.ObjectEncoder; +import java.lang.reflect.Field; + @EncoderFor(java.lang.String.class) public class String_Encoder implements ObjectEncoder { @Override public Object encode(Object object) { - return new StringImpl(((String) object).getBytes()); + String string = (String) object; + Field arrayField; + try { + arrayField = String.class.getDeclaredField("value"); + } catch (NoSuchFieldException e) { + throw new RuntimeException(e); + } + arrayField.setAccessible(true); + boolean isDefault; + try { + isDefault = arrayField.get(string) == null; + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } + byte[] bytes = isDefault ? new byte[0] : string.getBytes(); + return new StringImpl(bytes); } } diff --git a/approximations/src/main/java/encoders/java/util/ThreadLocal_Encoder.java b/approximations/src/main/java/encoders/java/util/ThreadLocal_Encoder.java index 0f5964a7..ba4e7ce3 100644 --- a/approximations/src/main/java/encoders/java/util/ThreadLocal_Encoder.java +++ b/approximations/src/main/java/encoders/java/util/ThreadLocal_Encoder.java @@ -9,6 +9,6 @@ public class ThreadLocal_Encoder implements ObjectEncoder { @Override public Object encode(Object object) { - return new ThreadLocalImpl<>(); + return new ThreadLocalImpl<>(object); } } diff --git a/approximations/src/main/java/generated/java/lang/IntegerImpl.java b/approximations/src/main/java/generated/java/lang/IntegerImpl.java index 168d659a..3eddf28f 100644 --- a/approximations/src/main/java/generated/java/lang/IntegerImpl.java +++ b/approximations/src/main/java/generated/java/lang/IntegerImpl.java @@ -26,12 +26,6 @@ public final class IntegerImpl implements Comparable, Serializable public static final int BYTES = 4; - public static final char[] digits = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' }; - - public static final char[] DigitTens = { '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '3', '3', '3', '3', '3', '3', '3', '3', '3', '3', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '5', '5', '5', '5', '5', '5', '5', '5', '5', '5', '6', '6', '6', '6', '6', '6', '6', '6', '6', '6', '7', '7', '7', '7', '7', '7', '7', '7', '7', '7', '8', '8', '8', '8', '8', '8', '8', '8', '8', '8', '9', '9', '9', '9', '9', '9', '9', '9', '9', '9' }; - - public static final char[] DigitOnes = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' }; - public static final int[] sizeTable = { 9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999, 2147483647 }; static { diff --git a/approximations/src/main/java/generated/java/lang/StringBuilderImpl.java b/approximations/src/main/java/generated/java/lang/StringBuilderImpl.java index 98d52929..63f5819f 100644 --- a/approximations/src/main/java/generated/java/lang/StringBuilderImpl.java +++ b/approximations/src/main/java/generated/java/lang/StringBuilderImpl.java @@ -14,6 +14,7 @@ import java.lang.String; import java.lang.StringBuffer; import java.lang.StringIndexOutOfBoundsException; +import java.util.Arrays; import java.util.stream.IntStream; import generated.java.util.stream.IntStreamImpl; @@ -30,273 +31,389 @@ public final class StringBuilderImpl implements Serializable, Comparable 1073741823) throw new OutOfMemoryError("Requested array size exceeds VM limit"); - this.value = new char[STRING_BUILDER_LENGTH_MAX]; + + this.value = new byte[STRING_BUILDER_LENGTH_MAX]; + this.byteCount = 0; } - private void _appendCharSequence(CharSequence seq, int seqStart, int seqEnd) { - if (seqStart < 0 || seqStart > seqEnd || seqEnd > seq.length()) - throw new IndexOutOfBoundsException(); - int available = this.value.length - this.count; - int len = seqEnd - seqStart; - if (len > available) - len = available; - if (len <= 0) - return; + private static String _getString(CharSequence seq) { + if (seq instanceof String) + return (String) seq; - String str; - if (seq instanceof String) { - str = (String) seq; - } else { - str = LibSLRuntime.toString(seq); + return LibSLRuntime.toString(seq); + } + + private static byte[] _getBytesOfSeq(CharSequence seq) { + if (seq instanceof String) + return ((String) seq).getBytes(); + + if (seq instanceof StringBuilderImpl) { + StringBuilderImpl sb = (StringBuilderImpl) seq; + return Arrays.copyOf(sb.value, sb.byteCount); } - char[] chars = str.toCharArray(); - LibSLRuntime.ArrayActions.copy(chars, seqStart, this.value, this.count, len); - this.count += len; + + return LibSLRuntime.toString(seq).getBytes(); + } + + private static CharSequence _getCharSequence(CharSequence seq) { + if (seq == null) + return "null"; + + return seq; } - private String _asString(int posStart, int posEnd) { - int len = posEnd - posStart; - if (len == 0) - return ""; + private static CharSequence _getCharSequence(Object obj) { + if (obj == null) + return "null"; - char[] symbols = new char[len]; - LibSLRuntime.ArrayActions.copy(this.value, posStart, symbols, 0, len); - return LibSLRuntime.toString(this.value); + return LibSLRuntime.toString(obj); } - public String _asString() { - int len = this.count; - if (len == 0) - return ""; + private static CharSequence _getCharSequence(boolean b) { + if (b) + return "true"; - if (len == this.value.length) - return LibSLRuntime.toString(this.value); + return "false"; + } - char[] symbols = new char[len]; - LibSLRuntime.ArrayActions.copy(this.value, 0, symbols, 0, len); - return LibSLRuntime.toString(this.value); + private int _charPosToBytePos(int charPos) { + return charPos << coder; } - private void _insertCharSequence(int offset, CharSequence seq, int seqStart, int seqEnd) { - if (seqStart < 0 || seqStart > seqEnd || seqEnd > seq.length() || offset > this.count) + private int _bytePosToCharPos(int charPos) { + return charPos >> coder; + } + + private static void _checkRangeBounds(int start, int end, int rightBound) { + if (start < 0 || start > end || end > rightBound) throw new IndexOutOfBoundsException(); + } + + private static void _checkSeqBounds(CharSequence seq, int seqStart, int seqEnd) { + _checkRangeBounds(seqStart, seqEnd, seq.length()); + } + + private void _checkByteOffset(int byteOffset) { + if (byteOffset < 0 || byteOffset > this.byteCount) + throw new IndexOutOfBoundsException(); + } + + private void _checkCharOffset(int charOffset) { + _checkByteOffset(_charPosToBytePos(charOffset)); + } + + private int _getByteSeqLength(int byteOffset, int byteSeqStart, int byteSeqEnd) { + int availableBytes = this.value.length - byteOffset; + int byteSeqLength = byteSeqEnd - byteSeqStart; + if (byteSeqLength > availableBytes) + byteSeqLength = availableBytes; + + return byteSeqLength; + } + + // TODO: unify _appendCharSequence with _appendChars #Approx + private void _appendCharSequence(CharSequence seq, int seqStart, int seqEnd) { + _checkSeqBounds(seq, seqStart, seqEnd); + + int byteSeqStart = _charPosToBytePos(seqStart); + int byteSeqEnd = _charPosToBytePos(seqEnd); + int byteSeqLength = _getByteSeqLength(byteCount, byteSeqStart, byteSeqEnd); + byte[] bytes = _getBytesOfSeq(seq); + LibSLRuntime.ArrayActions.copy(bytes, byteSeqStart, this.value, byteCount, byteSeqLength); + this.byteCount += byteSeqLength; + } + + private void _appendChars(char[] seq, int seqStart, int seqEnd) { + _checkRangeBounds(seqStart, seqEnd, seq.length); + + int byteSeqStart = _charPosToBytePos(seqStart); + int byteSeqEnd = _charPosToBytePos(seqEnd); + int byteSeqLength = _getByteSeqLength(byteCount, byteSeqStart, byteSeqEnd); + byte[] bytes = StringImpl._getBytes(seq); + LibSLRuntime.ArrayActions.copy(bytes, byteSeqStart, this.value, byteCount, byteSeqLength); + this.byteCount += byteSeqLength; + } + + private void _appendCharSequence(CharSequence seq) { + _appendCharSequence(seq, 0, seq.length()); + } + + private StringImpl _asString(int posStart, int posEnd) { + int bytePosStart = _charPosToBytePos(posStart); + int bytePosEnd = _charPosToBytePos(posEnd); + int byteLength = bytePosEnd - bytePosStart; + if (byteLength == 0) + return StringImpl._emptyString; + + if (bytePosStart == 0 && bytePosEnd == this.value.length) + return new StringImpl(this.value); + + byte[] bytes = new byte[byteLength]; + LibSLRuntime.ArrayActions.copy(this.value, bytePosStart, bytes, 0, byteLength); + return new StringImpl(bytes); + } + + public StringImpl _asString() { + return _asString(0, this.byteCount); + } + + // TODO: unify _insertCharSequence with _insertChars #Approx + private void _insertCharSequence(int offset, CharSequence seq, int seqStart, int seqEnd) { + _checkSeqBounds(seq, seqStart, seqEnd); - int available = this.value.length - offset; - int len = seqEnd - seqStart; - if (len > available) - len = available; + int byteOffset = _charPosToBytePos(offset); + _checkByteOffset(byteOffset); - if (len <= 0) + int byteSeqStart = _charPosToBytePos(seqStart); + int byteSeqEnd = _charPosToBytePos(seqEnd); + int availableBytes = this.value.length - byteOffset; + int byteLength = byteSeqEnd - byteSeqStart; + if (byteLength > availableBytes) + byteLength = availableBytes; + + if (byteLength <= 0) return; - int availableForLeftovers = available - len; + int availableForLeftovers = availableBytes - byteLength; if (availableForLeftovers > 0) { - int rightLeftovers = this.count - offset; - if (rightLeftovers > availableForLeftovers) { + int rightLeftovers = this.byteCount - byteOffset; + if (rightLeftovers > availableForLeftovers) rightLeftovers = availableForLeftovers; - } - if (rightLeftovers > 0) { - int rightIndex = offset + 1; - LibSLRuntime.ArrayActions.copy(this.value, rightIndex, this.value, rightIndex + len, rightLeftovers); - } + + if (rightLeftovers > 0) + // Moving bytes, that would be replaced, beyond right bound of insertion + LibSLRuntime.ArrayActions.copy(this.value, byteOffset, this.value, byteOffset + byteLength, rightLeftovers); } - String str; - if (seq instanceof String) { - str = (String) seq; - } else { - str = LibSLRuntime.toString(seq); + + byte[] bytes = _getBytesOfSeq(seq); + LibSLRuntime.ArrayActions.copy(bytes, byteSeqStart, this.value, byteOffset, byteLength); + this.byteCount += byteLength; + } + + @SuppressWarnings("SameParameterValue") + private void _insertChars(int offset, char[] chars, int seqStart, int seqEnd) { + _checkRangeBounds(seqStart, seqEnd, chars.length); + + int byteOffset = _charPosToBytePos(offset); + _checkByteOffset(byteOffset); + + int byteSeqStart = _charPosToBytePos(seqStart); + int byteSeqEnd = _charPosToBytePos(seqEnd); + int availableBytes = this.value.length - byteOffset; + int byteLength = byteSeqEnd - byteSeqStart; + if (byteLength > availableBytes) + byteLength = availableBytes; + + if (byteLength <= 0) + return; + + int availableForLeftovers = availableBytes - byteLength; + if (availableForLeftovers > 0) { + int rightLeftovers = this.byteCount - byteOffset; + if (rightLeftovers > availableForLeftovers) + rightLeftovers = availableForLeftovers; + + if (rightLeftovers > 0) + // Moving bytes, that would be replaced, beyond right bound of insertion + LibSLRuntime.ArrayActions.copy(this.value, byteOffset, this.value, byteOffset + byteLength, rightLeftovers); } - char[] chars = str.toCharArray(); - LibSLRuntime.ArrayActions.copy(chars, seqStart, this.value, offset, len); - this.count += len; + + byte[] bytes = StringImpl._getBytes(chars); + LibSLRuntime.ArrayActions.copy(bytes, byteSeqStart, this.value, byteOffset, byteLength); + this.byteCount += byteLength; + } + + private void _insertCharSequence(int offset, CharSequence seq) { + _insertCharSequence(offset, seq, 0, seq.length()); } private void _deleteChars(int start, int end) { - if (start < 0 || start > end || end > this.count) - throw new IndexOutOfBoundsException(); + int byteStart = _charPosToBytePos(start); + int byteEnd = _charPosToBytePos(end); + _checkRangeBounds(byteStart, byteEnd, this.byteCount); - int leftovers = this.count - end; + int leftovers = this.byteCount - byteEnd; if (leftovers > 0) - LibSLRuntime.ArrayActions.copy(this.value, end, this.value, start, leftovers); - this.count -= end - start; + LibSLRuntime.ArrayActions.copy(this.value, byteEnd, this.value, byteStart, leftovers); + int deletedBytesSize = byteEnd - byteStart; + this.byteCount -= deletedBytesSize; } @SuppressWarnings("DataFlowIssue") private void _assumeInvariants() { Engine.assume(this.value != null); Engine.assume(this.value.length <= STRING_BUILDER_LENGTH_MAX); - Engine.assume(this.count <= this.value.length); - Engine.assume(this.count >= 0); + Engine.assume(this.byteCount <= this.value.length); + Engine.assume(this.byteCount >= 0); + Engine.assume(this.coder == StringImpl._currentCoder()); } public StringBuilderImpl append(CharSequence seq) { _assumeInvariants(); - if (seq == null) { - _appendCharSequence("null", 0, 4); - } else { - _appendCharSequence(seq, 0, seq.length()); - } + seq = _getCharSequence(seq); + _appendCharSequence(seq); return this; } - @SuppressWarnings("ReplaceNullCheck") public StringBuilderImpl append(CharSequence seq, int start, int end) { _assumeInvariants(); - if (seq == null) { - _appendCharSequence("null", start, end); - } else { - _appendCharSequence(seq, start, end); - } + seq = _getCharSequence(seq); + _appendCharSequence(seq, start, end); + return this; } public StringBuilderImpl append(Object obj) { _assumeInvariants(); - if (obj == null) { - _appendCharSequence("null", 0, 4); - } else { - String seq = LibSLRuntime.toString(obj); - _appendCharSequence(seq, 0, seq.length()); - } + CharSequence seq = _getCharSequence(obj); + _appendCharSequence(seq); + return this; } public StringBuilderImpl append(String str) { _assumeInvariants(); - if (str == null) { - _appendCharSequence("null", 0, 4); - } else { - _appendCharSequence(str, 0, str.length()); - } + CharSequence seq = _getCharSequence(str); + _appendCharSequence(seq); + return this; } public StringBuilderImpl append(StringBuffer sb) { _assumeInvariants(); - if (sb == null) { - _appendCharSequence("null", 0, 4); - } else { - String seq = LibSLRuntime.toString(sb); - _appendCharSequence(seq, 0, seq.length()); - } + CharSequence seq = _getCharSequence(sb); + _appendCharSequence(seq); + return this; } public StringBuilderImpl append(boolean x) { _assumeInvariants(); - if (x) { - _appendCharSequence("true", 0, 4); - } else { - _appendCharSequence("false", 0, 5); - } + CharSequence seq = _getCharSequence(x); + _appendCharSequence(seq); + return this; } public StringBuilderImpl append(char x) { _assumeInvariants(); - if (this.count < this.value.length) { - value[this.count] = x; - this.count++; + if (this.byteCount < this.value.length) { + StringImpl._addCharToBytes(value, byteCount, x); + this.byteCount++; } + return this; } - public StringBuilderImpl append(char[] str) { + public StringBuilderImpl append(char[] chars) { _assumeInvariants(); - String seq = LibSLRuntime.toString(str); - _appendCharSequence(seq, 0, seq.length()); + _appendChars(chars, 0, chars.length); + return this; } - public StringBuilderImpl append(char[] str, int offset, int len) { + public StringBuilderImpl append(char[] chars, int offset, int len) { _assumeInvariants(); - String seq = LibSLRuntime.toString(str); - _appendCharSequence(seq, offset, len); + _appendChars(chars, offset, len); + return this; } public StringBuilderImpl append(double x) { _assumeInvariants(); String seq = LibSLRuntime.toString(x); - _appendCharSequence(seq, 0, seq.length()); + _appendCharSequence(seq); + return this; } public StringBuilderImpl append(float x) { _assumeInvariants(); String seq = LibSLRuntime.toString(x); - _appendCharSequence(seq, 0, seq.length()); + _appendCharSequence(seq); + return this; } public StringBuilderImpl append(int x) { _assumeInvariants(); String seq = LibSLRuntime.toString(x); - _appendCharSequence(seq, 0, seq.length()); + _appendCharSequence(seq); + return this; } public StringBuilderImpl append(long x) { _assumeInvariants(); String seq = LibSLRuntime.toString(x); - _appendCharSequence(seq, 0, seq.length()); + _appendCharSequence(seq); + return this; } public StringBuilderImpl appendCodePoint(int codePoint) { + // TODO: support code points #Approx _assumeInvariants(); - int cnt = this.count; + int cnt = this.byteCount; int len = this.value.length; if (Character.isBmpCodePoint(codePoint)) { if (cnt + 1 <= len) { - value[cnt] = ((char) codePoint); - this.count = cnt + 1; + value[cnt] = (byte) codePoint; + this.byteCount = cnt + 1; } } else { if (Character.isValidCodePoint(codePoint)) { if (cnt + 2 <= len) { - value[cnt + 1] = Character.lowSurrogate(codePoint); - value[cnt] = Character.highSurrogate(codePoint); - this.count = cnt + 2; + value[cnt + 1] = (byte) Character.lowSurrogate(codePoint); + value[cnt] = (byte) Character.highSurrogate(codePoint); + this.byteCount = cnt + 2; } } else { throw new IllegalArgumentException(); @@ -307,24 +424,27 @@ public StringBuilderImpl appendCodePoint(int codePoint) { public int capacity() { _assumeInvariants(); - return this.value.length; + return _bytePosToCharPos(this.value.length); } public char charAt(int index) { + // TODO: fix #Approx _assumeInvariants(); - if (index < 0 || index >= this.count) + index = _charPosToBytePos(index); + if (index < 0 || index >= this.byteCount) throw new StringIndexOutOfBoundsException(); - return value[index]; + return StringImpl._bytesToChar(value, index); } @NotNull public IntStream chars() { + // TODO: fix #Approx _assumeInvariants(); - int len = this.count; + int len = this.byteCount; int[] intValues = new int[len]; for (int i = 0; i < len; i++) { - intValues[i] = value[i]; + intValues[i] = StringImpl._bytesToChar(value, i); } return new IntStreamImpl(intValues); @@ -332,36 +452,40 @@ public IntStream chars() { public int codePointAt(int index) { _assumeInvariants(); - if (index < 0 || index >= this.count) + if (index < 0 || index >= this.byteCount) throw new StringIndexOutOfBoundsException(index); - return Character.codePointAt(this.value, index, this.count); + // TODO: support code points #Approx + return 0; } public int codePointBefore(int index) { _assumeInvariants(); int i = index - 1; - if (i < 0 || i >= this.count) + if (i < 0 || i >= this.byteCount) throw new StringIndexOutOfBoundsException(index); - return Character.codePointBefore(this.value, index, 0); + // TODO: support code points #Approx + return 0; } public int codePointCount(int beginIndex, int endIndex) { _assumeInvariants(); - if (beginIndex < 0 || beginIndex > endIndex || endIndex > this.count) + if (beginIndex < 0 || beginIndex > endIndex || endIndex > this.byteCount) throw new IndexOutOfBoundsException(); - return Character.codePointCount(this.value, beginIndex, endIndex - beginIndex); + // TODO: support code points #Approx + return 0; } @NotNull public IntStream codePoints() { + // TODO: support code points #Approx _assumeInvariants(); - int len = this.count; + int len = this.byteCount; int[] intValues = new int[len]; for (int i = 0; i < len; i++) { - intValues[i] = value[i]; + intValues[i] = StringImpl._bytesToChar(value, i); } return new IntStreamImpl(intValues); } @@ -371,20 +495,23 @@ public int compareTo(@NotNull StringBuilderImpl another) { if (another == this) return 0; - String thisString = _asString(); - String anotherString = another._asString(); + // TODO: implement compareTo in StringImpl #Approx + String thisString = _asString().toString(); + String anotherString = another._asString().toString(); return thisString.compareTo(anotherString); } public StringBuilderImpl delete(int start, int end) { _assumeInvariants(); _deleteChars(start, end); + return this; } public StringBuilderImpl deleteCharAt(int index) { _assumeInvariants(); _deleteChars(index, index + 1); + return this; } @@ -393,8 +520,9 @@ public void ensureCapacity(int minimumCapacity) { } public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) { + // TODO: fix #Approx _assumeInvariants(); - if (srcBegin < 0 || srcBegin > srcEnd || srcEnd > this.count) + if (srcBegin < 0 || srcBegin > srcEnd || srcEnd > this.byteCount) throw new StringIndexOutOfBoundsException(); int len = srcEnd - srcBegin; if (dst == null) @@ -403,83 +531,76 @@ public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) { throw new IndexOutOfBoundsException(); if (len > 0) LibSLRuntime.ArrayActions.copy(this.value, srcBegin, dst, dstBegin, len); + + LibSLRuntime.not_implemented(); } public char[] getValue() { _assumeInvariants(); - return this.value; + return StringImpl._getChars(this.value); } public int indexOf(String str) { _assumeInvariants(); - return _asString().indexOf(str); + // TODO: implement indexOf in StringImpl #Approx + return _asString().toString().indexOf(str); } public int indexOf(String str, int fromIndex) { _assumeInvariants(); - return _asString().indexOf(str, fromIndex); + // TODO: implement indexOf in StringImpl #Approx + return _asString().toString().indexOf(str, fromIndex); } public StringBuilderImpl insert(int dstOffset, CharSequence s) { _assumeInvariants(); - if (s == null) { - _insertCharSequence(dstOffset, "null", 0, 4); - } else { - _insertCharSequence(dstOffset, s, 0, s.length()); - } + _insertCharSequence(dstOffset, s); + return this; } - @SuppressWarnings("ReplaceNullCheck") public StringBuilderImpl insert(int dstOffset, CharSequence s, int start, int end) { _assumeInvariants(); - if (s == null) { - _insertCharSequence(dstOffset, "null", start, end); - } else { - _insertCharSequence(dstOffset, s, start, end); - } + _insertCharSequence(dstOffset, s, start, end); + return this; } public StringBuilderImpl insert(int dstOffset, Object obj) { _assumeInvariants(); - if (obj == null) { - _insertCharSequence(dstOffset, "null", 0, 4); - } else { - String s = LibSLRuntime.toString(obj); - _insertCharSequence(dstOffset, s, 0, s.length()); - } + CharSequence seq = _getCharSequence(obj); + _insertCharSequence(dstOffset, seq); + return this; } public StringBuilderImpl insert(int dstOffset, String s) { _assumeInvariants(); - if (s == null) { - _insertCharSequence(dstOffset, "null", 0, 4); - } else { - _insertCharSequence(dstOffset, s, 0, s.length()); - } + _insertCharSequence(dstOffset, s); + return this; } public StringBuilderImpl insert(int dstOffset, boolean x) { _assumeInvariants(); - String s = LibSLRuntime.toString(x); - _insertCharSequence(dstOffset, s, 0, s.length()); + CharSequence seq = _getCharSequence(x); + _insertCharSequence(dstOffset, seq); + return this; } public StringBuilderImpl insert(int dstOffset, char x) { _assumeInvariants(); - String s = LibSLRuntime.toString(x); - _insertCharSequence(dstOffset, s, 0, 1); + CharSequence seq = _getCharSequence(x); + _insertCharSequence(dstOffset, seq, 0, 1); + return this; } public StringBuilderImpl insert(int dstOffset, char[] x) { _assumeInvariants(); - String s = LibSLRuntime.toString(x); - _insertCharSequence(dstOffset, s, 0, s.length()); + _insertChars(dstOffset, x, 0, x.length); + return this; } @@ -487,118 +608,122 @@ public StringBuilderImpl insert(int index, char[] str, int offset, int len) { _assumeInvariants(); char[] arr = new char[len]; LibSLRuntime.ArrayActions.copy(str, offset, arr, 0, len); - String s = LibSLRuntime.toString(arr); - _insertCharSequence(index, s, 0, len); + _insertChars(index, arr, 0, len); + return this; } public StringBuilderImpl insert(int dstOffset, double x) { _assumeInvariants(); String s = LibSLRuntime.toString(x); - _insertCharSequence(dstOffset, s, 0, s.length()); + _insertCharSequence(dstOffset, s); + return this; } public StringBuilderImpl insert(int dstOffset, float x) { _assumeInvariants(); String s = LibSLRuntime.toString(x); - _insertCharSequence(dstOffset, s, 0, s.length()); + _insertCharSequence(dstOffset, s); + return this; } public StringBuilderImpl insert(int dstOffset, int x) { _assumeInvariants(); String s = LibSLRuntime.toString(x); - _insertCharSequence(dstOffset, s, 0, s.length()); + _insertCharSequence(dstOffset, s); + return this; } public StringBuilderImpl insert(int dstOffset, long x) { _assumeInvariants(); String s = LibSLRuntime.toString(x); - _insertCharSequence(dstOffset, s, 0, s.length()); + _insertCharSequence(dstOffset, s); + return this; } public int lastIndexOf(String str) { _assumeInvariants(); - return _asString().lastIndexOf(str, this.count); + return _asString().toString().lastIndexOf(str, this.byteCount); } public int lastIndexOf(String str, int fromIndex) { _assumeInvariants(); - return _asString().lastIndexOf(str, fromIndex); + return _asString().toString().lastIndexOf(str, fromIndex); } public int length() { _assumeInvariants(); - return this.count; + return this.byteCount; } public int offsetByCodePoints(int index, int codePointOffset) { _assumeInvariants(); - if (index < 0 || index > this.count) + if (index < 0 || index > this.byteCount) throw new IndexOutOfBoundsException(); - return Character.offsetByCodePoints(this.value, 0, this.count, index, codePointOffset); + // TODO: support code points #Approx + return 0; } public StringBuilderImpl replace(int start, int end, String s) { _assumeInvariants(); _deleteChars(start, end); - if (s == null) { - _insertCharSequence(start, "null", 0, 4); - } else { - _insertCharSequence(start, s, 0, s.length()); - } + _insertCharSequence(start, s); + return this; } public StringBuilderImpl reverse() { _assumeInvariants(); - if (this.count == 0) - return this; - - boolean hasSurrogates = false; - int n = this.count - 1; - for (int i = (n - 1) >> 1; i > -1; i--) { - int k = n - i; - char cj = value[i]; - char ck = value[k]; - value[i] = ck; - value[k] = cj; - if (Character.isSurrogate(cj) || Character.isSurrogate(ck)) { - hasSurrogates = true; - } - } - if (!hasSurrogates) + if (this.byteCount == 0) return this; - for (int i = 0; i < n; i++) { - char c2 = value[i]; - if (Character.isLowSurrogate(c2)) { - char c1 = value[i + 1]; - if (Character.isHighSurrogate(c1)) { - value[i] = c1; - i++; - value[i] = c2; - } - } - } + // TODO: implement #Approx +// boolean hasSurrogates = false; +// int n = this.byteCount - 1; +// for (int i = (n - 1) >> 1; i > -1; i--) { +// int k = n - i; +// byte cj = value[i]; +// byte ck = value[k]; +// value[i] = ck; +// value[k] = cj; +// if (Character.isSurrogate(cj) || Character.isSurrogate(ck)) { +// hasSurrogates = true; +// } +// } +// if (!hasSurrogates) +// return this; +// +// for (int i = 0; i < n; i++) { +// char c2 = value[i]; +// if (Character.isLowSurrogate(c2)) { +// char c1 = value[i + 1]; +// if (Character.isHighSurrogate(c1)) { +// value[i] = c1; +// i++; +// value[i] = c2; +// } +// } +// } return this; } public void setCharAt(int index, char x) { _assumeInvariants(); - if (index < 0 || index >= this.count) + if (index < 0 || index >= this.byteCount) throw new StringIndexOutOfBoundsException(); - value[index] = x; + StringImpl._addCharToBytes(value, index, x); } public void setLength(int newLength) { _assumeInvariants(); + newLength = _charPosToBytePos(newLength); int maxLength = this.value.length; if (newLength > maxLength) newLength = maxLength; @@ -606,46 +731,49 @@ public void setLength(int newLength) { if (newLength < 0) throw new StringIndexOutOfBoundsException(); - if (newLength < this.count) { - this.count = newLength; + if (newLength < this.byteCount) { + this.byteCount = newLength; return; } - if (newLength > this.count) { - LibSLRuntime.ArrayActions.fillRange(this.value, this.count, newLength, ((char) 0)); - this.count = newLength; + if (newLength > this.byteCount) { + LibSLRuntime.ArrayActions.fillRange(this.value, this.byteCount, newLength, ((byte) 0)); + this.byteCount = newLength; } } @NotNull public CharSequence subSequence(int start, int end) { _assumeInvariants(); - if (start < 0 || start > end || end > this.count) + // TODO: fix #Approx + if (start < 0 || start > end || end > this.byteCount) throw new StringIndexOutOfBoundsException(); - return _asString(start, end); + return _asString(start, end).toString(); } public String substring(int start) { _assumeInvariants(); - if (start < 0 || start > this.count) + // TODO: fix #Approx + if (start < 0 || start > this.byteCount) throw new StringIndexOutOfBoundsException(); - return _asString(start, this.count); + return _asString(start, this.byteCount).toString(); } public String substring(int start, int end) { _assumeInvariants(); - if (start < 0 || start > end || end > this.count) + // TODO: fix #Approx + if (start < 0 || start > end || end > this.byteCount) throw new StringIndexOutOfBoundsException(); - return _asString(start, end); + return _asString(start, end).toString(); } @NotNull public String toString() { _assumeInvariants(); - return _asString(); + return _asString().toString(); } public void trimToSize() { diff --git a/approximations/src/main/java/generated/java/lang/StringImpl.java b/approximations/src/main/java/generated/java/lang/StringImpl.java index c730a8a7..9cafde84 100644 --- a/approximations/src/main/java/generated/java/lang/StringImpl.java +++ b/approximations/src/main/java/generated/java/lang/StringImpl.java @@ -3,12 +3,13 @@ import java.io.Serializable; import java.lang.Object; import java.lang.StringIndexOutOfBoundsException; +import java.util.Arrays; import org.jacodb.approximation.annotation.Approximate; import org.usvm.api.Engine; import runtime.LibSLRuntime; -@SuppressWarnings("unused") +@SuppressWarnings({"unused", "overrides"}) @Approximate(java.lang.String.class) public class StringImpl implements Serializable { @@ -17,38 +18,161 @@ public class StringImpl implements Serializable { private static final int STRING_LENGTH_MAX = 50; - public byte[] value; + static final byte UTF16 = 1; - public int length; + static final byte LATIN1 = 0; - public StringImpl(byte[] value, int length) { + static final boolean COMPACT_STRINGS; + + static { + // Enforce coder == UTF8 + COMPACT_STRINGS = true; + } + + private final byte[] value; + + // TODO: everywhere add assume 'coder == LATIN1' #Approx + private final byte coder; + + public static StringImpl _emptyString = new StringImpl(new byte[] {}); + + public static byte _currentCoder() { + return COMPACT_STRINGS ? LATIN1 : UTF16; + } + + private int _charPosToBytePos(int charPos) { + return charPos << coder; + } + + private int _bytePosToCharPos(int charPos) { + return charPos >> coder; + } + + private static void _checkOffset(int offset, int length) { + if (offset < 0 || offset >= length) + throw new IndexOutOfBoundsException(); + } + + public static byte[] _charToBytes(char value) { + if (COMPACT_STRINGS) { + byte[] bytes = new byte[1]; + Engine.assume(value <= 0xFF); + bytes[0] = (byte) value; + return bytes; + } + + byte[] bytes = new byte[2]; + bytes[0] = (byte) value; + bytes[1] = (byte) (value >> 8); + return bytes; + } + + private static char _charFrom2Bytes(byte fst, byte snd) { + return (char) (((char) fst) | (((char) snd) << 8)); + } + + public static char _charFromByte(byte b) { + return (char) (((int) b) & 0xFF); + } + + public static char _bytesToChar(byte[] bytes, int bytePos) { + if (COMPACT_STRINGS) + return _charFromByte(bytes[bytePos]); + + return _charFrom2Bytes(bytes[bytePos], bytes[bytePos + 1]); + } + + public static void _addCharToBytes(byte[] bytes, int index, char value) { + if (COMPACT_STRINGS) { + Engine.assume(value <= 0xFF); + bytes[index] = (byte) value; + } else { + bytes[index++] = (byte) value; + bytes[index] = (byte) (value >> 8); + } + } + + public static byte[] _getBytes(char[] chars) { + int size = chars.length << _currentCoder(); + byte[] bytes = new byte[size]; + if (COMPACT_STRINGS) { + for (int i = 0; i < chars.length; i++) { + char c = chars[i]; + Engine.assume(c <= 0xFF); + bytes[i] = (byte) chars[i]; + } + } else { + int byteIndex = 0; + for (char c : chars) { + bytes[byteIndex++] = (byte) c; + bytes[byteIndex] = (byte) (c >> 8); + byteIndex++; + } + } + + return bytes; + } + + public static char[] _getChars(byte[] bytes) { + int size = bytes.length >> _currentCoder(); + char[] chars = new char[size]; + if (COMPACT_STRINGS) { + for (int i = 0; i < bytes.length; i++) { + byte c = bytes[i]; + chars[i] = _charFromByte(bytes[i]); + } + } else { + int byteIndex = 0; + for (int i = 0; i < chars.length; i++) { + char c = _charFrom2Bytes(bytes[byteIndex], bytes[byteIndex + 1]); + chars[i] = c; + byteIndex += 2; + } + } + + return chars; + } + + private StringImpl(byte[] value, byte coder) { + Engine.assume(coder == _currentCoder()); this.value = value; - this.length = length; + this.coder = coder; } public StringImpl() { - this(new byte[0], 0); + this(new byte[0], _currentCoder()); } public StringImpl(StringImpl original) { - this(original.value, original.length); + this(original.value, original.coder); } public StringImpl(byte[] bytes) { - int len = bytes.length; - this.length = len; - this.value = new byte[len]; - LibSLRuntime.ArrayActions.copy(bytes, 0, this.value, 0, len); + this(bytes, 0, bytes.length); } - public static java.lang.String copyValueOf(char[] data) { - return LibSLRuntime.toString(data); + private static void _checkBoundsOffCount(int offset, int count, int length) { + if (offset < 0 || count < 0 || offset > length - count) { + throw new StringIndexOutOfBoundsException(); + } } - public static java.lang.String copyValueOf(char[] data, int offset, int count) { + public StringImpl(byte[] bytes, int offset, int length) { + _checkBoundsOffCount(offset, length, bytes.length); + this.value = new byte[length]; + this.coder = _currentCoder(); + LibSLRuntime.ArrayActions.copy(bytes, offset, this.value, 0, length); + } + + public static StringImpl copyValueOf(char[] data) { + byte[] bytes = _getBytes(data); + return new StringImpl(bytes); + } + + public static StringImpl copyValueOf(char[] data, int offset, int count) { char[] segment = new char[count]; LibSLRuntime.ArrayActions.copy(data, offset, segment, 0, count); - return LibSLRuntime.toString(segment); + return copyValueOf(segment); } public static java.lang.String valueOf(Object x) { @@ -59,18 +183,18 @@ public static java.lang.String valueOf(boolean x) { return LibSLRuntime.toString(x); } - public static java.lang.String valueOf(char x) { - return LibSLRuntime.toString(x); + public static StringImpl valueOf(char x) { + byte[] bytes = _charToBytes(x); + return new StringImpl(bytes); } - public static java.lang.String valueOf(char[] data) { - return LibSLRuntime.toString(data); + public static StringImpl valueOf(char[] data) { + byte[] bytes = _getBytes(data); + return new StringImpl(bytes); } - public static java.lang.String valueOf(char[] data, int offset, int count) { - char[] segment = new char[count]; - LibSLRuntime.ArrayActions.copy(data, offset, segment, 0, count); - return LibSLRuntime.toString(segment); + public static StringImpl valueOf(char[] data, int offset, int count) { + return copyValueOf(data, offset, count); } public static java.lang.String valueOf(double x) { @@ -90,50 +214,110 @@ public static java.lang.String valueOf(long x) { } @SuppressWarnings("DataFlowIssue") + private void _assumeInvariants(StringImpl obj) { + Engine.assume(obj.coder == _currentCoder()); + Engine.assume(obj.value != null); + int len = obj.value.length >> obj.coder; + Engine.assume(len >= 0); + // TODO: add Engine.assumeSymbolic(instance, bool) #ASAP + Engine.assume(len <= STRING_LENGTH_MAX); + } + + private void _assumeInvariants() { + _assumeInvariants(this); + } + + boolean isLatin1() { + _assumeInvariants(); + return _currentCoder() == LATIN1; + } + + byte coder() { + _assumeInvariants(); + return coder; + } + + public int length() { + _assumeInvariants(); + return value.length >> coder; + } + + public char charAt(int index) { + _assumeInvariants(); + + int byteIndex = _charPosToBytePos(index); + _checkOffset(byteIndex, this.value.length); + + return _bytesToChar(this.value, byteIndex); + } + public StringImpl concat(StringImpl str) { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRING_LENGTH_MAX); - Engine.assume(this.length == this.value.length); + _assumeInvariants(); + _assumeInvariants(str); + byte[] otherVal = str.value; int otherLen = otherVal.length; if (otherLen == 0) return this; - int newLength = this.length + otherLen; + int newLength = this.value.length + otherLen; byte[] newValue = new byte[newLength]; - LibSLRuntime.ArrayActions.copy(this.value, 0, newValue, 0, this.length); - LibSLRuntime.ArrayActions.copy(otherVal, 0, newValue, this.length, otherLen); - return new StringImpl(newValue, newLength); + LibSLRuntime.ArrayActions.copy(this.value, 0, newValue, 0, this.value.length); + LibSLRuntime.ArrayActions.copy(otherVal, 0, newValue, this.value.length, otherLen); + return new StringImpl(newValue); } - @SuppressWarnings("DataFlowIssue") public byte[] getBytes() { - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRING_LENGTH_MAX); - Engine.assume(this.length == this.value.length); - return this.value; + _assumeInvariants(); + return Arrays.copyOf(this.value, this.value.length); } - @SuppressWarnings("DataFlowIssue") public void getBytes(int srcBegin, int srcEnd, byte[] dst, int dstBegin) { - if (srcBegin < 0) + _assumeInvariants(); + + int srcByteBegin = _charPosToBytePos(srcBegin); + int srcByteEnd = _charPosToBytePos(srcEnd); + int dstByteBegin = _charPosToBytePos(dstBegin); + + if (srcByteBegin < 0) throw new StringIndexOutOfBoundsException(srcBegin); - if (this.length < srcEnd) + + if (this.value.length < srcByteEnd) throw new StringIndexOutOfBoundsException(srcEnd); - int count = srcEnd - srcBegin; + + int count = srcByteEnd - srcByteBegin; if (count < 0) throw new StringIndexOutOfBoundsException(count); - Engine.assume(this.value != null); - Engine.assume(this.value.length <= STRING_LENGTH_MAX); - Engine.assume(this.length == this.value.length); - LibSLRuntime.ArrayActions.copy(this.value, srcBegin, dst, dstBegin, count); + + LibSLRuntime.ArrayActions.copy(this.value, srcByteBegin, dst, dstByteBegin, count); } - public boolean isEmpty() { - return this.length == 0; + public static boolean latin1Equals(byte[] value, byte[] other) { + if (value.length == other.length) { + for(int i = 0; i < value.length; ++i) { + if (value[i] != other[i]) { + return false; + } + } + + return true; + } else { + return false; + } } - public int length() { - return this.length; + public boolean equals(Object anObject) { + _assumeInvariants(); + if (this == anObject) { + return true; + } else { + if (anObject instanceof StringImpl) { + StringImpl aString = (StringImpl)anObject; + _assumeInvariants(aString); + return (!COMPACT_STRINGS || this.coder == aString.coder) && latin1Equals(this.value, aString.value); + } + + return false; + } } } diff --git a/approximations/src/main/java/generated/java/lang/SystemHelpersImpl.java b/approximations/src/main/java/generated/java/lang/SystemHelpersImpl.java new file mode 100644 index 00000000..2b15ae13 --- /dev/null +++ b/approximations/src/main/java/generated/java/lang/SystemHelpersImpl.java @@ -0,0 +1,10 @@ +package generated.java.lang; + +import org.jacodb.approximation.annotation.Approximate; +import runtime.LibSLRuntime; + +@Approximate(stub.java.lang.SystemHelpers.class) +public class SystemHelpersImpl { + + public static final LibSLRuntime.Map identityHashCodeMap = new LibSLRuntime.Map<>(new LibSLRuntime.IdentityMapContainer<>()); +} diff --git a/approximations/src/main/java/generated/java/lang/SystemImpl.java b/approximations/src/main/java/generated/java/lang/SystemImpl.java index b91d594a..03267058 100644 --- a/approximations/src/main/java/generated/java/lang/SystemImpl.java +++ b/approximations/src/main/java/generated/java/lang/SystemImpl.java @@ -17,18 +17,18 @@ import org.jacodb.approximation.annotation.Approximate; import org.usvm.api.Engine; import runtime.LibSLRuntime; +import stub.java.lang.SystemHelpers; @SuppressWarnings({"unused", "removal"}) @Approximate(java.lang.System.class) public final class SystemImpl { - private static final LibSLRuntime.Map propsMap = new LibSLRuntime.Map<>(new LibSLRuntime.HashMapContainer<>()); - private static volatile SecurityManager security = null; + private static Properties props; - private static Properties props = null; + private static volatile SecurityManager security = null; @SuppressWarnings("FieldMayBeFinal") - private static Console console = null; + private static Console cons = null; public static InputStream in = null; @@ -36,12 +36,6 @@ public final class SystemImpl { public static PrintStream err = null; - private static final long NANOTIME_BEGINNING_OF_TIME = 1000L; - - private static final long NANOTIME_WARP_MAX = 1000L; - - private static final LibSLRuntime.Map identityHashCodeMap = new LibSLRuntime.Map<>(new LibSLRuntime.IdentityMapContainer<>()); - static { initPhase1(); initPhase2(); @@ -50,71 +44,88 @@ public final class SystemImpl { private SystemImpl() { } + private static void _initProperty(LibSLRuntime.Map pm, Properties properties, String key, String value) { + pm.set(key, value); + switch (key) { + // Do not add private system properties to the Properties + case "sun.nio.MaxDirectMemorySize": + case "sun.nio.PageAlignDirectMemory": + // used by java.lang.Integer.IntegerCache + case "java.lang.Integer.IntegerCache.high": + // used by sun.launcher.LauncherHelper + case "sun.java.launcher.diag": + // used by jdk.internal.loader.ClassLoaders + case "jdk.boot.class.path.append": + break; + default: + properties.put(key, value); + } + } + private static void _initProperties() { - LibSLRuntime.Map pm = propsMap; + props = new Properties(); int javaVersion = 8; String userName = "Admin"; - pm.set("file.encoding", "Cp1251"); - pm.set("sun.io.unicode.encoding", "UnicodeLittle"); - pm.set("sun.jnu.encoding", "Cp1251"); - pm.set("sun.stderr.encoding", "cp866"); - pm.set("sun.stdout.encoding", "cp866"); + props.setProperty("file.encoding", "Cp1251"); + props.setProperty("sun.io.unicode.encoding", "UnicodeLittle"); + props.setProperty("sun.jnu.encoding", "Cp1251"); + props.setProperty("sun.stderr.encoding", "cp866"); + props.setProperty("sun.stdout.encoding", "cp866"); String[] versionStrings = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15" }; String versionString = versionStrings[javaVersion]; - pm.set("java.specification.name", "Java Platform API Specification"); - pm.set("java.specification.vendor", "Oracle Corporation"); - pm.set("java.specification.version", versionString); - pm.set("java.vm.info", "mixed mode"); - pm.set("java.vm.name", "OpenJDK 64-Bit Server VM"); - pm.set("java.vm.specification.name", "Java Virtual Machine Specification"); - pm.set("java.vm.specification.vendor", "Oracle Corporation"); - pm.set("java.vm.specification.version", versionString); - pm.set("java.vm.vendor", "Eclipse Adoptium"); - pm.set("java.vm.version", versionString.concat(".0.362+9")); - pm.set("java.library.path", "C:\\Program Files\\Eclipse Adoptium\\jdk-8.0.362.9-hotspot\\bin;C:\\Windows\\Sun\\Java\\bin;C:\\Windows\\system32;."); - pm.set("java.home", "C:\\Program Files\\Eclipse Adoptium\\jdk-8.0.362.9-hotspot"); - pm.set("sun.boot.library.path", "C:\\Program Files\\Eclipse Adoptium\\jdk-8.0.362.9-hotspot\\bin"); - pm.set("java.io.tmpdir", "T:\\Temp\\"); - pm.set("java.class.path", "."); + props.setProperty("java.specification.name", "Java Platform API Specification"); + props.setProperty("java.specification.vendor", "Oracle Corporation"); + props.setProperty("java.specification.version", versionString); + props.setProperty("java.vm.info", "mixed mode"); + props.setProperty("java.vm.name", "OpenJDK 64-Bit Server VM"); + props.setProperty("java.vm.specification.name", "Java Virtual Machine Specification"); + props.setProperty("java.vm.specification.vendor", "Oracle Corporation"); + props.setProperty("java.vm.specification.version", versionString); + props.setProperty("java.vm.vendor", "Eclipse Adoptium"); + props.setProperty("java.vm.version", versionString.concat(".0.362+9")); + props.setProperty("java.library.path", "C:\\Program Files\\Eclipse Adoptium\\jdk-8.0.362.9-hotspot\\bin;C:\\Windows\\Sun\\Java\\bin;C:\\Windows\\system32;."); + props.setProperty("java.home", "C:\\Program Files\\Eclipse Adoptium\\jdk-8.0.362.9-hotspot"); + props.setProperty("sun.boot.library.path", "C:\\Program Files\\Eclipse Adoptium\\jdk-8.0.362.9-hotspot\\bin"); + props.setProperty("java.io.tmpdir", "T:\\Temp\\"); + props.setProperty("java.class.path", "."); if (LibSLGlobals.SYSTEM_IS_WINDOWS) { - pm.set("file.separator", "\\"); - pm.set("line.separator", "\r\n"); - pm.set("path.separator", ";"); + props.setProperty( "file.separator", "\\"); + props.setProperty("line.separator", "\r\n"); + props.setProperty( "path.separator", ";"); } else { - pm.set("file.separator", "/"); - pm.set("line.separator", "\n"); - pm.set("path.separator", ":"); + props.setProperty("file.separator", "/"); + props.setProperty("line.separator", "\n"); + props.setProperty("path.separator", ":"); } - pm.set("user.country", "RU"); - pm.set("user.country.format", "US"); - pm.set("user.language", "ru"); + props.setProperty("user.country", "RU"); + props.setProperty("user.country.format", "US"); + props.setProperty("user.language", "ru"); String[] bytecodeVersions = { "?", "?", "?", "?", "?", "49.0", "50.0", "51.0", "52.0", "53.0", "54.0", "55.0", "?", "?", "?", "?" }; - pm.set("java.class.version", bytecodeVersions[javaVersion]); - pm.set("os.arch", "amd64"); - pm.set("os.name", "Windows 10"); - pm.set("os.version", "10.0"); - pm.set("sun.arch.data.model", "64"); - pm.set("sun.cpu.endian", "little"); - pm.set("sun.cpu.isalist", "amd64"); - pm.set("sun.desktop", "windows"); - pm.set("user.dir", "D:\\Company\\Prod\\Service"); - pm.set("user.home", "C:\\Users\\".concat(userName)); - pm.set("user.name", userName); - pm.set("user.script", ""); - pm.set("user.timezone", ""); - pm.set("user.variant", ""); - pm.set("sun.java.command", "org.example.MainClass"); - pm.set("awt.toolkit", "sun.awt.windows.WToolkit"); - pm.set("java.awt.graphicsenv", "sun.awt.Win32GraphicsEnvironment"); - pm.set("java.awt.printerjob", "sun.awt.windows.WPrinterJob"); - pm.set("sun.java.launcher", "SUN_STANDARD"); - pm.set("sun.management.compiler", "HotSpot 64-Bit Tiered Compilers"); - pm.set("sun.nio.MaxDirectMemorySize", "-1"); - pm.set("sun.os.patch.level", ""); - pm.set("java.vm.compressedOopsMode", "Zero based"); - pm.set("jdk.boot.class.path.append", ""); - pm.set("jdk.debug", "release"); - props = null; + props.setProperty("java.class.version", bytecodeVersions[javaVersion]); + props.setProperty("os.arch", "amd64"); + props.setProperty("os.name", "Windows 10"); + props.setProperty("os.version", "10.0"); + props.setProperty("sun.arch.data.model", "64"); + props.setProperty("sun.cpu.endian", "little"); + props.setProperty("sun.cpu.isalist", "amd64"); + props.setProperty("sun.desktop", "windows"); + props.setProperty("user.dir", "D:\\Company\\Prod\\Service"); + props.setProperty("user.home", "C:\\Users\\".concat(userName)); + props.setProperty("user.name", userName); + props.setProperty("user.script", ""); + props.setProperty("user.timezone", ""); + props.setProperty("user.variant", ""); + props.setProperty("sun.java.command", "org.example.MainClass"); + props.setProperty("awt.toolkit", "sun.awt.windows.WToolkit"); + props.setProperty("java.awt.graphicsenv", "sun.awt.Win32GraphicsEnvironment"); + props.setProperty("java.awt.printerjob", "sun.awt.windows.WPrinterJob"); + props.setProperty("sun.java.launcher", "SUN_STANDARD"); + props.setProperty("sun.management.compiler", "HotSpot 64-Bit Tiered Compilers"); + props.setProperty("sun.nio.MaxDirectMemorySize", "-1"); + props.setProperty("sun.os.patch.level", ""); + props.setProperty("java.vm.compressedOopsMode", "Zero based"); + props.setProperty("jdk.boot.class.path.append", ""); + props.setProperty("jdk.debug", "release"); } @SuppressWarnings("DataFlowIssue") @@ -150,17 +161,16 @@ public static String clearProperty(String key) { SecurityManager sm = security; if (sm != null) sm.checkPermission(new java.util.PropertyPermission(key, "write")); - LibSLRuntime.Map pm = propsMap; - if (!pm.hasKey(key)) + if (!props.containsKey(key)) return null; - String result = pm.get(key); - pm.remove(key); + String result = props.getProperty(key); + props.remove(key); return result; } public static Console console() { - return console; + return cons; } public static void exit(int status) { @@ -181,11 +191,7 @@ public static String getProperty(String key) { SecurityManager sm = security; if (sm != null) sm.checkPropertyAccess(key); - LibSLRuntime.Map pm = propsMap; - if (!pm.hasKey(key)) - return null; - - return pm.get(key); + return props.getProperty(key); } public static String getProperty(String key, String def) { @@ -194,9 +200,8 @@ public static String getProperty(String key, String def) { if (sm != null) { sm.checkPropertyAccess(key); } - LibSLRuntime.Map pm = propsMap; - if (pm.hasKey(key)) - return pm.get(key); + if (props.containsKey(key)) + return props.getProperty(key); return def; } @@ -223,19 +228,19 @@ public static int identityHashCode(Object x) { if (x == null) return 0; - if (identityHashCodeMap.hasKey(x)) { - Integer value = identityHashCodeMap.get(x); + if (SystemHelpersImpl.identityHashCodeMap.hasKey(x)) { + Integer value = SystemHelpersImpl.identityHashCodeMap.get(x); Engine.assume(value != null); return value; } - int result = identityHashCodeMap.size(); - identityHashCodeMap.set(x, result); + int result = SystemHelpersImpl.identityHashCodeMap.size(); + SystemHelpersImpl.identityHashCodeMap.set(x, result); return result; } public static String lineSeparator() { - return propsMap.get("line.separator"); + return props.getProperty("line.separator"); } @SuppressWarnings({"DuplicateCondition", "ConstantValue"}) @@ -310,15 +315,7 @@ public static String setProperty(String key, String value) { throw new NullPointerException("key can't be empty"); if (security != null) security.checkPermission(new java.util.PropertyPermission(key, "write")); - LibSLRuntime.Map pm = propsMap; - String result; - if (pm.hasKey(key)) { - result = pm.get(key); - } else { - result = null; - } - pm.set(key, value); - return result; + return (String)props.setProperty(key, value); } public static void setSecurityManager(SecurityManager s) { diff --git a/approximations/src/main/java/generated/java/lang/ThreadLocalImpl.java b/approximations/src/main/java/generated/java/lang/ThreadLocalImpl.java index 2fe224f8..156925b2 100644 --- a/approximations/src/main/java/generated/java/lang/ThreadLocalImpl.java +++ b/approximations/src/main/java/generated/java/lang/ThreadLocalImpl.java @@ -6,10 +6,14 @@ @Approximate(java.lang.ThreadLocal.class) public class ThreadLocalImpl { - private T storage = null; + private T storage; + + public ThreadLocalImpl(T value) { + storage = value; + } public static ThreadLocal withInitial(Supplier supplier) { - ThreadLocal local = new ThreadLocal(); + ThreadLocal local = new ThreadLocal<>(); local.set(supplier.get()); return local; } diff --git a/approximations/src/main/java/generated/java/util/AbstractCollectionImpl.java b/approximations/src/main/java/generated/java/util/AbstractCollectionImpl.java index 6087d6e1..89ce4c1a 100644 --- a/approximations/src/main/java/generated/java/util/AbstractCollectionImpl.java +++ b/approximations/src/main/java/generated/java/util/AbstractCollectionImpl.java @@ -13,23 +13,29 @@ @Approximate(java.util.AbstractCollection.class) public abstract class AbstractCollectionImpl implements Collection { - public transient int modCount; - public AbstractCollectionImpl(int modCount) { - this.modCount = modCount; + _setModCount(modCount); } abstract protected Object[] _mapToArray(); - protected void _checkForModification(int expectedModCount) { - if (this.modCount != expectedModCount) + abstract public int _getModCount(); + + abstract protected void _setModCount(int newModCount); + + public void _incrementModCount() { + _setModCount(_getModCount() + 1); + } + + public void _checkForModification(int expectedModCount) { + if (_getModCount() != expectedModCount) throw new ConcurrentModificationException(); } - abstract public int size(); + abstract protected int _size(); @NotNull - public Object[] toArray() { + public Object[] _toArray() { return _mapToArray(); } @@ -45,18 +51,18 @@ private T[] _toArray(T[] array, int size) { return array; } - public T[] toArray(IntFunction generator) { - int size = size(); + public T[] _toArray(IntFunction generator) { + int size = _size(); T[] array = generator.apply(size); return _toArray(array, size); } @NotNull - public T[] toArray(@NotNull T[] array) { - int size = size(); + public T[] _toArray(@NotNull T[] array) { + int size = _size(); return _toArray(array, size); } - abstract public String toString(); + abstract protected String _toString(); } diff --git a/approximations/src/main/java/generated/java/util/AbstractSpliteratorImpl.java b/approximations/src/main/java/generated/java/util/AbstractSpliteratorImpl.java index 9af3cd78..f0cbf60c 100644 --- a/approximations/src/main/java/generated/java/util/AbstractSpliteratorImpl.java +++ b/approximations/src/main/java/generated/java/util/AbstractSpliteratorImpl.java @@ -10,66 +10,72 @@ @Approximate(java.util.Spliterators.AbstractSpliterator.class) public abstract class AbstractSpliteratorImpl implements Spliterator { - public int index; - - public int fence; - - public int expectedModCount; - public AbstractSpliteratorImpl(int index, int fence, int expectedModCount) { Engine.assume(index >= 0); - this.index = index; - this.fence = fence; - this.expectedModCount = expectedModCount; + _setIndex(index); + _setFence(fence); + _setExpectedModCount(expectedModCount); } + abstract protected int _getIndex(); + + abstract protected void _setIndex(int newIndex); + + abstract protected int _getFence(); + + abstract protected void _setFence(int newFence); + + abstract protected int _getExpectedModCount(); + + abstract protected void _setExpectedModCount(int newExpectedModCount); + abstract protected AbstractSpliteratorImpl _create(int index, int fence); abstract protected int _parentModCount(); protected final void _eval() { - this.expectedModCount = _parentModCount(); + _setExpectedModCount(_parentModCount()); } abstract protected int _storageSize(); - protected int _getFence() { - if (this.fence < 0) { + protected int _fence() { + if (this._getFence() < 0) { _eval(); - this.fence = _storageSize(); - Engine.assume(this.fence >= 0); + _setFence(_storageSize()); + Engine.assume(this._getFence() >= 0); } - return this.fence; + return this._getFence(); } protected void _checkForModification() { - if (_parentModCount() != expectedModCount) + if (_parentModCount() != _getExpectedModCount()) throw new ConcurrentModificationException(); } - public abstract int characteristics(); + protected abstract int _characteristics(); - public long estimateSize() { - return getExactSizeIfKnown(); + public long _estimateSize() { + return _getExactSizeIfKnown(); } - public abstract void forEachRemaining(Consumer userAction); + protected abstract void _forEachRemaining(Consumer userAction); - public long getExactSizeIfKnown() { - return _getFence() - this.index; + public long _getExactSizeIfKnown() { + return _fence() - _getIndex(); } - public abstract boolean tryAdvance(Consumer userAction); + protected abstract boolean _tryAdvance(Consumer userAction); - public AbstractSpliteratorImpl trySplit() { - int hi = _getFence(); - int lo = this.index; + protected AbstractSpliteratorImpl _trySplit() { + int hi = _fence(); + int lo = _getIndex(); int mid = (lo + hi) >>> 1; if (lo >= mid) return null; - this.index = mid; + _setIndex(mid); return _create(lo, mid); } } diff --git a/approximations/src/main/java/generated/java/util/PropertiesImpl.java b/approximations/src/main/java/generated/java/util/PropertiesImpl.java new file mode 100644 index 00000000..2eb18535 --- /dev/null +++ b/approximations/src/main/java/generated/java/util/PropertiesImpl.java @@ -0,0 +1,19 @@ +package generated.java.util; + +import generated.java.util.map.ConcurrentHashMapImpl; +import org.jacodb.approximation.annotation.Approximate; + +import java.util.Properties; + +@Approximate(Properties.class) +public class PropertiesImpl { + + @SuppressWarnings("FieldCanBeLocal") + private final ConcurrentHashMapImpl map; + protected Properties defaults; + + private PropertiesImpl(Properties defaults, int initialCapacity) { + this.map = new ConcurrentHashMapImpl<>(initialCapacity); + this.defaults = defaults; + } +} diff --git a/approximations/src/main/java/generated/java/util/array/AbstractArraySpliteratorImpl.java b/approximations/src/main/java/generated/java/util/array/AbstractArraySpliteratorImpl.java index e1069e55..8585c485 100644 --- a/approximations/src/main/java/generated/java/util/array/AbstractArraySpliteratorImpl.java +++ b/approximations/src/main/java/generated/java/util/array/AbstractArraySpliteratorImpl.java @@ -14,11 +14,41 @@ public abstract class AbstractArraySpliteratorImpl extends AbstractSpliterato public int characteristics; + public int index; + + public int fence; + + public int expectedModCount; + public AbstractArraySpliteratorImpl(int index, int fence, int characteristics) { super(index, fence, 0); this.characteristics = characteristics | SpliteratorsImpl._characteristics; } + protected int _getIndex() { + return index; + } + + protected void _setIndex(int newIndex) { + this.index = newIndex; + } + + protected int _getFence() { + return fence; + } + + protected void _setFence(int newFence) { + this.fence = newFence; + } + + protected int _getExpectedModCount() { + return expectedModCount; + } + + protected void _setExpectedModCount(int newExpectedModCount) { + this.expectedModCount = newExpectedModCount; + } + protected int _parentModCount() { return 0; } @@ -27,28 +57,38 @@ protected int _storageSize() { return this.fence; } - protected int _getFence() { + protected int _fence() { return this.fence; } protected void _checkForModification() { } + @SuppressWarnings("MagicConstant") public boolean hasCharacteristics(int _characteristics) { return (this.characteristics & _characteristics) == _characteristics; } - public int characteristics() { + protected int _characteristics() { return this.characteristics; } + @SuppressWarnings("MagicConstant") + public int characteristics() { + return _characteristics(); + } + public long estimateSize() { - return super.estimateSize(); + return super._estimateSize(); } abstract protected E _getItem(int index); public void forEachRemaining(Consumer _action) { + _forEachRemaining(_action); + } + + protected void _forEachRemaining(Consumer _action) { if (_action == null) throw new NullPointerException(); @@ -60,6 +100,7 @@ public void forEachRemaining(Consumer _action) { } } + @SuppressWarnings("MagicConstant") public Comparator getComparator() { if (hasCharacteristics(LibSLGlobals.SPLITERATOR_SORTED)) return null; @@ -68,10 +109,14 @@ public Comparator getComparator() { } public long getExactSizeIfKnown() { - return super.getExactSizeIfKnown(); + return super._getExactSizeIfKnown(); } public boolean tryAdvance(Consumer _action) { + return _tryAdvance(_action); + } + + protected boolean _tryAdvance(Consumer _action) { if (_action == null) throw new NullPointerException(); @@ -86,6 +131,6 @@ public boolean tryAdvance(Consumer _action) { } public AbstractArraySpliteratorImpl trySplit() { - return (AbstractArraySpliteratorImpl) super.trySplit(); + return (AbstractArraySpliteratorImpl) super._trySplit(); } } diff --git a/approximations/src/main/java/generated/java/util/array/ArraysImpl.java b/approximations/src/main/java/generated/java/util/array/ArraysImpl.java new file mode 100644 index 00000000..ede67300 --- /dev/null +++ b/approximations/src/main/java/generated/java/util/array/ArraysImpl.java @@ -0,0 +1,420 @@ +package generated.java.util.array; + +import org.jacodb.approximation.annotation.Approximate; + +import java.util.Comparator; + +@SuppressWarnings("unused") +@Approximate(java.util.Arrays.class) +public class ArraysImpl { + + private static void _checkArrayNull(Object array) { + if (array == null) + throw new NullPointerException(); + } + + private static void _rangeCheck(int arrayLength, int fromIndex, int toIndex) { + if (fromIndex > toIndex) + throw new IllegalArgumentException(); + + if (fromIndex < 0) + throw new ArrayIndexOutOfBoundsException(); + + if (toIndex > arrayLength) + throw new ArrayIndexOutOfBoundsException(); + } + + private static boolean _isEmpty(int arrayLength, int fromIndex, int toIndex) { + return toIndex - fromIndex == 0 || arrayLength == 0; + } + + private static void _sortIntArray(int[] array, int fromIndex, int toIndex) { + if (_isEmpty(array.length, fromIndex, toIndex)) + return; + + int outerLimit = toIndex - 1; + for (int i = 0; i < outerLimit; i++) { + int innerLimit = toIndex - i - 1; + for (int j = 0; j < innerLimit; j++) { + int idxB = j + 1; + int a = array[j]; + int b = array[idxB]; + if (a > b) { + array[j] = b; + array[idxB] = a; + } + } + } + } + + private static void _sortLongArray(long[] array, int fromIndex, int toIndex) { + if (_isEmpty(array.length, fromIndex, toIndex)) + return; + + int outerLimit = toIndex - 1; + for (int i = 0; i < outerLimit; i++) { + int innerLimit = toIndex - i - 1; + for (int j = 0; j < innerLimit; j++) { + int idxB = j + 1; + long a = array[j]; + long b = array[idxB]; + if (a > b) { + array[j] = b; + array[idxB] = a; + } + } + } + } + + private static void _sortShortArray(short[] array, int fromIndex, int toIndex) { + if (_isEmpty(array.length, fromIndex, toIndex)) + return; + + int outerLimit = toIndex - 1; + for (int i = 0; i < outerLimit; i++) { + int innerLimit = toIndex - i - 1; + for (int j = 0; j < innerLimit; j++) { + int idxB = j + 1; + short a = array[j]; + short b = array[idxB]; + if (a > b) { + array[j] = b; + array[idxB] = a; + } + } + } + } + + private static void _sortCharArray(char[] array, int fromIndex, int toIndex) { + if (_isEmpty(array.length, fromIndex, toIndex)) + return; + + int outerLimit = toIndex - 1; + for (int i = 0; i < outerLimit; i++) { + int innerLimit = toIndex - i - 1; + for (int j = 0; j < innerLimit; j++) { + int idxB = j + 1; + char a = array[j]; + char b = array[idxB]; + if (a > b) { + array[j] = b; + array[idxB] = a; + } + } + } + } + + private static void _sortByteArray(byte[] array, int fromIndex, int toIndex) { + if (_isEmpty(array.length, fromIndex, toIndex)) + return; + + int outerLimit = toIndex - 1; + for (int i = 0; i < outerLimit; i++) { + int innerLimit = toIndex - i - 1; + for (int j = 0; j < innerLimit; j++) { + int idxB = j + 1; + byte a = array[j]; + byte b = array[idxB]; + if (a > b) { + array[j] = b; + array[idxB] = a; + } + } + } + } + + private static void _sortFloatArray(float[] array, int fromIndex, int toIndex) { + if (_isEmpty(array.length, fromIndex, toIndex)) + return; + + int outerLimit = toIndex - 1; + for (int i = 0; i < outerLimit; i++) { + int innerLimit = toIndex - i - 1; + for (int j = 0; j < innerLimit; j++) { + int idxB = j + 1; + float a = array[j]; + float b = array[idxB]; + if (a > b) { + array[j] = b; + array[idxB] = a; + } + } + } + } + + private static void _sortDoubleArray(double[] array, int fromIndex, int toIndex) { + if (_isEmpty(array.length, fromIndex, toIndex)) + return; + + int outerLimit = toIndex - 1; + for (int i = 0; i < outerLimit; i++) { + int innerLimit = toIndex - i - 1; + for (int j = 0; j < innerLimit; j++) { + int idxB = j + 1; + double a = array[j]; + double b = array[idxB]; + if (a > b) { + array[j] = b; + array[idxB] = a; + } + } + } + } + + private static > void _sortArray(T[] array, int fromIndex, int toIndex) { + if (_isEmpty(array.length, fromIndex, toIndex)) + return; + + int outerLimit = toIndex - 1; + for (int i = 0; i < outerLimit; i++) { + int innerLimit = toIndex - i - 1; + for (int j = 0; j < innerLimit; j++) { + int idxB = j + 1; + T a = array[j]; + T b = array[idxB]; + if (a.compareTo(b) > 0) { + array[j] = b; + array[idxB] = a; + } + } + } + } + + @SuppressWarnings("unchecked") + private static void _sortArray(T[] array, int fromIndex, int toIndex, Comparator comparator) { + if (_isEmpty(array.length, fromIndex, toIndex)) + return; + + int outerLimit = toIndex - 1; + for (int i = 0; i < outerLimit; i++) { + int innerLimit = toIndex - i - 1; + for (int j = 0; j < innerLimit; j++) { + int idxB = j + 1; + T a = array[j]; + T b = array[idxB]; + if (comparator != null && comparator.compare(a, b) > 0 || ((Comparable) a).compareTo(b) > 0) { + array[j] = b; + array[idxB] = a; + } + } + } + } + + @SuppressWarnings("unchecked") + private static void _sortArray(Object[] array, int fromIndex, int toIndex) { + if (_isEmpty(array.length, fromIndex, toIndex)) + return; + + int outerLimit = toIndex - 1; + for (int i = 0; i < outerLimit; i++) { + int innerLimit = toIndex - i - 1; + for (int j = 0; j < innerLimit; j++) { + int idxB = j + 1; + Object a = array[j]; + Object b = array[idxB]; + if (((Comparable) a).compareTo(b) > 0) { + array[j] = b; + array[idxB] = a; + } + } + } + } + + public static void sort(int[] a) { + _checkArrayNull(a); + _sortIntArray(a, 0, a.length); + } + + public static void sort(int[] a, int fromIndex, int toIndex) { + _checkArrayNull(a); + _rangeCheck(a.length, fromIndex, toIndex); + _sortIntArray(a, fromIndex, toIndex); + } + + public static void sort(long[] a) { + _checkArrayNull(a); + _sortLongArray(a, 0, a.length); + } + + public static void sort(long[] a, int fromIndex, int toIndex) { + _checkArrayNull(a); + _rangeCheck(a.length, fromIndex, toIndex); + _sortLongArray(a, fromIndex, toIndex); + } + + public static void sort(short[] a) { + _checkArrayNull(a); + _sortShortArray(a, 0, a.length); + } + + public static void sort(short[] a, int fromIndex, int toIndex) { + _checkArrayNull(a); + _rangeCheck(a.length, fromIndex, toIndex); + _sortShortArray(a, fromIndex, toIndex); + } + + public static void sort(char[] a) { + _checkArrayNull(a); + _sortCharArray(a, 0, a.length); + } + + public static void sort(char[] a, int fromIndex, int toIndex) { + _checkArrayNull(a); + _rangeCheck(a.length, fromIndex, toIndex); + _sortCharArray(a, fromIndex, toIndex); + } + + public static void sort(byte[] a) { + _checkArrayNull(a); + _sortByteArray(a, 0, a.length); + } + + public static void sort(byte[] a, int fromIndex, int toIndex) { + _checkArrayNull(a); + _rangeCheck(a.length, fromIndex, toIndex); + _sortByteArray(a, fromIndex, toIndex); + } + + public static void sort(float[] a) { + _checkArrayNull(a); + _sortFloatArray(a, 0, a.length); + } + + public static void sort(float[] a, int fromIndex, int toIndex) { + _checkArrayNull(a); + _rangeCheck(a.length, fromIndex, toIndex); + _sortFloatArray(a, fromIndex, toIndex); + } + + public static void sort(double[] a) { + _checkArrayNull(a); + _sortDoubleArray(a, 0, a.length); + } + + public static void sort(double[] a, int fromIndex, int toIndex) { + _checkArrayNull(a); + _rangeCheck(a.length, fromIndex, toIndex); + _sortDoubleArray(a, fromIndex, toIndex); + } + + public static void parallelSort(byte[] a) { + _checkArrayNull(a); + _sortByteArray(a, 0, a.length); + } + + public static void parallelSort(byte[] a, int fromIndex, int toIndex) { + _checkArrayNull(a); + _rangeCheck(a.length, fromIndex, toIndex); + _sortByteArray(a, fromIndex, toIndex); + } + + public static void parallelSort(char[] a) { + _checkArrayNull(a); + _sortCharArray(a, 0, a.length); + } + + public static void parallelSort(char[] a, int fromIndex, int toIndex) { + _checkArrayNull(a); + _rangeCheck(a.length, fromIndex, toIndex); + _sortCharArray(a, fromIndex, toIndex); + } + + public static void parallelSort(short[] a) { + _checkArrayNull(a); + _sortShortArray(a, 0, a.length); + } + + public static void parallelSort(short[] a, int fromIndex, int toIndex) { + _checkArrayNull(a); + _rangeCheck(a.length, fromIndex, toIndex); + _sortShortArray(a, fromIndex, toIndex); + } + + public static void parallelSort(int[] a) { + _checkArrayNull(a); + _sortIntArray(a, 0, a.length); + } + + public static void parallelSort(int[] a, int fromIndex, int toIndex) { + _checkArrayNull(a); + _rangeCheck(a.length, fromIndex, toIndex); + _sortIntArray(a, fromIndex, toIndex); + } + + public static void parallelSort(long[] a) { + _checkArrayNull(a); + _sortLongArray(a, 0, a.length); + } + + public static void parallelSort(long[] a, int fromIndex, int toIndex) { + _checkArrayNull(a); + _rangeCheck(a.length, fromIndex, toIndex); + _sortLongArray(a, fromIndex, toIndex); + } + + public static void parallelSort(float[] a) { + _checkArrayNull(a); + _sortFloatArray(a, 0, a.length); + } + + public static void parallelSort(float[] a, int fromIndex, int toIndex) { + _checkArrayNull(a); + _rangeCheck(a.length, fromIndex, toIndex); + _sortFloatArray(a, fromIndex, toIndex); + } + + public static void parallelSort(double[] a) { + _checkArrayNull(a); + _sortDoubleArray(a, 0, a.length); + } + + public static void parallelSort(double[] a, int fromIndex, int toIndex) { + _checkArrayNull(a); + _rangeCheck(a.length, fromIndex, toIndex); + _sortDoubleArray(a, fromIndex, toIndex); + } + + public static > void parallelSort(T[] a) { + _checkArrayNull(a); + _sortArray(a, 0, a.length); + } + + public static > void parallelSort(T[] a, int fromIndex, int toIndex) { + _checkArrayNull(a); + _rangeCheck(a.length, fromIndex, toIndex); + _sortArray(a, fromIndex, toIndex); + } + + public static void parallelSort(T[] a, Comparator cmp) { + _checkArrayNull(a); + _sortArray(a, 0, a.length, cmp); + } + + public static void parallelSort(T[] a, int fromIndex, int toIndex, Comparator cmp) { + _checkArrayNull(a); + _rangeCheck(a.length, fromIndex, toIndex); + _sortArray(a, fromIndex, toIndex, cmp); + } + + public static void sort(Object[] a) { + _checkArrayNull(a); + _sortArray(a, 0, a.length); + } + + public static void sort(Object[] a, int fromIndex, int toIndex) { + _checkArrayNull(a); + _rangeCheck(a.length, fromIndex, toIndex); + _sortArray(a, fromIndex, toIndex); + } + + public static void sort(T[] a, Comparator c) { + _checkArrayNull(a); + _sortArray(a, 0, a.length, c); + } + + public static void sort(T[] a, int fromIndex, int toIndex, Comparator c) { + _checkArrayNull(a); + _rangeCheck(a.length, fromIndex, toIndex); + _sortArray(a, fromIndex, toIndex, c); + } +} diff --git a/approximations/src/main/java/generated/java/util/list/AbstractListImpl.java b/approximations/src/main/java/generated/java/util/list/AbstractListImpl.java index 77318754..7df66555 100644 --- a/approximations/src/main/java/generated/java/util/list/AbstractListImpl.java +++ b/approximations/src/main/java/generated/java/util/list/AbstractListImpl.java @@ -1,7 +1,5 @@ package generated.java.util.list; -import java.io.Serial; -import java.io.Serializable; import java.lang.Comparable; import java.lang.IllegalArgumentException; import java.lang.IndexOutOfBoundsException; @@ -26,15 +24,9 @@ @Approximate(java.util.AbstractList.class) public abstract class AbstractListImpl extends AbstractCollectionImpl implements List { - public SymbolicList storage; - public AbstractListImpl(SymbolicList storage, int modCount) { super(modCount); - this.storage = storage; - } - - public AbstractListImpl() { - this(Engine.makeSymbolicList(), 0); + _setStorage(storage); } public AbstractListImpl(Collection c) { @@ -43,7 +35,7 @@ public AbstractListImpl(Collection c) { if (c == null) throw new NullPointerException(); - this.storage = Engine.makeSymbolicList(); + _setStorage(Engine.makeSymbolicList()); _addAllElements(0, c); } @@ -53,14 +45,12 @@ public AbstractListImpl(int initialCapacity) { if (initialCapacity < 0) throw new IllegalArgumentException(); - this.storage = Engine.makeSymbolicList(); + _setStorage(Engine.makeSymbolicList()); } - public SymbolicList _getStorage() { - SymbolicList storage = this.storage; - Engine.assume(storage != null); - return storage; - } + public abstract SymbolicList _getStorage(); + + public abstract void _setStorage(SymbolicList storage); public boolean _isValidIndex(int index, int length) { return index >= 0 && index < length; @@ -107,7 +97,7 @@ public boolean _addAllElements(int index, Collection c) { } } - this.modCount++; + _incrementModCount(); return oldLength != storage.size(); } @@ -122,16 +112,11 @@ public void _subListRangeCheck(int fromIndex, int toIndex, int size) { throw new IllegalArgumentException(); } - public void _checkForModification(int expectedModCount) { - if (this.modCount != expectedModCount) - throw new ConcurrentModificationException(); - } - public E _deleteElement(int index) { SymbolicList storage = _getStorage(); E result = storage.get(index); storage.remove(index); - this.modCount++; + _incrementModCount(); return result; } @@ -142,7 +127,7 @@ public E _checkedDeleteElement(int index) { public void _addElement(int index, E element) { _getStorage().insert(index, element); - this.modCount++; + _incrementModCount(); } public void _checkedAddElement(int index, E element) { @@ -162,19 +147,19 @@ public E _checkedSetElement(int index, E element) { return _setElement(index, element); } - public E _get(int index) { + public E _uncheckedGet(int index) { return _getStorage().get(index); } public E _checkedGet(int index) { _checkValidIndex(index); - return _getStorage().get(index); + return _uncheckedGet(index); } public void _replaceAllRange(UnaryOperator op, int i, int end) { - int expectedModCount = this.modCount; + int expectedModCount = _getModCount(); SymbolicList storage = _getStorage(); - while (this.modCount == expectedModCount && i < end) { + while (_getModCount() == expectedModCount && i < end) { E oldItem = storage.get(i); E newItem = op.apply(oldItem); storage.set(i, newItem); @@ -189,7 +174,7 @@ public boolean _removeIf(Predicate filter, int start, int end) { SymbolicList storage = _getStorage(); int oldLength = storage.size(); - int expectedModCount = this.modCount; + int expectedModCount = _getModCount(); Engine.assume(start <= end); for (int i = end - 1; i > start; i--) { E item = storage.get(i); @@ -277,8 +262,8 @@ public boolean _batchRemove(Collection c, boolean complement, int start, int if (!complement) return false; - this.storage = Engine.makeSymbolicList(); - this.modCount++; + _setStorage(Engine.makeSymbolicList()); + _incrementModCount(); return true; } @@ -317,11 +302,11 @@ public boolean _batchRemove(Collection c, boolean complement, int start, int @SuppressWarnings("unchecked") public void _do_sort(int start, int end, Comparator c) { if (start >= end) { - this.modCount++; + _incrementModCount(); return; } SymbolicList storage = _getStorage(); - int expectedModCount = this.modCount; + int expectedModCount = _getModCount(); Engine.assume(start >= 0); Engine.assume(end > 0); int outerLimit = end - 1; @@ -340,48 +325,48 @@ public void _do_sort(int start, int end, Comparator c) { _checkForModification(expectedModCount); } - public boolean add(E e) { + public boolean _add(E e) { SymbolicList storage = _getStorage(); storage.insert(storage.size(), e); - this.modCount++; + _incrementModCount(); return true; } - public void add(int index, E element) { + public void _add(int index, E element) { _checkedAddElement(index, element); } - public boolean addAll(@NotNull Collection c) { + public boolean _addAll(@NotNull Collection c) { return _addAllElements(_getStorage().size(), c); } - public boolean addAll(int index, @NotNull Collection c) { + public boolean _addAll(int index, @NotNull Collection c) { _checkValidAddIndex(index); return _addAllElements(index, c); } - public void clear() { - this.storage = Engine.makeSymbolicList(); - this.modCount++; + public void _clear() { + _setStorage(Engine.makeSymbolicList()); + _incrementModCount(); } @SuppressWarnings("unchecked") - public Object clone() throws CloneNotSupportedException { + public Object _clone() throws CloneNotSupportedException { AbstractListImpl clonedList = (AbstractListImpl) super.clone(); SymbolicList storageCopy = Engine.makeSymbolicList(); SymbolicList storage = _getStorage(); storage.copy(storageCopy, 0, 0, storage.size()); - clonedList.storage = storageCopy; - clonedList.modCount = 0; + clonedList._setStorage(storageCopy); + clonedList._setModCount(0); return clonedList; } - public boolean contains(Object o) { + public boolean _contains(Object o) { return indexOf(o) != -1; } @SuppressWarnings({"DataFlowIssue", "unchecked"}) - public boolean containsAll(@NotNull Collection c) { + public boolean _containsAll(@NotNull Collection c) { if (c instanceof AbstractListImpl) { SymbolicList otherStorage = ((AbstractListImpl) c)._getStorage(); Engine.assume(otherStorage != null); @@ -405,19 +390,19 @@ public boolean containsAll(@NotNull Collection c) { return true; } - public void ensureCapacity(int minCapacity) { - this.modCount++; + public void _ensureCapacity(int minCapacity) { + _incrementModCount(); } @SuppressWarnings("unchecked") - public boolean equals(Object other) { + public boolean _equals(Object other) { if (other == this) return true; if (other instanceof AbstractListImpl) { AbstractListImpl otherList = (AbstractListImpl) other; - int expectedModCount = this.modCount; - int otherExpectedModCount = otherList.modCount; + int expectedModCount = _getModCount(); + int otherExpectedModCount = otherList._getModCount(); SymbolicList otherStorage = otherList._getStorage(); SymbolicList storage = _getStorage(); int size = storage.size(); @@ -431,14 +416,14 @@ public boolean equals(Object other) { return false; } - public void forEach(Consumer _action) { + public void _forEach(Consumer _action) { if (_action == null) throw new NullPointerException(); - int expectedModCount = this.modCount; + int expectedModCount = this._getModCount(); int i = 0; SymbolicList storage = _getStorage(); - while (this.modCount == expectedModCount && i < storage.size()) { + while (this._getModCount() == expectedModCount && i < storage.size()) { E item = storage.get(i); _action.accept(item); i++; @@ -446,29 +431,29 @@ public void forEach(Consumer _action) { _checkForModification(expectedModCount); } - public E get(int index) { + public E _get(int index) { return _checkedGet(index); } - public int hashCode() { + public int _hashCode() { return LibSLRuntime.hashCode(_getStorage()); } - public int indexOf(Object o) { + public int _indexOf(Object o) { SymbolicList storage = _getStorage(); return LibSLRuntime.ListActions.find(storage, o, 0, storage.size()); } - public boolean isEmpty() { + public boolean _isEmpty() { return _getStorage().size() == 0; } @NotNull - public Iterator iterator() { + public Iterator _iterator() { return new ListIteratorStubImpl<>(this); } - public int lastIndexOf(Object o) { + public int _lastIndexOf(Object o) { SymbolicList storage = _getStorage(); int size = storage.size(); if (size == 0) @@ -485,21 +470,21 @@ public int lastIndexOf(Object o) { } @NotNull - public ListIterator listIterator() { + public ListIterator _listIterator() { return new ListIteratorStubImpl<>(this); } @NotNull - public ListIterator listIterator(int index) { + public ListIterator _listIterator(int index) { _checkValidIndex(index); return new ListIteratorStubImpl<>(this, index); } - public Stream parallelStream() { + public Stream _parallelStream() { return _makeStream(true); } - public boolean remove(Object o) { + public boolean _remove(Object o) { int index = indexOf(o); if (index == -1) return false; @@ -509,71 +494,71 @@ public boolean remove(Object o) { } - public E remove(int index) { + public E _remove(int index) { return _checkedDeleteElement(index); } - public boolean removeAll(@NotNull Collection c) { + public boolean _removeAll(@NotNull Collection c) { return _batchRemove(c, false, 0, _getStorage().size()); } - public boolean removeIf(Predicate filter) { + public boolean _removeIf(Predicate filter) { return _removeIf(filter, 0, _getStorage().size()); } - public void replaceAll(UnaryOperator op) { + public void _replaceAll(UnaryOperator op) { if (op == null) throw new NullPointerException(); _replaceAllRange(op, 0, _getStorage().size()); - this.modCount++; + _incrementModCount(); } - public boolean retainAll(@NotNull Collection c) { + public boolean _retainAll(@NotNull Collection c) { return _batchRemove(c, true, 0, _getStorage().size()); } - public E set(int index, E element) { + public E _set(int index, E element) { return _checkedSetElement(index, element); } - public int size() { + public int _size() { return _getStorage().size(); } - public void sort(Comparator c) { + public void _sort(Comparator c) { _do_sort(0, _getStorage().size(), c); } - public Spliterator spliterator() { + public Spliterator _spliterator() { return new ListSpliteratorStubImpl<>(this); } - public Stream stream() { + public Stream _stream() { return _makeStream(false); } @NotNull - public List subList(int fromIndex, int toIndex) { + public List _subList(int fromIndex, int toIndex) { _subListRangeCheck(fromIndex, toIndex, _getStorage().size()); return new SubListImpl<>(this, fromIndex, toIndex); } @NotNull - public Object[] toArray() { + public Object[] _toArray() { return _mapToArray(); } - public T[] toArray(IntFunction generator) { - return super.toArray(generator); + public T[] _toArray(IntFunction generator) { + return super._toArray(generator); } @NotNull - public T[] toArray(@NotNull T[] array) { - return super.toArray(array); + public T[] _toArray(@NotNull T[] array) { + return super._toArray(array); } - public String toString() { + public String _toString() { return LibSLRuntime.toString(_getStorage()); } } diff --git a/approximations/src/main/java/generated/java/util/list/ArrayListImpl.java b/approximations/src/main/java/generated/java/util/list/ArrayListImpl.java index 2ad8d2fc..a04c1b83 100644 --- a/approximations/src/main/java/generated/java/util/list/ArrayListImpl.java +++ b/approximations/src/main/java/generated/java/util/list/ArrayListImpl.java @@ -24,6 +24,10 @@ public class ArrayListImpl extends AbstractListImpl implements RandomAcces @Serial private static final long serialVersionUID = 8683452581122892189L; + private SymbolicList storage; + + private int modCount; + static { Engine.assume(true); } @@ -35,7 +39,7 @@ public ArrayListImpl(SymbolicList storage, int modCount) { @SuppressWarnings("unused") public ArrayListImpl() { - super(); + super(Engine.makeSymbolicList(), 0); } @SuppressWarnings("unused") @@ -48,154 +52,176 @@ public ArrayListImpl(int initialCapacity) { super(initialCapacity); } + public SymbolicList _getStorage() { + SymbolicList storage = this.storage; + Engine.assume(storage != null); + return storage; + } + + public void _setStorage(SymbolicList storage) { + this.storage = storage; + } + + public int _getModCount() { + return modCount; + } + + protected void _setModCount(int newModCount) { + this.modCount = newModCount; + } + public boolean add(E e) { - return super.add(e); + return super._add(e); } public void add(int index, E element) { - super.add(index, element); + super._add(index, element); } public boolean addAll(@NotNull Collection c) { - return super.addAll(c); + return super._addAll(c); } public boolean addAll(int index, @NotNull Collection c) { - return super.addAll(index, c); + return super._addAll(index, c); } public void clear() { - super.clear(); + super._clear(); } + @SuppressWarnings("MethodDoesntCallSuperMethod") public Object clone() throws CloneNotSupportedException { - return super.clone(); + return super._clone(); } public boolean contains(Object o) { - return super.contains(o); + return super._contains(o); } - @SuppressWarnings("SlowListContainsAll") public boolean containsAll(@NotNull Collection c) { - return super.containsAll(c); + return super._containsAll(c); } public void ensureCapacity(int minCapacity) { - super.ensureCapacity(minCapacity); + super._ensureCapacity(minCapacity); } + @SuppressWarnings("EqualsDoesntCheckParameterClass") public boolean equals(Object other) { - return Engine.typeIs(other, ArrayListImpl.class) && super.equals(other); + return Engine.typeIs(other, ArrayListImpl.class) && super._equals(other); } public void forEach(Consumer _action) { - super.forEach(_action); + super._forEach(_action); } public E get(int index) { - return super.get(index); + return super._get(index); } public int hashCode() { - return super.hashCode(); + return super._hashCode(); } public int indexOf(Object o) { - return super.indexOf(o); + return super._indexOf(o); } public boolean isEmpty() { - return super.isEmpty(); + return super._isEmpty(); } @NotNull public Iterator iterator() { - return super.iterator(); + return super._iterator(); } public int lastIndexOf(Object o) { - return super.lastIndexOf(o); + return super._lastIndexOf(o); } @NotNull public ListIterator listIterator() { - return super.listIterator(); + return super._listIterator(); } @NotNull public ListIterator listIterator(int index) { - return super.listIterator(index); + return super._listIterator(index); } + @NotNull public Stream parallelStream() { - return super.parallelStream(); + return super._parallelStream(); } public boolean remove(Object o) { - return super.remove(o); + return super._remove(o); } public E remove(int index) { - return super.remove(index); + return super._remove(index); } public boolean removeAll(@NotNull Collection c) { - return super.removeAll(c); + return super._removeAll(c); } - public boolean removeIf(Predicate filter) { - return super.removeIf(filter); + public boolean removeIf(@NotNull Predicate filter) { + return super._removeIf(filter); } - public void replaceAll(UnaryOperator op) { - super.replaceAll(op); + public void replaceAll(@NotNull UnaryOperator op) { + super._replaceAll(op); } public boolean retainAll(@NotNull Collection c) { - return super.retainAll(c); + return super._retainAll(c); } public E set(int index, E element) { - return super.set(index, element); + return super._set(index, element); } public int size() { - return super.size(); + return super._size(); } public void sort(Comparator c) { - super.sort(c); + super._sort(c); } + @NotNull public Spliterator spliterator() { - return super.spliterator(); + return super._spliterator(); } + @NotNull public Stream stream() { - return super.stream(); + return super._stream(); } @NotNull public List subList(int fromIndex, int toIndex) { - return super.subList(fromIndex, toIndex); + return super._subList(fromIndex, toIndex); } @NotNull public Object[] toArray() { - return super.toArray(); + return super._toArray(); } - public T[] toArray(IntFunction generator) { - return super.toArray(generator); + public T[] toArray(@NotNull IntFunction generator) { + return super._toArray(generator); } @NotNull public T[] toArray(@NotNull T[] array) { - return super.toArray(array); + return super._toArray(array); } public String toString() { - return super.toString(); + return super._toString(); } } diff --git a/approximations/src/main/java/generated/java/util/list/LinkedListImpl.java b/approximations/src/main/java/generated/java/util/list/LinkedListImpl.java index 81d40859..05dc4f94 100644 --- a/approximations/src/main/java/generated/java/util/list/LinkedListImpl.java +++ b/approximations/src/main/java/generated/java/util/list/LinkedListImpl.java @@ -30,6 +30,10 @@ public class LinkedListImpl extends AbstractListImpl implements Deque, @Serial private static final long serialVersionUID = 876323262645176354L; + private SymbolicList storage; + + private int modCount; + static { Engine.assume(true); } @@ -41,7 +45,7 @@ public LinkedListImpl(SymbolicList storage, int modCount) { @SuppressWarnings("unused") public LinkedListImpl() { - super(); + super(Engine.makeSymbolicList(), 0); } @SuppressWarnings("unused") @@ -49,6 +53,25 @@ public LinkedListImpl(Collection c) { super(c); } + public SymbolicList _getStorage() { + SymbolicList storage = this.storage; + Engine.assume(storage != null); + return storage; + } + + public void _setStorage(SymbolicList storage) { + this.storage = storage; + } + + public int _getModCount() { + return modCount; + } + + protected void _setModCount(int newModCount) { + this.modCount = newModCount; + } + + private E _unlinkFirst() { if (!_isValidIndex(0)) throw new NoSuchElementException(); @@ -60,23 +83,23 @@ private E _getFirstElement() { if (!_isValidIndex(0)) throw new NoSuchElementException(); - return _get(0); + return _uncheckedGet(0); } public boolean add(E e) { - return super.add(e); + return super._add(e); } public void add(int index, E element) { - super.add(index, element); + super._add(index, element); } public boolean addAll(@NotNull Collection c) { - return super.addAll(c); + return super._addAll(c); } public boolean addAll(int index, @NotNull Collection c) { - return super.addAll(index, c); + return super._addAll(index, c); } public void addFirst(E e) { @@ -88,20 +111,20 @@ public void addLast(E e) { } public void clear() { - super.clear(); + super._clear(); } + @SuppressWarnings("MethodDoesntCallSuperMethod") public Object clone() throws CloneNotSupportedException { - return super.clone(); + return super._clone(); } public boolean contains(Object o) { - return super.contains(o); + return super._contains(o); } - @SuppressWarnings("SlowListContainsAll") public boolean containsAll(@NotNull Collection c) { - return super.containsAll(c); + return super._containsAll(c); } @NotNull @@ -113,16 +136,17 @@ public E element() { return _getFirstElement(); } + @SuppressWarnings("EqualsDoesntCheckParameterClass") public boolean equals(Object o) { - return Engine.typeIs(o, LinkedListImpl.class) && super.equals(o); + return Engine.typeIs(o, LinkedListImpl.class) && super._equals(o); } public void forEach(Consumer _action) { - super.forEach(_action); + super._forEach(_action); } public E get(int index) { - return super.get(index); + return super._get(index); } public E getFirst() { @@ -130,38 +154,38 @@ public E getFirst() { } public E getLast() { - return super.get(_getStorage().size() - 1); + return super._get(_getStorage().size() - 1); } public int hashCode() { - return super.hashCode(); + return super._hashCode(); } public int indexOf(Object o) { - return super.indexOf(o); + return super._indexOf(o); } public boolean isEmpty() { - return super.isEmpty(); + return super._isEmpty(); } @NotNull public Iterator iterator() { - return super.iterator(); + return super._iterator(); } public int lastIndexOf(Object o) { - return super.lastIndexOf(o); + return super._lastIndexOf(o); } @NotNull public ListIterator listIterator() { - return super.listIterator(); + return super._listIterator(); } @NotNull public ListIterator listIterator(int index) { - return super.listIterator(index); + return super._listIterator(index); } public boolean offer(E e) { @@ -178,15 +202,16 @@ public boolean offerLast(E e) { return true; } + @NotNull public Stream parallelStream() { - return super.parallelStream(); + return super._parallelStream(); } public E peek() { if (isEmpty()) return null; - return _get(0); + return _uncheckedGet(0); } public E peekFirst() { @@ -198,7 +223,7 @@ public E peekLast() { if (size == 0) return null; - return _get(size - 1); + return _uncheckedGet(size - 1); } public E poll() { @@ -233,15 +258,15 @@ public E remove() { } public boolean remove(Object o) { - return super.remove(o); + return super._remove(o); } public E remove(int index) { - return super.remove(index); + return super._remove(index); } public boolean removeAll(@NotNull Collection c) { - return super.removeAll(c); + return super._removeAll(c); } public E removeFirst() { @@ -252,8 +277,8 @@ public boolean removeFirstOccurrence(Object o) { return remove(o); } - public boolean removeIf(Predicate filter) { - return super.removeIf(filter); + public boolean removeIf(@NotNull Predicate filter) { + return super._removeIf(filter); } public E removeLast() { @@ -289,54 +314,56 @@ public boolean removeLastOccurrence(Object o) { return false; } - public void replaceAll(UnaryOperator op) { - super.replaceAll(op); + public void replaceAll(@NotNull UnaryOperator op) { + super._replaceAll(op); } public boolean retainAll(@NotNull Collection c) { - return super.retainAll(c); + return super._retainAll(c); } public E set(int index, E element) { - return super.set(index, element); + return super._set(index, element); } public int size() { - return super.size(); + return super._size(); } public void sort(Comparator c) { - super.sort(c); + super._sort(c); } + @NotNull public Spliterator spliterator() { - return super.spliterator(); + return super._spliterator(); } + @NotNull public Stream stream() { - return super.stream(); + return super._stream(); } @NotNull public List subList(int fromIndex, int toIndex) { - return super.subList(fromIndex, toIndex); + return super._subList(fromIndex, toIndex); } @NotNull public Object[] toArray() { - return super.toArray(); + return super._toArray(); } - public T[] toArray(IntFunction generator) { - return super.toArray(generator); + public T[] toArray(@NotNull IntFunction generator) { + return super._toArray(generator); } @NotNull public T[] toArray(@NotNull T[] a) { - return super.toArray(a); + return super._toArray(a); } public String toString() { - return super.toString(); + return super._toString(); } } diff --git a/approximations/src/main/java/generated/java/util/list/ListIteratorStubImpl.java b/approximations/src/main/java/generated/java/util/list/ListIteratorStubImpl.java index b97694fd..e79010bb 100644 --- a/approximations/src/main/java/generated/java/util/list/ListIteratorStubImpl.java +++ b/approximations/src/main/java/generated/java/util/list/ListIteratorStubImpl.java @@ -31,7 +31,7 @@ public ListIteratorStubImpl(AbstractListImpl list, int index, int expectedMod } public ListIteratorStubImpl(AbstractListImpl list, int index) { - this(list, index, list.modCount); + this(list, index, list._getModCount()); } public ListIteratorStubImpl(AbstractListImpl list) { @@ -45,7 +45,7 @@ protected AbstractListImpl _getList() { } protected int _parentModCount() { - return _getList().modCount; + return _getList()._getModCount(); } protected int _getSize(SymbolicList storage) { @@ -100,11 +100,11 @@ public void remove() { _checkForModification(); AbstractListImpl list = _getList(); SymbolicList storage = list._getStorage(); - list.modCount++; + list._incrementModCount(); storage.remove(this.lastRet); this.cursor = this.lastRet; this.lastRet = -1; - this.expectedModCount = list.modCount; + this.expectedModCount = list._getModCount(); } public void set(E e) { @@ -120,11 +120,12 @@ public void add(E e) { _checkForModification(); AbstractListImpl list = _getList(); SymbolicList storage = list._getStorage(); - list.modCount++; + list._incrementModCount(); + // TODO: use ArrayList.add(e) storage.insert(this.cursor, e); this.cursor++; this.lastRet = -1; - this.expectedModCount = list.modCount; + this.expectedModCount = list._getModCount(); } public void forEachRemaining(Consumer userAction) { diff --git a/approximations/src/main/java/generated/java/util/list/ListSpliteratorStubImpl.java b/approximations/src/main/java/generated/java/util/list/ListSpliteratorStubImpl.java index 0ee02268..21d739da 100644 --- a/approximations/src/main/java/generated/java/util/list/ListSpliteratorStubImpl.java +++ b/approximations/src/main/java/generated/java/util/list/ListSpliteratorStubImpl.java @@ -14,6 +14,12 @@ public class ListSpliteratorStubImpl extends AbstractSpliteratorImpl { public AbstractListImpl list; + public int index; + + public int fence; + + public int expectedModCount; + protected ListSpliteratorStubImpl(AbstractListImpl list, int index, int fence, int expectedModCount) { super(index, fence, expectedModCount); Engine.assume(list != null); @@ -30,32 +36,61 @@ private AbstractListImpl _getList() { return result; } + protected int _getIndex() { + return index; + } + + protected void _setIndex(int newIndex) { + this.index = newIndex; + } + + protected int _getFence() { + return fence; + } + + protected void _setFence(int newFence) { + this.fence = newFence; + } + + protected int _getExpectedModCount() { + return expectedModCount; + } + + protected void _setExpectedModCount(int newExpectedModCount) { + this.expectedModCount = newExpectedModCount; + } + protected ListSpliteratorStubImpl _create(int index, int fence) { return new ListSpliteratorStubImpl<>(this.list, index, fence, this.expectedModCount); } protected int _parentModCount() { - return _getList().modCount; + return _getList()._getModCount(); } protected int _storageSize() { return _getList()._getStorage().size(); } - public int characteristics() { + protected int _characteristics() { return LibSLGlobals.SPLITERATOR_ORDERED | LibSLGlobals.SPLITERATOR_SIZED | LibSLGlobals.SPLITERATOR_SUBSIZED; } + @SuppressWarnings("MagicConstant") + public int characteristics() { + return _characteristics(); + } + public long estimateSize() { - return super.estimateSize(); + return super._estimateSize(); } - public void forEachRemaining(Consumer _action) { + protected void _forEachRemaining(Consumer _action) { if (_action == null) throw new NullPointerException(); SymbolicList storage = _getList()._getStorage(); - int fence = _getFence(); + int fence = _fence(); for (int i = this.index; i < fence; i++) { E item = storage.get(i); _action.accept(item); @@ -64,15 +99,19 @@ public void forEachRemaining(Consumer _action) { _checkForModification(); } + public void forEachRemaining(Consumer _action) { + _forEachRemaining(_action); + } + public long getExactSizeIfKnown() { - return super.getExactSizeIfKnown(); + return super._getExactSizeIfKnown(); } - public boolean tryAdvance(Consumer _action) { + protected boolean _tryAdvance(Consumer _action) { if (_action == null) throw new NullPointerException(); - int fence = _getFence(); + int fence = _fence(); int current = this.index; if (current >= fence) return false; @@ -86,7 +125,11 @@ public boolean tryAdvance(Consumer _action) { return true; } + public boolean tryAdvance(Consumer _action) { + return _tryAdvance(_action); + } + public ListSpliteratorStubImpl trySplit() { - return (ListSpliteratorStubImpl) super.trySplit(); + return (ListSpliteratorStubImpl) super._trySplit(); } } diff --git a/approximations/src/main/java/generated/java/util/list/SubListImpl.java b/approximations/src/main/java/generated/java/util/list/SubListImpl.java index 7aab3c14..b9dc94e3 100644 --- a/approximations/src/main/java/generated/java/util/list/SubListImpl.java +++ b/approximations/src/main/java/generated/java/util/list/SubListImpl.java @@ -37,6 +37,7 @@ public final class SubListImpl extends AbstractListImpl implements RandomA @SuppressWarnings("DataFlowIssue") private SubListImpl(AbstractListImpl list, SubListImpl parent, int offset, int length, int modCount) { + super(null, 0); Engine.assume(list != null); Engine.assume(offset >= 0); Engine.assume(length >= 0); @@ -52,6 +53,21 @@ public SubListImpl(AbstractListImpl list, int fromIndex, int toIndex) { this(list, null, fromIndex, toIndex - fromIndex, 0); } + public SymbolicList _getStorage() { + return null; + } + + public void _setStorage(SymbolicList storage) { + } + + public int _getModCount() { + return modCount; + } + + protected void _setModCount(int newModCount) { + this.modCount = newModCount; + } + public AbstractListImpl _getList() { AbstractListImpl result = this.list; Engine.assume(result != null); @@ -83,7 +99,7 @@ public boolean _addAllElements(int index, Collection c) { public void _updateSizeAndModCount(int sizeChange) { this.length += sizeChange; AbstractListImpl list = _getList(); - this.modCount = list.modCount; + this.modCount = list._getModCount(); SubListImpl parentSubList = this.parentSubList; while (parentSubList != null) { parentSubList.length += sizeChange; @@ -176,14 +192,14 @@ public void clear() { for (int i = start; i > end; i--) { rootStorage.remove(i); } - list.modCount++; + list._incrementModCount(); _updateSizeAndModCount(-size); } @SuppressWarnings("unchecked") public Object clone() throws CloneNotSupportedException { SubListImpl cloned = (SubListImpl) super.clone(); - cloned.list = (AbstractListImpl) this.list.clone(); + cloned.list = (AbstractListImpl) this.list._clone(); cloned.parentSubList = (SubListImpl) this.parentSubList.clone(); cloned.modCount = 0; return cloned; @@ -255,7 +271,7 @@ public void forEach(Consumer _action) { Engine.assume(this.length > 0); AbstractListImpl list = _getList(); SymbolicList rootStorage = list._getStorage(); - int expectedModCount = list.modCount; + int expectedModCount = list._getModCount(); this.modCount = expectedModCount; int end = _endIndex(); list._checkForModification(expectedModCount); @@ -327,6 +343,7 @@ public ListIterator listIterator(int index) { return new SubListIteratorStubImpl<>(this, index); } + @NotNull public Stream parallelStream() { return _makeStream(true); } @@ -359,7 +376,7 @@ public boolean removeAll(@NotNull Collection c) { return _batchRemove(c, false); } - public boolean removeIf(Predicate filter) { + public boolean removeIf(@NotNull Predicate filter) { AbstractListImpl list = _getList(); list._checkForModification(this.modCount); if (isEmpty()) @@ -376,7 +393,8 @@ public boolean removeIf(Predicate filter) { return false; } - public void replaceAll(UnaryOperator operator) { + @SuppressWarnings("ConstantValue") + public void replaceAll(@NotNull UnaryOperator operator) { if (operator == null) throw new NullPointerException(); @@ -407,13 +425,15 @@ public int size() { public void sort(Comparator c) { AbstractListImpl list = _getList(); list._do_sort(this.offset, _endIndex(), c); - this.modCount = list.modCount; + this.modCount = list._getModCount(); } + @NotNull public Spliterator spliterator() { return new SubListSpliteratorStubImpl<>(this); } + @NotNull public Stream stream() { return _makeStream(false); } @@ -428,16 +448,16 @@ public List subList(int fromIndex, int toIndex) { @NotNull public Object[] toArray() { - return super.toArray(); + return super._toArray(); } - public T[] toArray(IntFunction generator) { - return super.toArray(generator); + public T[] toArray(@NotNull IntFunction generator) { + return super._toArray(generator); } @NotNull public T[] toArray(@NotNull T[] array) { - return super.toArray(array); + return super._toArray(array); } public String toString() { diff --git a/approximations/src/main/java/generated/java/util/map/AbstractMapImpl.java b/approximations/src/main/java/generated/java/util/map/AbstractMapImpl.java index a7c3ba1b..5645eb93 100644 --- a/approximations/src/main/java/generated/java/util/map/AbstractMapImpl.java +++ b/approximations/src/main/java/generated/java/util/map/AbstractMapImpl.java @@ -13,27 +13,20 @@ @Approximate(java.util.AbstractMap.class) public abstract class AbstractMapImpl implements Map { - public LibSLRuntime.Map> storage; - - public transient int modCount; - - final boolean isHashMap; - - static LibSLRuntime.Map.Container> createContainer(boolean isHashMap) { + static LibSLRuntime.Map.Container> _createContainer(boolean isHashMap) { if (isHashMap) return new LibSLRuntime.HashMapContainer<>(); return new LibSLRuntime.IdentityMapContainer<>(); } - static LibSLRuntime.Map> createStorage(boolean isHashMap) { - return new LibSLRuntime.Map<>(createContainer(isHashMap)); + static LibSLRuntime.Map> _createStorage(boolean isHashMap) { + return new LibSLRuntime.Map<>(_createContainer(isHashMap)); } public AbstractMapImpl(boolean isHashMap) { - this.storage = createStorage(isHashMap); - this.modCount = 0; - this.isHashMap = isHashMap; + _setStorage(_createStorage(isHashMap)); + _setModCount(0); } public AbstractMapImpl(boolean isHashMap, Map m) { @@ -45,11 +38,11 @@ public AbstractMapImpl(boolean isHashMap, int initialCapacity) { if (initialCapacity < 0) throw new IllegalArgumentException(); - this.storage = createStorage(isHashMap); - this.modCount = 0; - this.isHashMap = isHashMap; + _setStorage(_createStorage(isHashMap)); + _setModCount(0); } + @SuppressWarnings("ExpressionComparedToItself") public AbstractMapImpl(boolean isHashMap, int initialCapacity, float loadFactor) { if (initialCapacity < 0) throw new IllegalArgumentException(); @@ -57,15 +50,22 @@ public AbstractMapImpl(boolean isHashMap, int initialCapacity, float loadFactor) if (loadFactor <= 0 || loadFactor != loadFactor) throw new IllegalArgumentException(); - this.storage = createStorage(isHashMap); - this.modCount = 0; - this.isHashMap = isHashMap; + _setStorage(_createStorage(isHashMap)); + _setModCount(0); } - public LibSLRuntime.Map> _getStorage() { - LibSLRuntime.Map> result = this.storage; - Engine.assume(result != null); - return result; + public abstract LibSLRuntime.Map> _getStorage(); + + public abstract void _setStorage(LibSLRuntime.Map> storage); + + abstract protected int _getModCount(); + + abstract protected void _setModCount(int newModCount); + + abstract protected boolean _isHashMap(); + + protected void _incrementModCount() { + _setModCount(_getModCount() + 1); } @SuppressWarnings("unchecked") @@ -89,25 +89,25 @@ private void _addAllElements(Map m) { Entry entry = new AbstractMap_EntryImpl<>(key, value); storage.set(key, entry); } - this.modCount++; + _incrementModCount(); } } public void _checkForModification(int expectedModCount) { - if (this.modCount != expectedModCount) + if (_getModCount() != expectedModCount) throw new ConcurrentModificationException(); } - public void clear() { - this.modCount++; - this.storage = createStorage(this.isHashMap); + public void _clear() { + _incrementModCount(); + _setStorage(_createStorage(_isHashMap())); } @SuppressWarnings("unchecked") - public Object clone() throws CloneNotSupportedException { + public Object _clone() throws CloneNotSupportedException { AbstractMapImpl clonedMap = (AbstractMapImpl) super.clone(); - clonedMap.storage = _getStorage().duplicate(); - clonedMap.modCount = 0; + clonedMap._setStorage(_getStorage().duplicate()); + clonedMap._setModCount(0); return clonedMap; } @@ -145,14 +145,14 @@ private void _update(K key, Map.Entry entry, V newValue) { } @SuppressWarnings("ConstantValue") - public V compute(K key, @NotNull BiFunction remappingFunction) { + public V _compute(K key, @NotNull BiFunction remappingFunction) { if (remappingFunction == null) throw new NullPointerException(); Map.Entry entry = _getEntry(key); V oldValue = _getEntryValueIfNotNull(entry); - int expectedModCount = this.modCount; + int expectedModCount = _getModCount(); V newValue = remappingFunction.apply(key, oldValue); _checkForModification(expectedModCount); _update(key, entry, newValue); @@ -161,7 +161,7 @@ public V compute(K key, @NotNull BiFunction r } @SuppressWarnings("ConstantValue") - public V computeIfAbsent(K key, @NotNull Function mappingFunction) { + public V _computeIfAbsent(K key, @NotNull Function mappingFunction) { if (mappingFunction == null) throw new NullPointerException(); @@ -171,7 +171,7 @@ public V computeIfAbsent(K key, @NotNull Function mappin if (oldValue != null) return oldValue; - int expectedModCount = this.modCount; + int expectedModCount = _getModCount(); V newValue = mappingFunction.apply(key); _checkForModification(expectedModCount); _update(key, entry, newValue); @@ -180,7 +180,7 @@ public V computeIfAbsent(K key, @NotNull Function mappin } @SuppressWarnings("ConstantValue") - public V computeIfPresent(K key, @NotNull BiFunction remappingFunction) { + public V _computeIfPresent(K key, @NotNull BiFunction remappingFunction) { if (remappingFunction == null) throw new NullPointerException(); @@ -190,7 +190,7 @@ public V computeIfPresent(K key, @NotNull BiFunction> storage = _getStorage(); return storage.size() != 0 && storage.hasKey((K) key); } - public boolean containsValue(Object value) { + public boolean _containsValue(Object value) { LibSLRuntime.Map> storage = _getStorage(); int storageSize = storage.size(); if (storageSize == 0) @@ -226,12 +226,12 @@ public boolean containsValue(Object value) { } @NotNull - public Set> entrySet() { + public Set> _entrySet() { return new Map_EntrySetImpl<>(this); } @SuppressWarnings({"unchecked", "ConstantValue"}) - public boolean equals(Object other) { + public boolean _equals(Object other) { if (other == this) return true; @@ -268,7 +268,7 @@ public boolean equals(Object other) { return true; } - public void forEach(BiConsumer userAction) { + public void _forEach(BiConsumer userAction) { if (userAction == null) throw new NullPointerException(); @@ -278,7 +278,7 @@ public void forEach(BiConsumer userAction) { return; Engine.assume(storageSize > 0); - int expectedModCount = this.modCount; + int expectedModCount = _getModCount(); LibSLRuntime.Map> unseen = storage.duplicate(); for (int i = 0; i < storageSize; i++) { K curKey = unseen.anyKey(); @@ -291,30 +291,30 @@ public void forEach(BiConsumer userAction) { } @SuppressWarnings("unchecked") - public V get(Object key) { + public V _get(Object key) { return _getEntryValueIfNotNull(_getEntry((K) key)); } @SuppressWarnings("unchecked") - public V getOrDefault(Object key, V defaultValue) { + public V _getOrDefault(Object key, V defaultValue) { return _getEntryValueIfNotNull(_getEntry((K) key), defaultValue); } - public int hashCode() { + public int _hashCode() { return LibSLRuntime.hashCode(_getStorage()); } - public boolean isEmpty() { + public boolean _isEmpty() { return _getStorage().size() == 0; } @NotNull - public Set keySet() { + public Set _keySet() { return new Map_KeySetImpl<>(this); } @SuppressWarnings("ConstantValue") - public V merge(K key, @NotNull V value, @NotNull BiFunction remappingFunction) { + public V _merge(K key, @NotNull V value, @NotNull BiFunction remappingFunction) { if (value == null) throw new NullPointerException(); @@ -329,7 +329,7 @@ public V merge(K key, @NotNull V value, @NotNull BiFunction entry = new AbstractMap_EntryImpl<>(key, value); storage.set(key, entry); - this.modCount++; + _incrementModCount(); return value; } - public V put(K key, V value) { - this.modCount++; + public V _put(K key, V value) { LibSLRuntime.Map> storage = _getStorage(); if (storage.hasKey(key)) { Map.Entry entry = storage.get(key); @@ -359,19 +358,20 @@ public V put(K key, V value) { Map.Entry entry = new AbstractMap_EntryImpl<>(key, value); storage.set(key, entry); + _incrementModCount(); return null; } @SuppressWarnings("ConstantValue") - public void putAll(@NotNull Map m) { + public void _putAll(@NotNull Map m) { if (m == null) throw new NullPointerException(); _addAllElements(m); } - public V putIfAbsent(K key, V value) { + public V _putIfAbsent(K key, V value) { LibSLRuntime.Map> storage = _getStorage(); if (storage.hasKey(key)) { Map.Entry entry = storage.get(key); @@ -380,20 +380,20 @@ public V putIfAbsent(K key, V value) { Map.Entry entry = new AbstractMap_EntryImpl<>(key, value); storage.set(key, entry); - this.modCount++; + _incrementModCount(); return null; } @SuppressWarnings("unchecked") - public V remove(Object key) { + public V _remove(Object key) { K typedKey = (K) key; LibSLRuntime.Map> storage = _getStorage(); if (storage.hasKey(typedKey)) { Map.Entry entry = storage.get(typedKey); V result = entry.getValue(); storage.remove(typedKey); - this.modCount++; + _incrementModCount(); return result; } @@ -401,7 +401,7 @@ public V remove(Object key) { } @SuppressWarnings("unchecked") - public boolean remove(Object key, Object value) { + public boolean _remove(Object key, Object value) { K typedKey = (K) key; LibSLRuntime.Map> storage = _getStorage(); if (storage.hasKey(typedKey)) { @@ -409,7 +409,7 @@ public boolean remove(Object key, Object value) { V curValue = entry.getValue(); if (LibSLRuntime.equals(curValue, value)) { storage.remove(typedKey); - this.modCount++; + _incrementModCount(); return true; } } @@ -417,7 +417,7 @@ public boolean remove(Object key, Object value) { return false; } - public V replace(K key, V value) { + public V _replace(K key, V value) { LibSLRuntime.Map> storage = _getStorage(); if (storage.hasKey(key)) { Map.Entry entry = storage.get(key); @@ -429,7 +429,7 @@ public V replace(K key, V value) { return null; } - public boolean replace(K key, V oldValue, V newValue) { + public boolean _replace(K key, V oldValue, V newValue) { LibSLRuntime.Map> storage = _getStorage(); if (storage.hasKey(key)) { Map.Entry entry = storage.get(key); @@ -443,7 +443,7 @@ public boolean replace(K key, V oldValue, V newValue) { return false; } - public void replaceAll(BiFunction function) { + public void _replaceAll(BiFunction function) { if (function == null) throw new NullPointerException(); @@ -453,7 +453,7 @@ public void replaceAll(BiFunction function) { return; Engine.assume(size > 0); - int expectedModCount = this.modCount; + int expectedModCount = _getModCount(); LibSLRuntime.Map> unseen = storage.duplicate(); for (int i = 0; i < size; i++) { K key = unseen.anyKey(); @@ -464,11 +464,11 @@ public void replaceAll(BiFunction function) { _checkForModification(expectedModCount); } - public int size() { + public int _size() { return _getStorage().size(); } - public String toString() { + public String _toString() { LibSLRuntime.Map> storage = _getStorage(); int size = storage.size(); if (size == 0) @@ -492,7 +492,7 @@ public String toString() { } @NotNull - public Collection values() { + public Collection _values() { return new Map_ValuesImpl<>(this); } diff --git a/approximations/src/main/java/generated/java/util/map/ConcurrentHashMapImpl.java b/approximations/src/main/java/generated/java/util/map/ConcurrentHashMapImpl.java index 3074b9d5..a2c35753 100644 --- a/approximations/src/main/java/generated/java/util/map/ConcurrentHashMapImpl.java +++ b/approximations/src/main/java/generated/java/util/map/ConcurrentHashMapImpl.java @@ -3,6 +3,7 @@ import org.jacodb.approximation.annotation.Approximate; import org.jetbrains.annotations.NotNull; import org.usvm.api.Engine; +import runtime.LibSLRuntime; import java.io.Serial; import java.io.Serializable; @@ -19,6 +20,10 @@ public class ConcurrentHashMapImpl extends AbstractMapImpl implement @Serial private static final long serialVersionUID = 7249069246763182397L; + private LibSLRuntime.Map> storage; + + private int modCount; + static { Engine.assume(true); } @@ -28,7 +33,7 @@ public ConcurrentHashMapImpl() { super(true); } - public ConcurrentHashMapImpl(Map m) { + public ConcurrentHashMapImpl(Map m) { super(true, m); } @@ -42,114 +47,138 @@ public ConcurrentHashMapImpl(int initialCapacity, float loadFactor) { super(true, initialCapacity, loadFactor); } + public LibSLRuntime.Map> _getStorage() { + LibSLRuntime.Map> result = this.storage; + Engine.assume(result != null); + return result; + } + + public void _setStorage(LibSLRuntime.Map> storage) { + this.storage = storage; + } + + protected int _getModCount() { + return modCount; + } + + protected void _setModCount(int newModCount) { + this.modCount = newModCount; + } + + protected boolean _isHashMap() { + return true; + } + public void clear() { - super.clear(); + super._clear(); } + @SuppressWarnings("MethodDoesntCallSuperMethod") public Object clone() throws CloneNotSupportedException { - return super.clone(); + return super._clone(); } public V compute(K key, @NotNull BiFunction remappingFunction) { - return super.compute(key, remappingFunction); + return super._compute(key, remappingFunction); } public V computeIfAbsent(K key, @NotNull Function mappingFunction) { - return super.computeIfAbsent(key, mappingFunction); + return super._computeIfAbsent(key, mappingFunction); } public V computeIfPresent(K key, @NotNull BiFunction remappingFunction) { - return super.computeIfPresent(key, remappingFunction); + return super._computeIfPresent(key, remappingFunction); } public boolean containsKey(Object key) { - return super.containsKey(key); + return super._containsKey(key); } public boolean containsValue(Object value) { - return super.containsValue(value); + return super._containsValue(value); } @NotNull public Set> entrySet() { - return super.entrySet(); + return super._entrySet(); } + @SuppressWarnings("EqualsDoesntCheckParameterClass") public boolean equals(Object other) { - return Engine.typeIs(other, ConcurrentHashMapImpl.class) && super.equals(other); + return Engine.typeIs(other, ConcurrentHashMapImpl.class) && super._equals(other); } public void forEach(BiConsumer userAction) { - super.forEach(userAction); + super._forEach(userAction); } public V get(Object key) { - return super.get(key); + return super._get(key); } public V getOrDefault(Object key, V defaultValue) { - return super.getOrDefault(key, defaultValue); + return super._getOrDefault(key, defaultValue); } public int hashCode() { - return super.hashCode(); + return super._hashCode(); } public boolean isEmpty() { - return super.isEmpty(); + return super._isEmpty(); } @NotNull public Set keySet() { - return super.keySet(); + return super._keySet(); } public V merge(K key, @NotNull V value, @NotNull BiFunction remappingFunction) { - return super.merge(key, value, remappingFunction); + return super._merge(key, value, remappingFunction); } public V put(K key, V value) { - return super.put(key, value); + return super._put(key, value); } public void putAll(@NotNull Map m) { - super.putAll(m); + super._putAll(m); } public V putIfAbsent(@NotNull K key, V value) { - return super.putIfAbsent(key, value); + return super._putIfAbsent(key, value); } public V remove(Object key) { - return super.remove(key); + return super._remove(key); } public boolean remove(@NotNull Object key, Object value) { - return super.remove(key, value); + return super._remove(key, value); } public V replace(@NotNull K key, @NotNull V value) { - return super.replace(key, value); + return super._replace(key, value); } public boolean replace(@NotNull K key, @NotNull V oldValue, @NotNull V newValue) { - return super.replace(key, oldValue, newValue); + return super._replace(key, oldValue, newValue); } public void replaceAll(BiFunction function) { - super.replaceAll(function); + super._replaceAll(function); } public int size() { - return super.size(); + return super._size(); } public String toString() { - return super.toString(); + return super._toString(); } @NotNull public Collection values() { - return super.values(); + return super._values(); } } diff --git a/approximations/src/main/java/generated/java/util/map/HashMapImpl.java b/approximations/src/main/java/generated/java/util/map/HashMapImpl.java index 3788bf1d..571c7c6c 100644 --- a/approximations/src/main/java/generated/java/util/map/HashMapImpl.java +++ b/approximations/src/main/java/generated/java/util/map/HashMapImpl.java @@ -14,6 +14,7 @@ import org.jacodb.approximation.annotation.Approximate; import org.jetbrains.annotations.NotNull; import org.usvm.api.Engine; +import runtime.LibSLRuntime; @Approximate(java.util.HashMap.class) public class HashMapImpl extends AbstractMapImpl implements Cloneable, Serializable { @@ -21,6 +22,10 @@ public class HashMapImpl extends AbstractMapImpl implements Cloneabl @Serial private static final long serialVersionUID = 362498820763181265L; + private LibSLRuntime.Map> storage; + + private int modCount; + static { Engine.assume(true); } @@ -44,114 +49,138 @@ public HashMapImpl(int initialCapacity, float loadFactor) { super(true, initialCapacity, loadFactor); } + public LibSLRuntime.Map> _getStorage() { + LibSLRuntime.Map> result = this.storage; + Engine.assume(result != null); + return result; + } + + public void _setStorage(LibSLRuntime.Map> storage) { + this.storage = storage; + } + + protected int _getModCount() { + return modCount; + } + + protected void _setModCount(int newModCount) { + this.modCount = newModCount; + } + + protected boolean _isHashMap() { + return true; + } + public void clear() { - super.clear(); + super._clear(); } + @SuppressWarnings("MethodDoesntCallSuperMethod") public Object clone() throws CloneNotSupportedException { - return super.clone(); + return super._clone(); } public V compute(K key, @NotNull BiFunction remappingFunction) { - return super.compute(key, remappingFunction); + return super._compute(key, remappingFunction); } public V computeIfAbsent(K key, @NotNull Function mappingFunction) { - return super.computeIfAbsent(key, mappingFunction); + return super._computeIfAbsent(key, mappingFunction); } public V computeIfPresent(K key, @NotNull BiFunction remappingFunction) { - return super.computeIfPresent(key, remappingFunction); + return super._computeIfPresent(key, remappingFunction); } public boolean containsKey(Object key) { - return super.containsKey(key); + return super._containsKey(key); } public boolean containsValue(Object value) { - return super.containsValue(value); + return super._containsValue(value); } @NotNull public Set> entrySet() { - return super.entrySet(); + return super._entrySet(); } + @SuppressWarnings("EqualsDoesntCheckParameterClass") public boolean equals(Object other) { - return Engine.typeIs(other, HashMapImpl.class) && super.equals(other); + return Engine.typeIs(other, HashMapImpl.class) && super._equals(other); } public void forEach(BiConsumer userAction) { - super.forEach(userAction); + super._forEach(userAction); } public V get(Object key) { - return super.get(key); + return super._get(key); } public V getOrDefault(Object key, V defaultValue) { - return super.getOrDefault(key, defaultValue); + return super._getOrDefault(key, defaultValue); } public int hashCode() { - return super.hashCode(); + return super._hashCode(); } public boolean isEmpty() { - return super.isEmpty(); + return super._isEmpty(); } @NotNull public Set keySet() { - return super.keySet(); + return super._keySet(); } public V merge(K key, @NotNull V value, @NotNull BiFunction remappingFunction) { - return super.merge(key, value, remappingFunction); + return super._merge(key, value, remappingFunction); } public V put(K key, V value) { - return super.put(key, value); + return super._put(key, value); } public void putAll(@NotNull Map m) { - super.putAll(m); + super._putAll(m); } public V putIfAbsent(K key, V value) { - return super.putIfAbsent(key, value); + return super._putIfAbsent(key, value); } public V remove(Object key) { - return super.remove(key); + return super._remove(key); } public boolean remove(Object key, Object value) { - return super.remove(key, value); + return super._remove(key, value); } public V replace(K key, V value) { - return super.replace(key, value); + return super._replace(key, value); } public boolean replace(K key, V oldValue, V newValue) { - return super.replace(key, oldValue, newValue); + return super._replace(key, oldValue, newValue); } public void replaceAll(BiFunction function) { - super.replaceAll(function); + super._replaceAll(function); } public int size() { - return super.size(); + return super._size(); } public String toString() { - return super.toString(); + return super._toString(); } @NotNull public Collection values() { - return super.values(); + return super._values(); } } diff --git a/approximations/src/main/java/generated/java/util/map/LinkedHashMapImpl.java b/approximations/src/main/java/generated/java/util/map/LinkedHashMapImpl.java index 791058b4..8b989fea 100644 --- a/approximations/src/main/java/generated/java/util/map/LinkedHashMapImpl.java +++ b/approximations/src/main/java/generated/java/util/map/LinkedHashMapImpl.java @@ -77,8 +77,9 @@ public Set> entrySet() { return super.entrySet(); } + @SuppressWarnings("EqualsDoesntCheckParameterClass") public boolean equals(Object other) { - return Engine.typeIs(other, LinkedHashMapImpl.class) && super.equals(other); + return Engine.typeIs(other, LinkedHashMapImpl.class) && super._equals(other); } public void forEach(BiConsumer userAction) { diff --git a/approximations/src/main/java/generated/java/util/map/Map_ContentsImpl.java b/approximations/src/main/java/generated/java/util/map/Map_ContentsImpl.java index 45166aa2..c00a1d45 100644 --- a/approximations/src/main/java/generated/java/util/map/Map_ContentsImpl.java +++ b/approximations/src/main/java/generated/java/util/map/Map_ContentsImpl.java @@ -24,30 +24,35 @@ public Map_ContentsImpl(AbstractMapImpl map) { this.map = map; } + public int _getModCount() { + return 0; + } + + protected void _setModCount(int newModCount) { + } + @SuppressWarnings("DataFlowIssue") - LibSLRuntime.Map> getStorage() { + LibSLRuntime.Map> _getStorage() { Engine.assume(this.map != null); return this.map._getStorage(); } abstract Content _contentByKey(LibSLRuntime.Map> storage, K key); - @SuppressWarnings("ConstantValue") protected Object[] _mapToArray() { - LibSLRuntime.Map> storage = getStorage(); - int storageSize = storage.size(); - Object[] result = new Object[storageSize]; - if (storageSize == 0) - return result; - - Engine.assume(storageSize > 0); + ArrayList items = new ArrayList<>(); + LibSLRuntime.Map> storage = _getStorage(); LibSLRuntime.Map> unseen = storage.duplicate(); - for (int i = 0; i < storageSize; i++) { + while (true) { K curKey = unseen.anyKey(); - result[i] = _contentByKey(storage, curKey); + if (!unseen.hasKey(curKey)) { + break; + } unseen.remove(curKey); + items.add(_contentByKey(storage, curKey)); } - return result; + + return items.toArray(); } public boolean add(Content e) { @@ -65,7 +70,7 @@ public void clear() { abstract boolean _containsInStorage(LibSLRuntime.Map> storage, Object o); public boolean contains(Object obj) { - LibSLRuntime.Map> storage = getStorage(); + LibSLRuntime.Map> storage = _getStorage(); if (storage.size() == 0) return false; @@ -100,7 +105,7 @@ public boolean equals(Object other) { if (c == null) return false; - if (getStorage().size() != c.size()) + if (_getStorage().size() != c.size()) return false; return containsAll(c); @@ -110,13 +115,13 @@ public void forEach(Consumer userAction) { if (userAction == null) throw new NullPointerException(); - LibSLRuntime.Map> storage = getStorage(); + LibSLRuntime.Map> storage = _getStorage(); int size = storage.size(); if (size == 0) return; Engine.assume(size > 0); - int expectedModCount = this.map.modCount; + int expectedModCount = this.map._getModCount(); LibSLRuntime.Map> unseen = storage.duplicate(); for (int i = 0; i < size; i++) { K key = unseen.anyKey(); @@ -127,18 +132,19 @@ public void forEach(Consumer userAction) { } public int hashCode() { - return LibSLRuntime.hashCode(getStorage()); + return LibSLRuntime.hashCode(_getStorage()); } public boolean isEmpty() { - return getStorage().size() == 0; + return _getStorage().size() == 0; } @NotNull public Iterator iterator() { - return new Map_Contents_IteratorImpl<>(this, getStorage().duplicate(), this.map.modCount); + return new Map_Contents_IteratorImpl<>(this, _getStorage().duplicate(), this.map._getModCount()); } + @NotNull @SuppressWarnings("unchecked") public Stream parallelStream() { Content[] items = (Content[]) _mapToArray(); @@ -152,7 +158,7 @@ public boolean removeAll(@NotNull Collection c) { if (c == null) throw new NullPointerException(); - LibSLRuntime.Map> storage = getStorage(); + LibSLRuntime.Map> storage = _getStorage(); int startStorageSize = storage.size(); int cSize = c.size(); if (startStorageSize == 0 || cSize == 0) @@ -164,7 +170,7 @@ public boolean removeAll(@NotNull Collection c) { K key = unseen.anyKey(); if (c.contains(_contentByKey(storage, key))) { storage.remove(key); - this.map.modCount++; + this.map._incrementModCount(); } unseen.remove(key); } @@ -179,11 +185,12 @@ public boolean removeAll(@NotNull Collection c) { return startStorageSize != storage.size(); } - public boolean removeIf(Predicate filter) { + @SuppressWarnings("ConstantValue") + public boolean removeIf(@NotNull Predicate filter) { if (filter == null) throw new NullPointerException(); - LibSLRuntime.Map> storage = getStorage(); + LibSLRuntime.Map> storage = _getStorage(); int startStorageSize = storage.size(); if (startStorageSize == 0) return false; @@ -193,7 +200,7 @@ public boolean removeIf(Predicate filter) { K curKey = unseen.anyKey(); if (filter.test(_contentByKey(storage, curKey))) { storage.remove(curKey); - this.map.modCount++; + this.map._incrementModCount(); } unseen.remove(curKey); } @@ -206,7 +213,7 @@ public boolean retainAll(@NotNull Collection c) { if (c == null) throw new NullPointerException(); - LibSLRuntime.Map> storage = getStorage(); + LibSLRuntime.Map> storage = _getStorage(); int startStorageSize = storage.size(); int cSize = c.size(); if (startStorageSize == 0 || cSize == 0) @@ -217,21 +224,27 @@ public boolean retainAll(@NotNull Collection c) { K curKey = unseen.anyKey(); if (!c.contains(_contentByKey(storage, curKey))) { storage.remove(curKey); - this.map.modCount++; + this.map._incrementModCount(); } } return startStorageSize != storage.size(); } + protected int _size() { + return this.map._size(); + } + public int size() { - return this.map.size(); + return _size(); } + @NotNull public Spliterator spliterator() { return new Map_Contents_SpliteratorImpl<>(this); } + @NotNull @SuppressWarnings("unchecked") public Stream stream() { Content[] items = (Content[]) _mapToArray(); @@ -240,20 +253,20 @@ public Stream stream() { @NotNull public Object[] toArray() { - return super.toArray(); + return super._toArray(); } - public T[] toArray(IntFunction generator) { - return super.toArray(generator); + public T[] toArray(@NotNull IntFunction generator) { + return super._toArray(generator); } @NotNull public T[] toArray(@NotNull T[] array) { - return super.toArray(array); + return super._toArray(array); } - public String toString() { - LibSLRuntime.Map> storage = getStorage(); + protected String _toString() { + LibSLRuntime.Map> storage = _getStorage(); int size = storage.size(); if (size == 0) return "[]"; @@ -272,4 +285,8 @@ public String toString() { return result.concat("]"); } + + public String toString() { + return _toString(); + } } diff --git a/approximations/src/main/java/generated/java/util/map/Map_ContentsSetImpl.java b/approximations/src/main/java/generated/java/util/map/Map_ContentsSetImpl.java index aeb1d5f6..1154a835 100644 --- a/approximations/src/main/java/generated/java/util/map/Map_ContentsSetImpl.java +++ b/approximations/src/main/java/generated/java/util/map/Map_ContentsSetImpl.java @@ -65,6 +65,7 @@ public Iterator iterator() { return super.iterator(); } + @NotNull public Stream parallelStream() { return super.parallelStream(); } @@ -73,7 +74,7 @@ public boolean removeAll(@NotNull Collection c) { return super.removeAll(c); } - public boolean removeIf(Predicate filter) { + public boolean removeIf(@NotNull Predicate filter) { return super.removeIf(filter); } @@ -85,10 +86,12 @@ public int size() { return super.size(); } + @NotNull public Spliterator spliterator() { return new Map_ContentsSet_SpliteratorImpl<>(this); } + @NotNull public Stream stream() { return super.stream(); } @@ -98,7 +101,7 @@ public Object[] toArray() { return super.toArray(); } - public T[] toArray(IntFunction generator) { + public T[] toArray(@NotNull IntFunction generator) { return super.toArray(generator); } diff --git a/approximations/src/main/java/generated/java/util/map/Map_Contents_IteratorImpl.java b/approximations/src/main/java/generated/java/util/map/Map_Contents_IteratorImpl.java index 258d5a3a..3d7714c8 100644 --- a/approximations/src/main/java/generated/java/util/map/Map_Contents_IteratorImpl.java +++ b/approximations/src/main/java/generated/java/util/map/Map_Contents_IteratorImpl.java @@ -43,10 +43,11 @@ private AbstractMapImpl _getMap() { } protected int _parentModCount() { - return _getMap().modCount; + return _getMap()._getModCount(); } private boolean _isEmpty() { + // TODO: make via 'contains(unseen.anyKey) == false' return this.unseen.size() == 0; } @@ -91,9 +92,9 @@ public void remove() { _checkForModification(); AbstractMapImpl map = _getMap(); map._getStorage().remove(key); - map.modCount++; + map._incrementModCount(); this.unseen.remove(key); - this.expectedModCount = map.modCount; + this.expectedModCount = map._getModCount(); this.currentKey = null; } } diff --git a/approximations/src/main/java/generated/java/util/map/Map_Contents_SpliteratorImpl.java b/approximations/src/main/java/generated/java/util/map/Map_Contents_SpliteratorImpl.java index bb3ac0e3..7bf870bc 100644 --- a/approximations/src/main/java/generated/java/util/map/Map_Contents_SpliteratorImpl.java +++ b/approximations/src/main/java/generated/java/util/map/Map_Contents_SpliteratorImpl.java @@ -22,6 +22,12 @@ public class Map_Contents_SpliteratorImpl extends AbstractSpliter SymbolicList unseenKeys; + public int index; + + public int fence; + + public int expectedModCount; + Map_Contents_SpliteratorImpl( Map_ContentsImpl contents, SymbolicList seenKeys, @@ -40,6 +46,30 @@ public Map_Contents_SpliteratorImpl(Map_ContentsImpl contents) { this(contents, Engine.makeSymbolicList(), null, 0, -1, 0); } + protected int _getIndex() { + return index; + } + + protected void _setIndex(int newIndex) { + this.index = newIndex; + } + + protected int _getFence() { + return fence; + } + + protected void _setFence(int newFence) { + this.fence = newFence; + } + + protected int _getExpectedModCount() { + return expectedModCount; + } + + protected void _setExpectedModCount(int newExpectedModCount) { + this.expectedModCount = newExpectedModCount; + } + protected AbstractSpliteratorImpl _create(int index, int fence) { return null; } @@ -67,26 +97,31 @@ private AbstractMapImpl _getMap() { } protected int _parentModCount() { - return _getMap().modCount; + return _getMap()._getModCount(); } protected int _storageSize() { - return _getContents().getStorage().size(); + return _getContents()._getStorage().size(); } protected int _defaultCharacteristics() { return 0; } - public int characteristics() { + protected int _characteristics() { if (this.fence < 0 || this.index == 0 && this.fence == _storageSize()) return LibSLGlobals.SPLITERATOR_SIZED | _defaultCharacteristics(); return _defaultCharacteristics(); } + @SuppressWarnings("MagicConstant") + public int characteristics() { + return _characteristics(); + } + public long estimateSize() { - return super.estimateSize(); + return super._estimateSize(); } private int _checkSizeOfUnseenKeys() { @@ -106,7 +141,7 @@ private int _checkSizeOfSeenKeys() { } private LibSLRuntime.Map> _removeSeenKeys() { - LibSLRuntime.Map> storage = _getContents().getStorage().duplicate(); + LibSLRuntime.Map> storage = _getContents()._getStorage().duplicate(); int size = _checkSizeOfSeenKeys(); for (int i = 0; i < size; i++) { K key = seenKeys.get(i); @@ -116,16 +151,16 @@ private LibSLRuntime.Map> _removeSeenKeys() { return storage; } - public void forEachRemaining(Consumer userAction) { + protected void _forEachRemaining(Consumer userAction) { if (userAction == null) throw new NullPointerException(); - int fence = _getFence(); + int fence = _fence(); Map_ContentsImpl contents = _getContents(); if (unseenKeys != null) { _checkSizeOfSeenKeys(); int size = _checkSizeOfUnseenKeys(); - LibSLRuntime.Map> storage = contents.getStorage(); + LibSLRuntime.Map> storage = contents._getStorage(); for (int i = 0; i < size; i++) { K key = unseenKeys.get(i); userAction.accept(contents._contentByKey(storage, key)); @@ -145,15 +180,19 @@ public void forEachRemaining(Consumer userAction) { _checkForModification(); } + public void forEachRemaining(Consumer userAction) { + _forEachRemaining(userAction); + } + public long getExactSizeIfKnown() { - return super.getExactSizeIfKnown(); + return super._getExactSizeIfKnown(); } - public boolean tryAdvance(Consumer userAction) { + protected boolean _tryAdvance(Consumer userAction) { if (userAction == null) throw new NullPointerException(); - int hi = _getFence(); + int hi = _fence(); if (this.index >= hi) return false; @@ -162,7 +201,7 @@ public boolean tryAdvance(Consumer userAction) { _checkSizeOfSeenKeys(); _checkSizeOfUnseenKeys(); K key = unseenKeys.get(0); - LibSLRuntime.Map> storage = contents.getStorage(); + LibSLRuntime.Map> storage = contents._getStorage(); userAction.accept(contents._contentByKey(storage, key)); unseenKeys.remove(0); seenKeys.insert(this.index, key); @@ -179,8 +218,12 @@ public boolean tryAdvance(Consumer userAction) { return true; } + public boolean tryAdvance(Consumer userAction) { + return _tryAdvance(userAction); + } + public Map_Contents_SpliteratorImpl trySplit() { - int hi = _getFence(); + int hi = _fence(); int lo = this.index; int mid = (hi + lo) >>> 1; if (lo >= mid) diff --git a/approximations/src/main/java/generated/java/util/map/Map_EntrySetImpl.java b/approximations/src/main/java/generated/java/util/map/Map_EntrySetImpl.java index 92c18664..cd5a86f1 100644 --- a/approximations/src/main/java/generated/java/util/map/Map_EntrySetImpl.java +++ b/approximations/src/main/java/generated/java/util/map/Map_EntrySetImpl.java @@ -78,6 +78,7 @@ public Iterator> iterator() { return super.iterator(); } + @NotNull public Stream> parallelStream() { return super.parallelStream(); } @@ -89,12 +90,12 @@ public boolean remove(Object o) { Map.Entry typedOtherEntry = (Map.Entry) o; K key = typedOtherEntry.getKey(); - LibSLRuntime.Map> storage = getStorage(); + LibSLRuntime.Map> storage = _getStorage(); if (storage.hasKey(key)) { Map.Entry entry = storage.get(key); if (LibSLRuntime.equals(entry, typedOtherEntry)) { storage.remove(key); - this.map.modCount++; + this.map._incrementModCount(); return true; } } @@ -106,7 +107,7 @@ public boolean removeAll(@NotNull Collection c) { return super.removeAll(c); } - public boolean removeIf(Predicate> filter) { + public boolean removeIf(@NotNull Predicate> filter) { return super.removeIf(filter); } @@ -118,10 +119,12 @@ public int size() { return super.size(); } + @NotNull public Spliterator> spliterator() { return super.spliterator(); } + @NotNull public Stream> stream() { return super.stream(); } @@ -131,7 +134,7 @@ public Object[] toArray() { return super.toArray(); } - public T[] toArray(IntFunction generator) { + public T[] toArray(@NotNull IntFunction generator) { return super.toArray(generator); } diff --git a/approximations/src/main/java/generated/java/util/map/Map_KeySetImpl.java b/approximations/src/main/java/generated/java/util/map/Map_KeySetImpl.java index 4caa9c6d..7f0b23ad 100644 --- a/approximations/src/main/java/generated/java/util/map/Map_KeySetImpl.java +++ b/approximations/src/main/java/generated/java/util/map/Map_KeySetImpl.java @@ -70,6 +70,7 @@ public Iterator iterator() { return super.iterator(); } + @NotNull public Stream parallelStream() { return super.parallelStream(); } @@ -77,10 +78,10 @@ public Stream parallelStream() { @SuppressWarnings("unchecked") public boolean remove(Object key) { K typedKey = (K) key; - LibSLRuntime.Map> storage = getStorage(); + LibSLRuntime.Map> storage = _getStorage(); if (storage.hasKey(typedKey)) { storage.remove(typedKey); - this.map.modCount++; + this.map._incrementModCount(); return true; } @@ -91,7 +92,7 @@ public boolean removeAll(@NotNull Collection c) { return super.removeAll(c); } - public boolean removeIf(Predicate filter) { + public boolean removeIf(@NotNull Predicate filter) { return super.removeIf(filter); } @@ -103,10 +104,12 @@ public int size() { return super.size(); } + @NotNull public Spliterator spliterator() { return super.spliterator(); } + @NotNull public Stream stream() { return super.stream(); } @@ -116,7 +119,7 @@ public Object[] toArray() { return super.toArray(); } - public T[] toArray(IntFunction generator) { + public T[] toArray(@NotNull IntFunction generator) { return super.toArray(generator); } diff --git a/approximations/src/main/java/generated/java/util/map/Map_ValuesImpl.java b/approximations/src/main/java/generated/java/util/map/Map_ValuesImpl.java index 9ce4255b..e983829f 100644 --- a/approximations/src/main/java/generated/java/util/map/Map_ValuesImpl.java +++ b/approximations/src/main/java/generated/java/util/map/Map_ValuesImpl.java @@ -39,7 +39,7 @@ public void clear() { } boolean _containsInStorage(LibSLRuntime.Map> storage, Object value) { - LibSLRuntime.Map> unseen = getStorage().duplicate(); + LibSLRuntime.Map> unseen = _getStorage().duplicate(); int size = unseen.size(); Engine.assume(size > 0); for (int i = 0; i < size; i++) { @@ -76,12 +76,13 @@ public Iterator iterator() { return super.iterator(); } + @NotNull public Stream parallelStream() { return super.parallelStream(); } public boolean remove(Object value) { - LibSLRuntime.Map> storage = getStorage(); + LibSLRuntime.Map> storage = _getStorage(); LibSLRuntime.Map> unseen = storage.duplicate(); int size = unseen.size(); Engine.assume(size >= 0); @@ -91,7 +92,7 @@ public boolean remove(Object value) { V curValue = entry.getValue(); if (LibSLRuntime.equals(curValue, value)) { storage.remove(key); - this.map.modCount++; + this.map._incrementModCount(); return true; } @@ -105,7 +106,7 @@ public boolean removeAll(@NotNull Collection c) { return super.removeAll(c); } - public boolean removeIf(Predicate filter) { + public boolean removeIf(@NotNull Predicate filter) { return super.removeIf(filter); } @@ -117,10 +118,12 @@ public int size() { return super.size(); } + @NotNull public Spliterator spliterator() { return super.spliterator(); } + @NotNull public Stream stream() { return super.stream(); } @@ -130,7 +133,7 @@ public Object[] toArray() { return super.toArray(); } - public T[] toArray(IntFunction generator) { + public T[] toArray(@NotNull IntFunction generator) { return super.toArray(generator); } diff --git a/approximations/src/main/java/generated/java/util/set/AbstractSetImpl.java b/approximations/src/main/java/generated/java/util/set/AbstractSetImpl.java index 78116933..e2b487a3 100644 --- a/approximations/src/main/java/generated/java/util/set/AbstractSetImpl.java +++ b/approximations/src/main/java/generated/java/util/set/AbstractSetImpl.java @@ -21,29 +21,24 @@ @Approximate(java.util.AbstractSet.class) public abstract class AbstractSetImpl extends AbstractCollectionImpl implements Set { - public LibSLRuntime.Map storage; - - private boolean isHashSet; - - private static LibSLRuntime.Map.Container createContainer(boolean isHashSet) { + private static LibSLRuntime.Map.Container _createContainer(boolean isHashSet) { if (isHashSet) return new LibSLRuntime.HashMapContainer<>(); return new LibSLRuntime.IdentityMapContainer<>(); } - private static LibSLRuntime.Map createStorage(boolean isHashSet) { - return new LibSLRuntime.Map<>(createContainer(isHashSet)); + private static LibSLRuntime.Map _createStorage(boolean isHashSet) { + return new LibSLRuntime.Map<>(_createContainer(isHashSet)); } - public AbstractSetImpl(LibSLRuntime.Map storage, int modCount, boolean isHashSet) { + public AbstractSetImpl(LibSLRuntime.Map storage, int modCount) { super(modCount); - this.storage = storage; - this.isHashSet = isHashSet; + _setStorage(storage); } public AbstractSetImpl(boolean isHashSet) { - this(createStorage(isHashSet), 0, isHashSet); + this(_createStorage(isHashSet), 0); } @SuppressWarnings("unused") @@ -59,11 +54,10 @@ public AbstractSetImpl(boolean isHashSet, int initialCapacity) { if (initialCapacity < 0) throw new IllegalArgumentException(); - this.storage = createStorage(isHashSet); - this.isHashSet = isHashSet; + _setStorage(_createStorage(isHashSet)); } - @SuppressWarnings("unused") + @SuppressWarnings({"unused", "ExpressionComparedToItself"}) public AbstractSetImpl(boolean isHashSet, int initialCapacity, float loadFactor) { super(0); @@ -73,8 +67,7 @@ public AbstractSetImpl(boolean isHashSet, int initialCapacity, float loadFactor) if (loadFactor <= 0 || loadFactor != loadFactor) throw new IllegalArgumentException(); - this.storage = createStorage(isHashSet); - this.isHashSet = isHashSet; + _setStorage(_createStorage(isHashSet)); } @SuppressWarnings("unused") @@ -83,13 +76,13 @@ public AbstractSetImpl(int initialCapacity, float loadFactor, boolean dummy) { LibSLRuntime.error("Private constructor call"); } - public LibSLRuntime.Map _getStorage() { - LibSLRuntime.Map storage = this.storage; - Engine.assume(storage != null); - return storage; - } + public abstract LibSLRuntime.Map _getStorage(); - private void _add(E key) { + public abstract void _setStorage(LibSLRuntime.Map storage); + + abstract protected boolean _isHashSet(); + + private void _internalAdd(E key) { _getStorage().set(key, LibSLGlobals.SOMETHING); } @@ -105,12 +98,12 @@ public boolean _addAllElements(Collection c) { } else { for (E key : c) { if (!storage.hasKey(key)) - _add(key); + _internalAdd(key); } } if (lengthBeforeAdd != storage.size()) { - this.modCount++; + _incrementModCount(); return true; } @@ -118,15 +111,18 @@ public boolean _addAllElements(Collection c) { } protected Object[] _mapToArray() { - int size = _getStorage().size(); - Object[] items = new Object[size]; + ArrayList items = new ArrayList<>(); LibSLRuntime.Map unseen = _getStorage().duplicate(); - for (int i = 0; i < size; i++) { + while (true) { E key = unseen.anyKey(); + if (!unseen.hasKey(key)) { + break; + } unseen.remove(key); - items[i] = key; + items.add(key); } - return items; + + return items.toArray(); } @SuppressWarnings("unchecked") @@ -135,9 +131,9 @@ public Stream _makeStream(boolean parallel) { return new StreamStubImpl<>(items, parallel); } - public boolean add(E obj) { + public boolean _add(E obj) { LibSLRuntime.Map storage = _getStorage(); - this.modCount++; + _incrementModCount(); if (storage.hasKey(obj)) return false; @@ -145,69 +141,69 @@ public boolean add(E obj) { return true; } - public void clear() { - this.storage = createStorage(this.isHashSet); - this.modCount++; + public void _clear() { + _setStorage(_createStorage(_isHashSet())); + _incrementModCount(); } @SuppressWarnings("unchecked") - public Object clone() throws CloneNotSupportedException { + public Object _clone() throws CloneNotSupportedException { AbstractSetImpl clonedSet = (AbstractSetImpl) super.clone(); - clonedSet.modCount = 0; - clonedSet.storage = _getStorage().duplicate(); + clonedSet._setModCount(0); + clonedSet._setStorage(_getStorage().duplicate()); return clonedSet; } @SuppressWarnings("unchecked") - public boolean contains(Object obj) { + public boolean _contains(Object obj) { if (isEmpty()) return false; return _getStorage().hasKey((E) obj); } - public boolean isEmpty() { + public boolean _isEmpty() { return _getStorage().size() == 0; } @NotNull - public Iterator iterator() { + public Iterator _iterator() { LibSLRuntime.Map unseenKeys = _getStorage().duplicate(); - return new Set_IteratorImpl<>(this.modCount, unseenKeys, this, null); + return new Set_IteratorImpl<>(_getModCount(), unseenKeys, this, null); } @SuppressWarnings("unchecked") - public boolean remove(Object elem) { + public boolean _remove(Object elem) { E typedElem = (E) elem; LibSLRuntime.Map storage = _getStorage(); if (storage.hasKey(typedElem)) { storage.remove(typedElem); - this.modCount++; + _incrementModCount(); return true; } return false; } - public int size() { + public int _size() { return _getStorage().size(); } - public Spliterator spliterator() { + public Spliterator _spliterator() { return new Set_SpliteratorImpl<>(this); } @SuppressWarnings("unchecked") - public boolean equals(Object other) { + public boolean _equals(Object other) { if (other == this) return true; if (!(other instanceof Set)) return false; - int expectedModCount = this.modCount; + int expectedModCount = _getModCount(); AbstractSetImpl otherSet = (AbstractSetImpl) other; - int otherExpectedModCount = otherSet.modCount; + int otherExpectedModCount = otherSet._getModCount(); LibSLRuntime.Map otherStorage = otherSet._getStorage(); LibSLRuntime.Map storage = _getStorage(); @@ -221,17 +217,17 @@ public boolean equals(Object other) { return result; } - public int hashCode() { + public int _hashCode() { return LibSLRuntime.hashCode(_getStorage()); } @SuppressWarnings({"ConstantValue", "unchecked"}) - public boolean removeAll(@NotNull Collection c) { + public boolean _removeAll(@NotNull Collection c) { if (c == null) { throw new NullPointerException(); } - int expectedModCount = this.modCount; + int expectedModCount = _getModCount(); int otherSize = c.size(); LibSLRuntime.Map storage = _getStorage(); int lengthBeforeRemoving = storage.size(); @@ -254,26 +250,26 @@ public boolean removeAll(@NotNull Collection c) { } } _checkForModification(expectedModCount); - this.modCount++; + _incrementModCount(); return lengthBeforeRemoving != storage.size(); } @NotNull - public Object[] toArray() { - return super.toArray(); + public Object[] _toArray() { + return super._toArray(); } @NotNull - public T[] toArray(@NotNull T[] array) { - return super.toArray(array); + public T[] _toArray(@NotNull T[] array) { + return super._toArray(array); } - public T[] toArray(IntFunction generator) { - return super.toArray(generator); + public T[] _toArray(IntFunction generator) { + return super._toArray(generator); } @SuppressWarnings("unchecked") - public boolean containsAll(@NotNull Collection c) { + public boolean _containsAll(@NotNull Collection c) { LibSLRuntime.Map storage = _getStorage(); for (Object key : c) { if (!storage.hasKey((E) key)) @@ -283,12 +279,12 @@ public boolean containsAll(@NotNull Collection c) { return true; } - public boolean addAll(@NotNull Collection c) { + public boolean _addAll(@NotNull Collection c) { return _addAllElements(c); } @SuppressWarnings("ConstantValue") - public boolean retainAll(@NotNull Collection c) { + public boolean _retainAll(@NotNull Collection c) { if (c == null) throw new NullPointerException(); @@ -304,20 +300,20 @@ public boolean retainAll(@NotNull Collection c) { i++; } if (lengthBeforeAdd != storage.size()) { - this.modCount++; + _incrementModCount(); return true; } return false; } - public boolean removeIf(Predicate filter) { + public boolean _removeIf(Predicate filter) { if (filter == null) throw new NullPointerException(); LibSLRuntime.Map storage = _getStorage(); int lengthBeforeAdd = storage.size(); - int expectedModCount = this.modCount; + int expectedModCount = _getModCount(); LibSLRuntime.Map unseenKeys = storage.duplicate(); int i = 0; while (i < lengthBeforeAdd) { @@ -329,20 +325,20 @@ public boolean removeIf(Predicate filter) { } _checkForModification(expectedModCount); if (lengthBeforeAdd != storage.size()) { - this.modCount++; + _incrementModCount(); return true; } return false; } - public void forEach(Consumer userAction) { + public void _forEach(Consumer userAction) { if (userAction == null) throw new NullPointerException(); LibSLRuntime.Map storage = _getStorage(); int count = storage.size(); - int expectedModCount = this.modCount; + int expectedModCount = _getModCount(); LibSLRuntime.Map unseenKeys = storage.duplicate(); int i = 0; while (i < count) { @@ -354,15 +350,15 @@ public void forEach(Consumer userAction) { _checkForModification(expectedModCount); } - public Stream stream() { + public Stream _stream() { return _makeStream(false); } - public Stream parallelStream() { + public Stream _parallelStream() { return _makeStream(true); } - public String toString() { + public String _toString() { LibSLRuntime.Map storage = _getStorage(); int count = storage.size(); if (count == 0) diff --git a/approximations/src/main/java/generated/java/util/set/HashSetImpl.java b/approximations/src/main/java/generated/java/util/set/HashSetImpl.java index 722abe06..3c2601b4 100644 --- a/approximations/src/main/java/generated/java/util/set/HashSetImpl.java +++ b/approximations/src/main/java/generated/java/util/set/HashSetImpl.java @@ -14,6 +14,7 @@ import org.jacodb.approximation.annotation.Approximate; import org.jetbrains.annotations.NotNull; import org.usvm.api.Engine; +import runtime.LibSLRuntime; @Approximate(java.util.HashSet.class) public class HashSetImpl extends AbstractSetImpl implements Cloneable, Serializable { @@ -21,6 +22,10 @@ public class HashSetImpl extends AbstractSetImpl implements Cloneable, Ser @Serial private static final long serialVersionUID = -5024744406713321676L; + private LibSLRuntime.Map storage; + + private int modCount; + static { Engine.assume(true); } @@ -46,98 +51,125 @@ private HashSetImpl(int initialCapacity, float loadFactor, boolean dummy) { super(initialCapacity, loadFactor, dummy); } + public LibSLRuntime.Map _getStorage() { + LibSLRuntime.Map storage = this.storage; + Engine.assume(storage != null); + return storage; + } + + public void _setStorage(LibSLRuntime.Map storage) { + this.storage = storage; + } + + protected boolean _isHashSet() { + return true; + } + + public int _getModCount() { + return modCount; + } + + protected void _setModCount(int newModCount) { + this.modCount = newModCount; + } + public boolean add(E obj) { - return super.add(obj); + return super._add(obj); } public void clear() { - super.clear(); + super._clear(); } + @SuppressWarnings("MethodDoesntCallSuperMethod") public Object clone() throws CloneNotSupportedException { - return super.clone(); + return super._clone(); } public boolean contains(Object obj) { - return super.contains(obj); + return super._contains(obj); } public boolean isEmpty() { - return super.isEmpty(); + return super._isEmpty(); } @NotNull public Iterator iterator() { - return super.iterator(); + return super._iterator(); } public boolean remove(Object elem) { - return super.remove(elem); + return super._remove(elem); } public int size() { - return super.size(); + return super._size(); } + @NotNull public Spliterator spliterator() { - return super.spliterator(); + return super._spliterator(); } + @SuppressWarnings("EqualsDoesntCheckParameterClass") public boolean equals(Object other) { - return Engine.typeIs(other, HashSetImpl.class) && super.equals(other); + return Engine.typeIs(other, HashSetImpl.class) && super._equals(other); } public int hashCode() { - return super.hashCode(); + return super._hashCode(); } public boolean removeAll(@NotNull Collection c) { - return super.removeAll(c); + return super._removeAll(c); } @NotNull public Object[] toArray() { - return super.toArray(); + return super._toArray(); } @NotNull public T[] toArray(@NotNull T[] a) { - return super.toArray(a); + return super._toArray(a); } - public T[] toArray(IntFunction generator) { - return super.toArray(generator); + public T[] toArray(@NotNull IntFunction generator) { + return super._toArray(generator); } public boolean containsAll(@NotNull Collection c) { - return super.containsAll(c); + return super._containsAll(c); } public boolean addAll(@NotNull Collection c) { - return super.addAll(c); + return super._addAll(c); } public boolean retainAll(@NotNull Collection c) { - return super.retainAll(c); + return super._retainAll(c); } - public boolean removeIf(Predicate filter) { - return super.removeIf(filter); + public boolean removeIf(@NotNull Predicate filter) { + return super._removeIf(filter); } public void forEach(Consumer userAction) { - super.forEach(userAction); + super._forEach(userAction); } + @NotNull public Stream stream() { - return super.stream(); + return super._stream(); } + @NotNull public Stream parallelStream() { - return super.parallelStream(); + return super._parallelStream(); } public String toString() { - return super.toString(); + return super._toString(); } } diff --git a/approximations/src/main/java/generated/java/util/set/LinkedHashSetImpl.java b/approximations/src/main/java/generated/java/util/set/LinkedHashSetImpl.java index 46fe05df..d44705b4 100644 --- a/approximations/src/main/java/generated/java/util/set/LinkedHashSetImpl.java +++ b/approximations/src/main/java/generated/java/util/set/LinkedHashSetImpl.java @@ -73,12 +73,14 @@ public int size() { return super.size(); } + @NotNull public Spliterator spliterator() { return super.spliterator(); } + @SuppressWarnings("EqualsDoesntCheckParameterClass") public boolean equals(Object other) { - return Engine.typeIs(other, LinkedHashSetImpl.class) && super.equals(other); + return Engine.typeIs(other, LinkedHashSetImpl.class) && super._equals(other); } public int hashCode() { @@ -99,7 +101,7 @@ public T[] toArray(@NotNull T[] a) { return super.toArray(a); } - public T[] toArray(IntFunction generator) { + public T[] toArray(@NotNull IntFunction generator) { return super.toArray(generator); } @@ -115,7 +117,7 @@ public boolean retainAll(@NotNull Collection c) { return super.retainAll(c); } - public boolean removeIf(Predicate filter) { + public boolean removeIf(@NotNull Predicate filter) { return super.removeIf(filter); } @@ -123,10 +125,12 @@ public void forEach(Consumer userAction) { super.forEach(userAction); } + @NotNull public Stream stream() { return super.stream(); } + @NotNull public Stream parallelStream() { return super.parallelStream(); } diff --git a/approximations/src/main/java/generated/java/util/set/Set_IteratorImpl.java b/approximations/src/main/java/generated/java/util/set/Set_IteratorImpl.java index 450cd3e0..98158b54 100644 --- a/approximations/src/main/java/generated/java/util/set/Set_IteratorImpl.java +++ b/approximations/src/main/java/generated/java/util/set/Set_IteratorImpl.java @@ -40,7 +40,7 @@ private AbstractSetImpl _getSet() { } protected int _parentModCount() { - return _getSet().modCount; + return _getSet()._getModCount(); } private boolean _isEmpty() { @@ -85,9 +85,9 @@ public void remove() { _checkForModification(); AbstractSetImpl set = _getSet(); set._getStorage().remove(key); - set.modCount++; + set._incrementModCount(); this.unseen.remove(key); - this.expectedModCount = set.modCount; + this.expectedModCount = set._getModCount(); this.currentKey = null; } } diff --git a/approximations/src/main/java/generated/java/util/set/Set_SpliteratorImpl.java b/approximations/src/main/java/generated/java/util/set/Set_SpliteratorImpl.java index 2afb32fe..7acad512 100644 --- a/approximations/src/main/java/generated/java/util/set/Set_SpliteratorImpl.java +++ b/approximations/src/main/java/generated/java/util/set/Set_SpliteratorImpl.java @@ -22,6 +22,12 @@ public final class Set_SpliteratorImpl extends AbstractSpliteratorImpl { SymbolicList unseenKeys; + public int index; + + public int fence; + + public int expectedModCount; + Set_SpliteratorImpl( AbstractSetImpl set, SymbolicList seenKeys, @@ -40,6 +46,30 @@ public Set_SpliteratorImpl(AbstractSetImpl set) { this(set, Engine.makeSymbolicList(), null, 0, -1, 0); } + protected int _getIndex() { + return index; + } + + protected void _setIndex(int newIndex) { + this.index = newIndex; + } + + protected int _getFence() { + return fence; + } + + protected void _setFence(int newFence) { + this.fence = newFence; + } + + protected int _getExpectedModCount() { + return expectedModCount; + } + + protected void _setExpectedModCount(int newExpectedModCount) { + this.expectedModCount = newExpectedModCount; + } + protected AbstractSpliteratorImpl _create(int index, int fence) { return null; } @@ -51,22 +81,27 @@ private AbstractSetImpl _getSet() { } protected int _parentModCount() { - return _getSet().modCount; + return _getSet()._getModCount(); } protected int _storageSize() { return _getSet()._getStorage().size(); } - public int characteristics() { + protected int _characteristics() { if (this.fence < 0 || this.index == 0 && this.fence == _storageSize()) return LibSLGlobals.SPLITERATOR_SIZED | LibSLGlobals.SPLITERATOR_DISTINCT; return LibSLGlobals.SPLITERATOR_DISTINCT; } + @SuppressWarnings("MagicConstant") + public int characteristics() { + return _characteristics(); + } + public long estimateSize() { - return super.estimateSize(); + return super._estimateSize(); } private int _checkSizeOfUnseenKeys() { @@ -96,11 +131,11 @@ private LibSLRuntime.Map _removeSeenKeys() { return storage; } - public void forEachRemaining(Consumer userAction) { + protected void _forEachRemaining(Consumer userAction) { if (userAction == null) throw new NullPointerException(); - int fence = _getFence(); + int fence = _fence(); if (unseenKeys != null) { _checkSizeOfSeenKeys(); int size = _checkSizeOfUnseenKeys(); @@ -123,15 +158,19 @@ public void forEachRemaining(Consumer userAction) { _checkForModification(); } + public void forEachRemaining(Consumer userAction) { + _forEachRemaining(userAction); + } + public long getExactSizeIfKnown() { - return super.getExactSizeIfKnown(); + return super._getExactSizeIfKnown(); } - public boolean tryAdvance(Consumer userAction) { + protected boolean _tryAdvance(Consumer userAction) { if (userAction == null) throw new NullPointerException(); - int hi = _getFence(); + int hi = _fence(); if (this.index >= hi) return false; @@ -155,8 +194,12 @@ public boolean tryAdvance(Consumer userAction) { return true; } - public Set_SpliteratorImpl trySplit() { - int hi = _getFence(); + public boolean tryAdvance(Consumer userAction) { + return _tryAdvance(userAction); + } + + protected Set_SpliteratorImpl _trySplit() { + int hi = _fence(); int lo = this.index; int mid = (hi + lo) >>> 1; if (lo >= mid) @@ -176,4 +219,8 @@ public Set_SpliteratorImpl trySplit() { this.index = mid; return new Set_SpliteratorImpl<>(this.set, newSeenKeys, newUnseenKeys, lo, mid, this.expectedModCount); } + + public Set_SpliteratorImpl trySplit() { + return _trySplit(); + } } diff --git a/approximations/src/main/java/generated/java/util/stream/BaseStreamImpl.java b/approximations/src/main/java/generated/java/util/stream/BaseStreamImpl.java index df1dbe22..656bea4c 100644 --- a/approximations/src/main/java/generated/java/util/stream/BaseStreamImpl.java +++ b/approximations/src/main/java/generated/java/util/stream/BaseStreamImpl.java @@ -39,19 +39,19 @@ protected SymbolicList _getCloseHandlers() { } protected StreamStubImpl _copyToObjStream(T[] storage) { - return new StreamStubImpl<>(storage, _getCloseHandlers(), isParallel, linkedOrConsumed); + return new StreamStubImpl<>(storage, _getCloseHandlers(), isParallel, false); } protected IntStreamImpl _copyToIntStream(int[] storage) { - return new IntStreamImpl(storage, _getCloseHandlers(), isParallel, linkedOrConsumed); + return new IntStreamImpl(storage, _getCloseHandlers(), isParallel, false); } protected LongStreamImpl _copyToLongStream(long[] storage) { - return new LongStreamImpl(storage, _getCloseHandlers(), isParallel, linkedOrConsumed); + return new LongStreamImpl(storage, _getCloseHandlers(), isParallel, false); } protected DoubleStreamImpl _copyToDoubleStream(double[] storage) { - return new DoubleStreamImpl(storage, _getCloseHandlers(), isParallel, linkedOrConsumed); + return new DoubleStreamImpl(storage, _getCloseHandlers(), isParallel, false); } public void evaluate() { diff --git a/approximations/src/main/java/generated/java/util/stream/DoubleStreamImpl.java b/approximations/src/main/java/generated/java/util/stream/DoubleStreamImpl.java index c5779c9b..f9bd64a0 100644 --- a/approximations/src/main/java/generated/java/util/stream/DoubleStreamImpl.java +++ b/approximations/src/main/java/generated/java/util/stream/DoubleStreamImpl.java @@ -68,7 +68,7 @@ protected int _getLength() { } private DoubleStreamImpl _copy(double[] storage) { - return new DoubleStreamImpl(storage, _getCloseHandlers(), isParallel, linkedOrConsumed); + return new DoubleStreamImpl(storage, _getCloseHandlers(), isParallel, false); } private DoubleStreamImpl _copy() { diff --git a/approximations/src/main/java/generated/java/util/stream/IntStreamImpl.java b/approximations/src/main/java/generated/java/util/stream/IntStreamImpl.java index 04f57a43..d00243ff 100644 --- a/approximations/src/main/java/generated/java/util/stream/IntStreamImpl.java +++ b/approximations/src/main/java/generated/java/util/stream/IntStreamImpl.java @@ -66,7 +66,7 @@ protected int _getLength() { } private IntStreamImpl _copy(int[] storage) { - return new IntStreamImpl(storage, _getCloseHandlers(), isParallel, linkedOrConsumed); + return new IntStreamImpl(storage, _getCloseHandlers(), isParallel, false); } private IntStreamImpl _copy() { diff --git a/approximations/src/main/java/generated/java/util/stream/LongStreamImpl.java b/approximations/src/main/java/generated/java/util/stream/LongStreamImpl.java index b7ba0843..9628acd3 100644 --- a/approximations/src/main/java/generated/java/util/stream/LongStreamImpl.java +++ b/approximations/src/main/java/generated/java/util/stream/LongStreamImpl.java @@ -66,7 +66,7 @@ protected int _getLength() { } private LongStreamImpl _copy(long[] storage) { - return new LongStreamImpl(storage, _getCloseHandlers(), isParallel, linkedOrConsumed); + return new LongStreamImpl(storage, _getCloseHandlers(), isParallel, false); } private LongStreamImpl _copy() { diff --git a/approximations/src/main/java/generated/java/util/stream/StreamStubImpl.java b/approximations/src/main/java/generated/java/util/stream/StreamStubImpl.java index c404dd87..6fb83caf 100644 --- a/approximations/src/main/java/generated/java/util/stream/StreamStubImpl.java +++ b/approximations/src/main/java/generated/java/util/stream/StreamStubImpl.java @@ -78,7 +78,7 @@ protected int _getLength() { } private StreamStubImpl _copy(T[] storage) { - return new StreamStubImpl<>(storage, _getCloseHandlers(), isParallel, linkedOrConsumed); + return new StreamStubImpl<>(storage, _getCloseHandlers(), isParallel, false); } private StreamStubImpl _copy() { diff --git a/approximations/src/main/java/generated/org/apache/commons/logging/LogImpl.java b/approximations/src/main/java/generated/org/apache/commons/logging/LogImpl.java deleted file mode 100644 index 10629579..00000000 --- a/approximations/src/main/java/generated/org/apache/commons/logging/LogImpl.java +++ /dev/null @@ -1,56 +0,0 @@ -package generated.org.apache.commons.logging; - -import org.jacodb.approximation.annotation.Approximate; - -@SuppressWarnings("unused") -@Approximate(org.apache.commons.logging.Log.class) -public class LogImpl { - - final boolean isFatalEnabled() { - return false; - } - - final boolean isErrorEnabled() { - return false; - } - - final boolean isWarnEnabled() { - return false; - } - - final boolean isInfoEnabled() { - return false; - } - - final boolean isDebugEnabled() { - return false; - } - - final boolean isTraceEnabled() { - return false; - } - - final void fatal(Object message) { } - - final void fatal(Object message, Throwable t) { } - - final void error(Object message) { } - - final void error(Object message, Throwable t) { } - - final void warn(Object message) { } - - final void warn(Object message, Throwable t) { } - - final void info(Object message) { } - - final void info(Object message, Throwable t) { } - - final void debug(Object message) { } - - final void debug(Object message, Throwable t) { } - - final void trace(Object message) { } - - final void trace(Object message, Throwable t) { } -} diff --git a/approximations/src/main/java/generated/org/springframework/boot/ClassUtilsImpl.java b/approximations/src/main/java/generated/org/springframework/boot/ClassUtilsImpl.java deleted file mode 100644 index 2828168e..00000000 --- a/approximations/src/main/java/generated/org/springframework/boot/ClassUtilsImpl.java +++ /dev/null @@ -1,19 +0,0 @@ -package generated.org.springframework.boot; - -import org.jacodb.approximation.annotation.Approximate; -import org.springframework.util.ClassUtils; - -@Approximate(ClassUtils.class) -public abstract class ClassUtilsImpl { - - private static String getMainPackageName() { - throw new IllegalStateException("'getMainPackageName' should be approximated"); - } - - public static String getPackageName(Class clazz) { - if (clazz.getName().equals("StartSpringTestClass")) - return ClassUtilsImpl.getMainPackageName(); - - return clazz.getPackageName(); - } -} diff --git a/approximations/src/main/java/generated/org/springframework/boot/ErrorsMethodArgumentResolverImpl.java b/approximations/src/main/java/generated/org/springframework/boot/ErrorsMethodArgumentResolverImpl.java deleted file mode 100644 index 475effc1..00000000 --- a/approximations/src/main/java/generated/org/springframework/boot/ErrorsMethodArgumentResolverImpl.java +++ /dev/null @@ -1,28 +0,0 @@ -package generated.org.springframework.boot; - -import org.jacodb.approximation.annotation.Approximate; -import org.springframework.core.MethodParameter; -import org.springframework.lang.Nullable; -import org.springframework.ui.ModelMap; -import org.springframework.util.Assert; -import org.springframework.util.CollectionUtils; -import org.springframework.web.bind.support.WebDataBinderFactory; -import org.springframework.web.context.request.NativeWebRequest; -import org.springframework.web.method.support.ModelAndViewContainer; - -@SuppressWarnings("unused") -@Approximate(org.springframework.web.method.annotation.ErrorsMethodArgumentResolver.class) -public class ErrorsMethodArgumentResolverImpl { - - @SuppressWarnings("RedundantThrows") - public Object resolveArgument(MethodParameter parameter, @Nullable ModelAndViewContainer mavContainer, NativeWebRequest webRequest, @Nullable WebDataBinderFactory binderFactory) throws Exception { - Assert.state(mavContainer != null, "Errors/BindingResult argument only supported on regular handler methods"); - ModelMap model = mavContainer.getModel(); - String lastKey = CollectionUtils.lastElement(model.keySet()); - if (lastKey != null) { - return model.get(lastKey); - } else { - throw new IllegalStateException("An Errors/BindingResult argument is expected to be declared immediately after the model attribute, the @RequestBody or the @RequestPart arguments to which they apply: " + parameter.getMethod()); - } - } -} diff --git a/approximations/src/main/java/generated/org/springframework/boot/LogFactoryImpl.java b/approximations/src/main/java/generated/org/springframework/boot/LogFactoryImpl.java deleted file mode 100644 index 28c01808..00000000 --- a/approximations/src/main/java/generated/org/springframework/boot/LogFactoryImpl.java +++ /dev/null @@ -1,17 +0,0 @@ -package generated.org.springframework.boot; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.impl.NoOpLog; -import org.jacodb.approximation.annotation.Approximate; - -@Approximate(org.apache.commons.logging.LogFactory.class) -public abstract class LogFactoryImpl { - - public static Log getLog(Class clazz) { - return new NoOpLog(); - } - - public static Log getLog(String name) { - return new NoOpLog(); - } -} diff --git a/approximations/src/main/java/generated/org/springframework/boot/MergedContextConfigurationImpl.java b/approximations/src/main/java/generated/org/springframework/boot/MergedContextConfigurationImpl.java deleted file mode 100644 index 5a183dac..00000000 --- a/approximations/src/main/java/generated/org/springframework/boot/MergedContextConfigurationImpl.java +++ /dev/null @@ -1,26 +0,0 @@ -package generated.org.springframework.boot; - -import org.jacodb.approximation.annotation.Approximate; -import org.springframework.lang.Nullable; -import org.springframework.test.context.ContextCustomizer; -import org.springframework.test.context.MergedContextConfiguration; - -import java.util.Collections; -import java.util.Set; - -@Approximate(MergedContextConfiguration.class) -public class MergedContextConfigurationImpl { - - private static final Set EMPTY_CONTEXT_CUSTOMIZERS = Collections.emptySet(); - - private static Set processContextCustomizers( - @Nullable Set contextCustomizers - ) { - if (contextCustomizers == null) - return EMPTY_CONTEXT_CUSTOMIZERS; - - contextCustomizers.removeIf(it -> it.getClass().getName().contains("TypeExcludeFiltersContextCustomizer")); - - return contextCustomizers; - } -} diff --git a/approximations/src/main/java/generated/org/springframework/boot/PathVariableMethodArgumentResolverImpl.java b/approximations/src/main/java/generated/org/springframework/boot/PathVariableMethodArgumentResolverImpl.java deleted file mode 100644 index 91da2d61..00000000 --- a/approximations/src/main/java/generated/org/springframework/boot/PathVariableMethodArgumentResolverImpl.java +++ /dev/null @@ -1,20 +0,0 @@ -package generated.org.springframework.boot; - -import org.jacodb.approximation.annotation.Approximate; -import org.springframework.core.MethodParameter; -import org.springframework.lang.Nullable; -import org.springframework.web.bind.support.WebDataBinderFactory; -import org.springframework.web.context.request.NativeWebRequest; -import org.springframework.web.method.support.ModelAndViewContainer; - -import static generated.org.springframework.boot.SymbolicValueFactory.createSymbolic; - -@Approximate(org.springframework.web.servlet.mvc.method.annotation.PathVariableMethodArgumentResolver.class) -public class PathVariableMethodArgumentResolverImpl { - - public final Object resolveArgument(MethodParameter parameter, @Nullable ModelAndViewContainer mavContainer, - NativeWebRequest webRequest, @Nullable WebDataBinderFactory binderFactory) throws Exception { - Class paramType = parameter.getParameterType(); - return createSymbolic(paramType); - } -} diff --git a/approximations/src/main/java/generated/org/springframework/boot/RequestParamMethodArgumentResolverImpl.java b/approximations/src/main/java/generated/org/springframework/boot/RequestParamMethodArgumentResolverImpl.java deleted file mode 100644 index 6751c96a..00000000 --- a/approximations/src/main/java/generated/org/springframework/boot/RequestParamMethodArgumentResolverImpl.java +++ /dev/null @@ -1,20 +0,0 @@ -package generated.org.springframework.boot; - -import org.jacodb.approximation.annotation.Approximate; -import org.springframework.core.MethodParameter; -import org.springframework.lang.Nullable; -import org.springframework.web.bind.support.WebDataBinderFactory; -import org.springframework.web.context.request.NativeWebRequest; -import org.springframework.web.method.support.ModelAndViewContainer; - -import static generated.org.springframework.boot.SymbolicValueFactory.createSymbolic; - -@Approximate(org.springframework.web.method.annotation.RequestParamMethodArgumentResolver.class) -public class RequestParamMethodArgumentResolverImpl { - - public final Object resolveArgument(MethodParameter parameter, @Nullable ModelAndViewContainer mavContainer, - NativeWebRequest webRequest, @Nullable WebDataBinderFactory binderFactory) throws Exception { - Class paramType = parameter.getParameterType(); - return createSymbolic(paramType); - } -} diff --git a/approximations/src/main/java/generated/org/springframework/boot/SpringApplicationImpl.java b/approximations/src/main/java/generated/org/springframework/boot/SpringApplicationImpl.java deleted file mode 100644 index 1c26d62f..00000000 --- a/approximations/src/main/java/generated/org/springframework/boot/SpringApplicationImpl.java +++ /dev/null @@ -1,74 +0,0 @@ -package generated.org.springframework.boot; - -import jakarta.servlet.Filter; -import org.jacodb.approximation.annotation.Approximate; -import org.springframework.boot.ApplicationArguments; -import org.springframework.boot.ApplicationContextFactory; -import org.springframework.boot.context.logging.LoggingApplicationListener; -import org.springframework.context.ApplicationListener; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.setup.DefaultMockMvcBuilder; -import org.springframework.test.web.servlet.setup.MockMvcBuilders; -import org.springframework.web.context.WebApplicationContext; - -import java.util.*; - -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; - -@Approximate(org.springframework.boot.SpringApplication.class) -public class SpringApplicationImpl { - - private List> listeners; - - private ApplicationContextFactory applicationContextFactory = ApplicationContextFactory.DEFAULT; - - private boolean registerShutdownHook = true; - - private Map>> allControllerPaths() { - return new HashMap<>(); - } - - protected void afterRefresh(ConfigurableApplicationContext context, ApplicationArguments args) { - startAnalysis(); - Object[] beans = context.getBeansOfType(Filter.class).values().toArray(); - Filter[] filters = Arrays.copyOf(beans, beans.length, Filter[].class); - DefaultMockMvcBuilder builder = MockMvcBuilders.webAppContextSetup((WebApplicationContext) context); - for (Filter filter : filters) { - builder.addFilter(filter); - } - MockMvc mockMvc = builder.build(); - Map>> allPaths = allControllerPaths(); - try { - for (String controllerName : allPaths.keySet()) { - Map> paths = allPaths.get(controllerName); - for (String path : paths.keySet()) { - List properties = paths.get(path); - String kind = (String) properties.get(0); - Integer paramCount = (Integer) properties.get(1); - Object[] pathArgs = new Object[paramCount]; - if (kind.equals("get")) - mockMvc.perform(get(path, pathArgs)); - if (kind.equals("post")) - mockMvc.perform(post(path, pathArgs)); - if (kind.equals("put")) - mockMvc.perform(put(path, pathArgs)); - if (kind.equals("delete")) - mockMvc.perform(delete(path, pathArgs)); - if (kind.equals("patch")) - mockMvc.perform(patch(path, pathArgs)); - } - } - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - private void startAnalysis() { } - - public void setListeners(Collection> listeners) { - registerShutdownHook = false; - listeners.removeIf(it -> it instanceof LoggingApplicationListener); - this.listeners = new ArrayList<>(listeners); - } -} diff --git a/approximations/src/main/java/generated/org/springframework/boot/StartSpring.java b/approximations/src/main/java/generated/org/springframework/boot/StartSpring.java deleted file mode 100644 index 41c9969a..00000000 --- a/approximations/src/main/java/generated/org/springframework/boot/StartSpring.java +++ /dev/null @@ -1,11 +0,0 @@ -package generated.org.springframework.boot; - -import org.springframework.test.context.TestContextManager; - -public class StartSpring { - - public static void startSpring() { - TestContextManager b = new TestContextManager(TestClass.class); - b.getTestContext().getApplicationContext(); - } -} diff --git a/approximations/src/main/java/generated/org/springframework/boot/SymbolicValueFactory.java b/approximations/src/main/java/generated/org/springframework/boot/SymbolicValueFactory.java deleted file mode 100644 index 57055eff..00000000 --- a/approximations/src/main/java/generated/org/springframework/boot/SymbolicValueFactory.java +++ /dev/null @@ -1,24 +0,0 @@ -package generated.org.springframework.boot; - -import org.usvm.api.Engine; - -public class SymbolicValueFactory { - public static Object createSymbolic(Class type) { - if (type == boolean.class) - return Engine.makeSymbolicBoolean(); - if (type == int.class) - return Engine.makeSymbolicInt(); - if (type == long.class) - return Engine.makeSymbolicLong(); - if (type == float.class) - return Engine.makeSymbolicFloat(); - if (type == byte.class) - return Engine.makeSymbolicByte(); - if (type == char.class) - return Engine.makeSymbolicChar(); - if (type == short.class) - return Engine.makeSymbolicShort(); - - return Engine.makeNullableSymbolic(type); - } -} diff --git a/approximations/src/main/java/generated/org/springframework/boot/TestClass.java b/approximations/src/main/java/generated/org/springframework/boot/TestClass.java deleted file mode 100644 index d66f59e8..00000000 --- a/approximations/src/main/java/generated/org/springframework/boot/TestClass.java +++ /dev/null @@ -1,12 +0,0 @@ -package generated.org.springframework.boot; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.test.web.servlet.MockMvc; - -@WebMvcTest -public class TestClass { - - @Autowired - private MockMvc mockMvc; -} diff --git a/approximations/src/main/java/generated/org/springframework/boot/TestContextManagerImpl.java b/approximations/src/main/java/generated/org/springframework/boot/TestContextManagerImpl.java deleted file mode 100644 index f50b2741..00000000 --- a/approximations/src/main/java/generated/org/springframework/boot/TestContextManagerImpl.java +++ /dev/null @@ -1,57 +0,0 @@ -package generated.org.springframework.boot; - -import org.jacodb.approximation.annotation.Approximate; -import org.springframework.test.context.TestContext; -import org.springframework.test.context.TestContextBootstrapper; -import org.springframework.test.context.TestContextManager; -import org.springframework.test.context.TestExecutionListener; -import org.springframework.util.ClassUtils; -import org.springframework.util.ReflectionUtils; - -import java.lang.reflect.Constructor; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -@Approximate(TestContextManager.class) -public class TestContextManagerImpl { - - private final TestContext testContext; - - private final List testExecutionListeners = new ArrayList<>(8); - - private static TestContext copyTestContext(TestContext testContext) { - Constructor constructor = - ClassUtils.getConstructorIfAvailable(testContext.getClass(), testContext.getClass()); - - if (constructor != null) { - try { - ReflectionUtils.makeAccessible(constructor); - return constructor.newInstance(testContext); - } - catch (Exception ignored) { - } - } - - // Fallback to original instance - return testContext; - } - - public TestContextManagerImpl(TestContextBootstrapper testContextBootstrapper) { - this.testContext = testContextBootstrapper.buildTestContext(); - registerTestExecutionListeners(testContextBootstrapper.getTestExecutionListeners()); - } - - public final TestContext getTestContext() { - return this.testContext; - } - - public void registerTestExecutionListeners(List testExecutionListeners) { - registerTestExecutionListeners(testExecutionListeners.toArray(new TestExecutionListener[0])); - } - - public void registerTestExecutionListeners(TestExecutionListener... testExecutionListeners) { - Collections.addAll(this.testExecutionListeners, testExecutionListeners); - } - -} diff --git a/approximations/src/main/java/runtime/LibSLRuntime.java b/approximations/src/main/java/runtime/LibSLRuntime.java index fb03400d..67122554 100644 --- a/approximations/src/main/java/runtime/LibSLRuntime.java +++ b/approximations/src/main/java/runtime/LibSLRuntime.java @@ -5,6 +5,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import generated.java.lang.StringImpl; import org.usvm.api.Engine; import org.usvm.api.SymbolicIdentityMap; import org.usvm.api.SymbolicList; @@ -87,7 +88,6 @@ public static int getUniqueId() { //} } - private static final int BUFF_SIZE_BYTE = 4; private static final int BUFF_SIZE_SHORT = 6; private static final int BUFF_SIZE_INT = 11; @@ -97,38 +97,46 @@ public static String toString(final boolean v) { return v ? "true" : "false"; } - @SuppressWarnings("ConstantConditions") - public static String toString(byte v) { - if (v == 0) return "0"; - if (v == Byte.MIN_VALUE) return "-128"; - if (v == Byte.MAX_VALUE) return "127"; - // TODO: add more common cases - - Engine.assume(v > Byte.MIN_VALUE); - Engine.assume(v < Byte.MAX_VALUE); + private static byte digitToByte(long i) { + return (byte) ('0' + i); + } - final char[] chars = new char[BUFF_SIZE_BYTE]; + private static String numberToString(long n, int buffSize) { + byte[] bytes = new byte[buffSize]; - final boolean isNegative = v < 0; + final boolean isNegative = n < 0; if (isNegative) - v = (byte) -v; + n = -n; int len = 0; - int pos = BUFF_SIZE_BYTE; - while (v != 0) { + int pos = buffSize; + while (n != 0) { pos--; len++; - chars[pos] = (char) ('0' + (v % 10)); - v /= 10; + bytes[pos] = digitToByte(n % 10); + n /= 10; } if (isNegative) { pos--; len++; - chars[pos] = '-'; + bytes[pos] = '-'; } - return new String(chars, pos, len); + return new String(bytes, pos, len); + } + + @SuppressWarnings("ConstantConditions") + public static String toString(byte v) { + if (v == 0) return "0"; + if (v == Byte.MIN_VALUE) return "-128"; + if (v == Byte.MAX_VALUE) return "127"; + // TODO: add more common cases + + Engine.assume(v > Byte.MIN_VALUE); + Engine.assume(v < Byte.MAX_VALUE); + + return numberToString(v, BUFF_SIZE_BYTE); } @SuppressWarnings("ConstantConditions") @@ -141,28 +149,7 @@ public static String toString(short v) { Engine.assume(v > Short.MIN_VALUE); Engine.assume(v < Short.MAX_VALUE); - final char[] chars = new char[BUFF_SIZE_SHORT]; - - final boolean isNegative = v < 0; - if (isNegative) - v = (short) -v; - - int len = 0; - int pos = BUFF_SIZE_SHORT; - while (v != 0) { - pos--; - len++; - chars[pos] = (char) ('0' + (v % 10)); - v /= 10; - } - - if (isNegative) { - pos--; - len++; - chars[pos] = '-'; - } - - return new String(chars, pos, len); + return numberToString(v, BUFF_SIZE_SHORT); } @SuppressWarnings("ConstantConditions") @@ -175,28 +162,7 @@ public static String toString(int v) { Engine.assume(v > Integer.MIN_VALUE); Engine.assume(v < Integer.MAX_VALUE); - final char[] chars = new char[BUFF_SIZE_INT]; - - final boolean isNegative = v < 0; - if (isNegative) - v = -v; - - int len = 0; - int pos = BUFF_SIZE_INT; - while (v != 0) { - pos--; - len++; - chars[pos] = (char) ('0' + (v % 10)); - v /= 10; - } - - if (isNegative) { - pos--; - len++; - chars[pos] = '-'; - } - - return new String(chars, pos, len); + return numberToString(v, BUFF_SIZE_INT); } @SuppressWarnings("ConstantConditions") @@ -209,40 +175,18 @@ public static String toString(long v) { Engine.assume(v > Long.MIN_VALUE); Engine.assume(v < Long.MAX_VALUE); - final char[] chars = new char[BUFF_SIZE_LONG]; - - final boolean isNegative = v < 0; - if (isNegative) - v = -v; - - int len = 0; - int pos = BUFF_SIZE_LONG; - while (v != 0) { - pos--; - len++; - chars[pos] = (char) ('0' + (v % 10)); - v /= 10; - } - - if (isNegative) { - pos--; - len++; - chars[pos] = '-'; - } - - return new String(chars, pos, len); + return numberToString(v, BUFF_SIZE_LONG); } - public static String toString(final char v) { - return String.valueOf(v); + public static String toString(char v) { + return new String(StringImpl._charToBytes(v)); } // TODO: do we need more variants for other primitive array types? - public static String toString(final char[] v) { - return new String(v); + public static String toString(char[] v) { + return new String(StringImpl._getBytes(v)); } - private static final float FLOAT_MULTIPLIER_REGULAR = 1e+6f; // 8 decimal positions private static final int FLOAT_MULTIPLIER_REGULAR_count = 6; private static final int FLOAT_MULTIPLIER_REGULAR_int = (int) FLOAT_MULTIPLIER_REGULAR; diff --git a/approximations/src/main/java/stub/java/lang/SystemHelpers.java b/approximations/src/main/java/stub/java/lang/SystemHelpers.java new file mode 100644 index 00000000..7dadc5ae --- /dev/null +++ b/approximations/src/main/java/stub/java/lang/SystemHelpers.java @@ -0,0 +1,8 @@ +package stub.java.lang; + +import runtime.LibSLRuntime; + +public final class SystemHelpers { + +// public static final LibSLRuntime.Map identityHashCodeMap = null; +} diff --git a/approximations/src/main/java/stub/java/util/array/AbstractArraySpliterator.java b/approximations/src/main/java/stub/java/util/array/AbstractArraySpliterator.java index 659d9058..729a1d93 100644 --- a/approximations/src/main/java/stub/java/util/array/AbstractArraySpliterator.java +++ b/approximations/src/main/java/stub/java/util/array/AbstractArraySpliterator.java @@ -32,7 +32,7 @@ public boolean hasCharacteristics(int _characteristics) { throw new LinkageError(); } - public int characteristics() { + public int _characteristics() { throw new LinkageError(); } @@ -42,7 +42,7 @@ public long estimateSize() { abstract protected E _getItem(int index); - public void forEachRemaining(Consumer _action) { + public void _forEachRemaining(Consumer _action) { throw new LinkageError(); } @@ -54,7 +54,7 @@ public long getExactSizeIfKnown() { throw new LinkageError(); } - public boolean tryAdvance(Consumer _action) { + public boolean _tryAdvance(Consumer _action) { throw new LinkageError(); } diff --git a/approximations/src/main/java/stub/java/util/list/ListIteratorStub.java b/approximations/src/main/java/stub/java/util/list/ListIteratorStub.java index 79bb2ea1..33331294 100644 --- a/approximations/src/main/java/stub/java/util/list/ListIteratorStub.java +++ b/approximations/src/main/java/stub/java/util/list/ListIteratorStub.java @@ -17,7 +17,7 @@ public ListIteratorStub(AbstractListImpl list, int index, int expectedModCoun } public ListIteratorStub(AbstractListImpl list, int index) { - this(list, index, list.modCount); + this(list, index, list._getModCount()); throw new LinkageError(); } diff --git a/approximations/src/main/java/stub/java/util/map/Map_Contents.java b/approximations/src/main/java/stub/java/util/map/Map_Contents.java index e59fe8b9..aff2dfb6 100644 --- a/approximations/src/main/java/stub/java/util/map/Map_Contents.java +++ b/approximations/src/main/java/stub/java/util/map/Map_Contents.java @@ -91,7 +91,7 @@ public boolean retainAll(@NotNull Collection c) { throw new LinkageError(); } - public int size() { + public int _size() { throw new LinkageError(); } @@ -117,7 +117,7 @@ public T[] toArray(@NotNull T[] array) { throw new LinkageError(); } - public String toString() { + public String _toString() { throw new LinkageError(); } } diff --git a/usvm-api/usvm-api.jar b/usvm-api/usvm-api.jar deleted file mode 100644 index fb9607f8e8d57073af1a092cd5f130eea444d990..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 11342 zcma)ibzD^4_BSm^Hz?hm(%nc&OT*CJoze(Hcc&mJ(k%!`gOs#1NHc`A{D#-7KJw_j z@1D;&bN*QCyJPLW_9{hLXc#OA2zYo1J|L_n1h_%ny}%6t{K!kFiZDJ^kYt92Q2a@l z`LbK1$`5M)F_-`!{D9ei5z31wJe8DCQDu^sJeD6EkdtL(8by|6q#GU_sa9s0U|(8a zS%5mCzY*S_0`flz0rnREB396anze(4fT%_N zK9!%Scf=C5W)`+4Oh(oKC#P5HR$iDASiaQqeXnw#Ygu+Y)X1S7>y;44plh|1(PBbS z3J;qzw!r0V22?|8-69AHzjGJyAv#1SKCKq&?_rO(;7vt_IT2%@<2mpcNj=M8Z}z)A zo+E}}TG`XPY0=#*??ys92xvVa;?}jfu!LYFd!Ju z7y~@V)=1UXua$9ZCF+)=GnEAKuGB!Sp%d=`7fVF-A&vSWHfZgLoMeDA*ZW-*%h6*U z=BU;$;YJXF=tz{6sGUeY%}XBX()eWRHlL1xjIqO71Xrw&I-&BNvGy5Ty@VbZuF)6%h*%cFZ}aXzw8%pgkR!VeH`&=&4k>DDQ8w(teep zc3hoULfFHNdk)_@`kb!}ZxZesOAoOL_l2c*oi%UUx*f+2Rf9LF992vgmY8$r$t!cQ z_`Y`k#<2rR`?vvqWlpOkv!ry`zN-*@>Yl?EZK~EwN7boGPm_g{hb?JHfjsrb(-NK4 z=eLgRyLMV@Pcp2=u`Mhq9%{d_pI_6el8(4&*k;{*W$^0C`C;GKJHyL#+l!KAeC+sP zIpE81hsAjwE(ClA{q${C=VWUmuXF$jL=kyCkwIybQy4m71})YY`x^Ry_G6U374$Ev zh4!R)4pcGEJGq{|L%KRARo|%_THPfwl@^%G*qJR{j)7-v)^4M{^ig0Rw0o4rGB{4E zCgwYS>J8{qIaQVYWU*_;QIfG^4c}QMS!>)Z*=h2!zd{RVzDW@%hnNOdE}+?lxppWg)39JC3UbA)WgyjEoGHtHI~Dc z*E)8SZDkr5ua;nZ@AgEu7EEf`bhk#a;6DgHC5D?C*Cfg$8PDo<3Z*4>2p z4?eZVH5!AK4=i*J#^)nH>nM3bLYDa@_z`~`hh+H%5P3I#q93j~T?RGIySR9qX) zlqBSAi)$2O2}>cOm7QCbX1_&_z8?7o*o%1*DIhX}xZ8R`;N$05!X$!?3&O-Jh<>Tt zMCwga#Y1gxjYfQg2XyraJ3bEszwuM`!vt*DIO85GPK!3Ycv7C4lo?SYGm97yZs#X= zlB^f#yY_B;#89JzkE*?9@s#k5zo?L81J9saS0tt_WCWpu6nuTqGv1Xb^nDd$zLi4w zdfSL`xws0Rf0u}A_s$?vPMh%Ge3liX9M+S>ayx}U<$|Cu`ZW1t4#C#rBV|4Xa%Qy%t-%Jk|CnZ4O8kgjDC@{Fa@V(%*dC`aT_ta zmtPQpD$vB9C8uqq%{GB8oB-HXl=!LUrexaI{n#m=X^}SwN4$kznq#G+dMG+uE^5Pb z5c0Di%#$-@vSmAToT)%hKJ^69BjH3i?3KQJYO0Xp$GL5?)@B(cHSVHOkGy&2-Ha>s z(B&er)X4-C$xb=RPxBPW%Td@CJsKYKjXr9Q%2e_dXYT45np)KK03ahtW-oVPrgk!i z!RQA+WbI61vAae5{j%|%H=1>agn$66ZwRXUDqY3H#?a2%!sw~7iLJARvxhvu{=3Q! zRvu7zFO1d7So3N{ThTjT(gt_7l|&X3N*og&Q8&^=Il?Dqi@Z2{<2~wOKF}@PkSzXV zLFN|EW|r5!vEaMULJ&(h!%t!;UxyC9jiWhbWOFF@-4F`RvZ|MQ61Kp-6Z;ZQ0^w5+ z1!a;HR8Ny1kqTc@4ql_3YCr&>4z!~f#01>;)9uU%{a7Kjnrwd}j0dui(+om+^CVvQ zpjkn9B`DXa56}70hC!HTB8+C}F}B#3B0MU~QHm8-CRkROju4Gx4CW4XUc2B-?n1Wh zP}%^s(I+}FoA2dkPy$mLL=vPh`-%P58zTy|la?&sHt`@Y_Ln{h zN|hxi>h;DTRIi?COzjDUDx;*+-ws8n-pbrrX5bLXu+l4#d4UPxC*$sirRcv%jx0kG z81*_pp&tE7q@wk}q^~=|~1z!zrqj^)5 zLZt~i9NMzUT)6wD#_fKW-DW;=ts_`=s9@O<{Y`d1W#*zh^Ic}nn7FEnI`)yXZPRWd zMDj>z@+ACU#uce+r-S8^VT6Vr2(?GEeWneU451ot6xf_+FN(hcU3^7>n6fYNXAogD ztjPSJX%PR`?2M{|4CFjCUv%L*?PD^BRn14tSRSbkv3NcVS;kuJn-kLZ-w1s6jA7LF;$dMu81skr< zj;YzG?q*$Z3J*pGqdG?sK)X>ZAMl?4(J{oQ{4b7aLtiKP1MqSKoNLtveh$Ze<-{Kp5HK}a~lw;3uf;*9UL;fx;uz-GAV%YbkWnyb&XKdp5 zn-O(q3)YoId^`pd--(&>Z%h*3nI-KUzn@N<7+D!;5wwuo@Rvp_hU_wbn zTJV@`{xtTt;J|+0z3EUGT~XetNOkpQ<%OXQoi3Q2v02kvC&6v=78Nc(rrarWZFa!H ziS^j~diCd%l(|A2ug2e^i0jxVn5Vn1UHYJ0j*G5#gM>9OPuH9%P@h(kD(UB;z~v1Q+ab;w zsub^r#hIZQg`M0}YBTLUjOpOjS_VHfe_OR@hL$Eq&i`4v?+eFwYBwba2M4DOXX^?_ zB?7I$?s$=eD41Vh!Utd~~LNaI6Rk{aXelA!=4;Lb|@* zb~vS>-kieaKqjm5m$WcXy0~g7$b~3L-qNswziMCOnM(^!JgHc^9?M%(tsf-Fc_~VR z@(~)p`$KPgZ~Gtw6j1oAlC2W*Vpo`mo*eptbc{cyG#jfu zj00AYbzW_zNm4RU90$6XsQAY7yGI(~Ocif$YSq(>=*bj%ro_B7;9@CSq3YrPyl-Sk z3}45nf{7er-J)*XZAZ={IolHX+OjBk4R9$PEvbAg~~r$$#? zxQXWBL$N_rKtl$B(q1!x+aXbH@g(WSS!m5x?c+1Z9^DyGPBBLsb=s4K)rRP3JhH?> z0K$U#=97}u{z|~Etap+THYzR5Tg^9^2O5sTFvW3QK7*i_8KW??Jqaptm=_7F=tL@= zWgATv5BZd~+p}f5;W~A)sY0b=NmVDTLMnNwis?q58M$yJFEE-+RZ%oc4V6%JmpqFPnl$=F5XHZrz_a}fptgPj@|eOw+SP`v`|Q^{*-Q|H6nN$K;+I8ihj%$ zrW2I+yd%k!kfW6EJr;80dkoM^3J+zh7p4@z3V~seaev5zS>@|`{b!<-yl!OMgdRqF z_PGU}a-Ja%gLXyun(JqZ@Q{bflz`fO*B;QdsBp8U!GLexEPY`)!&fvuOf5yF1Doui zk8!bdlx0>EbDfj((0&WANb71z8QUPb?cdI@($9u4owDRX6Keq!fX<48hY4uN%MRn(@_xa_;#1<_EM@vNv}(Z*P@ zthmou^OutSb6EMl0HK`%`xj8!C~jS|-z;5Z#l4Zfa*#x|zp9n}@TO9fFSYs0r+E8q zkN9OQyS{8Uyl=vuF;aO&4MA@jg3=eBs*=sId+*`QRJqxm1fXM+qVK0I^_~DG_1FSQRr>c`;*z=I+Ld&4>UZ1d@ zeV>8GOCay1PW+gTS=*IEkyNr$HdDT>Z@0WsXKd^C?Y&!ZazJ*T6ReXc!8(clf9fQ# zG4oGdw5ak}4eQ%JTor{TJVnApop}V*UME98fn&S>B#Ko zD?)35!>xt$k=p)h76uNbD%DtsW!qu^wdX9=Q^*k+D+b^ron? z1XFYx4wP6e3~Q>a+K92sY1hkr{wT9KBvT4d-I`FSUNFEbbx3EYKuj)M8=zzfOaRsd zXzBn`c0pssQK0;N^I7y>U_hyRVB3^STuTAY<#De`CzZotQ^4btA_o00o0JZ&l0$F_ zUYl4OCl)(*bP#Q#dXqbN@b zv&lj`Pd1M{o7O!{N|mL#)7|i7OEq!Z|wEfA?t=9DG5ZBTPC)()O_a9j#=iW&Rs-a zYM&g*7@TK(Q(ifJb&BY@NXah={CZL|zKNpw6+M@brS%BIdY!p9lo|bs5TxIS(~*2a z>x=dR0XW*nzlVhz4drUFu=5tn!eqtg>vX*ZcH4QsU6{T>+OkD+MT*Y#>OB0~OQ0?9z)Q3ZW3LC_$N%{oXg1$S zm)V!ol+4+{^bw8_#1>k?&wz7i`Ws$0|24MUH8wqGF2z*qXQ0SrSr zSzpiA;LwNoNNt-8geIRdtG(qb$Xp9*7033Oz$A7Nr-}8Ia~u;oNhHKvV`@81xLHcn z2ld~!Vc}4Hup|8l-HlrqQ@Qn)8Qy<-=%UubKf?KXfwz$TC+YFeMxL;d+76 z#Al~lYrauZpM3_rj#HgCom7AuIEV|;eEyAcAscL4-N`LzE*adVAm-nVa(+W0pF^dYr@8Jhv}0sQyu?+TcGmLW|Ic>VE1%zPpIUifu5n~%s;txVr|#(drW>@gINOcKhxYVF}Zk8Z9tSjDrPA-e9+#|H(0Owc3cEE>C4i){8pRdTTpf;l7Q2UP;*D ztDFimuA_RLDSo;cLS{%p8G@&HyvlIHOJ(gXtDlY+h5_t$b$cxfM-25QoJZhGK772g zl&yT)nhRzkZ7VgS#aWagFqmSPw0yP2zdiwA2) zgyS6PIMp=LMyp}u{lx^*dt&Q`y$`<3koD-K^0<~7H9E?&q%K-cS`Z@)qA*nGKg-oP z$!(gfOjD0&d{5;dkK=WOZ87+zVUlsmVvLNpvL>B=g0$g|h zF8kn3z24@)0|`&poR3f+aI%CMt|4#csKahUx|mOBHCD7gbGOr|b~z*_p)bYua6}Ch z@zWCo^Iwx*;Yi`jGF*puv3`K@4R_}dirZe5Lvo-ZQ_#a2jL$fGEk!3IGu&qc>^VG! zu$ZMLL^U8St`Tex1!jMw7Q2i-2f~M-t8ejks+1YBtcpd2Pi&7gxC7m=c9C(uK&{zO zZDu00kG2%s>sc(c_lPq~Z7b&nkhsPR7E=-(*UpEXl(DsG(BUPpcX!L5 z^|6xiNK*9R#Tkh^0;l>KgE+L56?m+}&^e8nICTgcNjEQ>*cdho=s(y$hw<~->DZQt zTBY&vdj3t+(Z$%XpuV<{eLGM}`U=GXct*Pls`g9V(UKf^9UT*YRLC|9?Ke=iEohsz zi0S!pl$Zl_J|m>uxJ{pZT$H+*)nC=jqZKjH5`f9lde zgrD`WCGhbeTes9;gi ze=#AYo-`$Ls!JrU0p$H}u)psL@D=j+Adj)hpMyM7s@HOx;H?w__lF?Q52o+o3UPol z;JYXODnZ+BoQ0q}8c}zqoDqq$f_`<@U)&vr^P#nxM3J1FO!n6eDk}NJ5Aiz++s{}1 zQQJdBuT>t@4&|XYwNUW%Y@VC(fZi+$`9htCO;KXuSt?(AGItlOJl8bvc%PW1_^IAj zzoDs*gL#=(tafCi5&Nk389|5|dkuEjMT*7dZI#tnzPD$td(OVmywSn? zPY;6V1<|x#lZt_wEwo*sgjPHYU^<7_hcZ#rZ18c+_`meC*zXy<#;iEIT}soww$9Re z9ASEfP$B}Geyq`R&5-L^FU{Uve0&@*nnK$#o7H3KMKgrmaqih2jz3?; zTytTL(emte+y@j`*uOFP=-a+sa4$*$5^OX^&Fp%25t5aIX_-V@J7gy>Y(|zUum1a7 zp?Hivn$7b%kt&n5O+*6x0(BaXVOlLy)O5!QWT%Q|i`OV#I_ro8Y}SfP5z5~DvDWAp zO+AW>2i^_tmrtrt3b3W35@dr&3HcJYT;ILyVPa*`5%W&m5@s+&fKB*P-fIu7#xQOK zNpDLClGzCAckn|t1pP%yyo1iZ!m7!LfgQ^db-v;U89;HWXS z;vh*_>2SgS3-8`$Q@q)z zh_FkuKh$V6$GJ9^VXvJB(}u1lJ}~9QA}~1tZC`#o3eX+YOJ-2y^YX>ZLW8%;i}H?I zBSqk(*p`_PeO7a^Y6H-=rb{GLI)XAhiS@m=Y%0JKZeH*K(*f)1f5iiTEZct$*!RWz ze#TmrM`fTyumtiymAopx5qWko)>cm?j*b`NKX&DkVV&gi+*B$zM=S=*v1;WkbyzZ#hwjq~)7~p~H~85jEy+g=Io$gx>gI`!l*KJy?d1E$ zP+zEyY-xC%esvQdvT9NO%JfJlJ~wtn@2&9g=V(n$RxNu(ZrW_&+|p3enU{cGr+l{- znc4XX=}5g1tBOpks1hff*ISC(^8UW(hM@5c2EA05)-5h5kJgVzN5oMMm-!Y971NPa zk|l_Ql`XSl7{rvK^{_Bi(h4DNo``e3?aL(z5=7Wo+~EX#2oTLkw7D6gC5^Dgb_nW# z;q6`ZE12K4Vv?xm?moEoffHO^@UJNLkM;l0wiU6r_`djwiB?Wy!dM~CXcTE$6|Kt8 z)V)|w$J`Hs>yjd9q|4b^d=KZKwBbVv;u(OaMHd~!OVN(}#+`7p$jYXo@FQ&p9?z

>#*bj8Oz(Y1Hk8d~#^AiOks2%KTKuTU$#YR5Wt(6rMiDI+ke^$&j-q-ZJ7- z3eO%fAtVdX>O>)`1E zdHh;J*gTsNA-P>Ry`BNjPKq)k71+8rs*dlJpAr^wg0%fL0;^gSkWYqSQX05jcwRkm zUrR{ub{+?Gl>r)RW7|^R%dUh`%+OQC8efGgHFbS4xH-L@JdkJyIdP<8NU|rH7&FSf zY0tZqpEbt1bz?uH+yp*+N+le(97mCyke)OYR7j9R>omkLg(au21h0q{5|GGHO-j)X z@zjAv<8x)0J{56JpVJWk)LNOsTP>@2BnLeYqevtkFg_(bFVBeZw13N=r_ShZ@0K~L=!5wU_zXaVCdN|x86*dNChGs^(IVFJcMIevg`!E}zzr}Te zj{2<>LgMUti}?2gBcxu`qj0CNz=wwTzFYbuK!4|rem^Qcu?yhT9$K)OtVOrJq6ml? z^daG~7jrKmg*;1|K?}2qN>Yt(m3G*YA)ZW_~}!r_j?MfSwQiR=)ARk#;OFDn2V9u6wU`;VnhW%IYvG1{0x=jLlmC6 z{;20W*ZXCiK0V|9yF%yv(H{MYAtEQ)_}EQka@Wpf5LE`g*13E|?CRYhb){PB-YPC* zV?Ls^>RL*SA#8%AmA4r$j00dgkk-umzl?2NU)i{fq}Og-K7!CL%_%nqKHTvzk>E!d zhs-bKNP&~I@O_&hxnt^bw4r}%Qcd4Ow`7A3*dBYf;_}Ic^}Tt50M0(iGaM5)z&ISf zYP&5Fd;w#S$Xtx8xf>}qFtw&WAtFY0XWfUl-G9-*no!wenI=_LgjbY+yhL^r!B8)A zY=$A*4@yxM5(*3Y?}b};HXZ~78pNK+-T%)ru79%qsf_E6_^uWB(}LeW+5S<~bsyo5 z`bWjsUG3KQcGs~h`17uw>c4T^RdRiAcN}Tp&z}`o|7819UDq$R&VRDq6>i;Uy(hxb|kS@ZQzn7hTgUxx4tCJAg5{~Y+;2!3q;e-$O%$Go2&|Anaxj`sW!^JlXB zKGq%Y4^iADZ@;(yw+Fz1>))_`q;l^=+)w5H04eb2_#4Fi#O{5_`+3e^kXDF)8Py-M zp7&AjP=3tyF1h%<-OW`F=^pCORO5Y&`>DnsCm-~?S4f$V? zUf^r;kC1;b>+hr9H&1_|UXlC-^}exsAM*YM{tJ?U;vVEbH_!L$Tu~Mltn?rtaKJx* L@K^nv%?$B>kQgEz diff --git a/usvm-api/usvm-jvm-api.jar b/usvm-api/usvm-jvm-api.jar new file mode 100644 index 0000000000000000000000000000000000000000..ab19153418050bbc7409602492a0fe144b1eccb0 GIT binary patch literal 13121 zcma)jby!th^EQGsNDD}VfRuCz(#-+s?(RM`DBa!NAl;49(v5_4NVlZacYJ-+$Mfp@ z`_^@BIDf3U_ueyeW@gRYM@ACrAtnR_92~^E%oH^U(1QH-2ejZpmz1yqKb^R=2t5>p z%+HMqAxUaguOSccKpSvD7fAfqMk#)2aS>s8h38TtU!(>H0Frdi$B-rIsD}qfs^u6a znU_DWeun%P82DWug21fpjDNc!_?~Z1_H7T)-qG@ZZbbg~MqL}z|Jpp}sFa8f0|6m{ z{{2;cqJG;fY-Ma}W%yj*Lf76tPg&gwLlJY4QYyuqemm@w05ol6tYkx>n0}rz08fpD zQB2l0`qB1iA0R0SqSQ%N_6qg}!h>H}6H#MTF5_1A`30waa%w8BNwd3&(Z=54^*PVA zozd5k*4BG?h=LU@Ovq7mZykKKtT4W5;OG44DXg4mEm}?Gfk$3-p++Xd9A5DTML1pz zLIS8^f=H_mT>-_>WwY$XriN0IBRE(?GPXdWO3ROSEE5$4tm;(TJ4_F%Fufl^LLsAI zq`bu)U@Co9BPfZ9K1$%7&T%S0eX$$;v;xyk@1_|TDc zIo?&O=V$^SpLtSUwbKzZC-ea!VB_gZr3E#mwFm7(HydW<8>EpOv57_2PFXs^v5BiQ zv%bk%JL&2)3!qd)2ZPj+CnRjTR6}M-o;v<#%t9BMJp!5u4(K76WDJI@Z}gJ zh&5yh(reNU`m1%5x5;cd5PB+h5*6mAsA1?nmKZ9*pSsEmO{Be9v*qCbJU3tj9AaVc z@A#T5L07OkBcoDtXZUf77TBn@*pkD+ibTc%GS)el{R}x`t(kZ&!X$~;L8_|KX||r} zX%an58Wys+2WJK$UT0lbq?ux{XIblVRh-8!Xv+1Z8zfqaN{UjbI-gux45({E zmKti#&Jaf)wb{NN8e2VREce7srNaF1AquT;V*UjyB0nXQU$s`mT6%+q6~gOE90v?U zR?Py>Cn?)#7xCqB_(*clncvUQ*425* zJ?wl@o8y{ESls*O)e{%YQt^j$x@-NMSo<;2Y57Vu`u^81aUVZ$S;P{^7PeO!FSvTV zZy(Jg*$mgVcX(o?Ed&@K?}mzKBjh$qhEZbCUmfNqUl`G`lt!ByrDZ#Jtscnt@9d+j zxHh#j5zg`(YatM!aL33@|xDT-$J;kB-oNkz@b0jfW>f5vrtRw*kx(X;2)Z`G&w(%`EtX?65#mu z>MI+|#eobnqDPCg50cj|9f}DJTryc;iq93Dt$5ex<&O9UvOx7W-E_7+XijL0Gw4oF zY^?>}ha)yL^rE02Agv-C#g|}T%XS!|D*H-SY4yB9KfqsI^dD%UU_X+G>MR*)7A4|O z7~RPcY~{aSsz{llc~*0Sv~kZ}tlB!T!J6YFX#;)BQp7%3+|!d4k#J0aw5I7C5#SbD zFJf~Pu`Fmp_|YYc(;JW;zN6^8G=MxXFRWb#Nlss{xUu2UXsB{-N5*s!O|R@{u4SdL zp>_OONvC@ttZ%;fy#{ibTcagY{oa5k^uhpg-+VBAJpzn%^}7~=&R04(T;_*@g;dHe z%89*db8G{cD(r11Rp%tT&`E~2@nN*abF`v5AD8nJSiMVpn06l+M93unVt4oNt61 zTK!|Vj-W^8#23AEr$wis3K0(xG;ua~NRPrN8u@Bztzy6gEzon;ShSE`q2M`cLpzKKjo^|A1EcL7{O!dVL z46PhY9bBYzZN6s}Ke++v4nEA6KBFf`UI@X~>}JiQRvJ{grUGpZZz@JV%1{oWeu}P( zoP1@!0(&X@fs5RcBxbbxG(E=tkn_vs-PH}GO#~tawEqCZNvccB5dlxkF!5Q>ibB(Z z6WUWI@r`&Ok?gRH?p*i1v3iKs<-dkUYSo~0x zklM@&=cxva?PGD8*S9h9vM0jpWAik{tp{S&$Mw6weZxKJeD!EOz%}F)x!M`RvPfSrh4DaFbYT}sUi1>Tn3o|IW@oR9(PST z2^mI>Wl}yLQO5fL5DgG3ULL8&7uVpwka`h#VH;_mc8My=Nrb^ZI(X%KiCLOD5;$TT z_0jw@`u?8V8Px9v0O|Z^9f<{Q07EN%YXd{O|0>4tdd_=JL7VMBmLvb0knne55o^2e zUm?rLW(g>MO#gcfjOi{(rHAbT4-sV%3o1k4NK>dY6NOQW`&?Bh07e~qd*0yxp4)_YfN;&$VALF|4Ke zxL`3X45)ZsYN^DvnG^nj3;1Od-8HO^72{lbgo4i99H64Gx8lB;!iinbrp1MasA=XTwoae#ah9t=V_5nC3ldznn2gH zzp3q&o|&P(!#~RVt~stV>uDYs7#Iu~X-60e5tzK2Y=_(N)hdnKE^ol?WXt+Z>?Enj zeQwF*I=V7kM4Fdh6hARdC9NzkB_llnbzg5AjOxpc+1}$5fQ}3F2oMm=f0g<}>=n1PvG}K|SJJef6T*CHo~LACy*g>7FCi}`n9@HS zKvh#SNrI{-Fu`G4=p!lr-ay@U@>7*)JhQ&mr66}3(kT2O1NWC4oP#pV?y6LAW^N%j zkBhxVZR5O~FNZ|0A2dKShr?lF>Emyr8Ya4C5p7-NTd|(x?I7lCFbF9F1{{=dG3nH0 z8Ha7eyL?UtMSkcubR5dZg3@ykK%-{ zW_QMaQLh1?W83wMVIyh}aIm91NjgtxxKjMmBy?-}s+yO|@B~Wo4J|Iz z6gwBkilt6+gZGmcOSbB$Jl%#FjhFVA)Z@GnHJl86 zt${)zBawP7^9Qr6`U{wPNu2yx1Edej#?84P{YSRw$+Z@0Jf(?(;0Q@Y*gS}~8u`aE55M}9qW^-Y6uZUQ?Idtp3znM!9@tK4pV}hDV0&dt(5FmQ=1=Um{TDqAbLO~_s z7<%6t_FUp_5u;Vyu*$Jw51Q6Z*kGP?(SV~%ebqK>#cAE&#~6mX-NZc?7S=)*#R7FL-P^CP|iFNSU}xktCl`?3%F;d5?@(Z>gF?(z584Lm{) zTi);n-zS<#(cgr1#RoP$Gj^x%{^DBw(APE1n>q^XwOp z%CHhCp15gKW_ZCa=FOg-#ygzVQRmiu5Fl;k%&ayLGZv@ck_~*xvfgx0^m|6@K8l0G z07aW=Q1gN2|BN=E+T!0)MivxhQ16B%N@tW-yQJ5~*+yZad&Qr~nq*Cqkk|OaaQ!FB zJnIeLd0T53L2LY>+sad-NwgH!wZw*^=IN2C#i3hN*7pm9n9)Knlb_Kx5I}c zpQlxhYmxY=8W@dgn=lV#tFY#>MK^XN@r83dCM}gKLE3Xp&$$q;ke@Sz1p8)m8&H$G+u)db zwm?GC9;NIoS5s@v9pLuA7K@a+;CSiO_XPr7wQX=mvf^Va39n~R7m?VV2oJpWSj^I0 z+f#}ygDBeW?i}BjY8Qg(Or@dP9|*4>mAcb6e&vcTNYuUT-V6&#D}*p+>PR}}+}_CN z=Geqga}l8$ZgdR3!to>^9)cTp!QP0n+kNmp|MqrNYj(+PD@1{07XnYKEm&D-m~NG{ zlWK7z;sWQcYe(luBQskgH#-%39QhRas>pdAdIv3{ixn-dG(#Zf$fN=-A;^T^w_(-$ z_G^C2*M>7XRYtUPB*k-C6pu-LfyP4o=)-)}go2YC%Bt0%8(rFDc%rKAH{-z>LFlq- z$7?hsd97q2o+u(U=Q%0{TJiVB=B<>wRGvqWcZ2t{qsf|XVUvUrP0wB3x%{im3ZM*@@rf-2 z>FTU4HIK|b{@nXL{4o-8CE-2n@3BQbW_hv`3e<6hgMgs@KVu8P)ZXD&a0ye8wFfmO z@2nh~=P2;rwqu&Bo6^KTtr4OoWvdOGkzk=#p&;n`QwSkX&iarY1dQ71M2RNLA zb*waWO71Qw;zcY9aF`6MuiUfK<=u-!L zDyGWujZx(imkIWMnYsg)*P7FwlI=x><`*?9&=+KGA^y!`1yo8O%}C&9BPze?NJiWK zj@@2_RF3yU4e8fDIlgh^r!{`;3%)3v zKpTrbsdaH{u2IzEEptP*$|z|d*ev#J-ngvaR|`o8bQjN+7VS5maM|s&Yt~an7Pov# z?B%sj-KgNoRC5y!_mUa1bf+iow?HirqSVx~)J7oKMXtwe8;on*C=RvddfAik#h9V> ztZDisrpl8-0}hu$4JDZgQ%=i*PL-AD1`;l=i)aRs)0?m1hqb0?1ZpA!+bllKSv1@o zA@mfum}!g1dtcwt?^{jQ#3gJY>ywVLv(>YIxUOP7`1%^TPqX}RI*mXXp*K8y)7zj6 z-P#tC8|TJwU1~#Z**vPvMazza2;r`L+#cfzolescYW5M%Mm-AS8D4bjXn}6n{fWy1 ziY$EuY!g)yLgAKyvsK2C7s@2ou3hgt6%WV}TS;AfO}#Sov;_Ba12|&zQ~MHQ${~Sb z!|ED&*|F=XTpa*N-iSye%xwT%h*;hkVTL55P)6`p=Tyt9C2n=>{6_{OeYrqfB2*8?_}K7qe>deVL}+)h8xdL^UUVJghb?)!Ece`! zDmeYt-B+a?t*r4&!C%z%uST*lhsvIu%?5vMNyRDGPOtu)WfZabddh+({WAp*f;py3 zmDG5>(;Z4K8-)=iOpgIc@ls<%s9hjgOXoaF`dz6eTa}1XYedT=O9tz~+hglQg!;Ba zRc8Fj2!H3JQ+g_8WxE8$WUTZE{DAm^T8S+428m;KQ{^l2flL2}V)yO(8K(D}2)048 zu{a5J0TH%RaWw(28d7AYfNIHAJb8J{8;|R78MD-6GAY;J2`olhzBG!Ne%e)zai7!# z_=7VILuk`Wup^~W^BJlk7%TjBUgJ$yTF+|oy453?KI5}v8dbU|6oF3n4jpxceRoO zL+j~keEkB)BPikC)`Ut0BKZ8~CgUu=#7lJr<-$<)j3y>C|3YNMe716Y4xDABF{=RE zn4=G88R*kWx5g%B$$Gu~Xq~>^5`;0nvKLG7$$sd%oZ{+Q_4bZCL3O7FB^@k}Wy=l7 zf}pY-<3iyY!*X%a{oQc`)E6d15)T4Jx}wl{;e|k*slr<=P#s_pu>6%ir~J5se*;Zv zzB9pMknZV~$BM30*2ApR3?A<>Q`G$QTU}qTCiM2ce3OgZxwG69m=)u~w8{dBB{Nc5 z9p8v@UZ~uW5y#k<5m7kTMar2(s;;4yJc!9S#=G2)bs%Fxp#dwv@~c!Dz=!@ zb1l}OjWkNy2Yln8i&5`T^_j=CUwzPf9y8Czfu#aa^#6Gj{;$S~f#IJUCxJvdSQ()F zK?cenl;HW}hmg>B;cw1j|NZn^8fPt!r-=C>0}&pNO%gs!rafLjU81A47VCbJ7%NNB z41Kaj#>HutR@ZiR*=VBjmg4r|d%OJil_JLYOTZ6@%aliW9P+#NPBDx!2uadk^bUvm z8b_|u>|YJvT^*LULaDTQ5NK{qp)#Y2M(~-v;)%?sc^BOH{++S97vD(s8fSYnpA$uM z76}Oh&Wn#wJ*){H+B}0?wR{2o2T!9JSWa;{d_2ASinJLoauw;UQ%>3#F9`QioJz2i zr_6TmlCfv*!fPzNyn+czKE=~`G`r7LF4##Cr}b^zqvVjTN8|9Rb!K{1xdxX4R9;TmQ&?i=Gt81^qa!o z>A*IBw3F(=d2WWo&fp~pi6K#=l@l9HJEu_ZVb7{|h!$0eT!i{A?j{Tn@U&-YE7(h1 z151pFes-~+)0Efd)FL6>Bbs@c?G;h! z@K%!y*3s)$Q?n@fk)hUyek(LLKR@iP5w3L2l0)mcJI%)Z@#tY?x@{}5CE2Bv4=NSA zGJAG+lj?);U9+$egzx~Mvq$cNsg}#mmQ)p{(!zyh1UVrO;QT04nEmzos2?Ds^27Ol0+Trt7Y{%RLX42CHVWr@CsqvTa9)d|P_hj%_ntUm<011I zj>(vq@~fp#Je?yrc%MlQe~jPc{~&D6JyF7|p?ktcl&hUUw?dXwgZLov$%I0hGxWh% z_=erflaCGBXcy+O$;w~I=ort+((a(KPneN4lx&az@J39-L#b^<4N8DkuIV;6NZz#% z`dyppH%F`VwwSM@FP!2=$=OkPQM4p(_UcT|fTy?cLA%51-o|40C zKhkK-vUYuVcmAmD!MR+bUhhB~
2`1W$moaYv**j~p4QC2T0J;}^W zfa(c_wsQMae$>(JUu{a3ZeB(u)QNWvp26G*93fj+!(ByG**mV_3HeO;TGAc5kx-lby+6=*!T~DfN&S)Z znw$IRCEDDRFPFKtuoB^nnUuVb}yL>;_7FY`oU4j8KpQBK70uW_W%p8_{@q!={#b7pYZad z+&a{{p!m6*a~PDh5lDmA@7(VpoO|rOAL(xN3-}hX38csNa@uny=%Iyj76b#+m%|x& z`qdEVEJ@x!5*>E;z7DJ_tC@1yj;q%5^nmvXLp1zQI1a$6&9g=pPb~2{>pzlK+{tVt zr|ED2R(sG4c;CWiDN7RQ?GEhE%T?>{)^B34ubkR9s z5&v{m1_BtN&!1nLkJ98;f(xn-m?yrVOG<>ivD&VNuk29J7p24gv~4IiM3Lng@k(i>h36<3ZA+ZK8=;W2qZli>zLrzjjb z$&MF(|A*eT-nKyqNI;uIUw<3SdbN);59gu19_w)9sy#N`j?n~SPvWll5rZ%7lL}4 zQf9W@7PgYqSJUpwAsxU6;{;Rs(ZfiJO%{#~t8kH%q3Ks?+BOB2bq{+(YQ1CwvdXqq zfumJLmuq%I%r*p431-Rry-A-+a%lNl$_ioZH9`<=?8sX!a!5AUkvtJl zNGKL7xQR#@KHdpn&~nn6%g?T24Zu9SB5iBG-+3gl))K2{yK&@gx+6SMaXe)aqz%Ot zw0x*F6_tBv6OAeG6k0p_ocyfLlry(5z+~sW(ZaMsXk|8f_FDjSagx78v{_*83#^io z6bp@f{A{Z0WMpl5riFZ-J6H*l>~V!Uy%g1_RQ_VY^1z+&JXyhjRo^ZmcrB+nehfNaT<-#y_UYF^JdoZtkH;1rC1M=EzP-pwUy4pWtfcQTXI8akt*vi4q<-6~O z$!l7p^Mh&&T0{rB8G)=)BE{>96|m zwhUT z9u6=j5x*;8%9Q}l!%409BRm*VB zyyA|UMaAB|7vTy0y6Zofrxmhe30y@wiOP&K`2Yqmg9Q3To{g-0@OZk`I$YrdIIg)dUs zg~0dx+VQ1J(I1rzYD4$PItbT@qi$*MPot>}>0?Fd?}~dU_Mi#;6JT3`WiaShjp7psHTCJHfhG2Mpe{axi!F;`;}*DEj7F$=??EUB>{ zb?V@Vh;0TBs2F{NMinB<}uO>`%nqZ=1iZTrVon z-=AXtqVfJ40i22Zjjj8AeY>$E=;JpA?f;Va#@+qCzDXp5KK|s~{x7j_Oy2M7n^-64 z<4>_~R9$dUa9-~Z;asmHaM6FWe8FMBSzW(iI6-Otw=dBCjG+f0kv=b zi20ML1djDh78Jezv%YnUzOQc@5(AMUe#81fx&em(C*Ax2$@TL18w5B72OJWdkn#(% z2JtUX^#^(iIO;c)AMg5&B=UXz$L)~7P=8WJz%jrnBR^1by-NOy@dv~Hn!bSF0DMaP z>jqEI{`QbRZt&a87#tXUMDz>T5oGw^EdBHCe*phJFak#g?>GNK_5qRm|APF-?lU;@ zH>4jH``tUeKtCP$4f#i@0S*D)+5Gizb$^5Sr^fzQpA#Guyp{3`G#QkS{`g$rjTLZ6 z@H6=@$Xt@YK!Tsp!6Cs literal 0 HcmV?d00001 From 6cb97e5fd6cd3284a3d6512d53516270889e573a Mon Sep 17 00:00:00 2001 From: Pavel Balay <71063977+Bupaheh@users.noreply.github.com> Date: Mon, 23 Jun 2025 17:24:42 +0300 Subject: [PATCH 05/10] Increase max string length & approximate concurrent hash map constructor (#17) --- .../src/main/java/generated/java/lang/StringImpl.java | 2 +- .../java/generated/java/util/map/ConcurrentHashMapImpl.java | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/approximations/src/main/java/generated/java/lang/StringImpl.java b/approximations/src/main/java/generated/java/lang/StringImpl.java index 9cafde84..1088863c 100644 --- a/approximations/src/main/java/generated/java/lang/StringImpl.java +++ b/approximations/src/main/java/generated/java/lang/StringImpl.java @@ -16,7 +16,7 @@ public class StringImpl implements Serializable { @java.io.Serial private static final long serialVersionUID = -6849794470754667710L; - private static final int STRING_LENGTH_MAX = 50; + private static final int STRING_LENGTH_MAX = 256; static final byte UTF16 = 1; diff --git a/approximations/src/main/java/generated/java/util/map/ConcurrentHashMapImpl.java b/approximations/src/main/java/generated/java/util/map/ConcurrentHashMapImpl.java index a2c35753..c889c875 100644 --- a/approximations/src/main/java/generated/java/util/map/ConcurrentHashMapImpl.java +++ b/approximations/src/main/java/generated/java/util/map/ConcurrentHashMapImpl.java @@ -47,6 +47,11 @@ public ConcurrentHashMapImpl(int initialCapacity, float loadFactor) { super(true, initialCapacity, loadFactor); } + @SuppressWarnings("unused") + public ConcurrentHashMapImpl(int initialCapacity, float loadFactor, int concurrencyLevel) { + super(true, initialCapacity, loadFactor); + } + public LibSLRuntime.Map> _getStorage() { LibSLRuntime.Map> result = this.storage; Engine.assume(result != null); From 7deb55c9598a385ac3e1587bc39cc3d2bd69e058 Mon Sep 17 00:00:00 2001 From: Valentyn Sobol Date: Tue, 1 Jul 2025 13:07:50 +0300 Subject: [PATCH 06/10] Dummy commit to reset jitpack cache --- approximations/build.gradle.kts | 1 + 1 file changed, 1 insertion(+) diff --git a/approximations/build.gradle.kts b/approximations/build.gradle.kts index 52cd63a8..90004cdd 100644 --- a/approximations/build.gradle.kts +++ b/approximations/build.gradle.kts @@ -43,3 +43,4 @@ publishing { } } } + From 320f8db9ea5dc63a72822f06a9a127ed021074cc Mon Sep 17 00:00:00 2001 From: Mikhail Kosticyn Date: Mon, 28 Jul 2025 11:30:57 +0300 Subject: [PATCH 07/10] Updated approximations (#18) * [fix] fixed approximations * [chore] updated jacodb version * [fix] fixed `String` approximation - assuming small length if string is symbolic * [todo] added todo's --- approximations/build.gradle.kts | 3 +- .../java/generated/java/lang/StringImpl.java | 15 +- .../generated/java/util/array/ArrayImpl.java | 447 ++++++++++++++++++ .../generated/java/util/list/SubListImpl.java | 2 +- .../util/map/Map_Contents_IteratorImpl.java | 8 +- .../java/util/set/Set_IteratorImpl.java | 7 +- .../src/main/java/runtime/LibSLRuntime.java | 3 + usvm-api/usvm-jvm-api.jar | Bin 13121 -> 13641 bytes 8 files changed, 468 insertions(+), 17 deletions(-) create mode 100644 approximations/src/main/java/generated/java/util/array/ArrayImpl.java diff --git a/approximations/build.gradle.kts b/approximations/build.gradle.kts index 90004cdd..1cb40584 100644 --- a/approximations/build.gradle.kts +++ b/approximations/build.gradle.kts @@ -11,7 +11,7 @@ repositories { } private val jacodbPackage = "com.github.UnitTestBot.jacodb" -private val jacodbVersion = "453ec7c0b3" // jacodb neo branch +private val jacodbVersion = "d7dd9d343b" // jacodb neo branch dependencies { compileOnly("$jacodbPackage:jacodb-api-jvm:$jacodbVersion") @@ -43,4 +43,3 @@ publishing { } } } - diff --git a/approximations/src/main/java/generated/java/lang/StringImpl.java b/approximations/src/main/java/generated/java/lang/StringImpl.java index 1088863c..f21f6de5 100644 --- a/approximations/src/main/java/generated/java/lang/StringImpl.java +++ b/approximations/src/main/java/generated/java/lang/StringImpl.java @@ -16,7 +16,7 @@ public class StringImpl implements Serializable { @java.io.Serial private static final long serialVersionUID = -6849794470754667710L; - private static final int STRING_LENGTH_MAX = 256; + private static final int STRING_LENGTH_MAX = 50; static final byte UTF16 = 1; @@ -219,8 +219,7 @@ private void _assumeInvariants(StringImpl obj) { Engine.assume(obj.value != null); int len = obj.value.length >> obj.coder; Engine.assume(len >= 0); - // TODO: add Engine.assumeSymbolic(instance, bool) #ASAP - Engine.assume(len <= STRING_LENGTH_MAX); + Engine.assumeSymbolic(obj, len <= STRING_LENGTH_MAX); } private void _assumeInvariants() { @@ -293,6 +292,10 @@ public void getBytes(int srcBegin, int srcEnd, byte[] dst, int dstBegin) { } public static boolean latin1Equals(byte[] value, byte[] other) { + Boolean arrayEquals = Engine.arrayEquals(value, other); + if (arrayEquals != null) + return arrayEquals; + if (value.length == other.length) { for(int i = 0; i < value.length; ++i) { if (value[i] != other[i]) { @@ -313,6 +316,7 @@ public boolean equals(Object anObject) { } else { if (anObject instanceof StringImpl) { StringImpl aString = (StringImpl)anObject; + Engine.assume(aString.value != value); _assumeInvariants(aString); return (!COMPACT_STRINGS || this.coder == aString.coder) && latin1Equals(this.value, aString.value); } @@ -320,4 +324,9 @@ public boolean equals(Object anObject) { return false; } } + + public boolean isEmpty() { + _assumeInvariants(); + return value.length == 0; + } } diff --git a/approximations/src/main/java/generated/java/util/array/ArrayImpl.java b/approximations/src/main/java/generated/java/util/array/ArrayImpl.java new file mode 100644 index 00000000..6f13b389 --- /dev/null +++ b/approximations/src/main/java/generated/java/util/array/ArrayImpl.java @@ -0,0 +1,447 @@ +package generated.java.util.array; + +import org.jacodb.approximation.annotation.Approximate; + +@Approximate(java.lang.reflect.Array.class) +public class ArrayImpl { + + public static int getLength(Object array) throws IllegalArgumentException { + if (array instanceof int[]) + return ((int[]) array).length; + + if (array instanceof byte[]) + return ((byte[]) array).length; + + if (array instanceof char[]) + return ((char[]) array).length; + + if (array instanceof long[]) + return ((long[]) array).length; + + if (array instanceof boolean[]) + return ((boolean[]) array).length; + + if (array instanceof short[]) + return ((short[]) array).length; + + if (array instanceof float[]) + return ((float[]) array).length; + + if (array instanceof double[]) + return ((double[]) array).length; + + if (array instanceof Object[]) + return ((Object[]) array).length; + + throw new IllegalArgumentException(); + } + + public static Object get(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException { + if (array == null) + throw new NullPointerException(); + + if (array instanceof int[]) + return ((int[]) array)[index]; + + if (array instanceof byte[]) + return ((byte[]) array)[index]; + + if (array instanceof char[]) + return ((char[]) array)[index]; + + if (array instanceof long[]) + return ((long[]) array)[index]; + + if (array instanceof boolean[]) + return ((boolean[]) array)[index]; + + if (array instanceof short[]) + return ((short[]) array)[index]; + + if (array instanceof float[]) + return ((float[]) array)[index]; + + if (array instanceof double[]) + return ((double[]) array)[index]; + + if (array instanceof Object[]) + return ((Object[]) array)[index]; + + throw new IllegalArgumentException(); + } + + public static boolean getBoolean(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException { + if (array == null) + throw new NullPointerException(); + + if (array instanceof boolean[]) + return ((boolean[]) array)[index]; + + throw new IllegalArgumentException(); + } + + public static byte getByte(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException { + if (array == null) + throw new NullPointerException(); + + if (array instanceof byte[]) + return ((byte[]) array)[index]; + + throw new IllegalArgumentException(); + } + + public static char getChar(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException { + if (array == null) + throw new NullPointerException(); + + if (array instanceof char[]) + return ((char[]) array)[index]; + + throw new IllegalArgumentException(); + } + + public static short getShort(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException { + if (array == null) + throw new NullPointerException(); + + if (array instanceof short[]) + return ((short[]) array)[index]; + + if (array instanceof byte[]) + return ((byte[]) array)[index]; + + throw new IllegalArgumentException(); + } + + public static int getInt(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException { + if (array == null) + throw new NullPointerException(); + + if (array instanceof int[]) + return ((int[]) array)[index]; + + if (array instanceof byte[]) + return ((byte[]) array)[index]; + + if (array instanceof char[]) + return ((char[]) array)[index]; + + if (array instanceof short[]) + return ((short[]) array)[index]; + + throw new IllegalArgumentException(); + } + + public static long getLong(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException { + if (array == null) + throw new NullPointerException(); + + if (array instanceof int[]) + return ((int[]) array)[index]; + + if (array instanceof byte[]) + return ((byte[]) array)[index]; + + if (array instanceof char[]) + return ((char[]) array)[index]; + + if (array instanceof long[]) + return ((long[]) array)[index]; + + if (array instanceof short[]) + return ((short[]) array)[index]; + + throw new IllegalArgumentException(); + } + + public static float getFloat(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException { + if (array == null) + throw new NullPointerException(); + + if (array instanceof int[]) + return ((int[]) array)[index]; + + if (array instanceof byte[]) + return ((byte[]) array)[index]; + + if (array instanceof char[]) + return ((char[]) array)[index]; + + if (array instanceof long[]) + return ((long[]) array)[index]; + + if (array instanceof short[]) + return ((short[]) array)[index]; + + if (array instanceof float[]) + return ((float[]) array)[index]; + + throw new IllegalArgumentException(); + } + + public static double getDouble(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException { + if (array == null) + throw new NullPointerException(); + + if (array instanceof int[]) + return ((int[]) array)[index]; + + if (array instanceof byte[]) + return ((byte[]) array)[index]; + + if (array instanceof char[]) + return ((char[]) array)[index]; + + if (array instanceof long[]) + return ((long[]) array)[index]; + + if (array instanceof short[]) + return ((short[]) array)[index]; + + if (array instanceof float[]) + return ((float[]) array)[index]; + + if (array instanceof double[]) + return ((double[]) array)[index]; + + throw new IllegalArgumentException(); + } + + public static void set(Object array, int index, Object value) throws IllegalArgumentException, ArrayIndexOutOfBoundsException { + if (array == null) + throw new NullPointerException(); + + if (array instanceof int[]) { + ((int[]) array)[index] = (int) value; + return; + } + + if (array instanceof byte[]) { + ((byte[]) array)[index] = (byte) value; + return; + } + + if (array instanceof char[]) { + ((char[]) array)[index] = (char) value; + return; + } + + if (array instanceof long[]) { + ((long[]) array)[index] = (long) value; + return; + } + + if (array instanceof boolean[]) { + ((boolean[]) array)[index] = (boolean) value; + return; + } + + if (array instanceof short[]) { + ((short[]) array)[index] = (short) value; + return; + } + + if (array instanceof float[]) { + ((float[]) array)[index] = (float) value; + return; + } + + if (array instanceof double[]) { + ((double[]) array)[index] = (double) value; + return; + } + + if (array instanceof Object[]) { + ((Object[]) array)[index] = value; + return; + } + + throw new IllegalArgumentException(); + } + + public static void setBoolean(Object array, int index, boolean value) throws IllegalArgumentException, ArrayIndexOutOfBoundsException { + if (array == null) + throw new NullPointerException(); + + if (array instanceof boolean[]) { + ((boolean[]) array)[index] = value; + return; + } + + throw new IllegalArgumentException(); + } + + public static void setByte(Object array, int index, byte value) throws IllegalArgumentException, ArrayIndexOutOfBoundsException { + if (array == null) + throw new NullPointerException(); + + if (array instanceof int[]) { + ((int[]) array)[index] = value; + return; + } + + if (array instanceof byte[]) { + ((byte[]) array)[index] = value; + return; + } + + if (array instanceof long[]) { + ((long[]) array)[index] = value; + return; + } + + if (array instanceof short[]) { + ((short[]) array)[index] = value; + return; + } + + if (array instanceof float[]) { + ((float[]) array)[index] = value; + return; + } + + if (array instanceof double[]) { + ((double[]) array)[index] = value; + return; + } + + throw new IllegalArgumentException(); + } + + public static void setChar(Object array, int index, char value) throws IllegalArgumentException, ArrayIndexOutOfBoundsException { + if (array == null) + throw new NullPointerException(); + + if (array instanceof int[]) { + ((int[]) array)[index] = value; + return; + } + + if (array instanceof char[]) { + ((char[]) array)[index] = value; + return; + } + + if (array instanceof long[]) { + ((long[]) array)[index] = value; + return; + } + + if (array instanceof float[]) { + ((float[]) array)[index] = value; + return; + } + + if (array instanceof double[]) { + ((double[]) array)[index] = value; + return; + } + + throw new IllegalArgumentException(); + } + + public static void setShort(Object array, int index, short value) throws IllegalArgumentException, ArrayIndexOutOfBoundsException { + if (array == null) + throw new NullPointerException(); + + if (array instanceof int[]) { + ((int[]) array)[index] = value; + return; + } + + if (array instanceof long[]) { + ((long[]) array)[index] = value; + return; + } + + if (array instanceof short[]) { + ((short[]) array)[index] = value; + return; + } + + if (array instanceof float[]) { + ((float[]) array)[index] = value; + return; + } + + if (array instanceof double[]) { + ((double[]) array)[index] = value; + return; + } + + throw new IllegalArgumentException(); + } + + public static void setInt(Object array, int index, int value) throws IllegalArgumentException, ArrayIndexOutOfBoundsException { + if (array == null) + throw new NullPointerException(); + + if (array instanceof int[]) { + ((int[]) array)[index] = value; + return; + } + + if (array instanceof long[]) { + ((long[]) array)[index] = value; + return; + } + + if (array instanceof float[]) { + ((float[]) array)[index] = (float) value; + return; + } + + if (array instanceof double[]) { + ((double[]) array)[index] = value; + return; + } + + throw new IllegalArgumentException(); + } + + public static void setLong(Object array, int index, long value) throws IllegalArgumentException, ArrayIndexOutOfBoundsException { + if (array == null) + throw new NullPointerException(); + + if (array instanceof long[]) { + ((long[]) array)[index] = value; + return; + } + + if (array instanceof double[]) { + ((double[]) array)[index] = (double) value; + return; + } + + throw new IllegalArgumentException(); + } + + public static void setFloat(Object array, int index, float value) throws IllegalArgumentException, ArrayIndexOutOfBoundsException { + if (array == null) + throw new NullPointerException(); + + if (array instanceof float[]) { + ((float[]) array)[index] = value; + return; + } + + if (array instanceof double[]) { + ((double[]) array)[index] = value; + return; + } + + throw new IllegalArgumentException(); + } + + public static void setDouble(Object array, int index, Object value) throws IllegalArgumentException, ArrayIndexOutOfBoundsException { + if (array == null) + throw new NullPointerException(); + + if (array instanceof double[]) { + ((double[]) array)[index] = (double) value; + return; + } + + throw new IllegalArgumentException(); + } +} diff --git a/approximations/src/main/java/generated/java/util/list/SubListImpl.java b/approximations/src/main/java/generated/java/util/list/SubListImpl.java index b9dc94e3..f59c0371 100644 --- a/approximations/src/main/java/generated/java/util/list/SubListImpl.java +++ b/approximations/src/main/java/generated/java/util/list/SubListImpl.java @@ -50,7 +50,7 @@ private SubListImpl(AbstractListImpl list, SubListImpl parent, int offset, } public SubListImpl(AbstractListImpl list, int fromIndex, int toIndex) { - this(list, null, fromIndex, toIndex - fromIndex, 0); + this(list, null, fromIndex, toIndex - fromIndex, list._getModCount()); } public SymbolicList _getStorage() { diff --git a/approximations/src/main/java/generated/java/util/map/Map_Contents_IteratorImpl.java b/approximations/src/main/java/generated/java/util/map/Map_Contents_IteratorImpl.java index 3d7714c8..ca510a78 100644 --- a/approximations/src/main/java/generated/java/util/map/Map_Contents_IteratorImpl.java +++ b/approximations/src/main/java/generated/java/util/map/Map_Contents_IteratorImpl.java @@ -47,23 +47,19 @@ protected int _parentModCount() { } private boolean _isEmpty() { - // TODO: make via 'contains(unseen.anyKey) == false' - return this.unseen.size() == 0; + return !this.unseen.hasKey(this.unseen.anyKey()); } public void forEachRemaining(Consumer userAction) { if (userAction == null) throw new NullPointerException(); - int size = this.unseen.size(); - Engine.assume(size >= 0); Map_ContentsImpl contents = _getContents(); - while (size > 0) { + while (!_isEmpty()) { _checkForModification(); K curKey = this.unseen.anyKey(); userAction.accept(contents._contentByKey(this.unseen, curKey)); this.unseen.remove(curKey); - size--; } } diff --git a/approximations/src/main/java/generated/java/util/set/Set_IteratorImpl.java b/approximations/src/main/java/generated/java/util/set/Set_IteratorImpl.java index 98158b54..403b1b2f 100644 --- a/approximations/src/main/java/generated/java/util/set/Set_IteratorImpl.java +++ b/approximations/src/main/java/generated/java/util/set/Set_IteratorImpl.java @@ -44,21 +44,18 @@ protected int _parentModCount() { } private boolean _isEmpty() { - return this.unseen.size() == 0; + return !this.unseen.hasKey(this.unseen.anyKey()); } public void forEachRemaining(Consumer userAction) { if (userAction == null) throw new NullPointerException(); - int size = this.unseen.size(); - Engine.assume(size >= 0); - while (size > 0) { + while (!_isEmpty()) { _checkForModification(); E curKey = this.unseen.anyKey(); userAction.accept(curKey); this.unseen.remove(curKey); - size--; } } diff --git a/approximations/src/main/java/runtime/LibSLRuntime.java b/approximations/src/main/java/runtime/LibSLRuntime.java index 67122554..e91a1bba 100644 --- a/approximations/src/main/java/runtime/LibSLRuntime.java +++ b/approximations/src/main/java/runtime/LibSLRuntime.java @@ -609,6 +609,7 @@ public static String toString(final Map v) { // TODO: use less complex approach String res = "{"; + // TODO: use unseen.remove instead of size final Map.Container unseen = v.map.duplicate(); while (count != 0) { final K key = unseen.anyKey(); @@ -721,6 +722,7 @@ public static int hashCode(final Map v) { // TODO: use less complex approach int res = 1; + // TODO: use unseen.remove instead of size final Map.Container unseen = v.map.duplicate(); while (count != 0) { final K key = unseen.anyKey(); @@ -823,6 +825,7 @@ public static boolean equals(final Map a, final Map b) { return true; Engine.assume(length >= 0); + // TODO: use unseen.remove instead of size final Map.Container unseen = a.map.duplicate(); while (length != 0) { final K key = unseen.anyKey(); diff --git a/usvm-api/usvm-jvm-api.jar b/usvm-api/usvm-jvm-api.jar index ab19153418050bbc7409602492a0fe144b1eccb0..6b83cb1aff457ab049042d978d92a92008bfc4bb 100644 GIT binary patch delta 2962 zcmZWrc{r4N8=l65Y$eJtL-u7XlWi#C*tamUB_X7cFxj%rYdDoH+bgoKnUkm(lqHR$ zI8t^BgDE0mvRAZxvvj`i>iXX6davic?&tnJ&+~iU_m8{dLXST$)`|@#2!U{NLL~9K znY^-WmjZV)F_vr>=pjLZ8HloMjNAZgu-m&l=&A9+JsbW!=4Nq>!w(|P<^Tb|i}NH#Sd6ZDZA>ZOt>OAtkfrPaDxpK+Q_ zF6D3JZzxwz+?H=DGb)Yjyh@R_Bb3@{UvQa77VSF=o2-*coGb_4B&iTq5c4_siON-u zY@Cq|pj50V*m(9jwCzd6gp96Wx^=5ZtbC%|rkbBV)f=k0SjVZCW(!;Ek>5V|DQex) zq%%8EffDuotcCh9+Vtk>s8p%x8`I)mcAI4$rC~NE(rpbe4c2$wt|3ns2+)Re z?tEtp_?bZ_6ijvtZJr&JzwdCB_&D&=YOr8Qw-C%QCCbk6QgqNud%v^q(oM@ei&59B zo3Td^hft*Ko%9qRzH%)ntaVZ{E+fTo_b!lnzapq9VCv__A)HCGX7xQiXHZP&rC~nh4THbSnzE_DrT(b*Jjq``p_K zd9u6XSM$ObT4k&@Ot?%+d;1^9JK<0X6?Z-^TG~CjF?X9A?lGiunt^~ymdNPtx9g;SjnaBWxRALe z_H;xb;CI5j-#t@Q&(FbbWGibB*%+row266nEyTY_+vo8x=t(p<<#qt9dt|fg@x?t0hbg08N1IYi zy+$2ye^=r@^E$1|)@-pihG?3cAe~yNug>w)1@?u`n5SV6<_qi51Ui?U-bt3d9a$?I zsSzE=*q#rEJ6@W7;{@BLn7{TkX(9atO8E@T$o$3XOEPsqAu9eGvOK{q(MBN7cf5lb&@#!^(H*jb`S2Rz zw%2WG=l&mUMp~NMMl)O6ot%9`5e_0`v|bwX6UHHcd9r~x6}N?fgVotQESw*_YN z=n09|i)$;%ZZ{japDxz7-dJu=SfE7l1~o6IWllw`wYff6yqr5FJs!Is{g>u3BC5Un z{+FiqUSFJGtcSC3(d)riONW95f%tX(75N`xjTd4*OSaqMF-{N6YK#4E@HM9Dmmb9@ z<~ls)aP)(PyK~o+MZpV01ac^F^}_9`l`uIOZ42so;S$GlhVlFM$#R~| zR;?um?hChiSU{$!*&IFH>v8%BLA}8{ZaY=hKhv#2cxyO3G&>xO_S28dXyPkk_sz`z zVBudU^jDpGMR-(7%LkF0z~8_SW)&?m`LjxO_lT~<$A7AaawOxm=8BCYo>u8J%V~U}_`lLTR(z^Q~)M9^}n&BR1uH{%+u&Q?}KBQ|Myocy3 zpF7z;q`-!tZg(6ZbADnsemnTlCpAq3ti+iU7h!k9-3a6!DiTf0o`Em1fiD zOKEoer}X}QoR;p8p@P@yI^nOfv+9Ecs%C(@$fNu37S%T@hYAy&9k0(A4Me{Qt+b{- zzZUUoZ;pKqq%sPiDWJfR-%LZDT4qLc+{DR zW}ZthCXnNIVS$80Tr7|wy!&r4HKwE!@s^DVh(|b}Oi(Amw}+En?o1X983v|v36rRj zhgqY1m9k<1GZ_*~{9O*m0yvcM9)=MDA1i7wToU+6QJ+x`R8>MVqqmXkUBkQVwYPk;Y?DhX}8^z$e%PlY99B%r^tbmR8xIRIHP!1IA6 z!f5Oh`rv^vUa#<*ybC^#r71g8C>is-6#1|t|AbGZ=|VZix|v&8Qbj;FWtj6GQ9Ht<4Ac-%LpkQWF>0*7PbRsR o73s?^he05Uzs>kX0jyJF{Ru1da{)^9&n^KfsvlslQ)USN10%9K*Z=?k delta 2567 zcmZuz2{=@H8$ZT2#@J_UW6c(Zv5c*J-Nuq-5G7kkS0qwV)-Gd+dXkirZDfncnvAs+ znS>^Wlyogwz9fpNWWRN1&h*{;xc58fInV!h-uL(Z-uM6h&-1*eH~4X&kTa2+2L%9d zIPkD2@4ApWw`*$dbz^&O_FIxNw3Mqu%Yc?J%jh*2>6RnT2LSfsAe>8?bT~@l5Nblh zF)sx7A?}I`RH879TS!DA?~V-Jpk`--B@rb)AfH%Zx@@6H?&piPw{d|f z_Z8G(1M-upsAL~K(Zu)DdT>jgNTbQDSjTSWker<1%fp_uNK^^w3YUVztm@RglUf?5 z-#aFtny8*MbjSChFe49PM)Y zuBWu*F73O&Iq5rmQ$hA4wSN5 zEk5JDL-Y4b>OWI%AP;I^?m`~S$x(l+UG`3os6f~Ds!w@PkXagD=5jQ}%r4l?1f6Y= z8mH`4)+b9hppeSc#1+3-#`}LVd^Cb>Y9b%tq3voci7is7>Pgry8-uE`yn?&X6zw8fOmXc`Vx4=%7L!d#hu=vU>;22 zbHn>j_nWJYGyFoG#6}0O#w)Q@dRYpsSEFw8M0k*OaWd(7+kRwM{*z>j+|DhJ;+`D~ z->jZ?2H6*#@s^N|q0}Z=j8Fd%aTP_uuD+o8&F*s?3_WqOr65WzS;r9->$dq^LUW4j zU_@NO9PaOw)?g@8evgeO55&#M zwTax*7>HljKlk1GwpWhpjrDX(llT;)|HdlOZpCCy*^*4=uhK%`x9`uG-vMGgvcpvD z;o@AT{1VamC%tkz7w``X34L!ugI1QDzit`hFGk*3-!R6nE;<_u#n=tLK)2bN{Y!nIE1M?-8?Svn1>+*)RcQ$MxXMdPi zdA8GMjY^`3XL$d>SDHMp>h3O1&;BfrobicHzj*#i^S(38^hwJgg;z1fW{D03SLY8! zzoiS&$E=Uk!qjlhhh}HvS_3>*!c`1bGjQ(7A-<$juCuvaHZ_k8#iG@ftOzqdZJHzSOTMFYx9D zgk_~+kB?$){9a9#Wg8_{CmAeA9v`ZJ1IOo2k)T)-CNR;BF=_W7KYfeDt-=Ywilc zC4`Uk?4BJ=wcomuZmgYXO>LifL#U3QoF+@BBKp&(5oIO%7-7DQ7Lsf=ahm_=adWG8AR4`T85DIxL z9Kr(uoP;L_q)H(;AP2MgKQ#qVQ5_Dp$s-{uU4Dui0(X`9VGw9l5$06zOcl=oTiNmh(SQUZM?gup_5PO@5kRx&hXUeK3?;yrD!y?Ln9T@b# zDr58he`m-TP*h#&UjdgC{m_Nn0H6W~0F7-~nxFuXsmc#d8c0D0ykUTWQ50D^3gDQs z0Jz7HQ@o=g23D%fmIvReh>HB9TVN5(-M9mCGgU>|ZHM+(U)WBCv-Y>bs(0tM%pX-i zQM@sf(GHJ+?Na+0%MbphApoZRJfE8^7gGar4d8b`l2z1rSGFXB^(bzWJf;PGK!sR@ Wq%)D1_2UKrGORn19{?(#!}$|vb1n=3 From aa9e3584461ebc50bb1f580d8ca25d888f0cdfe4 Mon Sep 17 00:00:00 2001 From: Mikhail Kosticyn Date: Tue, 29 Jul 2025 19:29:55 +0300 Subject: [PATCH 08/10] Fixed string equality (#19) * [fix] fixed string equality * [fix] added `arrayEquals` description --- .../java/generated/java/lang/StringImpl.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/approximations/src/main/java/generated/java/lang/StringImpl.java b/approximations/src/main/java/generated/java/lang/StringImpl.java index f21f6de5..13611ae5 100644 --- a/approximations/src/main/java/generated/java/lang/StringImpl.java +++ b/approximations/src/main/java/generated/java/lang/StringImpl.java @@ -292,21 +292,22 @@ public void getBytes(int srcBegin, int srcEnd, byte[] dst, int dstBegin) { } public static boolean latin1Equals(byte[] value, byte[] other) { + /* + `Engine.arrayEquals` checks arrays lengths: + - if they are equal, but symbolic, returns null + - Otherwise checks equality of each element and returns non-null value + */ Boolean arrayEquals = Engine.arrayEquals(value, other); if (arrayEquals != null) return arrayEquals; - if (value.length == other.length) { - for(int i = 0; i < value.length; ++i) { - if (value[i] != other[i]) { - return false; - } + for(int i = 0; i < value.length; ++i) { + if (value[i] != other[i]) { + return false; } - - return true; - } else { - return false; } + + return true; } public boolean equals(Object anObject) { From dcc2d99fe3a0993d2512c85538640982bbfe6b1a Mon Sep 17 00:00:00 2001 From: Startsev Matvey Date: Mon, 6 Oct 2025 18:11:19 +0300 Subject: [PATCH 09/10] [feat] adds TreeSet approximation (#20) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Старцев Матвей --- .../decoders/java/util/TreeSet_Decoder.java | 138 +++++++++++++++ .../encoders/java/util/TreeSet_Encoder.java | 19 ++ .../generated/java/util/set/TreeSetImpl.java | 163 ++++++++++++++++++ 3 files changed, 320 insertions(+) create mode 100644 approximations/src/main/java/decoders/java/util/TreeSet_Decoder.java create mode 100644 approximations/src/main/java/encoders/java/util/TreeSet_Encoder.java create mode 100644 approximations/src/main/java/generated/java/util/set/TreeSetImpl.java diff --git a/approximations/src/main/java/decoders/java/util/TreeSet_Decoder.java b/approximations/src/main/java/decoders/java/util/TreeSet_Decoder.java new file mode 100644 index 00000000..2dcc60e0 --- /dev/null +++ b/approximations/src/main/java/decoders/java/util/TreeSet_Decoder.java @@ -0,0 +1,138 @@ +package decoders.java.util; + +import org.jacodb.api.jvm.*; +import org.usvm.api.SymbolicMap; +import org.usvm.api.decoder.DecoderApi; +import org.usvm.api.decoder.DecoderFor; +import org.usvm.api.decoder.ObjectData; +import org.usvm.api.decoder.ObjectDecoder; + +import java.util.ArrayList; +import java.util.List; +import java.util.TreeSet; + +import static org.usvm.api.decoder.DecoderUtils.findStorageField; + +@DecoderFor(TreeSet.class) +public final class TreeSet_Decoder implements ObjectDecoder { + private volatile JcMethod[] cachedMethods = null; + private volatile JcMethod cached_TreeSet_ctor = null; + private volatile JcMethod cached_TreeSet_add = null; + private volatile JcField cached_TreeSet_storage = null; + private volatile JcField cached_Map_map = null; + private volatile JcField cached_HashMapContainer_map = null; + + @Override + public T createInstance(final JcClassOrInterface approximation, + final ObjectData approximationData, + final DecoderApi decoder) { + JcMethod ctor = cached_TreeSet_ctor; + // TODO: add synchronization if needed + if (ctor == null) { + final List methodList = approximation.getDeclaredMethods(); + final int methodCount = methodList.size(); + JcMethod[] methods = new JcMethod[methodCount]; + cachedMethods = methods = methodList.toArray(methods); + + for (int i = 0; i != methodCount; i++) { + JcMethod m = methods[i]; + + if (m.isConstructor()) { + List params = m.getParameters(); + if (!params.isEmpty()) continue; + cached_TreeSet_ctor = ctor = m; + break; + } + } + } + + final List args = new ArrayList<>(); + return decoder.invokeMethod(ctor, args); + } + + @Override + public void initializeInstance(final JcClassOrInterface approximation, + final ObjectData approximationData, + final T outputInstance, + final DecoderApi decoder) { + JcField f_ts_storage = cached_TreeSet_storage; + // TODO: add synchronization if needed + if (f_ts_storage == null) { + cached_TreeSet_storage = f_ts_storage = findStorageField(approximation); + } + + final ObjectData storageData = approximationData.getObjectField(f_ts_storage); + if (storageData == null) + return; + + JcMethod m_add = cached_TreeSet_add; + // TODO: add synchronization if needed + if (m_add == null) { + final JcMethod[] methods = cachedMethods; + for (int i = 0, c = methods.length; i != c; i++) { + JcMethod m = methods[i]; + + if (!"add".equals(m.getName())) continue; + List params = m.getParameters(); + if (params.size() != 1) continue; + if (!"java.lang.Object".equals(params.get(0).getType().getTypeName())) continue; + + m_add = m; + break; + } + cached_TreeSet_add = m_add; + } + + JcField f_m_map = cached_Map_map; + // TODO: add synchronization if needed + if (f_m_map == null) { + JcClasspath cp = approximation.getClasspath(); + { + List fields = cp.findClassOrNull("runtime.LibSLRuntime$Map").getDeclaredFields(); + for (int i = 0, c = fields.size(); i != c; i++) { + JcField field = fields.get(i); + + if ("map".equals(field.getName())) { + cached_Map_map = f_m_map = field; + break; + } + } + } + { + List fields = cp.findClassOrNull("runtime.LibSLRuntime$HashMapContainer").getDeclaredFields(); + for (int i = 0, c = fields.size(); i != c; i++) { + JcField field = fields.get(i); + + if ("map".equals(field.getName())) { + cached_HashMapContainer_map = field; + break; + } + } + } + } + + final ObjectData rtMapContainerData = storageData.getObjectField(f_m_map); + if (rtMapContainerData == null) + return; + + final SymbolicMap map = rtMapContainerData.decodeSymbolicMapField(cached_HashMapContainer_map); + if (map == null) + return; + + int length = map.size(); + if (length == Integer.MAX_VALUE) + return; + + while (length > 0) { + T key = map.anyKey(); + + List args = new ArrayList<>(); + args.add(outputInstance); + args.add(key); + decoder.invokeMethod(m_add, args); + + map.remove(key); + length--; + } + } +} diff --git a/approximations/src/main/java/encoders/java/util/TreeSet_Encoder.java b/approximations/src/main/java/encoders/java/util/TreeSet_Encoder.java new file mode 100644 index 00000000..e667fb0b --- /dev/null +++ b/approximations/src/main/java/encoders/java/util/TreeSet_Encoder.java @@ -0,0 +1,19 @@ +package encoders.java.util; + +import generated.java.util.set.TreeSetImpl; +import org.usvm.api.encoder.EncoderFor; +import org.usvm.api.encoder.ObjectEncoder; + +import java.util.Set; +import java.util.TreeSet; + +@EncoderFor(TreeSet.class) +public class TreeSet_Encoder implements ObjectEncoder { + + @Override + @SuppressWarnings("unchecked") + public Object encode(Object object) { + Set set = (Set) object; + return new TreeSetImpl<>(set); + } +} diff --git a/approximations/src/main/java/generated/java/util/set/TreeSetImpl.java b/approximations/src/main/java/generated/java/util/set/TreeSetImpl.java new file mode 100644 index 00000000..ba89cffc --- /dev/null +++ b/approximations/src/main/java/generated/java/util/set/TreeSetImpl.java @@ -0,0 +1,163 @@ +package generated.java.util.set; + +import org.jacodb.approximation.annotation.Approximate; +import org.jetbrains.annotations.NotNull; +import org.usvm.api.Engine; +import runtime.LibSLRuntime; + +import java.io.Serial; +import java.io.Serializable; +import java.util.Collection; +import java.util.Iterator; +import java.util.Spliterator; +import java.util.TreeSet; +import java.util.function.Consumer; +import java.util.function.IntFunction; +import java.util.function.Predicate; +import java.util.stream.Stream; + +@Approximate(TreeSet.class) +public class TreeSetImpl extends AbstractSetImpl implements Cloneable, Serializable { + + @Serial + private static final long serialVersionUID = -2479143000061671589L; + + private LibSLRuntime.Map storage; + + private int modCount; + + static { + Engine.assume(true); + } + + public TreeSetImpl() { + super(true); + } + + public TreeSetImpl(Collection c) { + super(true, c); + } + + public TreeSetImpl(int initialCapacity) { + super(true, initialCapacity); + } + + public TreeSetImpl(int initialCapacity, float loadFactor) { + super(true, initialCapacity, loadFactor); + } + + @SuppressWarnings("unused") + private TreeSetImpl(int initialCapacity, float loadFactor, boolean dummy) { + super(initialCapacity, loadFactor, dummy); + } + + public LibSLRuntime.Map _getStorage() { + LibSLRuntime.Map storage = this.storage; + Engine.assume(storage != null); + return storage; + } + + public void _setStorage(LibSLRuntime.Map storage) { this.storage = storage; } + + protected boolean _isHashSet() { return true; } + + public int _getModCount() { return modCount; } + + protected void _setModCount(int newModCount) { this.modCount = newModCount; } + + public boolean add(E e) { return super._add(e); } + + public void clear() { super._clear(); } + + @SuppressWarnings("MethodDoesntCallSuperMethod") + public Object clone() throws CloneNotSupportedException { + return super._clone(); + } + + public boolean contains(Object obj) { + return super._contains(obj); + } + + public boolean isEmpty() { + return super._isEmpty(); + } + + @NotNull + public Iterator iterator() { + return super._iterator(); + } + + public boolean remove(Object elem) { + return super._remove(elem); + } + + public int size() { + return super._size(); + } + + @NotNull + public Spliterator spliterator() { + return super._spliterator(); + } + + @SuppressWarnings("EqualsDoesntCheckParameterClass") + public boolean equals(Object other) { + return Engine.typeIs(other, TreeSetImpl.class) && super._equals(other); + } + + public int hashCode() { + return super._hashCode(); + } + + public boolean removeAll(@NotNull Collection c) { + return super._removeAll(c); + } + + @NotNull + public Object[] toArray() { + return super._toArray(); + } + + @NotNull + public T[] toArray(@NotNull T[] a) { + return super._toArray(a); + } + + public T[] toArray(@NotNull IntFunction generator) { + return super._toArray(generator); + } + + public boolean containsAll(@NotNull Collection c) { + return super._containsAll(c); + } + + public boolean addAll(@NotNull Collection c) { + return super._addAll(c); + } + + public boolean retainAll(@NotNull Collection c) { + return super._retainAll(c); + } + + public boolean removeIf(@NotNull Predicate filter) { + return super._removeIf(filter); + } + + public void forEach(Consumer userAction) { + super._forEach(userAction); + } + + @NotNull + public Stream stream() { + return super._stream(); + } + + @NotNull + public Stream parallelStream() { + return super._parallelStream(); + } + + public String toString() { + return super._toString(); + } +} From 607384f1a70a75923b2cc4086eff84695156cc3a Mon Sep 17 00:00:00 2001 From: Startsev Matvey Date: Tue, 7 Oct 2025 19:03:48 +0300 Subject: [PATCH 10/10] Fixes throwable approximation and Map.Container (#21) * [fix] fixed `Map.Container` - added assumes * [fix] fixed `Throwable` approximation --------- Co-authored-by: MchKosticyn --- .../generated/java/lang/ThrowableImpl.java | 4 ++-- .../src/main/java/runtime/LibSLRuntime.java | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/approximations/src/main/java/generated/java/lang/ThrowableImpl.java b/approximations/src/main/java/generated/java/lang/ThrowableImpl.java index 58bea77f..320f149d 100644 --- a/approximations/src/main/java/generated/java/lang/ThrowableImpl.java +++ b/approximations/src/main/java/generated/java/lang/ThrowableImpl.java @@ -29,8 +29,8 @@ public class ThrowableImpl implements Serializable { public final synchronized void addSuppressed(java.lang.Throwable exception) { } - public synchronized java.lang.Throwable fillInStackTrace() { - return Engine.makeSymbolic(java.lang.Throwable.class); + public synchronized ThrowableImpl fillInStackTrace() { + return this; } public StackTraceElement[] getStackTrace() { diff --git a/approximations/src/main/java/runtime/LibSLRuntime.java b/approximations/src/main/java/runtime/LibSLRuntime.java index e91a1bba..52d36df7 100644 --- a/approximations/src/main/java/runtime/LibSLRuntime.java +++ b/approximations/src/main/java/runtime/LibSLRuntime.java @@ -1335,6 +1335,8 @@ public HashMapContainer() { public void merge(Map.Container container) { Engine.assume(container instanceof HashMapContainer); HashMapContainer other = (HashMapContainer) container; + Engine.assume(map != null); + Engine.assume(other.map != null); map.merge(other.map); } @@ -1346,37 +1348,44 @@ public Map.Container getCleanInstance() { @Override public Map.Container duplicate() { final HashMapContainer obj = new HashMapContainer<>(); + Engine.assume(map != null); obj.map.merge(this.map); return obj; } @Override public boolean containsKey(K key) { + Engine.assume(map != null); return map.containsKey(key); } @Override public K anyKey() { + Engine.assume(map != null); return map.anyKey(); } @Override public V get(K key) { + Engine.assume(map != null); return map.get(key); } @Override public void set(K key, V value) { + Engine.assume(map != null); map.set(key, value); } @Override public void remove(K key) { + Engine.assume(map != null); map.remove(key); } @Override public int size() { + Engine.assume(map != null); return map.size(); } } @@ -1394,6 +1403,8 @@ public IdentityMapContainer() { public void merge(Map.Container container) { Engine.assume(container instanceof IdentityMapContainer); IdentityMapContainer other = (IdentityMapContainer) container; + Engine.assume(map != null); + Engine.assume(other.map != null); map.merge(other.map); } @@ -1405,37 +1416,44 @@ public Map.Container getCleanInstance() { @Override public Map.Container duplicate() { final IdentityMapContainer obj = new IdentityMapContainer<>(); + Engine.assume(map != null); obj.map.merge(this.map); return obj; } @Override public boolean containsKey(K key) { + Engine.assume(map != null); return map.containsKey(key); } @Override public K anyKey() { + Engine.assume(map != null); return map.anyKey(); } @Override public V get(K key) { + Engine.assume(map != null); return map.get(key); } @Override public void set(K key, V value) { + Engine.assume(map != null); map.set(key, value); } @Override public void remove(K key) { + Engine.assume(map != null); map.remove(key); } @Override public int size() { + Engine.assume(map != null); return map.size(); } }