├── .gitattributes ├── .github └── workflows │ ├── ci.yml │ ├── gradle-publish.yml │ └── python-runner-publish.yml ├── .gitignore ├── .gitmodules ├── COPYRIGHT_HEADER.txt ├── LICENSE ├── NOTICE.txt ├── README.md ├── build.gradle.kts ├── buildSrc ├── build.gradle.kts ├── settings.gradle.kts └── src │ └── main │ └── kotlin │ ├── Dependencies.kt │ ├── DetektConfiguration.kt │ ├── usvm.kotlin-conventions.gradle.kts │ └── usvmpython │ ├── Names.kt │ ├── Utils.kt │ └── tasks │ ├── CPythonBuildTasks.kt │ ├── JNIHeaderTask.kt │ ├── ManualRunTasks.kt │ └── PythonSamplesTasks.kt ├── detekt ├── baselines │ ├── usvm-core-Main.yml │ ├── usvm-core-Test.yml │ ├── usvm-jvm-Main.yml │ ├── usvm-jvm-Test.yml │ ├── usvm-jvm-instrumentation-Main.yml │ ├── usvm-jvm-instrumentation-Test.yml │ ├── usvm-sample-language-Main.yml │ ├── usvm-sample-language-Test.yml │ ├── usvm-util-Main.yml │ └── usvm-util-Test.yml └── config.yml ├── docs ├── assets │ └── images │ │ ├── injection.png │ │ └── injection_fp.png ├── meeting-minutes │ ├── 2023-02-21.md │ ├── 2023-02-22.md │ ├── 2023-04-25.md │ └── 2023-08-18.md └── proposals │ └── instrumentation-prosal.md ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── jitpack.yml ├── settings.gradle.kts ├── usvm-core ├── build.gradle.kts └── src │ ├── main │ └── kotlin │ │ └── org │ │ └── usvm │ │ ├── CallStack.kt │ │ ├── Composition.kt │ │ ├── Context.kt │ │ ├── ExprTransformer.kt │ │ ├── Expressions.kt │ │ ├── Interpreter.kt │ │ ├── Machine.kt │ │ ├── Mocks.kt │ │ ├── PathNode.kt │ │ ├── PathSelector.kt │ │ ├── State.kt │ │ ├── StateForker.kt │ │ ├── StepScope.kt │ │ ├── UComponents.kt │ │ ├── USizeExprProvider.kt │ │ ├── api │ │ ├── EngineApi.kt │ │ ├── MemoryApi.kt │ │ ├── MockApi.kt │ │ └── collection │ │ │ ├── ListCollectionApi.kt │ │ │ └── ObjectMapCollectionApi.kt │ │ ├── collection │ │ ├── array │ │ │ ├── ArrayRegion.kt │ │ │ ├── ArrayRegionApi.kt │ │ │ ├── ArrayRegionTranslator.kt │ │ │ ├── Expressions.kt │ │ │ ├── UArrayModelRegion.kt │ │ │ ├── USymbolicArrayCopyAdapter.kt │ │ │ ├── USymbolicArrayId.kt │ │ │ ├── USymbolicArrayIndexKeyInfo.kt │ │ │ └── length │ │ │ │ ├── ArrayLengthRegion.kt │ │ │ │ ├── ArrayLengthRegionTranslator.kt │ │ │ │ ├── Expressions.kt │ │ │ │ ├── UArrayLengthModelRegion.kt │ │ │ │ └── USymbolicArrayLengthId.kt │ │ ├── field │ │ │ ├── Expressions.kt │ │ │ ├── FieldRegionTranslator.kt │ │ │ ├── FieldsRegion.kt │ │ │ ├── UFieldsModelRegion.kt │ │ │ └── USymbolicFieldId.kt │ │ ├── map │ │ │ ├── USymbolicMapKeyInfo.kt │ │ │ ├── length │ │ │ │ ├── Expressions.kt │ │ │ │ ├── UMapLengthModelRegion.kt │ │ │ │ ├── UMapLengthRegion.kt │ │ │ │ ├── UMapLengthRegionTranslator.kt │ │ │ │ └── USymbolicMapLengthId.kt │ │ │ ├── primitive │ │ │ │ ├── Expressions.kt │ │ │ │ ├── UMapModelRegion.kt │ │ │ │ ├── UMapRegion.kt │ │ │ │ ├── UMapRegionApi.kt │ │ │ │ ├── UMapRegionTranslator.kt │ │ │ │ ├── USymbolicMapId.kt │ │ │ │ └── USymbolicMapMergeAdapter.kt │ │ │ └── ref │ │ │ │ ├── Expressions.kt │ │ │ │ ├── URefMapModelRegion.kt │ │ │ │ ├── URefMapRegion.kt │ │ │ │ ├── URefMapRegionApi.kt │ │ │ │ ├── URefMapRegionTranslator.kt │ │ │ │ ├── USymbolicRefMapId.kt │ │ │ │ └── USymbolicRefMapMergeAdapter.kt │ │ └── set │ │ │ ├── USetCollectionDecoder.kt │ │ │ ├── USetRegionBuilder.kt │ │ │ ├── USetUpdatesTranslator.kt │ │ │ ├── USymbolicSetElementsCollector.kt │ │ │ ├── USymbolicSetEntries.kt │ │ │ ├── USymbolicSetKeyInfo.kt │ │ │ ├── USymbolicSetUnionElements.kt │ │ │ ├── primitive │ │ │ ├── Expressions.kt │ │ │ ├── USetModelRegion.kt │ │ │ ├── USetRegion.kt │ │ │ ├── USetRegionApi.kt │ │ │ ├── USetRegionTranslator.kt │ │ │ ├── USymbolicSetId.kt │ │ │ └── USymbolicSetUnionAdapter.kt │ │ │ └── ref │ │ │ ├── Expressions.kt │ │ │ ├── URefSetModelRegion.kt │ │ │ ├── URefSetRegion.kt │ │ │ ├── URefSetRegionApi.kt │ │ │ ├── URefSetRegionTranslator.kt │ │ │ ├── USymbolicRefSetId.kt │ │ │ └── USymbolicRefSetUnionAdapter.kt │ │ ├── constraints │ │ ├── EqualityConstraints.kt │ │ ├── PathConstraints.kt │ │ ├── TypeConstraints.kt │ │ ├── ULogicalConstraints.kt │ │ └── UNumericConstraints.kt │ │ ├── forkblacklists │ │ ├── TargetsReachableForkBlackList.kt │ │ └── UForkBlackList.kt │ │ ├── memory │ │ ├── HeapRefSplitting.kt │ │ ├── Memory.kt │ │ ├── RegistersStack.kt │ │ ├── SymbolicCollectionUpdates.kt │ │ ├── USymbolicCollection.kt │ │ ├── USymbolicCollectionAdapter.kt │ │ ├── USymbolicCollectionId.kt │ │ ├── USymbolicCollectionKeyInfo.kt │ │ ├── UpdateNodes.kt │ │ └── key │ │ │ ├── UHeapRefKeyInfo.kt │ │ │ └── USizeExprKeyInfo.kt │ │ ├── merging │ │ ├── CloseStatesSearcher.kt │ │ ├── MergeGuard.kt │ │ ├── Merging.kt │ │ └── MergingPathSelector.kt │ │ ├── model │ │ ├── EagerModels.kt │ │ ├── FunctionAppCollector.kt │ │ ├── LazyModelDecoder.kt │ │ ├── LazyModels.kt │ │ ├── Model.kt │ │ ├── ModelRegions.kt │ │ ├── UModelEvaluator.kt │ │ └── UTypeModel.kt │ │ ├── ps │ │ ├── BfsPathSelector.kt │ │ ├── CompletelyFairPathSelector.kt │ │ ├── ConstantTimeFairPathSelector.kt │ │ ├── DfsPathSelector.kt │ │ ├── ExceptionPropagationPathSelector.kt │ │ ├── ExecutionTreeTracker.kt │ │ ├── InterleavedPathSelector.kt │ │ ├── IterativeDeepeningPs.kt │ │ ├── KeyedPathSelector.kt │ │ ├── LoopLimiterPs.kt │ │ ├── ParallelPathSelector.kt │ │ ├── PathSelectorFactory.kt │ │ ├── RandomTreePathSelector.kt │ │ ├── StateLoopStatistic.kt │ │ ├── StateLoopTracker.kt │ │ ├── StateWeighter.kt │ │ └── WeightedPathSelector.kt │ │ ├── solver │ │ ├── ExprTranslator.kt │ │ ├── RegionTranslator.kt │ │ ├── Solver.kt │ │ ├── TypeSolver.kt │ │ └── USoftConstraintsProvider.kt │ │ ├── statistics │ │ ├── ApplicationGraph.kt │ │ ├── CoverageStatistics.kt │ │ ├── StatisticsByMethodPrinter.kt │ │ ├── StepsStatistics.kt │ │ ├── TimeStatistics.kt │ │ ├── TransitiveCoverageZoneObserver.kt │ │ ├── UDebugProfileObserver.kt │ │ ├── UInterpreterObserver.kt │ │ ├── UMachineObserver.kt │ │ ├── collectors │ │ │ ├── AllStatesCollector.kt │ │ │ ├── CoveredNewStatesCollector.kt │ │ │ ├── StatesCollector.kt │ │ │ └── TargetsReachedStatesCollector.kt │ │ ├── constraints │ │ │ └── SoftConstraintsObserver.kt │ │ └── distances │ │ │ ├── CallGraphStatistics.kt │ │ │ ├── CallGraphStatisticsImpl.kt │ │ │ ├── CallStackDistanceCalculator.kt │ │ │ ├── CfgStatistics.kt │ │ │ ├── CfgStatisticsImpl.kt │ │ │ ├── DistanceCalculator.kt │ │ │ ├── InterprocDistanceCalculator.kt │ │ │ └── PlainCallGraphStatistics.kt │ │ ├── stopstrategies │ │ ├── StepLimitStopStrategy.kt │ │ ├── StepsFromLastCoveredStopStrategy.kt │ │ ├── StopStrategy.kt │ │ ├── StopStrategyFactory.kt │ │ ├── TargetsReachedStopStrategy.kt │ │ └── TimeoutStopStrategy.kt │ │ ├── targets │ │ ├── UTarget.kt │ │ ├── UTargetController.kt │ │ └── UTargetsSet.kt │ │ ├── types │ │ ├── SupportTypeStream.kt │ │ ├── TypeRegion.kt │ │ ├── TypeStream.kt │ │ └── TypeSystem.kt │ │ └── utils │ │ ├── ResultUtils.kt │ │ └── StateUtils.kt │ └── test │ └── kotlin │ └── org │ └── usvm │ ├── CompositionTest.kt │ ├── TestApplicationGraph.kt │ ├── TestUtil.kt │ ├── UContextInterningTest.kt │ ├── api │ └── collections │ │ ├── ObjectMapTest.kt │ │ ├── SymbolicCollectionTestBase.kt │ │ └── SymbolicListTest.kt │ ├── constraints │ ├── EqualityConstraintsTests.kt │ └── NumericConstraintsTests.kt │ ├── memory │ ├── HeapMemCpyTest.kt │ ├── HeapMemsetTest.kt │ ├── HeapRefEqTest.kt │ ├── HeapRefSplittingTest.kt │ ├── MemoryRegionTest.kt │ ├── SetEntriesTest.kt │ └── UpdatesIteratorTest.kt │ ├── merging │ ├── CloseStatesSearcherTest.kt │ ├── MemoryMergingTest.kt │ └── PathConstraintsMergingTest.kt │ ├── model │ ├── ModelCompositionTest.kt │ └── ModelDecodingTest.kt │ ├── ps │ ├── CompletelyFairPathSelectorTests.kt │ ├── ConstantTimeFairPathSelectorTests.kt │ ├── ExecutionTreeTrackerTest.kt │ └── RandomTreePathSelectorTests.kt │ ├── solver │ ├── SoftConstraintsTest.kt │ └── TranslationTest.kt │ ├── statistics │ ├── CallStackDistanceCalculatorTests.kt │ └── InterprocDistanceCalculatorTests.kt │ └── types │ ├── TypeSolverTest.kt │ ├── TypeStreamTest.kt │ ├── single │ └── SingleTypeSystem.kt │ └── system │ ├── Builders.kt │ ├── Instance.kt │ ├── TestTypeSystem.kt │ └── TestTypes.kt ├── usvm-dataflow ├── build.gradle.kts └── src │ └── main │ └── kotlin │ └── org │ └── usvm │ └── dataflow │ ├── config │ ├── Condition.kt │ ├── Position.kt │ └── TaintAction.kt │ ├── graph │ ├── ApplicationGraph.kt │ └── BackwardGraphs.kt │ ├── ifds │ ├── AccessPath.kt │ ├── Accessors.kt │ ├── Analyzer.kt │ ├── Edge.kt │ ├── FlowFunctions.kt │ ├── IfdsResult.kt │ ├── Manager.kt │ ├── Reason.kt │ ├── Runner.kt │ ├── Summary.kt │ ├── TraceGraph.kt │ ├── UnitResolver.kt │ └── Vertex.kt │ ├── sarif │ ├── Sarif.kt │ ├── SourceFileResolver.kt │ └── Vulnerability.kt │ ├── taint │ ├── Sarif.kt │ ├── TaintAnalysisOptions.kt │ ├── TaintAnalyzers.kt │ ├── TaintBidiRunner.kt │ ├── TaintEvents.kt │ ├── TaintFacts.kt │ ├── TaintFlowFunctions.kt │ ├── TaintManager.kt │ ├── TaintSummaries.kt │ └── Types.kt │ └── util │ ├── Traits.kt │ └── Utils.kt ├── usvm-jvm-dataflow ├── build.gradle.kts └── src │ ├── main │ └── kotlin │ │ └── org │ │ └── usvm │ │ └── dataflow │ │ └── jvm │ │ ├── flow │ │ ├── AbstractFlowAnalysis.kt │ │ ├── BackwardFlowAnalysis.kt │ │ ├── FlowAnalysis.kt │ │ ├── FlowAnalysisImpl.kt │ │ ├── ForwardFlowAnalysis.kt │ │ ├── NullAssumptionAnalysis.kt │ │ └── ReachingDefinitionsAnalysis.kt │ │ ├── graph │ │ ├── ApplicationGraphFactory.kt │ │ ├── JcApplicationGraph.kt │ │ ├── JcApplicationGraphImpl.kt │ │ ├── JcNoopInst.kt │ │ └── SimplifiedJcApplicationGraph.kt │ │ ├── ifds │ │ └── UnitResolver.kt │ │ ├── npe │ │ ├── NpeAnalyzers.kt │ │ ├── NpeFlowFunctions.kt │ │ ├── NpeManager.kt │ │ └── Utils.kt │ │ ├── taint │ │ └── TaintManager.kt │ │ ├── unused │ │ ├── Sarif.kt │ │ ├── UnusedVariableAnalyzer.kt │ │ ├── UnusedVariableEvents.kt │ │ ├── UnusedVariableFacts.kt │ │ ├── UnusedVariableFlowFunctions.kt │ │ ├── UnusedVariableManager.kt │ │ ├── UnusedVariableSummaries.kt │ │ └── Utils.kt │ │ └── util │ │ └── JcTraits.kt │ ├── samples │ └── java │ │ ├── NpeExamples.java │ │ ├── SqlInjectionExamples.java │ │ ├── TaintExamples.java │ │ └── UntrustedLoopBound.java │ └── test │ ├── java │ └── org │ │ └── usvm │ │ └── dataflow │ │ └── jvm │ │ └── impl │ │ └── JavaAnalysisApiTest.java │ ├── kotlin │ └── org │ │ └── usvm │ │ └── dataflow │ │ └── jvm │ │ └── impl │ │ ├── BaseAnalysisTest.kt │ │ ├── ConditionEvaluatorTest.kt │ │ ├── IfdsNpeTest.kt │ │ ├── IfdsSqlTest.kt │ │ ├── IfdsTaintTest.kt │ │ ├── IfdsUntrustedLoopBoundTest.kt │ │ ├── IfdsUnusedTest.kt │ │ ├── JodaDateTimeAnalysisTest.kt │ │ └── TaintFlowFunctionsTest.kt │ └── resources │ ├── additional.json │ ├── config_small.json │ ├── config_test.json │ ├── config_untrusted_loop_bound.json │ └── pointerbench.jar ├── usvm-jvm-instrumentation ├── README.md ├── build.gradle.kts └── src │ ├── collectors │ └── java │ │ └── org │ │ └── usvm │ │ └── instrumentation │ │ └── collector │ │ └── trace │ │ ├── MockCollector.java │ │ └── TraceCollector.java │ ├── main │ ├── kotlin │ │ └── org │ │ │ └── usvm │ │ │ └── instrumentation │ │ │ ├── agent │ │ │ ├── Agent.kt │ │ │ └── ClassTransformer.kt │ │ │ ├── classloader │ │ │ └── WorkerClassLoader.kt │ │ │ ├── executor │ │ │ ├── InstrumentationProcessRunner.kt │ │ │ ├── RdProcessRunner.kt │ │ │ ├── TraceDeserializer.kt │ │ │ ├── UTestConcreteExecutor.kt │ │ │ └── UsvmRdCoroutineScope.kt │ │ │ ├── generated │ │ │ └── models │ │ │ │ ├── InstrumentedProcessModel.Generated.kt │ │ │ │ ├── InstrumentedProcessRoot.Generated.kt │ │ │ │ ├── SyncProtocolModel.Generated.kt │ │ │ │ └── SyncProtocolRoot.Generated.kt │ │ │ ├── instrumentation │ │ │ ├── JcInstructionTracer.kt │ │ │ ├── JcInstrumenter.kt │ │ │ ├── JcInstrumenterFactory.kt │ │ │ ├── JcRuntimeTraceInstrumenter.kt │ │ │ ├── NoInstrumentation.kt │ │ │ ├── TraceHelper.kt │ │ │ └── Tracer.kt │ │ │ ├── mock │ │ │ ├── MockClassRebuilder.kt │ │ │ └── MockHelper.kt │ │ │ ├── rd │ │ │ ├── InstrumentedProcess.kt │ │ │ ├── Lifetimed.kt │ │ │ ├── RdServer.kt │ │ │ ├── RdServerProcess.kt │ │ │ ├── RdUtils.kt │ │ │ └── UTestExecutor.kt │ │ │ ├── serializer │ │ │ ├── SerializationContext.kt │ │ │ ├── SerializationUtils.kt │ │ │ ├── UTestInstSerializer.kt │ │ │ └── UTestValueDescriptorSerializer.kt │ │ │ ├── testcase │ │ │ ├── UTest.kt │ │ │ ├── api │ │ │ │ ├── Api.kt │ │ │ │ └── Response.kt │ │ │ ├── descriptor │ │ │ │ ├── Descriptor.kt │ │ │ │ ├── Descriptor2ValueConverter.kt │ │ │ │ ├── StaticDescriptorsBuilder.kt │ │ │ │ ├── UTestUnexpectedExecutionBuilder.kt │ │ │ │ └── Value2DescriptorConverter.kt │ │ │ └── executor │ │ │ │ └── UTestExpressionExecutor.kt │ │ │ └── util │ │ │ ├── Classloader.kt │ │ │ ├── Collection.kt │ │ │ ├── Constants.kt │ │ │ ├── File.kt │ │ │ ├── Instrumentation.kt │ │ │ ├── Jacodb.kt │ │ │ ├── Jar.kt │ │ │ ├── Printer.kt │ │ │ ├── Reflection.kt │ │ │ ├── Try.kt │ │ │ └── UTestUtils.kt │ └── rdgen │ │ └── org │ │ └── usvm │ │ └── instrumentation │ │ └── models │ │ ├── InstrumentedProcessModel.kt │ │ └── SyncProtocolModel.kt │ ├── samples │ └── java │ │ └── example │ │ ├── A.java │ │ ├── AnnotationsEx.java │ │ ├── Arrays.java │ │ ├── B.java │ │ ├── C.java │ │ ├── ClassWithNestedClasses.java │ │ ├── ClassWithStaticField.java │ │ ├── EnumClass.java │ │ ├── Ex1.java │ │ ├── Ex2.java │ │ ├── Ex3.java │ │ ├── MockAbstractClass.java │ │ ├── MockClass.java │ │ ├── MockInterface.java │ │ ├── MyAnnotation.java │ │ ├── ParentStaticFieldUser.java │ │ ├── Singleton.java │ │ ├── SleepingClass.java │ │ └── StaticInterfaceMethodCall.java │ └── test │ └── kotlin │ └── org │ └── usvm │ └── instrumentation │ ├── executor │ ├── ConcreteExecutorTests.kt │ └── UTestConcreteExecutorTest.kt │ └── util │ └── UTestCreator.kt ├── usvm-jvm ├── build.gradle.kts └── src │ ├── main │ └── kotlin │ │ └── org │ │ └── usvm │ │ ├── api │ │ ├── JcTest.kt │ │ ├── checkers │ │ │ ├── JcChecker.kt │ │ │ └── JcCheckerImpl.kt │ │ ├── targets │ │ │ ├── JcTarget.kt │ │ │ ├── Position.kt │ │ │ ├── TaintAction.kt │ │ │ ├── TaintAnalysis.kt │ │ │ ├── TaintCondition.kt │ │ │ └── TaintConfigurationItem.kt │ │ └── util │ │ │ ├── JcClassLoader.kt │ │ │ ├── JcTestDecoders.kt │ │ │ ├── JcTestInterpreter.kt │ │ │ ├── JcTestInterpreterDecoderApi.kt │ │ │ ├── JcTestResolver.kt │ │ │ ├── JcTestStateResolver.kt │ │ │ └── Reflection.kt │ │ ├── machine │ │ ├── JcApplicationGraph.kt │ │ ├── JcApproximations.kt │ │ ├── JcCallGraphStatistics.kt │ │ ├── JcComponents.kt │ │ ├── JcContext.kt │ │ ├── JcDebugProfileObserver.kt │ │ ├── JcExpressions.kt │ │ ├── JcInterpreterObserver.kt │ │ ├── JcLoopTracker.kt │ │ ├── JcMachine.kt │ │ ├── JcMachineOptions.kt │ │ ├── JcMethodCallInst.kt │ │ ├── JcSolverFactory.kt │ │ ├── JcTransformer.kt │ │ ├── JcTypeSystem.kt │ │ ├── interpreter │ │ │ ├── JcCallSiteRegion.kt │ │ │ ├── JcExprResolver.kt │ │ │ ├── JcFixedInheritorsNumberTypeSelector.kt │ │ │ ├── JcInterpreter.kt │ │ │ ├── JcVirtualInvokeResolver.kt │ │ │ ├── statics │ │ │ │ ├── JcStaticFieldReading.kt │ │ │ │ └── JcStaticFieldsRegion.kt │ │ │ └── transformers │ │ │ │ ├── JcMultiDimArrayAllocationTransformer.kt │ │ │ │ ├── JcSingleInstructionTransformer.kt │ │ │ │ └── JcStringConcatTransformer.kt │ │ ├── mocks │ │ │ └── JcMocker.kt │ │ ├── operator │ │ │ ├── JcBinaryOperator.kt │ │ │ ├── JcOperatorUtils.kt │ │ │ └── JcUnaryOperator.kt │ │ └── state │ │ │ ├── JcMethodResult.kt │ │ │ ├── JcState.kt │ │ │ └── JcStateUtils.kt │ │ └── util │ │ ├── JcApproximationUtils.kt │ │ ├── JcMethodUtils.kt │ │ └── Utils.kt │ ├── sample-approximations │ ├── java │ │ └── org │ │ │ └── usvm │ │ │ └── samples │ │ │ └── approximations │ │ │ ├── TestListApproximation.java │ │ │ ├── TestMapApproximation.java │ │ │ └── TestVMApproximation.java │ └── kotlin │ │ └── org │ │ └── usvm │ │ └── samples │ │ └── approximations │ │ ├── TestListDecoder.kt │ │ └── TestMapDecoder.kt │ ├── samples-jdk11 │ └── java │ │ └── org │ │ └── usvm │ │ └── samples │ │ └── strings │ │ └── StringConcatSamples.java │ ├── samples │ ├── java │ │ └── org │ │ │ └── usvm │ │ │ ├── api │ │ │ ├── exception │ │ │ │ └── UMockAssumptionViolatedException.kt │ │ │ └── mock │ │ │ │ └── UMock.kt │ │ │ └── samples │ │ │ ├── algorithms │ │ │ ├── ArraysQuickSort.java │ │ │ ├── BinarySearch.java │ │ │ ├── CorrectBracketSequences.java │ │ │ ├── Graph.java │ │ │ ├── GraphExample.java │ │ │ ├── ReturnExample.java │ │ │ ├── Sort.java │ │ │ └── errors │ │ │ │ ├── Cartoons.java │ │ │ │ └── Taxi.java │ │ │ ├── annotations │ │ │ ├── ClassWithRefField.java │ │ │ ├── NotNullAnnotation.java │ │ │ └── lombok │ │ │ │ ├── EnumWithAnnotations.java │ │ │ │ ├── EnumWithoutAnnotations.java │ │ │ │ └── NotNullAnnotations.java │ │ │ ├── approximations │ │ │ ├── ApproximationsApiExample.java │ │ │ ├── ApproximationsExample.java │ │ │ ├── TestList.java │ │ │ └── TestMap.java │ │ │ ├── arrays │ │ │ ├── ArrayOfArrays.java │ │ │ ├── ArrayOfObjects.java │ │ │ ├── ArrayStoreExceptionExamples.java │ │ │ ├── ArraysOverwriteValue.java │ │ │ ├── CopyOfExample.java │ │ │ ├── FinalStaticFieldArray.java │ │ │ ├── IntArrayBasics.java │ │ │ ├── MultiDimensional.java │ │ │ ├── ObjectWithPrimitivesClass.java │ │ │ ├── ObjectWithPrimitivesClassSucc.java │ │ │ ├── OneDimensional.java │ │ │ ├── PrimitiveArrays.java │ │ │ ├── SomeImplementation.java │ │ │ └── SomeInterface.java │ │ │ ├── ast │ │ │ ├── Ast.java │ │ │ ├── AstExample.java │ │ │ ├── Binary.java │ │ │ ├── Constant.java │ │ │ ├── DefaultSubstitutor.java │ │ │ ├── Evaluator.java │ │ │ ├── Minus.java │ │ │ ├── Sum.java │ │ │ ├── Variable.java │ │ │ └── Visitor.java │ │ │ ├── callgraph │ │ │ ├── CallGraphTestClass1.java │ │ │ ├── CallGraphTestClass2.java │ │ │ ├── CallGraphTestClass3.java │ │ │ ├── CallGraphTestClass4.java │ │ │ └── CallGraphTestInterface.java │ │ │ ├── casts │ │ │ ├── ArrayCastExample.java │ │ │ ├── CastClass.java │ │ │ ├── CastClassFirstSucc.java │ │ │ ├── CastClassSecondSucc.java │ │ │ ├── CastExample.java │ │ │ ├── ClassWithGenerics.java │ │ │ ├── Colorable.java │ │ │ ├── ColoredPoint.java │ │ │ ├── GenericCastExample.java │ │ │ ├── InstanceOfExample.java │ │ │ └── Point.java │ │ │ ├── checkers │ │ │ └── DivisionExample.java │ │ │ ├── codegen │ │ │ ├── AnotherClassWithVoidStaticMethods.java │ │ │ ├── ClassFromTheSamePackage.java │ │ │ ├── ClassWithStaticAndInnerClasses.java │ │ │ ├── ClassWithVoidStaticMethods.java │ │ │ ├── CodegenExample.java │ │ │ ├── FileWithTopLevelFunctionsReflectHelper.java │ │ │ ├── JavaAssert.java │ │ │ ├── VoidStaticMethodsTestingClass.java │ │ │ ├── deepequals │ │ │ │ ├── ClassWithCrossReferenceRelationship.java │ │ │ │ ├── ClassWithNullableField.java │ │ │ │ ├── DeepEqualsTestingClass.java │ │ │ │ └── inner │ │ │ │ │ ├── GraphNode.java │ │ │ │ │ └── Node.java │ │ │ ├── modifiers │ │ │ │ └── ClassWithPrivateMutableFieldOfPrivateType.java │ │ │ └── nested │ │ │ │ └── ClassFromAnotherPackage.java │ │ │ ├── collections │ │ │ ├── CustomClass.java │ │ │ ├── CustomerExamples.java │ │ │ ├── GenericListsExample.java │ │ │ ├── LinkedLists.java │ │ │ ├── ListAlgorithms.java │ │ │ ├── ListIterators.java │ │ │ ├── ListWrapperReturnsVoidExample.java │ │ │ ├── Lists.java │ │ │ ├── MapEntrySet.java │ │ │ ├── MapKeySet.java │ │ │ ├── MapValues.java │ │ │ ├── Maps.java │ │ │ ├── Optionals.java │ │ │ ├── QueueUsages.java │ │ │ ├── SetIterators.java │ │ │ └── Sets.java │ │ │ ├── controlflow │ │ │ ├── Conditions.java │ │ │ ├── CycleDependedCondition.java │ │ │ ├── Cycles.java │ │ │ └── Switch.java │ │ │ ├── enums │ │ │ ├── ClassWithEnum.java │ │ │ ├── ClassWithEnumField.java │ │ │ ├── ComplexEnumExamples.java │ │ │ ├── CustomEnum.java │ │ │ ├── SimpleEnumExample.java │ │ │ └── State.java │ │ │ ├── exceptions │ │ │ ├── ExceptionClusteringExamples.java │ │ │ ├── ExceptionExamples.java │ │ │ ├── JvmCrashExamples.java │ │ │ └── MyCheckedException.java │ │ │ ├── functions │ │ │ ├── Simple.java │ │ │ └── Throwing.java │ │ │ ├── inner │ │ │ ├── ClassWithInnerAndNestedClassExample.java │ │ │ ├── InnerCalls.java │ │ │ └── NestedCalls.java │ │ │ ├── invokes │ │ │ ├── AbstractImplementor.java │ │ │ ├── BaseClass.java │ │ │ ├── DefaultInterface.java │ │ │ ├── DerivedClass.java │ │ │ ├── InvokeClass.java │ │ │ ├── InvokeExample.java │ │ │ ├── NativeExample.java │ │ │ ├── ObjectExample.java │ │ │ ├── Realization.java │ │ │ ├── SimpleInterface.java │ │ │ ├── SimpleInterfaceExample.java │ │ │ ├── SimpleInterfaceImpl.java │ │ │ ├── StaticInvokeExample.java │ │ │ ├── VirtualInvokeAbstractClass.java │ │ │ ├── VirtualInvokeAbstractClassSucc.java │ │ │ ├── VirtualInvokeClass.java │ │ │ ├── VirtualInvokeClassSucc.java │ │ │ ├── VirtualInvokeExample.java │ │ │ └── VirtualInvokeNestedIteExample.java │ │ │ ├── lambda │ │ │ ├── CustomPredicateExample.java │ │ │ ├── InvokeDynamicExamples.java │ │ │ ├── PredicateCapturedLocalVariable.java │ │ │ ├── PredicateCapturedNonStaticField.java │ │ │ ├── PredicateCapturedParameter.java │ │ │ ├── PredicateCapturedStaticField.java │ │ │ ├── PredicateNoCapturedValues.java │ │ │ ├── PredicateNotExample.java │ │ │ ├── SimpleLambdaExamples.java │ │ │ └── ThrowingWithLambdaExample.java │ │ │ ├── loops │ │ │ ├── Loops.java │ │ │ └── While.java │ │ │ ├── math │ │ │ ├── BitOperators.java │ │ │ ├── DivRemExamples.java │ │ │ ├── DoubleFunctions.java │ │ │ └── OverflowExamples.java │ │ │ ├── mixed │ │ │ ├── LoggerExample.java │ │ │ ├── MonitorUsage.java │ │ │ ├── Overload.java │ │ │ ├── PrivateConstructorExample.java │ │ │ ├── SerializableExample.java │ │ │ ├── SimpleNoCondition.java │ │ │ ├── Simplifier.java │ │ │ └── StaticMethodExamples.java │ │ │ ├── mock │ │ │ ├── CommonMocksExample.java │ │ │ ├── InnerMockWithFieldExample.java │ │ │ ├── InterfaceWithoutImplementors.java │ │ │ ├── MockFinalClassExample.java │ │ │ ├── MockRandomExamples.java │ │ │ ├── MockReturnObjectExample.java │ │ │ ├── MockStaticFieldExample.java │ │ │ ├── MockStaticMethodExample.java │ │ │ ├── MockWithFieldExample.java │ │ │ ├── MockWithSideEffectExample.java │ │ │ ├── UseNetwork.java │ │ │ ├── aliasing │ │ │ │ ├── AliasingInParamsExample.java │ │ │ │ ├── ClassFromTheSamePackage.java │ │ │ │ └── parent │ │ │ │ │ └── InterfaceFromAnotherPackage.java │ │ │ ├── fields │ │ │ │ ├── ClassUsingClassWithRandomField.java │ │ │ │ └── ClassWithRandomField.java │ │ │ ├── others │ │ │ │ ├── ClassWithStaticField.java │ │ │ │ ├── FinalClass.java │ │ │ │ ├── Generator.java │ │ │ │ ├── Locator.java │ │ │ │ ├── Network.java │ │ │ │ ├── Random.java │ │ │ │ ├── SideEffectApplier.java │ │ │ │ └── VersionStamp.java │ │ │ ├── provider │ │ │ │ ├── Provider.java │ │ │ │ └── impl │ │ │ │ │ └── ProviderImpl.java │ │ │ └── service │ │ │ │ ├── Service.java │ │ │ │ └── impl │ │ │ │ ├── ExampleClass.java │ │ │ │ ├── ServiceWithArguments.java │ │ │ │ ├── ServiceWithField.java │ │ │ │ └── ServiceWithStaticField.java │ │ │ ├── models │ │ │ ├── CompositeModelMinimizationExample.java │ │ │ ├── ModelsIdEqualityExample.java │ │ │ └── ObjectWithRefFieldClass.java │ │ │ ├── natives │ │ │ └── NativeExamples.java │ │ │ ├── nested │ │ │ └── DeepNested.java │ │ │ ├── numbers │ │ │ └── ArithmeticUtils.java │ │ │ ├── objects │ │ │ ├── AbstractAnonymousClass.java │ │ │ ├── AnonymousClassesExample.java │ │ │ ├── ClassForTestClinitSections.java │ │ │ ├── ClassRef.java │ │ │ ├── ClassWithClassRef.java │ │ │ ├── ClassWithPrivateField.java │ │ │ ├── HiddenFieldAccessModifiersExample.java │ │ │ ├── HiddenFieldAccessModifiersSucc.java │ │ │ ├── HiddenFieldAccessModifiersSuper.java │ │ │ ├── HiddenFieldExample.java │ │ │ ├── HiddenFieldSuccClass.java │ │ │ ├── HiddenFieldSuperClass.java │ │ │ ├── Id.java │ │ │ ├── LocalClassExample.java │ │ │ ├── ModelMinimizationExamples.java │ │ │ ├── ObjectWithFinalStatic.java │ │ │ ├── ObjectWithPrimitivesClass.java │ │ │ ├── ObjectWithPrimitivesClassSucc.java │ │ │ ├── ObjectWithPrimitivesExample.java │ │ │ ├── ObjectWithRefFieldClass.java │ │ │ ├── ObjectWithRefFieldExample.java │ │ │ ├── ObjectWithStaticFieldsClass.java │ │ │ ├── ObjectWithStaticFieldsExample.java │ │ │ ├── ObjectWithStatics.java │ │ │ ├── ObjectWithThrowableConstructor.java │ │ │ ├── PrivateFields.java │ │ │ ├── RecursiveType.java │ │ │ ├── RecursiveTypeClass.java │ │ │ ├── SemiImmutableClass.java │ │ │ ├── SimpleClassExample.java │ │ │ ├── SimpleClassMultiInstanceExample.java │ │ │ ├── SimpleDataClass.java │ │ │ ├── Vector2D.java │ │ │ ├── WrappedInt.java │ │ │ └── WrappedIntQuad.java │ │ │ ├── operators │ │ │ ├── Logic.java │ │ │ ├── Math.java │ │ │ ├── Overflow.java │ │ │ └── Shift.java │ │ │ ├── primitives │ │ │ ├── ByteExamples.java │ │ │ ├── CharAsFieldObject.java │ │ │ ├── CharExamples.java │ │ │ ├── DoubleExamples.java │ │ │ ├── FloatExamples.java │ │ │ └── IntExamples.java │ │ │ ├── psbenchmarks │ │ │ ├── Collatz.java │ │ │ └── LoanExam.java │ │ │ ├── recursion │ │ │ └── Recursion.java │ │ │ ├── reflection │ │ │ └── NewInstanceExample.java │ │ │ ├── statics │ │ │ └── StaticsTypesExample.java │ │ │ ├── stdlib │ │ │ ├── DateExample.java │ │ │ ├── JavaIOFileInputStreamCheck.java │ │ │ └── StaticsPathDiversion.java │ │ │ ├── stream │ │ │ ├── BaseStreamExample.java │ │ │ ├── DoubleStreamExample.java │ │ │ ├── IntStreamExample.java │ │ │ ├── LongStreamExample.java │ │ │ └── StreamsAsMethodResultExample.java │ │ │ ├── strings │ │ │ ├── GenericExamples.java │ │ │ └── StringExamples.java │ │ │ ├── strings11 │ │ │ └── StringConcat.java │ │ │ ├── structures │ │ │ ├── Heap.java │ │ │ ├── MinStack.java │ │ │ ├── MinStackExample.java │ │ │ ├── Pair.java │ │ │ └── StandardStructures.java │ │ │ ├── substitution │ │ │ ├── StaticSubstitution.java │ │ │ └── StaticSubstitutionExamples.java │ │ │ ├── symbolic │ │ │ ├── ClassWithComplicatedMethods.java │ │ │ └── ComplicatedMethodsSubstitutionsStorage.java │ │ │ ├── taint │ │ │ └── Taint.java │ │ │ ├── ternary │ │ │ └── Ternary.java │ │ │ ├── threads │ │ │ ├── CountDownLatchExamples.java │ │ │ ├── ExecutorServiceExamples.java │ │ │ ├── FutureExamples.java │ │ │ └── ThreadExamples.java │ │ │ ├── types │ │ │ ├── CastExamples.java │ │ │ ├── CollectionAsField.java │ │ │ ├── GenericWithUpperBound.java │ │ │ ├── Generics.java │ │ │ ├── Hierarchy.java │ │ │ ├── PathDependentGenericsExample.java │ │ │ ├── TypeBorders.java │ │ │ └── TypeMatches.java │ │ │ ├── unsafe │ │ │ ├── UnsafeOperations.java │ │ │ └── UnsafeWithField.java │ │ │ └── wrappers │ │ │ ├── BooleanWrapper.java │ │ │ ├── ByteWrapper.java │ │ │ ├── CharacterWrapper.java │ │ │ ├── DoubleWrapper.java │ │ │ ├── FloatWrapper.java │ │ │ ├── IntegerWrapper.java │ │ │ ├── LongWrapper.java │ │ │ └── ShortWrapper.java │ └── kotlin │ │ └── org │ │ └── usvm │ │ └── examples │ │ └── codegen │ │ └── FileWithTopLevelFunctions.kt │ ├── test │ ├── kotlin │ │ └── org │ │ │ └── usvm │ │ │ ├── machine │ │ │ ├── JcCallGraphStatisticsTests.kt │ │ │ └── operator │ │ │ │ ├── JcBinaryOperatorTest.kt │ │ │ │ ├── JcOperatorTestData.kt │ │ │ │ └── JcUnaryOperatorTest.kt │ │ │ ├── samples │ │ │ ├── JacoDBContainer.kt │ │ │ ├── JavaMethodTestRunner.kt │ │ │ ├── algorithms │ │ │ │ ├── BinarySearchTest.kt │ │ │ │ ├── CorrectBracketSequencesTest.kt │ │ │ │ ├── GraphTest.kt │ │ │ │ └── SortTest.kt │ │ │ ├── annotations │ │ │ │ ├── NotNullAnnotationTest.kt │ │ │ │ └── lombok │ │ │ │ │ ├── EnumWithAnnotationsTest.kt │ │ │ │ │ ├── EnumWithoutAnnotationsTest.kt │ │ │ │ │ └── NotNullAnnotationsTest.kt │ │ │ ├── approximations │ │ │ │ ├── ApproximationsDecoderTest.kt │ │ │ │ ├── ApproximationsExampleTest.kt │ │ │ │ ├── ApproximationsTest.kt │ │ │ │ ├── ApproximationsTestRunner.kt │ │ │ │ ├── ArrayListSpliteratorApproximationsTest.kt │ │ │ │ └── SymbolicCollectionModelTest.kt │ │ │ ├── arrays │ │ │ │ ├── ArrayOfArraysTest.kt │ │ │ │ ├── ArrayOfObjectsTest.kt │ │ │ │ ├── ArrayStoreExceptionExamplesTest.kt │ │ │ │ ├── ArraysOverwriteValueTest.kt │ │ │ │ ├── CopyOfExampleTest.kt │ │ │ │ ├── FinalStaticFieldArrayTest.kt │ │ │ │ ├── IntArrayBasicsTest.kt │ │ │ │ ├── PrimitiveArraysTest.kt │ │ │ │ ├── TestMultiDimensional.kt │ │ │ │ └── TestOneDimensional.kt │ │ │ ├── casts │ │ │ │ ├── ArrayCastExampleTest.kt │ │ │ │ ├── CastClassTest.kt │ │ │ │ ├── CastExampleTest.kt │ │ │ │ ├── GenericCastExampleTest.kt │ │ │ │ └── InstanceOfExampleTest.kt │ │ │ ├── checkers │ │ │ │ ├── DivisionExampleTest.kt │ │ │ │ └── JcDiv42Checker.kt │ │ │ ├── codegen │ │ │ │ ├── ClassWithStaticAndInnerClassesTest.kt │ │ │ │ ├── CodegenExampleTest.kt │ │ │ │ ├── FileWithTopLevelFunctionsTest.kt │ │ │ │ ├── JavaAssertTest.kt │ │ │ │ ├── VoidStaticMethodsTest.kt │ │ │ │ ├── deepequals │ │ │ │ │ ├── ClassWithCrossReferenceRelationshipTest.kt │ │ │ │ │ ├── ClassWithNullableFieldTest.kt │ │ │ │ │ └── DeepEqualsTest.kt │ │ │ │ └── modifiers │ │ │ │ │ └── ClassWithPrivateMutableFieldOfPrivateTypeTest.kt │ │ │ ├── collections │ │ │ │ ├── CustomerExamplesTest.kt │ │ │ │ ├── GenericListsExampleTest.kt │ │ │ │ ├── LinkedListsTest.kt │ │ │ │ ├── ListAlgorithmsTest.kt │ │ │ │ ├── ListIteratorsTest.kt │ │ │ │ ├── ListWrapperReturnsVoidTest.kt │ │ │ │ ├── ListsPart1Test.kt │ │ │ │ ├── ListsPart2Test.kt │ │ │ │ ├── ListsPart3Test.kt │ │ │ │ ├── MapEntrySetTest.kt │ │ │ │ ├── MapKeySetTest.kt │ │ │ │ ├── MapValuesTest.kt │ │ │ │ ├── MapsPart1Test.kt │ │ │ │ ├── MapsPart2Test.kt │ │ │ │ ├── OptionalsTest.kt │ │ │ │ ├── QueueUsagesTest.kt │ │ │ │ ├── SetIteratorsTest.kt │ │ │ │ └── SetsTest.kt │ │ │ ├── controlflow │ │ │ │ ├── ConditionsTest.kt │ │ │ │ ├── CycleDependedConditionTest.kt │ │ │ │ ├── CyclesTest.kt │ │ │ │ └── SwitchTest.kt │ │ │ ├── enums │ │ │ │ ├── ClassWithEnumFieldTest.kt │ │ │ │ ├── ClassWithEnumTest.kt │ │ │ │ └── ComplexEnumExamplesTest.kt │ │ │ ├── exceptions │ │ │ │ ├── ExceptionExamplesTest.kt │ │ │ │ └── JvmCrashExamplesTest.kt │ │ │ ├── functions │ │ │ │ ├── TestSimple.kt │ │ │ │ └── TestThrowing.kt │ │ │ ├── inner │ │ │ │ └── ClassWithInnerAndNestedClassExampleTest.kt │ │ │ ├── invokes │ │ │ │ ├── AstExampleTest.kt │ │ │ │ ├── InvokeExampleTest.kt │ │ │ │ ├── NativeExampleTest.kt │ │ │ │ ├── ObjectExampleTest.kt │ │ │ │ ├── SimpleInterfaceExampleTest.kt │ │ │ │ ├── StaticInvokeExampleTest.kt │ │ │ │ ├── VirtualInvokeExampleTest.kt │ │ │ │ └── VirtualInvokeNestedIteExampleTest.kt │ │ │ ├── lambda │ │ │ │ ├── CustomPredicateExampleTest.kt │ │ │ │ ├── InvokeDynamicExamplesTest.kt │ │ │ │ ├── PredicateNotExampleTest.kt │ │ │ │ ├── SimpleLambdaExamplesTest.kt │ │ │ │ └── ThrowingWithLambdaExampleTest.kt │ │ │ ├── loops │ │ │ │ ├── TestIterationLimit.kt │ │ │ │ └── TestWhile.kt │ │ │ ├── math │ │ │ │ ├── BitOperatorsTest.kt │ │ │ │ ├── DivRemExamplesTest.kt │ │ │ │ ├── DoubleFunctionsTest.kt │ │ │ │ └── OverflowAsErrorTest.kt │ │ │ ├── mixed │ │ │ │ ├── LoggerExampleTest.kt │ │ │ │ ├── MonitorUsageTest.kt │ │ │ │ ├── OverloadTest.kt │ │ │ │ ├── PrivateConstructorExampleTest.kt │ │ │ │ ├── SerializableExampleTest.kt │ │ │ │ ├── SimpleNoConditionTest.kt │ │ │ │ ├── SimplifierTest.kt │ │ │ │ └── StaticMethodExamplesTest.kt │ │ │ ├── mock │ │ │ │ ├── ArgumentsMockTest.kt │ │ │ │ ├── CommonMocksExampleTest.kt │ │ │ │ ├── FieldMockTest.kt │ │ │ │ ├── InnerMockWithFieldChecker.kt │ │ │ │ ├── MockFinalClassTest.kt │ │ │ │ ├── MockRandomTest.kt │ │ │ │ ├── MockReturnObjectExampleTest.kt │ │ │ │ ├── MockStaticFieldExampleTest.kt │ │ │ │ ├── MockStaticMethodExampleTest.kt │ │ │ │ ├── MockWithFieldChecker.kt │ │ │ │ ├── MockWithSideEffectExampleTest.kt │ │ │ │ ├── StaticFieldMockTest.kt │ │ │ │ ├── UseNetworkTest.kt │ │ │ │ ├── aliasing │ │ │ │ │ └── AliasingInParamsExampleTest.kt │ │ │ │ ├── fields │ │ │ │ │ └── ClassUsingClassWithRandomFieldTest.kt │ │ │ │ └── model │ │ │ │ │ ├── FieldMockChecker.kt │ │ │ │ │ └── UseNetworkModelBasedTest.kt │ │ │ ├── models │ │ │ │ ├── CompositeModelMinimizationChecker.kt │ │ │ │ └── ModelsIdEqualityChecker.kt │ │ │ ├── natives │ │ │ │ └── NativeExamplesTest.kt │ │ │ ├── numbers │ │ │ │ └── ArithmeticUtilsTest.kt │ │ │ ├── objects │ │ │ │ ├── AbstractAnonymousClassTest.kt │ │ │ │ ├── AnonymousClassesExampleTest.kt │ │ │ │ ├── ClassForTestClinitSectionsTest.kt │ │ │ │ ├── ClassRefTest.kt │ │ │ │ ├── ClassWithClassRefTest.kt │ │ │ │ ├── HiddenFieldAccessModifiersTest.kt │ │ │ │ ├── HiddenFieldExampleTest.kt │ │ │ │ ├── LocalClassExampleTest.kt │ │ │ │ ├── ModelMinimizationExamplesTest.kt │ │ │ │ ├── ObjectWithFinalStaticTest.kt │ │ │ │ ├── ObjectWithPrimitivesClassTest.kt │ │ │ │ ├── ObjectWithPrimitivesExampleTest.kt │ │ │ │ ├── ObjectWithRefFieldsExampleTest.kt │ │ │ │ ├── ObjectWithStaticFieldsExampleTest.kt │ │ │ │ ├── ObjectWithThrowableConstructorTest.kt │ │ │ │ ├── PrivateFieldsTest.kt │ │ │ │ ├── RecursiveTypeTest.kt │ │ │ │ ├── SimpleClassExampleTest.kt │ │ │ │ ├── SimpleClassMultiInstanceExampleTest.kt │ │ │ │ ├── TestId.kt │ │ │ │ ├── TestStatics.kt │ │ │ │ └── TestVector2D.kt │ │ │ ├── operators │ │ │ │ ├── TestLogic.kt │ │ │ │ ├── TestOverflow.kt │ │ │ │ └── TestShift.kt │ │ │ ├── primitives │ │ │ │ ├── ByteExamplesTest.kt │ │ │ │ ├── CharExamplesTest.kt │ │ │ │ ├── DoubleExamplesTest.kt │ │ │ │ ├── FloatExamplesTest.kt │ │ │ │ └── IntExamplesTest.kt │ │ │ ├── psbenchmarks │ │ │ │ ├── TestCollatz.kt │ │ │ │ └── TestLoanExam.kt │ │ │ ├── recursion │ │ │ │ └── RecursionTest.kt │ │ │ ├── reflection │ │ │ │ └── NewInstanceExampleTest.kt │ │ │ ├── statics │ │ │ │ └── StaticsTypesTest.kt │ │ │ ├── stdlib │ │ │ │ ├── DateExampleTest.kt │ │ │ │ ├── JavaIOFileInputStreamCheckTest.kt │ │ │ │ └── StaticsPathDiversionTest.kt │ │ │ ├── stream │ │ │ │ ├── BaseStreamExampleTest.kt │ │ │ │ ├── DoubleStreamExampleTest.kt │ │ │ │ ├── IntStreamExampleTest.kt │ │ │ │ ├── LongStreamExampleTest.kt │ │ │ │ └── StreamsAsMethodResultExampleTest.kt │ │ │ ├── strings │ │ │ │ ├── GenericExamplesTest.kt │ │ │ │ ├── StringConcatSamplesTest.kt │ │ │ │ └── StringExamplesTest.kt │ │ │ ├── strings11 │ │ │ │ └── StringConcatTest.kt │ │ │ ├── structures │ │ │ │ ├── HeapTest.kt │ │ │ │ ├── MinStackExampleTest.kt │ │ │ │ └── StandardStructuresTest.kt │ │ │ ├── substitution │ │ │ │ └── StaticsSubstitutionTest.kt │ │ │ ├── symbolic │ │ │ │ └── ClassWithComplicatedMethodsTest.kt │ │ │ ├── taint │ │ │ │ └── TaintTest.kt │ │ │ ├── threads │ │ │ │ ├── CountDownLatchExamplesTest.kt │ │ │ │ ├── ExecutorServiceExamplesTest.kt │ │ │ │ ├── FutureExamplesTest.kt │ │ │ │ └── ThreadExamplesTest.kt │ │ │ ├── types │ │ │ │ ├── CastExamplesTest.kt │ │ │ │ ├── GenericWithUpperBoundTest.kt │ │ │ │ ├── GenericsTest.kt │ │ │ │ ├── PathDependentGenericsExampleTest.kt │ │ │ │ ├── TypeBordersTest.kt │ │ │ │ └── TypeMatchesTest.kt │ │ │ ├── unsafe │ │ │ │ ├── UnsafeOperationsTest.kt │ │ │ │ └── UnsafeWithFieldTest.kt │ │ │ └── wrappers │ │ │ │ ├── BooleanWrapperTest.kt │ │ │ │ ├── ByteWrapperTest.kt │ │ │ │ ├── CharacterWrapperTest.kt │ │ │ │ ├── DoubleWrapperTest.kt │ │ │ │ ├── FloatWrapperTest.kt │ │ │ │ ├── IntegerWrapperTest.kt │ │ │ │ ├── LongWrapperTest.kt │ │ │ │ └── ShortWrapperTest.kt │ │ │ └── util │ │ │ ├── JcTestExecutor.kt │ │ │ ├── JcTestExecutorDecoderApi.kt │ │ │ ├── TestResolvingOptions.kt │ │ │ ├── UTestRunner.kt │ │ │ ├── UTestRunnerController.kt │ │ │ ├── UsvmTest.kt │ │ │ └── Util.kt │ └── resources │ │ ├── burningwave.static.properties │ │ └── logback.xml │ └── usvm-api │ └── java │ └── org │ └── usvm │ └── api │ ├── Engine.java │ ├── SymbolicIdentityMap.java │ ├── SymbolicList.java │ ├── SymbolicMap.java │ ├── decoder │ ├── DecoderApi.java │ ├── DecoderFor.java │ ├── ObjectData.java │ └── ObjectDecoder.java │ ├── encoder │ ├── EncoderFor.java │ └── ObjectEncoder.java │ └── internal │ ├── SymbolicIdentityMapImpl.java │ ├── SymbolicListImpl.java │ └── SymbolicMapImpl.java ├── usvm-python ├── README.md ├── build.gradle.kts ├── buildDistWithoutPip.sh ├── cpythonadapter │ ├── build.gradle.kts │ ├── cpython_check │ │ ├── .gitignore │ │ ├── run_check.sh │ │ └── sample_handler.c │ ├── include_pip_in_build │ └── src │ │ └── main │ │ └── c │ │ ├── approximations │ │ ├── builtins.c │ │ └── list.c │ │ ├── converters.c │ │ ├── descriptors.c │ │ ├── include │ │ ├── approximations.h │ │ ├── classnames.h │ │ ├── converters.h │ │ ├── descriptors.h │ │ ├── manual_handlers.h │ │ ├── symbolic_methods.h │ │ ├── utils.h │ │ └── virtual_objects.h │ │ ├── manual_handlers.c │ │ ├── org_usvm_interpreter_CPythonAdapter.c │ │ ├── symbolic_methods.c │ │ ├── utils.c │ │ └── virtual_objects.c ├── docs │ ├── API.md │ ├── structure.md │ └── usvm_python_scheme.png ├── python_approximations │ └── approximations │ │ ├── __init__.py │ │ ├── api.py │ │ └── implementations │ │ ├── __init__.py │ │ ├── dict.py │ │ ├── list.py │ │ ├── set.py │ │ └── tuple.py ├── run_cpython.sh ├── src │ ├── main │ │ ├── kotlin │ │ │ └── org │ │ │ │ └── usvm │ │ │ │ └── runner │ │ │ │ └── UtBotPythonRunnerEntryPoint.kt │ │ └── resources │ │ │ └── logback.xml │ └── test │ │ ├── kotlin │ │ └── org │ │ │ └── usvm │ │ │ ├── runner │ │ │ ├── BuildSamples.kt │ │ │ ├── PythonTestRunner.kt │ │ │ ├── SamplesBuild.kt │ │ │ └── manual │ │ │ │ ├── ManualTest.kt │ │ │ │ ├── analyzers │ │ │ │ ├── ConcolicAndConcreteChecker.kt │ │ │ │ ├── OrdinaryAnalyzer.kt │ │ │ │ └── ProgramAnalyzer.kt │ │ │ │ └── program │ │ │ │ ├── LocalProgramProvider.kt │ │ │ │ ├── PrimitivePrograms.kt │ │ │ │ ├── ProgramProvider.kt │ │ │ │ ├── SampleProgram.kt │ │ │ │ ├── SampleProgramProvider.kt │ │ │ │ └── StringProgramProvider.kt │ │ │ ├── samples │ │ │ ├── DictsTest.kt │ │ │ ├── EnumerateTest.kt │ │ │ ├── FloatsTest.kt │ │ │ ├── GeneratorsTest.kt │ │ │ ├── IllegalOperationTest.kt │ │ │ ├── ListsTest.kt │ │ │ ├── MethodsTest.kt │ │ │ ├── PathDiversionTest.kt │ │ │ ├── SetsTest.kt │ │ │ ├── SimpleCustomClassesTest.kt │ │ │ ├── SimpleExampleTest.kt │ │ │ ├── SimpleTypeInferenceTest.kt │ │ │ ├── SimpleUsageOfModulesTest.kt │ │ │ ├── SlicesTest.kt │ │ │ ├── TupleTest.kt │ │ │ └── VirtualObjectsTest.kt │ │ │ └── utils │ │ │ └── PathUtils.kt │ │ └── resources │ │ ├── logging │ │ ├── logback-debug.xml │ │ └── logback-info.xml │ │ └── samples │ │ ├── BadProgram.py │ │ ├── Dicts.py │ │ ├── Enumerate.py │ │ ├── Floats.py │ │ ├── Generators.py │ │ ├── Lists.py │ │ ├── Methods.py │ │ ├── PathDiversionExample.py │ │ ├── Sets.py │ │ ├── SimpleCustomClasses.py │ │ ├── SimpleExample.py │ │ ├── SimpleTypeInference.py │ │ ├── Slices.py │ │ ├── Tricky.py │ │ ├── Tuple.py │ │ ├── sample_submodule │ │ ├── SimpleUsageOfModules.py │ │ ├── sample_functions.py │ │ └── structures.py │ │ └── tricky │ │ ├── CompositeObjects.py │ │ └── UnsafeCode.py ├── usvm-python-annotations │ ├── build.gradle.kts │ └── src │ │ └── main │ │ ├── java │ │ └── org │ │ │ └── usvm │ │ │ └── annotations │ │ │ ├── CPythonAdapterJavaMethod.java │ │ │ ├── CPythonFunction.java │ │ │ ├── SymbolicMemberDescriptor.java │ │ │ ├── SymbolicMethod.java │ │ │ └── SymbolicMethodDescriptor.java │ │ ├── kotlin │ │ └── org │ │ │ └── usvm │ │ │ └── annotations │ │ │ ├── CPythonAdapterJavaMethodProcessor.kt │ │ │ ├── CPythonFunctionProcessor.kt │ │ │ ├── ConverterToJNITypeDescriptor.kt │ │ │ ├── DataClasses.kt │ │ │ ├── SymbolicMemberDescriptorProcessor.kt │ │ │ ├── SymbolicMethodDescriptorProcessor.kt │ │ │ ├── SymbolicMethodProcessor.kt │ │ │ ├── Utils.kt │ │ │ ├── codegeneration │ │ │ ├── AvailableSlotGeneration.kt │ │ │ ├── CPythonFunctionGeneration.kt │ │ │ ├── GenerateDefinitions.kt │ │ │ ├── SymbolicMemberDescriptorGeneration.kt │ │ │ └── SymbolicMethodGeneration.kt │ │ │ └── ids │ │ │ ├── ApproximationId.kt │ │ │ ├── NativeId.kt │ │ │ ├── SlotId.kt │ │ │ └── SymbolicMethodId.kt │ │ └── resources │ │ └── META-INF │ │ └── services │ │ └── javax.annotation.processing.Processor ├── usvm-python-commons │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── kotlin │ │ └── org │ │ └── usvm │ │ └── python │ │ ├── model │ │ ├── PyTest.kt │ │ ├── PyValue.kt │ │ ├── PyValueVisitor.kt │ │ └── Utils.kt │ │ └── ps │ │ └── PyPathSelectorType.kt ├── usvm-python-main │ ├── build.gradle.kts │ └── src │ │ └── main │ │ ├── java │ │ └── org │ │ │ └── usvm │ │ │ └── interpreter │ │ │ └── CPythonAdapter.java │ │ └── kotlin │ │ └── org │ │ └── usvm │ │ ├── language │ │ ├── Callables.kt │ │ ├── Program.kt │ │ ├── PyInstruction.kt │ │ └── Utils.kt │ │ ├── machine │ │ ├── ConcolicRunContext.kt │ │ ├── ConcolicRunContextUtils.kt │ │ ├── Mocking.kt │ │ ├── PyComponents.kt │ │ ├── PyContext.kt │ │ ├── PyExecutionException.kt │ │ ├── PyMachine.kt │ │ ├── PyPathConstraints.kt │ │ ├── PyState.kt │ │ ├── interpreters │ │ │ ├── concrete │ │ │ │ ├── ConcretePythonInterpreter.kt │ │ │ │ ├── utils │ │ │ │ │ ├── NamedSymbolForCPython.kt │ │ │ │ │ ├── SymbolForCPython.kt │ │ │ │ │ └── VirtualPythonObject.kt │ │ │ │ └── venv │ │ │ │ │ ├── Activation.kt │ │ │ │ │ └── VenvConfig.kt │ │ │ └── symbolic │ │ │ │ ├── SymbolicClonesOfGlobals.kt │ │ │ │ ├── USVMPythonInterpreter.kt │ │ │ │ └── operations │ │ │ │ ├── basic │ │ │ │ ├── Common.kt │ │ │ │ ├── Constants.kt │ │ │ │ ├── Control.kt │ │ │ │ ├── Dict.kt │ │ │ │ ├── Enumerate.kt │ │ │ │ ├── Float.kt │ │ │ │ ├── Int.kt │ │ │ │ ├── List.kt │ │ │ │ ├── MethodNotifications.kt │ │ │ │ ├── Range.kt │ │ │ │ ├── Set.kt │ │ │ │ ├── Slice.kt │ │ │ │ ├── Tuple.kt │ │ │ │ └── Virtual.kt │ │ │ │ ├── descriptors │ │ │ │ ├── ApproximationDescriptor.kt │ │ │ │ ├── MemberDescriptor.kt │ │ │ │ ├── MethodDescriptor.kt │ │ │ │ ├── PythonMethodDescriptor.kt │ │ │ │ └── Slice.kt │ │ │ │ ├── nativecalls │ │ │ │ ├── Impls.kt │ │ │ │ └── NativeCallConstraints.kt │ │ │ │ ├── symbolicmethods │ │ │ │ ├── Builtins.kt │ │ │ │ ├── List.kt │ │ │ │ ├── Set.kt │ │ │ │ └── Utils.kt │ │ │ │ └── tracing │ │ │ │ ├── PathTracing.kt │ │ │ │ └── SymbolicHandlerEvent.kt │ │ ├── model │ │ │ ├── PathConstraintsInfo.kt │ │ │ ├── PyModel.kt │ │ │ ├── PythonMockEvaluator.kt │ │ │ ├── Utils.kt │ │ │ └── regions │ │ │ │ ├── WrappedArrayIndexRegion.kt │ │ │ │ ├── WrappedArrayLengthRegion.kt │ │ │ │ ├── WrappedRefMapRegion.kt │ │ │ │ ├── WrappedRefSetRegion.kt │ │ │ │ └── WrappedSetRegion.kt │ │ ├── ps │ │ │ ├── PyPathSelectorFactory.kt │ │ │ ├── PyVirtualPathSelector.kt │ │ │ ├── Utils.kt │ │ │ ├── WeightedPyPathSelector.kt │ │ │ ├── strategies │ │ │ │ ├── Api.kt │ │ │ │ └── impls │ │ │ │ │ ├── Action.kt │ │ │ │ │ ├── BaselineStrategy.kt │ │ │ │ │ ├── DelayedForkByInstruction.kt │ │ │ │ │ ├── RandomizedPriorityActionStrategy.kt │ │ │ │ │ ├── TypeRatingByNumberOfHints.kt │ │ │ │ │ └── WeightedActionStrategy.kt │ │ │ └── types │ │ │ │ ├── Prioritization.kt │ │ │ │ └── SymbolTypeTree.kt │ │ ├── results │ │ │ ├── PyMachineResultsReceiver.kt │ │ │ ├── observers │ │ │ │ ├── InputModelObserver.kt │ │ │ │ ├── InputPythonObjectObserver.kt │ │ │ │ ├── NewStateObserver.kt │ │ │ │ └── PyTestObserver.kt │ │ │ └── serialization │ │ │ │ ├── EmptyObjectSerializer.kt │ │ │ │ ├── ObjectWithDictSerializer.kt │ │ │ │ ├── PickleArgsSerializer.kt │ │ │ │ ├── PickleObjectSerializer.kt │ │ │ │ ├── PythonObjectSerializer.kt │ │ │ │ ├── ReprObjectSerializer.kt │ │ │ │ └── StandardPythonObjectSerializer.kt │ │ ├── symbolicobjects │ │ │ ├── Fields.kt │ │ │ ├── PreallocatedObjects.kt │ │ │ ├── SymbolicObjectConstruction.kt │ │ │ ├── SymbolicPythonObject.kt │ │ │ ├── memory │ │ │ │ ├── ArrayLike.kt │ │ │ │ ├── Bool.kt │ │ │ │ ├── Dict.kt │ │ │ │ ├── Enumerate.kt │ │ │ │ ├── Float.kt │ │ │ │ ├── Int.kt │ │ │ │ ├── ListIterator.kt │ │ │ │ ├── Range.kt │ │ │ │ ├── RangeIterator.kt │ │ │ │ ├── Set.kt │ │ │ │ ├── Slice.kt │ │ │ │ ├── StandardFields.kt │ │ │ │ ├── Str.kt │ │ │ │ └── TupleIterator.kt │ │ │ └── rendering │ │ │ │ ├── DefaultPyValueProvider.kt │ │ │ │ ├── PyValueBuilder.kt │ │ │ │ └── PyValueRenderer.kt │ │ ├── types │ │ │ ├── ElementConstraints.kt │ │ │ ├── TypeSystem.kt │ │ │ ├── Types.kt │ │ │ ├── UtTypeConversion.kt │ │ │ ├── VirtualTypes.kt │ │ │ └── streams │ │ │ │ ├── PyMockTypeStream.kt │ │ │ │ └── TypeFilter.kt │ │ └── utils │ │ │ ├── Generators.kt │ │ │ ├── GlobalParameters.kt │ │ │ ├── PyDebugProfileObserver.kt │ │ │ ├── PyImportUtils.kt │ │ │ ├── PyMachineStatistics.kt │ │ │ ├── UHeapRefUtils.kt │ │ │ └── UtTypeUtils.kt │ │ └── runner │ │ ├── InputModelObserverForRunner.kt │ │ ├── NewStateObserverForRunner.kt │ │ ├── PickledObjectCommunicator.kt │ │ └── PyMachineSocketRunner.kt └── usvm-python-runner │ ├── build.gradle.kts │ └── src │ ├── main │ └── kotlin │ │ └── org │ │ └── usvm │ │ └── runner │ │ ├── Config.kt │ │ ├── DebugRunner.kt │ │ ├── DistributionLayout.kt │ │ ├── PythonSymbolicAnalysisRunner.kt │ │ ├── USVMPythonAnalysisResultReceiver.kt │ │ ├── USVMPythonRunner.kt │ │ └── venv │ │ ├── VenvConfig.kt │ │ └── VenvUtils.kt │ └── test │ └── kotlin │ └── org │ └── usvm │ └── runner │ ├── ManualTest.kt │ ├── PrintingResultReceiver.kt │ └── TestingLayout.kt ├── usvm-sample-language ├── build.gradle.kts └── src │ ├── main │ └── kotlin │ │ └── org │ │ └── usvm │ │ ├── language │ │ ├── Domain.kt │ │ ├── Exceptions.kt │ │ ├── Expressions.kt │ │ ├── Stmts.kt │ │ ├── Types.kt │ │ ├── Utils.kt │ │ └── builders │ │ │ ├── Extensions.kt │ │ │ ├── MethodBuilders.kt │ │ │ ├── MethodScope.kt │ │ │ └── ProgramDecl.kt │ │ └── machine │ │ ├── ProgramExecutionResults.kt │ │ ├── ResultModelConverter.kt │ │ ├── SampleApplicationGraph.kt │ │ ├── SampleExprResolver.kt │ │ ├── SampleInterpreter.kt │ │ ├── SampleLanguageComponents.kt │ │ ├── SampleMachine.kt │ │ ├── SampleState.kt │ │ ├── SampleTarget.kt │ │ ├── SampleTypeSystem.kt │ │ └── Utils.kt │ └── test │ ├── kotlin │ └── org │ │ └── usvm │ │ ├── machine │ │ ├── DfsTest.kt │ │ ├── LoopTest.kt │ │ ├── MathTest.kt │ │ ├── MergingTest.kt │ │ └── StructTest.kt │ │ └── programs │ │ ├── DfsProgram.kt │ │ ├── LoopProgram.kt │ │ ├── MathProgram.kt │ │ ├── MergingProgram.kt │ │ └── StructProgram.kt │ └── resources │ └── logback.xml ├── usvm-ts-dataflow ├── .gitignore ├── README.md ├── build.gradle.kts └── src │ ├── main │ ├── kotlin │ │ └── org │ │ │ └── usvm │ │ │ └── dataflow │ │ │ └── ts │ │ │ ├── graph │ │ │ ├── BackwardGraph.kt │ │ │ └── EtsApplicationGraph.kt │ │ │ ├── ifds │ │ │ ├── EtsIfdsMethodRunner.kt │ │ │ ├── EtsIfdsRunner.kt │ │ │ ├── EtsIfdsSourceRunner.kt │ │ │ └── UnitResolver.kt │ │ │ ├── infer │ │ │ ├── AccessPath.kt │ │ │ ├── Accessors.kt │ │ │ ├── Alias.kt │ │ │ ├── AnalyzerEvent.kt │ │ │ ├── ApplicationGraph.kt │ │ │ ├── BackwardAnalyzer.kt │ │ │ ├── BackwardFlowFunctions.kt │ │ │ ├── EntryPointsProcessor.kt │ │ │ ├── EtsTypeFact.kt │ │ │ ├── ForwardAnalyzer.kt │ │ │ ├── ForwardFlowFunctions.kt │ │ │ ├── KnownType.kt │ │ │ ├── LiveVariables.kt │ │ │ ├── TypeDomainFact.kt │ │ │ ├── TypeFactProcessor.kt │ │ │ ├── TypeGuesser.kt │ │ │ ├── TypeInferenceManager.kt │ │ │ ├── TypeInferenceResult.kt │ │ │ ├── TypeSimplification.kt │ │ │ ├── annotation │ │ │ │ ├── EtsSceneAnnotator.kt │ │ │ │ ├── ExprTypeAnnotator.kt │ │ │ │ ├── StmtTypeAnnotator.kt │ │ │ │ ├── TypeScheme.kt │ │ │ │ ├── TypeSchemes.kt │ │ │ │ └── ValueTypeAnnotator.kt │ │ │ ├── cli │ │ │ │ ├── Dump.kt │ │ │ │ └── InferTypes.kt │ │ │ ├── dto │ │ │ │ ├── ConvertToDto.kt │ │ │ │ ├── DTO.kt │ │ │ │ ├── EtsTypeToDto.kt │ │ │ │ └── EtsValueToDto.kt │ │ │ └── verify │ │ │ │ ├── VerificationResult.kt │ │ │ │ ├── Verify.kt │ │ │ │ └── collectors │ │ │ │ ├── ClassSummaryCollector.kt │ │ │ │ ├── StmtSummaryCollector.kt │ │ │ │ ├── SummaryCollector.kt │ │ │ │ └── Utils.kt │ │ │ └── util │ │ │ ├── EtsTraits.kt │ │ │ ├── LoadEts.kt │ │ │ ├── Map.kt │ │ │ ├── RealLocals.kt │ │ │ ├── ToStringLimited.kt │ │ │ └── Utils.kt │ └── resources │ │ └── logback.xml │ ├── test │ ├── kotlin │ │ └── org │ │ │ └── usvm │ │ │ └── dataflow │ │ │ └── ts │ │ │ └── test │ │ │ ├── EtsIfdsTest.kt │ │ │ ├── EtsProjectAnalysisTest.kt │ │ │ ├── EtsSceneTest.kt │ │ │ ├── EtsTaintAnalysisTest.kt │ │ │ ├── EtsTypeInferenceTest.kt │ │ │ ├── EtsTypeResolverAbcTest.kt │ │ │ ├── EtsTypeResolverPerformanceTest.kt │ │ │ ├── EtsTypeResolverWithAstTest.kt │ │ │ └── utils │ │ │ ├── AbcProjects.kt │ │ │ ├── ClassMatcherStatistics.kt │ │ │ ├── ExpectedTypesExtractor.kt │ │ │ ├── PerformanceReport.kt │ │ │ ├── TaintConfig.kt │ │ │ ├── TypeInferenceStatistics.kt │ │ │ └── Utils.kt │ └── resources │ │ ├── logback-test.xml │ │ └── ts │ │ ├── call.ts │ │ ├── cast.ts │ │ ├── data.ts │ │ ├── microphone.ts │ │ ├── microphone_ctor.ts │ │ ├── nested_init.ts │ │ ├── resolver_test.ts │ │ ├── taint.ts │ │ ├── testcases.ts │ │ └── types.ts │ └── testFixtures │ └── kotlin │ └── org │ └── usvm │ └── dataflow │ └── ts │ ├── LoadEts.kt │ ├── Resources.kt │ └── TestFactoryDsl.kt ├── usvm-ts ├── .gitignore ├── build.gradle.kts └── src │ ├── main │ └── kotlin │ │ └── org │ │ └── usvm │ │ ├── api │ │ ├── TsTest.kt │ │ ├── checkers │ │ │ └── UnreachableCodeDetector.kt │ │ └── targets │ │ │ └── TsTarget.kt │ │ ├── machine │ │ ├── TsComponents.kt │ │ ├── TsContext.kt │ │ ├── TsGraph.kt │ │ ├── TsInterpreterObserver.kt │ │ ├── TsMachine.kt │ │ ├── TsMethodCall.kt │ │ ├── TsOptions.kt │ │ ├── TsTransformer.kt │ │ ├── expr │ │ │ ├── ExprUtil.kt │ │ │ ├── TsExprResolver.kt │ │ │ └── TsExpressions.kt │ │ ├── interpreter │ │ │ ├── TsInterpreter.kt │ │ │ └── TsStatic.kt │ │ ├── operator │ │ │ ├── TsBinaryOperator.kt │ │ │ └── TsUnaryOperator.kt │ │ ├── state │ │ │ ├── TsMethodResult.kt │ │ │ ├── TsState.kt │ │ │ └── TsStateUtils.kt │ │ └── types │ │ │ ├── EtsAuxiliaryType.kt │ │ │ ├── EtsFakeType.kt │ │ │ ├── FakeExprUtil.kt │ │ │ └── TsTypeSystem.kt │ │ └── util │ │ ├── EtsFieldResolver.kt │ │ ├── EtsHierarchy.kt │ │ ├── LValueUtil.kt │ │ ├── MethodResolver.kt │ │ └── Utils.kt │ └── test │ ├── kotlin │ └── org │ │ └── usvm │ │ ├── checkers │ │ └── UnreachableCodeDetector.kt │ │ ├── project │ │ ├── DemoCalc.kt │ │ └── Photos.kt │ │ ├── samples │ │ ├── Arrays.kt │ │ ├── Call.kt │ │ ├── FieldAccess.kt │ │ ├── InstanceFields.kt │ │ ├── InstanceMethods.kt │ │ ├── MinValue.kt │ │ ├── Null.kt │ │ ├── Numeric.kt │ │ ├── StaticFields.kt │ │ ├── StaticMethods.kt │ │ ├── Truthy.kt │ │ ├── TypeCoercion.kt │ │ ├── Undefined.kt │ │ ├── operators │ │ │ ├── Add.kt │ │ │ ├── And.kt │ │ │ ├── Equality.kt │ │ │ ├── Neg.kt │ │ │ └── Or.kt │ │ └── types │ │ │ ├── ObjectUsage.kt │ │ │ ├── StructuralEquality.kt │ │ │ └── TypeStream.kt │ │ └── util │ │ ├── LoadEts.kt │ │ ├── ObjectClass.kt │ │ ├── PathUtils.kt │ │ ├── Resources.kt │ │ ├── Truthy.kt │ │ ├── TsMethodTestRunner.kt │ │ ├── TsTestResolver.kt │ │ └── Util.kt │ └── resources │ ├── checkers │ └── UnreachableCode.ts │ ├── logback-test.xml │ └── samples │ ├── Arrays.ts │ ├── Call.ts │ ├── FieldAccess.ts │ ├── InstanceFields.ts │ ├── InstanceMethods.ts │ ├── MinValue.ts │ ├── Null.ts │ ├── Numeric.ts │ ├── StaticFields.ts │ ├── StaticMethods.ts │ ├── Truthy.ts │ ├── TypeCoercion.ts │ ├── Undefined.ts │ ├── operators │ ├── Add.ts │ ├── And.ts │ ├── Equality.ts │ ├── Neg.ts │ └── Or.ts │ └── types │ ├── ObjectUsage.ts │ ├── StructuralEquality.ts │ └── TypeStream.ts └── usvm-util ├── build.gradle.kts └── src ├── main └── kotlin │ └── org │ └── usvm │ ├── UMachineOptions.kt │ ├── algorithms │ ├── CachingSequence.kt │ ├── DeterministicPriorityCollection.kt │ ├── DisjointSets.kt │ ├── GraphIterators.kt │ ├── GraphUtils.kt │ ├── Lca.kt │ ├── RandomizedPriorityCollection.kt │ ├── SeparationUtils.kt │ ├── TrieNode.kt │ ├── UPersistentMultiMap.kt │ ├── UPriorityCollection.kt │ └── WeightedAaTree.kt │ ├── collections │ └── immutable │ │ ├── extensions.kt │ │ ├── implementations │ │ ├── immutableMap │ │ │ ├── TrieIterator.kt │ │ │ └── TrieNode.kt │ │ └── immutableSet │ │ │ ├── TrieNode.kt │ │ │ └── UPersistentHashSetIterator.kt │ │ └── internal │ │ ├── ForEachOneBit.kt │ │ └── MutabilityOwnership.kt │ ├── regions │ ├── IntIntervalsRegion.kt │ ├── ProductRegion.kt │ ├── Region.kt │ ├── RegionTree.kt │ ├── SetRegion.kt │ └── TrivialRegion.kt │ ├── test │ └── util │ │ ├── TestRunner.kt │ │ └── checkers │ │ └── Matchers.kt │ └── util │ ├── Assertions.kt │ ├── Logging.kt │ ├── MathUtils.kt │ ├── Maybe.kt │ ├── RealTimeStopwatch.kt │ ├── Stopwatch.kt │ └── TimeLimitedIterator.kt └── test └── kotlin └── org └── usvm ├── algorithms ├── CachingSequenceTest.kt ├── DisjointSetsTests.kt ├── RandomizedPriorityCollectionTests.kt ├── Utils.kt └── WeightedAaTreeTests.kt ├── regions ├── IntIntervalsRegionTest.kt ├── ProductRegionTest.kt ├── RegionTreeIteratorTest.kt ├── RegionTreeTests.kt └── SetRegionTest.kt └── test ├── GraphUtilsDistanceTests.kt ├── GraphUtilsLimitedBfsTests.kt ├── MathUtilsTests.kt ├── RealTimeStopwatchTests.kt └── TestGraphs.kt /.gitattributes: -------------------------------------------------------------------------------- 1 | # 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | # 4 | # Linux start script should use lf 5 | /gradlew text eol=lf 6 | 7 | # These are Windows script files and should use crlf 8 | *.bat text eol=crlf 9 | 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore Gradle project-specific cache directory 2 | .gradle 3 | 4 | # Ignore Gradle build output directory 5 | build 6 | buildSrc/build 7 | buildSrc/.gradle 8 | 9 | # Ignore Idea directory 10 | .idea 11 | 12 | # Ignore vim cache 13 | *.swp 14 | 15 | # Ignore Python execution cache 16 | __pycache__/ 17 | run_python_with_gdb.sh 18 | 19 | # Ignore Kotlin build directory 20 | .kotlin/ 21 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "usvm-python/cpythonadapter/cpython"] 2 | path = usvm-python/cpythonadapter/cpython 3 | url = https://github.com/tochilinak/cpython.git 4 | branch = wrapper-3.11.9 5 | -------------------------------------------------------------------------------- /COPYRIGHT_HEADER.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 UnitTestBot contributors (utbot.org) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | -------------------------------------------------------------------------------- /NOTICE.txt: -------------------------------------------------------------------------------- 1 | UnitTestBot 2 | Copyright 2022 UnitTestBot contributors (utbot.org) 3 | -------------------------------------------------------------------------------- /buildSrc/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | 5 | val kotlinVersion = "2.1.0" 6 | val detektVersion = "1.23.5" 7 | val gjavahVersion = "0.3.1" 8 | 9 | repositories { 10 | mavenCentral() 11 | gradlePluginPortal() 12 | maven("https://jitpack.io") 13 | } 14 | 15 | dependencies { 16 | implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion") 17 | implementation("io.gitlab.arturbosch.detekt:detekt-gradle-plugin:$detektVersion") 18 | implementation("org.glavo:gjavah:$gjavahVersion") 19 | } 20 | -------------------------------------------------------------------------------- /buildSrc/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name="usvm-conventions" 2 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/usvmpython/tasks/JNIHeaderTask.kt: -------------------------------------------------------------------------------- 1 | package usvmpython.tasks 2 | 3 | import gradle.kotlin.dsl.accessors._466a692754d3da37fc853e1c7ad8ae1e.main 4 | import gradle.kotlin.dsl.accessors._466a692754d3da37fc853e1c7ad8ae1e.sourceSets 5 | import org.glavo.javah.JavahTask 6 | import org.gradle.api.Project 7 | import usvmpython.getGeneratedHeadersPath 8 | import usvmpython.CPYTHON_ADAPTER_CLASS 9 | 10 | 11 | fun Project.generateJNIForCPythonAdapterTask() { 12 | val task = JavahTask() 13 | task.outputDir = getGeneratedHeadersPath().toPath() 14 | val classpath = sourceSets.main.get().runtimeClasspath 15 | classpath.files.forEach { 16 | task.addClassPath(it.toPath()) 17 | } 18 | task.addClass(CPYTHON_ADAPTER_CLASS) 19 | task.run() 20 | } 21 | -------------------------------------------------------------------------------- /docs/assets/images/injection.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UnitTestBot/usvm/f7bb9d710003dd8aff7befa83e7e47c0a8239387/docs/assets/images/injection.png -------------------------------------------------------------------------------- /docs/assets/images/injection_fp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UnitTestBot/usvm/f7bb9d710003dd8aff7befa83e7e47c0a8239387/docs/assets/images/injection_fp.png -------------------------------------------------------------------------------- /docs/meeting-minutes/2023-02-22.md: -------------------------------------------------------------------------------- 1 | # 22 December 2023 2 | 3 | ## Memory Regions 4 | 5 | - We don't want to internalize memory regions, because it requires structural comparison which could be quite complex in time. 6 | - Anyway, we have to cache a result of translation of a memory region. Moreover, results depends on `defaultValue`, so we need to bear in mind it when caching. 7 | - Equals and hashcode on memory regions must be computed lazily 8 | - Proper caching of memory regions requires multi-indexed arrays in KSMT which is unsupported right now, but soon will be ready 9 | 10 | ## UModel 11 | 12 | - There are shouldn't be `decode` functions in UMemory components. 13 | - UExprTranslator performs decoding based on translated cache. USolver constructs UModel, delegating some calls to UExprTranslator, not to UMemory. 14 | -------------------------------------------------------------------------------- /docs/proposals/instrumentation-prosal.md: -------------------------------------------------------------------------------- 1 | # Instrumentation proposal 2 | 3 | ## Test-framework: 4 | * Input: UTest (assemble models, concrete values, additional information) + 5 | * Runner accept serialized UTest, assemble concrete values and run instrumented code on it + 6 | * Dynamic instrumentation + 7 | 8 | ## Instrumentation 9 | Requirements: 10 | * Instrumentation: 11 | * trace 12 | * at the first stage only jacodb statements + 13 | * concolic? 14 | * statics rollback 15 | * redefine classes in classloader 16 | * non-deterministic functions mocks ? 17 | * stdlib mocks ? 18 | * at the first stage just ignore ? 19 | * Run with timeout + 20 | * Sandbox ? 21 | * Result, diff + 22 | * smth like UResult (assemble models?) + 23 | * diffs between input and output + 24 | * Static fields links - 25 | * for what? -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | kotlin.code.style=official 2 | 3 | org.gradle.daemon=true 4 | kotlin.daemon.jvm.options=-Xmx4g 5 | org.gradle.parallel=true 6 | org.gradle.caching=true 7 | org.gradle.workers.max=8 8 | org.gradle.jvmargs=-Xmx1g "-XX:MaxMetaspaceSize=384m" 9 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UnitTestBot/usvm/f7bb9d710003dd8aff7befa83e7e47c0a8239387/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-all.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /jitpack.yml: -------------------------------------------------------------------------------- 1 | jdk: openjdk11 2 | -------------------------------------------------------------------------------- /usvm-core/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("usvm.kotlin-conventions") 3 | } 4 | 5 | dependencies { 6 | api(project(":usvm-util")) 7 | api(Libs.ksmt_core) 8 | api(Libs.ksmt_z3) 9 | api(Libs.kotlinx_collections) 10 | 11 | testImplementation(Libs.mockk) 12 | testImplementation(Libs.junit_jupiter_params) 13 | testImplementation(Libs.ksmt_yices) 14 | } 15 | 16 | publishing { 17 | publications { 18 | create("maven") { 19 | from(components["java"]) 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /usvm-core/src/main/kotlin/org/usvm/Interpreter.kt: -------------------------------------------------------------------------------- 1 | package org.usvm 2 | 3 | /** 4 | * An abstract [UInterpreter] used in a symbolic machine. 5 | */ 6 | abstract class UInterpreter { 7 | /** 8 | * Interpreters a single step inside a [state]. 9 | * 10 | * @return next states. 11 | */ 12 | abstract fun step(state: State): StepResult 13 | 14 | override fun toString(): String = this::class.simpleName?:"" 15 | } -------------------------------------------------------------------------------- /usvm-core/src/main/kotlin/org/usvm/PathSelector.kt: -------------------------------------------------------------------------------- 1 | package org.usvm 2 | 3 | interface UPathSelector { 4 | fun isEmpty(): Boolean 5 | 6 | /** 7 | * @return the next state in the path selector. 8 | */ 9 | fun peek(): State 10 | 11 | /** 12 | * Removes the [state] from the path selector. 13 | */ 14 | fun remove(state: State) 15 | 16 | /** 17 | * Adds [states] to the path selector. 18 | */ 19 | fun add(states: Collection) 20 | 21 | /** 22 | * Updates the internal priority of the [state]. 23 | */ 24 | fun update(state: State) 25 | } -------------------------------------------------------------------------------- /usvm-core/src/main/kotlin/org/usvm/collection/set/USymbolicSetEntries.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.collection.set 2 | 3 | /** 4 | * All symbolic set entries (added and removed). 5 | * Set entries marked as [isInput] when: 6 | * 1. The original set is input 7 | * 2. The original set is concrete, but has been united with an input set. 8 | * */ 9 | class USymbolicSetEntries { 10 | private val _entries: MutableSet = hashSetOf() 11 | val entries: Set 12 | get() = _entries 13 | 14 | var isInput: Boolean = false 15 | private set 16 | 17 | fun add(entry: Entry) { 18 | _entries.add(entry) 19 | } 20 | 21 | fun markAsInput() { 22 | isInput = true 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /usvm-core/src/main/kotlin/org/usvm/collection/set/USymbolicSetUnionElements.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.collection.set 2 | 3 | interface USymbolicSetUnionElements { 4 | fun collectSetElements(elements: USymbolicSetElementsCollector.Elements) 5 | } 6 | -------------------------------------------------------------------------------- /usvm-core/src/main/kotlin/org/usvm/forkblacklists/UForkBlackList.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.forkblacklists 2 | 3 | import org.usvm.UState 4 | 5 | /** 6 | * @see shouldForkTo 7 | */ 8 | interface UForkBlackList, Statement> { 9 | 10 | /** 11 | * Determines if the [state] should fork to the branch with location of [stmt]. 12 | */ 13 | fun shouldForkTo(state: State, stmt: Statement): Boolean 14 | 15 | companion object { 16 | fun , Statement> createDefault() = object : 17 | UForkBlackList { 18 | override fun shouldForkTo(state: State, stmt: Statement): Boolean = true 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /usvm-core/src/main/kotlin/org/usvm/ps/DfsPathSelector.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.ps 2 | 3 | import org.usvm.UPathSelector 4 | 5 | class DfsPathSelector : UPathSelector { 6 | private val stack = ArrayDeque() 7 | 8 | override fun isEmpty() = stack.isEmpty() 9 | 10 | override fun peek() = stack.last() 11 | override fun update(state: State) { 12 | // nothing to do 13 | } 14 | 15 | override fun remove(state: State) { 16 | when (state) { 17 | stack.last() -> stack.removeLast() // fast remove from the tail 18 | stack.first() -> stack.removeFirst() // fast remove from the head 19 | else -> stack.remove(state) 20 | } 21 | } 22 | 23 | override fun add(states: Collection) { 24 | stack.addAll(states) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /usvm-core/src/main/kotlin/org/usvm/ps/StateLoopTracker.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.ps 2 | 3 | import org.usvm.UState 4 | 5 | interface StateLoopTracker> { 6 | /** 7 | * If [statement] is an entrypoint of some loop returns this loop. 8 | * Returns null if the statement doesn't belong to any loop or 9 | * the statement is in the loop body, but is not the first (header) statement 10 | * */ 11 | fun findLoopEntrance(statement: Statement): Loop? 12 | 13 | /** 14 | * Returns true if the given [forkPoint] can affect the [loop] iteration number 15 | * (e.g. jump to the next iteration). 16 | * */ 17 | fun isLoopIterationFork(loop: Loop, forkPoint: Statement): Boolean 18 | } 19 | -------------------------------------------------------------------------------- /usvm-core/src/main/kotlin/org/usvm/ps/StateWeighter.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.ps 2 | 3 | /** 4 | * @see weight 5 | */ 6 | fun interface StateWeighter { 7 | 8 | /** 9 | * Returns state's weight for [WeightedPathSelector]. 10 | */ 11 | fun weight(state: State): Weight 12 | } 13 | -------------------------------------------------------------------------------- /usvm-core/src/main/kotlin/org/usvm/statistics/ApplicationGraph.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.statistics 2 | 3 | interface ApplicationGraph { 4 | fun predecessors(node: Statement): Sequence 5 | fun successors(node: Statement): Sequence 6 | 7 | fun callees(node: Statement): Sequence 8 | fun callers(method: Method): Sequence 9 | 10 | fun entryPoints(method: Method): Sequence 11 | fun exitPoints(method: Method): Sequence 12 | 13 | fun methodOf(node: Statement): Method 14 | 15 | fun statementsOf(method: Method): Sequence 16 | } 17 | -------------------------------------------------------------------------------- /usvm-core/src/main/kotlin/org/usvm/statistics/UInterpreterObserver.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.statistics 2 | 3 | interface UInterpreterObserver { 4 | // Empty 5 | } -------------------------------------------------------------------------------- /usvm-core/src/main/kotlin/org/usvm/statistics/collectors/AllStatesCollector.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.statistics.collectors 2 | 3 | import org.usvm.UState 4 | 5 | /** 6 | * [StatesCollector] implementation collecting all states. 7 | */ 8 | class AllStatesCollector> : StatesCollector { 9 | private val mutableCollectedStates = mutableListOf() 10 | override val collectedStates: List = mutableCollectedStates 11 | 12 | override fun onStateTerminated(state: State, stateReachable: Boolean) { 13 | if (stateReachable) { 14 | mutableCollectedStates.add(state) 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /usvm-core/src/main/kotlin/org/usvm/statistics/collectors/StatesCollector.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.statistics.collectors 2 | 3 | import org.usvm.statistics.UMachineObserver 4 | 5 | /** 6 | * Interface for [UMachineObserver]s which are able to 7 | * collect states. 8 | */ 9 | interface StatesCollector : UMachineObserver { 10 | /** 11 | * Current list of collected states. 12 | */ 13 | val collectedStates: List 14 | } 15 | -------------------------------------------------------------------------------- /usvm-core/src/main/kotlin/org/usvm/statistics/constraints/SoftConstraintsObserver.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.statistics.constraints 2 | 3 | import org.usvm.UState 4 | import org.usvm.utils.applySoftConstraints 5 | import org.usvm.statistics.UMachineObserver 6 | 7 | class SoftConstraintsObserver> : UMachineObserver { 8 | override fun onStateTerminated(state: State, stateReachable: Boolean) { 9 | if (stateReachable) { 10 | // TODO actually, only states presented in CoveredNewStatesCollector should be here, 11 | // so for now soft constraints are applied for more states than required. Rewrite it after refactoring 12 | // path selector factory, observers, collectors, etc. 13 | state.applySoftConstraints() 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /usvm-core/src/main/kotlin/org/usvm/statistics/distances/CallGraphStatistics.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.statistics.distances 2 | 3 | /** 4 | * Calculates call graph metrics. 5 | */ 6 | interface CallGraphStatistics { 7 | 8 | /** 9 | * Checks if [methodTo] is reachable from [methodFrom] in call graph. 10 | */ 11 | fun checkReachability(methodFrom: Method, methodTo: Method): Boolean 12 | } 13 | -------------------------------------------------------------------------------- /usvm-core/src/main/kotlin/org/usvm/statistics/distances/CfgStatistics.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.statistics.distances 2 | 3 | /** 4 | * Calculates CFG metrics. 5 | */ 6 | interface CfgStatistics { 7 | 8 | /** 9 | * Returns shortest CFG distance from [stmtFrom] to [stmtTo] located in [method]. 10 | */ 11 | fun getShortestDistance(method: Method, stmtFrom: Statement, stmtTo: Statement): UInt 12 | 13 | /** 14 | * Returns CFG distance from [stmtFrom] to the closest exit point of [method]. 15 | */ 16 | fun getShortestDistanceToExit(method: Method, stmtFrom: Statement): UInt 17 | } 18 | -------------------------------------------------------------------------------- /usvm-core/src/main/kotlin/org/usvm/statistics/distances/PlainCallGraphStatistics.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.statistics.distances 2 | 3 | /** 4 | * Limit case [CallGraphStatistics] implementation which considers two methods reachable 5 | * only if they are the same. 6 | */ 7 | class PlainCallGraphStatistics : CallGraphStatistics { 8 | 9 | override fun checkReachability(methodFrom: Method, methodTo: Method): Boolean = methodFrom == methodTo 10 | } 11 | -------------------------------------------------------------------------------- /usvm-core/src/main/kotlin/org/usvm/stopstrategies/StepLimitStopStrategy.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.stopstrategies 2 | 3 | import org.usvm.statistics.StepsStatistics 4 | 5 | /** 6 | * [StopStrategy] which stops when the [limit] number of steps is reached. 7 | */ 8 | class StepLimitStopStrategy(private val limit: ULong, private val stepsStatistics: StepsStatistics<*, *>) : StopStrategy { 9 | override fun shouldStop(): Boolean = stepsStatistics.totalSteps > limit 10 | } 11 | -------------------------------------------------------------------------------- /usvm-core/src/main/kotlin/org/usvm/stopstrategies/TargetsReachedStopStrategy.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.stopstrategies 2 | 3 | import org.usvm.targets.UTarget 4 | 5 | /** 6 | * A stop strategy which stops when all terminal targets in [targets] are reached. 7 | */ 8 | class TargetsReachedStopStrategy(private val targets: Collection>) : StopStrategy { 9 | override fun shouldStop(): Boolean = targets.all { it.isRemoved } 10 | } 11 | -------------------------------------------------------------------------------- /usvm-core/src/main/kotlin/org/usvm/stopstrategies/TimeoutStopStrategy.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.stopstrategies 2 | 3 | import org.usvm.statistics.TimeStatistics 4 | import kotlin.time.Duration 5 | 6 | /** 7 | * [StopStrategy] implementation which stops execution on timeout. Time measurement is started on first 8 | * [shouldStop] call. 9 | */ 10 | class TimeoutStopStrategy(private val timeout: Duration, private val timeStatistics: TimeStatistics<*, *>) : StopStrategy { 11 | override fun shouldStop(): Boolean = 12 | timeStatistics.runningTime > timeout 13 | } 14 | -------------------------------------------------------------------------------- /usvm-core/src/main/kotlin/org/usvm/targets/UTargetController.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.targets 2 | 3 | interface UTargetController { 4 | val targets: MutableCollection> 5 | } 6 | -------------------------------------------------------------------------------- /usvm-core/src/main/kotlin/org/usvm/utils/ResultUtils.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.utils 2 | 3 | import org.usvm.solver.USatResult 4 | import org.usvm.solver.USolverResult 5 | 6 | fun USolverResult.ensureSat(): USatResult { 7 | check(this is USatResult) { "Expected SAT result, but got $this" } 8 | return this 9 | } 10 | -------------------------------------------------------------------------------- /usvm-dataflow/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("usvm.kotlin-conventions") 3 | } 4 | 5 | dependencies { 6 | implementation(project(":usvm-util")) 7 | api(Libs.jacodb_api_common) 8 | implementation(Libs.jacodb_taint_configuration) 9 | api(Libs.sarif4k) 10 | } 11 | 12 | publishing { 13 | publications { 14 | create("maven") { 15 | from(components["java"]) 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /usvm-dataflow/src/main/kotlin/org/usvm/dataflow/graph/ApplicationGraph.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.dataflow.graph 2 | 3 | /** 4 | * Provides both CFG and call graph (i.e., the supergraph in terms of RHS95 paper). 5 | */ 6 | interface ApplicationGraph { 7 | fun predecessors(node: Statement): Sequence 8 | fun successors(node: Statement): Sequence 9 | 10 | fun callees(node: Statement): Sequence 11 | fun callers(method: Method): Sequence 12 | 13 | fun entryPoints(method: Method): Sequence 14 | fun exitPoints(method: Method): Sequence 15 | 16 | fun methodOf(node: Statement): Method 17 | } 18 | -------------------------------------------------------------------------------- /usvm-jvm-dataflow/src/test/resources/pointerbench.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UnitTestBot/usvm/f7bb9d710003dd8aff7befa83e7e47c0a8239387/usvm-jvm-dataflow/src/test/resources/pointerbench.jar -------------------------------------------------------------------------------- /usvm-jvm-instrumentation/README.md: -------------------------------------------------------------------------------- 1 | # Instrumentation module of the usvm project 2 | 3 | Features: 4 | * Execution and state building for target method 5 | * Trace in jacodb instruction via dynamic instrumentation 6 | * Static rollback 7 | * Run with timeout 8 | 9 | TODO: 10 | * Mocks 11 | * Sandbox 12 | * Concolic trace 13 | 14 | Input: 15 | * classpath of analyzing project + UTest (see Tests and org.usvm.instrumentation.testcase.api.api.kt) 16 | 17 | Output: 18 | * Execution state (see org.usvm.instrumentation.testcase.api.response.kt) 19 | 20 | Example of module usage for simple classes and guava located in tests -------------------------------------------------------------------------------- /usvm-jvm-instrumentation/src/main/kotlin/org/usvm/instrumentation/executor/UsvmRdCoroutineScope.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.instrumentation.executor 2 | 3 | import com.jetbrains.rd.framework.util.RdCoroutineScope 4 | import com.jetbrains.rd.framework.util.asCoroutineDispatcher 5 | import com.jetbrains.rd.util.lifetime.Lifetime 6 | import com.jetbrains.rd.util.threading.SingleThreadScheduler 7 | 8 | class UsvmRdCoroutineScope( 9 | lifetime: Lifetime, 10 | scheduler: SingleThreadScheduler 11 | ) : RdCoroutineScope(lifetime) { 12 | override val defaultDispatcher = scheduler.asCoroutineDispatcher 13 | } 14 | -------------------------------------------------------------------------------- /usvm-jvm-instrumentation/src/main/kotlin/org/usvm/instrumentation/instrumentation/JcInstrumenter.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.instrumentation.instrumentation 2 | 3 | import org.jacodb.api.jvm.JcClasspath 4 | import org.objectweb.asm.tree.ClassNode 5 | 6 | interface JcInstrumenter { 7 | 8 | val jcClasspath: JcClasspath 9 | 10 | fun instrumentClass(classNode: ClassNode): ClassNode 11 | } -------------------------------------------------------------------------------- /usvm-jvm-instrumentation/src/main/kotlin/org/usvm/instrumentation/instrumentation/JcInstrumenterFactory.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.instrumentation.instrumentation 2 | 3 | import org.jacodb.api.jvm.JcClasspath 4 | 5 | interface JcInstrumenterFactory { 6 | fun create(jcClasspath: JcClasspath): T 7 | } 8 | 9 | class JcRuntimeTraceInstrumenterFactory : JcInstrumenterFactory { 10 | override fun create(jcClasspath: JcClasspath): JcRuntimeTraceInstrumenter = JcRuntimeTraceInstrumenter(jcClasspath) 11 | } 12 | class NoInstrumentationFactory : JcInstrumenterFactory { 13 | override fun create(jcClasspath: JcClasspath): NoInstrumentation = NoInstrumentation(jcClasspath) 14 | } -------------------------------------------------------------------------------- /usvm-jvm-instrumentation/src/main/kotlin/org/usvm/instrumentation/instrumentation/NoInstrumentation.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.instrumentation.instrumentation 2 | 3 | import org.jacodb.api.jvm.JcClasspath 4 | import org.objectweb.asm.tree.ClassNode 5 | 6 | class NoInstrumentation( 7 | override val jcClasspath: JcClasspath 8 | ) : JcInstrumenter { 9 | override fun instrumentClass(classNode: ClassNode): ClassNode { 10 | return classNode 11 | } 12 | } -------------------------------------------------------------------------------- /usvm-jvm-instrumentation/src/main/kotlin/org/usvm/instrumentation/instrumentation/Tracer.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.instrumentation.instrumentation 2 | 3 | interface Tracer { 4 | 5 | fun getTrace(): T 6 | 7 | fun reset() 8 | 9 | } -------------------------------------------------------------------------------- /usvm-jvm-instrumentation/src/main/kotlin/org/usvm/instrumentation/rd/Lifetimed.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.instrumentation.rd 2 | 3 | import com.jetbrains.rd.util.lifetime.Lifetime 4 | 5 | interface Lifetimed { 6 | val lifetime: Lifetime 7 | fun terminate() 8 | } 9 | -------------------------------------------------------------------------------- /usvm-jvm-instrumentation/src/main/kotlin/org/usvm/instrumentation/rd/RdServer.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.instrumentation.rd 2 | 3 | import com.jetbrains.rd.framework.IProtocol 4 | 5 | interface RdServer: Lifetimed { 6 | val isAlive: Boolean 7 | val protocol: IProtocol 8 | } 9 | -------------------------------------------------------------------------------- /usvm-jvm-instrumentation/src/main/kotlin/org/usvm/instrumentation/rd/RdServerProcess.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.instrumentation.rd 2 | 3 | import com.jetbrains.rd.framework.Protocol 4 | import com.jetbrains.rd.util.lifetime.LifetimeDefinition 5 | import com.jetbrains.rd.util.lifetime.isAlive 6 | import org.usvm.instrumentation.generated.models.InstrumentedProcessModel 7 | 8 | class RdServerProcess( 9 | private val process: Process, 10 | override val lifetime: LifetimeDefinition, 11 | override val protocol: Protocol, 12 | val model: InstrumentedProcessModel 13 | ) : RdServer { 14 | override val isAlive: Boolean 15 | get() = lifetime.isAlive && process.isAlive 16 | 17 | override fun terminate() { 18 | lifetime.terminate() 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /usvm-jvm-instrumentation/src/main/kotlin/org/usvm/instrumentation/testcase/UTest.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.instrumentation.testcase 2 | 3 | import org.usvm.instrumentation.testcase.api.UTestCall 4 | import org.usvm.instrumentation.testcase.api.UTestInst 5 | 6 | // TODO it is not a UTest, it is JcTest 7 | class UTest( 8 | val initStatements: List, 9 | val callMethodExpression: UTestCall 10 | ) -------------------------------------------------------------------------------- /usvm-jvm-instrumentation/src/main/rdgen/org/usvm/instrumentation/models/SyncProtocolModel.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.instrumentation.models 2 | 3 | import com.jetbrains.rd.generator.nova.* 4 | 5 | object SyncProtocolRoot: Root() 6 | 7 | object SyncProtocolModel: Ext(SyncProtocolRoot) { 8 | init { 9 | signal("synchronizationSignal", PredefinedType.string).async 10 | } 11 | } -------------------------------------------------------------------------------- /usvm-jvm-instrumentation/src/samples/java/example/AnnotationsEx.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | public class AnnotationsEx { 4 | @MyAnnotation 5 | public static int getSelfAnnotationCount() throws NoSuchMethodException { 6 | return AnnotationsEx.class.getMethod("getSelfAnnotationCount").getAnnotations().length; 7 | } 8 | 9 | @MyAnnotation 10 | public static String getAnnotationDefaultValue() throws NoSuchMethodException { 11 | return AnnotationsEx.class 12 | .getMethod("getAnnotationDefaultValue") 13 | .getAnnotation(MyAnnotation.class) 14 | .x(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /usvm-jvm-instrumentation/src/samples/java/example/B.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Objects; 5 | 6 | public class B implements Comparable { 7 | 8 | public int f; 9 | 10 | static ArrayList l = new ArrayList<>(); 11 | 12 | static { 13 | l.add(43534); 14 | } 15 | 16 | @Override 17 | public boolean equals(Object o) { 18 | if (this == o) return true; 19 | if (o == null || getClass() != o.getClass()) return false; 20 | B b = (B) o; 21 | return f == b.f; 22 | } 23 | 24 | @Override 25 | public int hashCode() { 26 | return Objects.hash(f); 27 | } 28 | 29 | @Override 30 | public int compareTo(B b) { 31 | return Integer.compare(f, b.f); 32 | } 33 | } -------------------------------------------------------------------------------- /usvm-jvm-instrumentation/src/samples/java/example/C.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | public class C { 4 | 5 | static int a(Class clazz) { 6 | return 1; 7 | } 8 | 9 | public static int lol() { 10 | return a(IllegalAccessException.class); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /usvm-jvm-instrumentation/src/samples/java/example/ClassWithNestedClasses.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | public class ClassWithNestedClasses { 4 | 5 | static class A { 6 | int a = 1; 7 | 8 | static class B { 9 | 10 | public B(int b) { 11 | this.b = b; 12 | } 13 | int b = 2; 14 | 15 | public B getB() { 16 | b++; 17 | return new B(b); 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /usvm-jvm-instrumentation/src/samples/java/example/ClassWithStaticField.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | public class ClassWithStaticField { 4 | public static String STATIC_FIELD = "static field content"; 5 | } 6 | -------------------------------------------------------------------------------- /usvm-jvm-instrumentation/src/samples/java/example/EnumClass.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | import java.util.ArrayList; 4 | 5 | public enum EnumClass { 6 | A, B, C; 7 | 8 | public int a; 9 | public int b; 10 | public static int c; 11 | public ArrayList arr = new ArrayList<>(); 12 | 13 | public int lol() { 14 | b++; 15 | return a + b + c + arr.size(); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /usvm-jvm-instrumentation/src/samples/java/example/Ex1.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | public class Ex1 { 4 | 5 | public int lol(Ex2 ex) { 6 | return -1; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /usvm-jvm-instrumentation/src/samples/java/example/Ex2.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | public class Ex2 { 4 | 5 | public Ex2(Ex3 ex3) { 6 | this.ex3 = ex3; 7 | } 8 | 9 | public Ex3 ex3; 10 | } 11 | -------------------------------------------------------------------------------- /usvm-jvm-instrumentation/src/samples/java/example/Ex3.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | public class Ex3 { 4 | 5 | Integer val; 6 | } 7 | -------------------------------------------------------------------------------- /usvm-jvm-instrumentation/src/samples/java/example/MockAbstractClass.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | public abstract class MockAbstractClass { 4 | 5 | public String stringField = ""; 6 | public int intField = 238; 7 | 8 | 9 | public abstract int getI(); 10 | 11 | public String getStr() { return "zzz"; } 12 | 13 | public int methodWithInternalInvocation() { 14 | return intField + getI(); 15 | } 16 | 17 | 18 | } 19 | -------------------------------------------------------------------------------- /usvm-jvm-instrumentation/src/samples/java/example/MockClass.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class MockClass { 6 | 7 | public String stringField = ""; 8 | public int intField; 9 | 10 | public int getI() { 11 | return 111; 12 | } 13 | 14 | public String getStr() { return "abcd"; } 15 | 16 | static int staticMock() { 17 | return 1; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /usvm-jvm-instrumentation/src/samples/java/example/MockInterface.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | public interface MockInterface { 4 | 5 | int intMock(); 6 | 7 | String strMock(); 8 | 9 | default int intMockDefault() { 10 | return 1; 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /usvm-jvm-instrumentation/src/samples/java/example/MyAnnotation.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | import java.lang.annotation.Retention; 4 | import java.lang.annotation.RetentionPolicy; 5 | 6 | @Retention(RetentionPolicy.RUNTIME) 7 | public @interface MyAnnotation { 8 | String x() default "MyAnnotation default value"; 9 | } 10 | -------------------------------------------------------------------------------- /usvm-jvm-instrumentation/src/samples/java/example/ParentStaticFieldUser.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | public class ParentStaticFieldUser extends ClassWithStaticField { 4 | public static String getParentStaticField() { 5 | return ParentStaticFieldUser.STATIC_FIELD; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /usvm-jvm-instrumentation/src/samples/java/example/Singleton.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class Singleton { 6 | 7 | private Singleton() { 8 | arr = new ArrayList<>(); 9 | } 10 | private final ArrayList arr; 11 | private static Singleton instance; 12 | public static Singleton getInstance() { 13 | if (instance == null) instance = new Singleton(); 14 | return instance; 15 | } 16 | 17 | public void addToArray(Integer a) { 18 | arr.add(a); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /usvm-jvm-instrumentation/src/samples/java/example/SleepingClass.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | public class SleepingClass { 4 | public static void sleepFor(Long timeInMillis) throws InterruptedException { 5 | Thread.sleep(timeInMillis); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /usvm-jvm-instrumentation/src/samples/java/example/StaticInterfaceMethodCall.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | import java.util.function.Function; 4 | 5 | public class StaticInterfaceMethodCall { 6 | public static void callStaticInterfaceMethod() { 7 | Function.identity(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /usvm-jvm/src/main/kotlin/org/usvm/api/targets/JcTarget.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.api.targets 2 | 3 | import org.jacodb.api.jvm.cfg.JcInst 4 | import org.usvm.targets.UTarget 5 | 6 | /** 7 | * Base class for JcMachine targets. 8 | */ 9 | abstract class JcTarget(location: JcInst? = null) : UTarget(location) 10 | -------------------------------------------------------------------------------- /usvm-jvm/src/main/kotlin/org/usvm/api/util/JcTestResolver.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.api.util 2 | 3 | import org.jacodb.api.jvm.JcTypedMethod 4 | import org.usvm.api.JcTest 5 | import org.usvm.machine.state.JcState 6 | 7 | interface JcTestResolver { 8 | fun resolve(method: JcTypedMethod, state: JcState): JcTest 9 | } 10 | -------------------------------------------------------------------------------- /usvm-jvm/src/main/kotlin/org/usvm/machine/JcMachineOptions.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.machine 2 | 3 | /** 4 | * JcMachine specific options. 5 | * */ 6 | data class JcMachineOptions( 7 | /** 8 | * During virtual call resolution the machine should consider all possible call implementations. 9 | * By default, the machine forks on few concrete implementation and ignore remaining. 10 | * */ 11 | val forkOnRemainingTypes: Boolean = false, 12 | 13 | /** 14 | * Controls, whether the machine should analyze states with implicit exceptions (e.g. NPE). 15 | * */ 16 | val forkOnImplicitExceptions: Boolean = true, 17 | 18 | /** 19 | * Hard constraint for maximal array size. 20 | * */ 21 | val arrayMaxSize: Int = 1_500, 22 | ) 23 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/api/exception/UMockAssumptionViolatedException.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.api.exception 2 | 3 | 4 | class UMockAssumptionViolatedException : RuntimeException() { 5 | override val message: String 6 | get() = "UMock assumption violated" 7 | } 8 | 9 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/api/mock/UMock.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.api.mock 2 | 3 | import org.usvm.api.Engine 4 | import org.usvm.api.exception.UMockAssumptionViolatedException 5 | 6 | fun assume(predicate: Boolean) { 7 | // TODO inline it 8 | if (!predicate) { 9 | Engine.assume(false) 10 | throw UMockAssumptionViolatedException() 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/annotations/lombok/EnumWithAnnotations.java: -------------------------------------------------------------------------------- 1 | //package org.usvm.samples.annotations.lombok; 2 | // 3 | //import lombok.AllArgsConstructor; 4 | //import lombok.Getter; 5 | // 6 | //@Getter 7 | //@AllArgsConstructor 8 | //public enum EnumWithAnnotations { 9 | // ENUM_CONSTANT("Constant_1"); 10 | // private final String constant; 11 | //} 12 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/annotations/lombok/EnumWithoutAnnotations.java: -------------------------------------------------------------------------------- 1 | //package org.usvm.samples.annotations.lombok; 2 | // 3 | // 4 | //public enum EnumWithoutAnnotations { 5 | // ENUM_CONSTANT("Constant_1"); 6 | // private final String constant; 7 | // 8 | // EnumWithoutAnnotations(String constant) { 9 | // this.constant = constant; 10 | // } 11 | // 12 | // public String getConstant() { 13 | // return constant; 14 | // } 15 | //} -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/annotations/lombok/NotNullAnnotations.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.annotations.lombok; 2 | 3 | import lombok.NonNull; 4 | 5 | public class NotNullAnnotations { 6 | 7 | public int lombokNonNull(@NonNull Integer value) { 8 | return value; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/approximations/TestList.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.approximations; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class TestList { 7 | private final List list = new ArrayList<>(); 8 | 9 | public int size() { 10 | return list.size(); 11 | } 12 | 13 | public void add(T value) { 14 | list.add(value); 15 | } 16 | 17 | public T get(int idx) { 18 | return list.get(idx); 19 | } 20 | 21 | @Override 22 | public String toString() { 23 | return list.toString(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/approximations/TestMap.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.approximations; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | public class TestMap { 7 | private final Map data = new HashMap<>(); 8 | 9 | int size() { 10 | return data.size(); 11 | } 12 | 13 | boolean containsKey(final K key) { 14 | return data.containsKey(key); 15 | } 16 | 17 | V put(final K key, final V value) { 18 | return data.put(key, value); 19 | } 20 | 21 | V get(final K key) { 22 | return data.get(key); 23 | } 24 | 25 | void putAll(final TestMap other) { 26 | data.putAll(other.data); 27 | } 28 | 29 | @Override 30 | public String toString() { 31 | return data.toString(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/arrays/ObjectWithPrimitivesClass.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.arrays; 2 | 3 | public class ObjectWithPrimitivesClass { 4 | public int valueByDefault = 5; 5 | 6 | public int x, y; 7 | double weight; 8 | 9 | public ObjectWithPrimitivesClass() { 10 | } 11 | 12 | public ObjectWithPrimitivesClass(int x, int y, double weight) { 13 | this.x = x; 14 | this.y = y; 15 | this.weight = weight; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/arrays/ObjectWithPrimitivesClassSucc.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.arrays; 2 | 3 | public class ObjectWithPrimitivesClassSucc extends ObjectWithPrimitivesClass { 4 | public int anotherX; //, y; TODO: hidden field disabled, we do not support it yet 5 | 6 | public ObjectWithPrimitivesClassSucc() { 7 | } 8 | 9 | public ObjectWithPrimitivesClassSucc(int x, int y, double weight, int anotherX) { 10 | super(x, y, weight); 11 | this.anotherX = anotherX; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/arrays/SomeImplementation.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.arrays; 2 | 3 | public class SomeImplementation implements SomeInterface { 4 | @Override 5 | public int foo() { 6 | return 0; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/arrays/SomeInterface.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.arrays; 2 | 3 | public interface SomeInterface { 4 | int foo(); 5 | } 6 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/ast/Ast.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.ast; 2 | 3 | public interface Ast { 4 | T accept(Visitor visitor); 5 | } 6 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/ast/Binary.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.ast; 2 | 3 | abstract class Binary implements Ast { 4 | private final Ast left, right; 5 | 6 | public Binary(Ast left, Ast right) { 7 | this.left = left; 8 | this.right = right; 9 | } 10 | 11 | public Ast getLeft() { 12 | return left; 13 | } 14 | 15 | public Ast getRight() { 16 | return right; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/ast/Constant.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.ast; 2 | 3 | public class Constant implements Ast { 4 | final private int constant; 5 | 6 | public Constant(int constant) { 7 | this.constant = constant; 8 | } 9 | 10 | @Override 11 | public T accept(Visitor visitor) { 12 | return visitor.visit(this); 13 | } 14 | 15 | public int getConstant() { 16 | return constant; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/ast/Minus.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.ast; 2 | 3 | public class Minus extends Binary { 4 | public Minus(Ast left, Ast right) { 5 | super(left, right); 6 | } 7 | 8 | @Override 9 | public T accept(Visitor visitor) { 10 | return visitor.visit(this); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/ast/Sum.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.ast; 2 | 3 | public class Sum extends Binary { 4 | public Sum(Ast left, Ast right) { 5 | super(left, right); 6 | } 7 | 8 | @Override 9 | public T accept(Visitor visitor) { 10 | return visitor.visit(this); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/ast/Variable.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.ast; 2 | 3 | public class Variable implements Ast { 4 | public final int id; 5 | 6 | public Variable(int id) { 7 | this.id = id; 8 | } 9 | 10 | @Override 11 | public T accept(Visitor visitor) { 12 | return visitor.visit(this); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/ast/Visitor.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.ast; 2 | 3 | public interface Visitor { 4 | T visit(Constant constant); 5 | 6 | T visit(Sum sum); 7 | 8 | T visit(Minus minus); 9 | 10 | T visit(Variable variable); 11 | } 12 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/callgraph/CallGraphTestClass1.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.callgraph; 2 | 3 | public class CallGraphTestClass1 { 4 | 5 | public int A() { 6 | return 1; 7 | } 8 | 9 | public final int B() { 10 | return 2; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/callgraph/CallGraphTestClass2.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.callgraph; 2 | 3 | public class CallGraphTestClass2 extends CallGraphTestClass1 { 4 | 5 | private CallGraphTestInterface callGraphTestInterface; 6 | 7 | @Override 8 | public int A() { 9 | return callGraphTestInterface.A() + 3; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/callgraph/CallGraphTestClass3.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.callgraph; 2 | 3 | public class CallGraphTestClass3 { 4 | 5 | public int C(CallGraphTestClass1 callGraphTestClass1) { 6 | return callGraphTestClass1.A(); 7 | } 8 | 9 | public int D(CallGraphTestInterface callGraphTestInterface) { 10 | return callGraphTestInterface.A(); 11 | } 12 | 13 | public int E(CallGraphTestClass1 callGraphTestClass1) { 14 | return callGraphTestClass1.B(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/callgraph/CallGraphTestClass4.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.callgraph; 2 | 3 | public class CallGraphTestClass4 implements CallGraphTestInterface { 4 | 5 | @Override 6 | public int A() { 7 | return 4; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/callgraph/CallGraphTestInterface.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.callgraph; 2 | 3 | public interface CallGraphTestInterface { 4 | 5 | int A(); 6 | } 7 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/casts/CastClass.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.casts; 2 | 3 | import static org.usvm.api.mock.UMockKt.assume; 4 | 5 | public class CastClass { 6 | int x; 7 | int defaultValue = 5; 8 | 9 | int foo() { 10 | return defaultValue; 11 | } 12 | 13 | CastClass castToInheritor() { 14 | assume(this instanceof CastClassFirstSucc); 15 | 16 | return this; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/casts/CastClassFirstSucc.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.casts; 2 | 3 | public class CastClassFirstSucc extends CastClass { 4 | int z = 10; 5 | 6 | @Override 7 | int foo() { 8 | return z; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/casts/CastClassSecondSucc.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.casts; 2 | 3 | public class CastClassSecondSucc extends CastClass { 4 | int d = 20; 5 | 6 | @Override 7 | int foo() { 8 | return d; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/casts/Colorable.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.casts; 2 | 3 | public interface Colorable { 4 | void setColor(int color); 5 | } 6 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/casts/Point.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.casts; 2 | 3 | public class Point { 4 | public int x, y; 5 | 6 | public Point(int x, int y) { 7 | this.x = x; 8 | this.y = y; 9 | } 10 | 11 | public String toString() { 12 | return "(" + x + "," + y + ")"; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/codegen/AnotherClassWithVoidStaticMethods.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.codegen; 2 | 3 | public class AnotherClassWithVoidStaticMethods { 4 | public static void throwException(int x) { 5 | if (x < 0) { 6 | throw new IllegalArgumentException("Less than zero value"); 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/codegen/ClassFromTheSamePackage.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.codegen; 2 | 3 | public class ClassFromTheSamePackage { 4 | public final static int a = 1; 5 | public static int b = 2; 6 | 7 | static int foo(Integer a) { 8 | if (a == null) { 9 | return -1; 10 | } 11 | 12 | if (a == Integer.MAX_VALUE) { 13 | return 1; 14 | } 15 | 16 | return a; 17 | } 18 | 19 | @Override 20 | public boolean equals(Object o) { 21 | if (this == o) return true; 22 | return o != null && getClass() == o.getClass(); 23 | } 24 | 25 | @Override 26 | public int hashCode() { 27 | return 31; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/codegen/ClassWithVoidStaticMethods.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.codegen; 2 | 3 | public class ClassWithVoidStaticMethods { 4 | static int x = 1; 5 | 6 | public static void changeStaticField(int x) { 7 | ClassWithVoidStaticMethods.x = x; 8 | } 9 | 10 | public static void throwException(int x) { 11 | if (x < 0) { 12 | throw new IllegalArgumentException("Less than zero value"); 13 | } 14 | 15 | if (x > 0) { 16 | throw new IllegalStateException("More than zero value"); 17 | } 18 | 19 | changeStaticField(x); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/codegen/FileWithTopLevelFunctionsReflectHelper.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.codegen; 2 | 3 | import org.usvm.examples.codegen.FileWithTopLevelFunctionsKt; 4 | 5 | // We can't access FileWithTopLevelFunctionsKt::class from Kotlin, so we use this class to get reflection from Java 6 | public class FileWithTopLevelFunctionsReflectHelper { 7 | static Class clazz = FileWithTopLevelFunctionsKt.class; 8 | } 9 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/codegen/JavaAssert.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.codegen; 2 | 3 | public class JavaAssert { 4 | public int assertPositive(int value) { 5 | assert value > 0; 6 | return value; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/codegen/VoidStaticMethodsTestingClass.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.codegen; 2 | 3 | public class VoidStaticMethodsTestingClass { 4 | public void invokeChangeStaticFieldMethod(int x) { 5 | ClassWithVoidStaticMethods.changeStaticField(x); 6 | if (ClassWithVoidStaticMethods.x == 10) { 7 | throw new RuntimeException("Value equals 10"); 8 | } 9 | } 10 | 11 | public void invokeThrowExceptionMethod(int x) { 12 | ClassWithVoidStaticMethods.throwException(x); 13 | } 14 | 15 | public void invokeAnotherThrowExceptionMethod(int x) { 16 | AnotherClassWithVoidStaticMethods.throwException(x); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/codegen/deepequals/inner/GraphNode.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.codegen.deepequals.inner; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class GraphNode { 7 | public List nextNodes; 8 | public int value; 9 | 10 | static int staticField; 11 | 12 | public GraphNode(List nextNodes, int value) { 13 | this.nextNodes = nextNodes; 14 | this.value = value; 15 | } 16 | 17 | public GraphNode(int value) { 18 | this(new ArrayList<>(), value); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/codegen/deepequals/inner/Node.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.codegen.deepequals.inner; 2 | 3 | public class Node { 4 | public Node next; 5 | public int value; 6 | 7 | static int staticField; 8 | 9 | public Node(Node next, int value) { 10 | this.next = next; 11 | this.value = value; 12 | } 13 | 14 | public Node(int value) { 15 | this(null, value); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/codegen/modifiers/ClassWithPrivateMutableFieldOfPrivateType.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.codegen.modifiers; 2 | 3 | public class ClassWithPrivateMutableFieldOfPrivateType { 4 | @SuppressWarnings({"FieldCanBeLocal", "unused"}) 5 | private PrivateClass privateMutableField = null; 6 | 7 | public int changePrivateMutableFieldWithPrivateType() { 8 | privateMutableField = new PrivateClass(); 9 | 10 | return privateMutableField.x; 11 | } 12 | 13 | private static class PrivateClass { 14 | int x = 0; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/collections/CustomClass.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.collections; 2 | 3 | public class CustomClass { 4 | int value; 5 | 6 | CustomClass(int value) { 7 | this.value = value; 8 | } 9 | 10 | @Override 11 | public boolean equals(Object o) { 12 | if (o instanceof CustomClass) { 13 | CustomClass that = (CustomClass) o; 14 | return value == that.value; 15 | } 16 | return false; 17 | } 18 | 19 | @Override 20 | public int hashCode() { 21 | return value; 22 | } 23 | 24 | @Override 25 | public String toString() { 26 | return Integer.toString(value); 27 | } 28 | } -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/collections/ListWrapperReturnsVoidExample.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.collections; 2 | 3 | import java.util.List; 4 | 5 | public class ListWrapperReturnsVoidExample { 6 | public int runForEach(List list) { 7 | final int[] i = {0}; 8 | list.forEach(o -> { 9 | if (o == null) i[0]++; 10 | }); 11 | return i[0]; 12 | } 13 | 14 | public int sumPositiveForEach(List list) { 15 | final int[] sum = {0}; 16 | list.forEach(i -> { 17 | if (i > 0) { 18 | sum[0] += i; 19 | } 20 | }); 21 | if (sum[0] == 0) { 22 | return 0; 23 | } else { 24 | return sum[0]; 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/enums/SimpleEnumExample.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.enums; 2 | 3 | public enum SimpleEnumExample { 4 | SUCCESS(10), ERROR(-10); 5 | 6 | final int x; 7 | 8 | SimpleEnumExample(int x) { 9 | this.x = x; 10 | } 11 | 12 | @Override 13 | public String toString() { 14 | return String.format("Enum: {name: %s, x: %d, ordinal: %d}", name(), x, ordinal()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/exceptions/JvmCrashExamples.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.exceptions; 2 | 3 | import sun.misc.Unsafe; 4 | 5 | import java.lang.reflect.Field; 6 | 7 | public class JvmCrashExamples { 8 | public int exit(int i) { 9 | if (i == 0) { 10 | System.exit(-1); 11 | throw new RuntimeException("Exit"); 12 | } 13 | 14 | return i; 15 | } 16 | 17 | public int crash(int i) throws Exception { 18 | Field f = Unsafe.class.getDeclaredField("theUnsafe"); 19 | f.setAccessible(true); 20 | Unsafe unsafe = (Unsafe) f.get(null); 21 | unsafe.putAddress(0, 0); 22 | 23 | if (i == 0) { 24 | return i; 25 | } 26 | 27 | return 1; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/exceptions/MyCheckedException.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.exceptions; 2 | 3 | @SuppressWarnings("serial") 4 | public class MyCheckedException extends Exception { 5 | private final int i; 6 | 7 | public MyCheckedException(int i) { 8 | this.i = i; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/functions/Simple.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.functions; 2 | 3 | public class Simple { 4 | public int calcTwoFunctions(int x, int y) { 5 | int res = square(x) + id(y); 6 | if (res < 0 && y >= 0) { 7 | return 0; 8 | } 9 | return 1; 10 | } 11 | 12 | private int square(int x) { 13 | return x * x; 14 | } 15 | 16 | private int id(int y) { 17 | return y; 18 | } 19 | 20 | public int factorial(int n) { 21 | if (n > 10 || n < 0) { 22 | return 1; 23 | } 24 | return (n == 0 ? 1 : factorial(n - 1)); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/functions/Throwing.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.functions; 2 | 3 | public class Throwing { 4 | public int throwSometimes(int x) { 5 | if (x == 1) { 6 | throw new IllegalArgumentException(); 7 | } 8 | return x; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/invokes/AbstractImplementor.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.invokes; 2 | 3 | public abstract class AbstractImplementor implements SimpleInterface { 4 | @Override 5 | public abstract int constValue(); 6 | } 7 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/invokes/BaseClass.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.invokes; 2 | 3 | // class with an implementation of foo 4 | public class BaseClass { 5 | public int foo() { 6 | return 0; 7 | } 8 | } -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/invokes/DefaultInterface.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.invokes; 2 | 3 | // interface with a default implementation of foo 4 | public interface DefaultInterface { 5 | default int foo() { 6 | throw new UnsupportedOperationException(); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/invokes/DerivedClass.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.invokes; 2 | 3 | // Derived class does not provide implementation of foo 4 | public class DerivedClass extends BaseClass implements DefaultInterface { 5 | } 6 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/invokes/InvokeClass.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.invokes; 2 | 3 | public class InvokeClass { 4 | public int value; 5 | 6 | public int divBy(int den) { 7 | return value / den; 8 | } 9 | 10 | public void updateValue(int newValue) { 11 | value = newValue; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/invokes/ObjectExample.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.invokes; 2 | 3 | public class ObjectExample { 4 | public String objectToStringVirtualInvokeExample(Object x) { 5 | if (x == null) { 6 | return null; 7 | } 8 | 9 | return x.toString(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/invokes/Realization.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.invokes; 2 | 3 | public class Realization extends AbstractImplementor { 4 | @Override 5 | public int constValue() { 6 | return 10; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/invokes/SimpleInterface.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.invokes; 2 | 3 | public interface SimpleInterface { 4 | default int addConstantToValue(int value) { 5 | return value + 5; 6 | } 7 | 8 | default int subtractConstantFromValue(int value) { 9 | return value - 5; 10 | } 11 | 12 | int constValue(); 13 | } 14 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/invokes/SimpleInterfaceExample.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.invokes; 2 | 3 | public class SimpleInterfaceExample { 4 | public int overrideMethod(SimpleInterface objectExample, int value) { 5 | return objectExample.addConstantToValue(value); 6 | } 7 | 8 | public int defaultMethod(SimpleInterface objectExample, int value) { 9 | return objectExample.subtractConstantFromValue(value); 10 | } 11 | 12 | public int invokeMethodFromImplementor(AbstractImplementor objectExample) { 13 | return objectExample.constValue(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/invokes/SimpleInterfaceImpl.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.invokes; 2 | 3 | @SuppressWarnings("unused") 4 | public class SimpleInterfaceImpl implements SimpleInterface { 5 | public int addConstantToValue(int value) { 6 | return value + 2; 7 | } 8 | 9 | @Override 10 | public int constValue() { 11 | return 5; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/invokes/StaticInvokeExample.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.invokes; 2 | 3 | public class StaticInvokeExample { 4 | public static int maxForThree(int x, short y, byte z) { 5 | int max = maxForTwo(x, y); 6 | 7 | if (max > z) { 8 | return max; 9 | } else { 10 | return z; 11 | } 12 | } 13 | 14 | private static int maxForTwo(int x, short y) { 15 | if (x > y) { 16 | return x; 17 | } else { 18 | return y; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/invokes/VirtualInvokeAbstractClass.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.invokes; 2 | 3 | public abstract class VirtualInvokeAbstractClass { 4 | int abstractFoo() { 5 | return 1; 6 | } 7 | 8 | int abstractBar() { 9 | return 1; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/invokes/VirtualInvokeAbstractClassSucc.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.invokes; 2 | 3 | public class VirtualInvokeAbstractClassSucc extends VirtualInvokeAbstractClass { 4 | @Override 5 | int abstractBar() { 6 | return 2; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/invokes/VirtualInvokeClass.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.invokes; 2 | 3 | public class VirtualInvokeClass { 4 | int foo(int value) { 5 | if (value > 0) { 6 | return 1; 7 | } 8 | if (value < 0) { 9 | return 2; 10 | } 11 | throw new RuntimeException(); 12 | } 13 | 14 | int bar() { 15 | return 1; 16 | } 17 | 18 | int fooBar() { 19 | return bar(); 20 | } 21 | 22 | Object getObject() { 23 | return 10; 24 | } 25 | } 26 | 27 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/invokes/VirtualInvokeClassSucc.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.invokes; 2 | 3 | public class VirtualInvokeClassSucc extends VirtualInvokeClass { 4 | private int x; 5 | 6 | int returnX(VirtualInvokeClassSucc obj) { 7 | return obj.x; 8 | } 9 | 10 | @Override 11 | int foo(int value) { 12 | if (value > 0) { 13 | return 1; 14 | } 15 | if (value < 0) { 16 | return -1; 17 | } 18 | return 0; 19 | } 20 | 21 | @Override 22 | int bar() { 23 | return 2; 24 | } 25 | 26 | @Override 27 | int fooBar() { 28 | return bar(); 29 | } 30 | 31 | @Override 32 | Object getObject() { 33 | return null; 34 | } 35 | } -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/lambda/PredicateNotExample.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.lambda; 2 | 3 | import java.util.function.Predicate; 4 | 5 | public class PredicateNotExample { 6 | public boolean predicateNotExample(int a) { 7 | if (Predicate.not(i -> i.equals(5)).test(a)) { 8 | return true; 9 | } else { 10 | return false; 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/lambda/SimpleLambdaExamples.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.lambda; 2 | 3 | import java.util.function.BiFunction; 4 | import java.util.function.Predicate; 5 | 6 | public class SimpleLambdaExamples { 7 | public int biFunctionLambdaExample(int a, int b) { 8 | BiFunction division = (numerator, divisor) -> numerator / divisor; 9 | 10 | return division.apply(a, b); 11 | } 12 | 13 | @SuppressWarnings("Convert2MethodRef") 14 | public Predicate choosePredicate(boolean isNotNullPredicate) { 15 | if (isNotNullPredicate) { 16 | return (o -> o != null); 17 | } else { 18 | return (o -> o == null); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/math/DivRemExamples.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.math; 2 | 3 | public class DivRemExamples { 4 | public int div(int x, int y) { 5 | return x / y; 6 | } 7 | 8 | public int rem(int x, int y) { 9 | return x % y; 10 | } 11 | 12 | public boolean remPositiveConditional(int d) { 13 | return (11 % d == 2); 14 | } 15 | 16 | public boolean remNegativeConditional(int d) { 17 | return (-11 % d == -2); 18 | } 19 | 20 | 21 | public boolean remWithConditions(int d) { 22 | return d >= 0 && (-11 % d == -2); 23 | } 24 | 25 | public double remDoubles(double x, double y) { 26 | return x % y; 27 | } 28 | 29 | public double remDoubleInt(double x, int y) { 30 | return x % y; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/mixed/LoggerExample.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.mixed; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.usvm.samples.objects.ObjectWithPrimitivesClass; 6 | 7 | public class LoggerExample { 8 | private static final Logger logger = LoggerFactory.getLogger(ObjectWithPrimitivesClass.class); 9 | 10 | public int example() { 11 | int a = 5; 12 | int b = 10; 13 | 14 | int sum = a + b; 15 | 16 | logger.debug("Debug info"); 17 | logger.error("An error"); 18 | logger.info("Info"); 19 | 20 | return sum; 21 | } 22 | 23 | public int loggerUsage() { 24 | if (logger.isDebugEnabled()) { 25 | return 1; 26 | } else { 27 | return 2; 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/mixed/MonitorUsage.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.mixed; 2 | 3 | public class MonitorUsage { 4 | public int simpleMonitor(int x) { 5 | int y; 6 | if (x > 0) { 7 | synchronized (this) { 8 | y = x + 2; 9 | } 10 | } else { 11 | y = -1; 12 | } 13 | return y > 0 ? 1 : 0; 14 | } 15 | } -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/mixed/Overload.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.mixed; 2 | 3 | public class Overload { 4 | public int sign(int x) { 5 | if (x > 0) { 6 | return 1; 7 | } else if (x < 0) { 8 | return -1; 9 | } else { 10 | return 0; 11 | } 12 | } 13 | 14 | public int signBinary(int x, int y) { 15 | if (x + y > 0) { 16 | return 1; 17 | } else if (x + y < 0) { 18 | return -1; 19 | } else { 20 | return 0; 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/mixed/PrivateConstructorExample.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.mixed; 2 | 3 | /** 4 | * This class is used for testing the engine behavior 5 | * when working with classes that have only 6 | * private constructors 7 | */ 8 | public class PrivateConstructorExample { 9 | int a, b; 10 | 11 | private PrivateConstructorExample(int a, int b) { 12 | this.a = a; 13 | this.b = b; 14 | } 15 | 16 | public int limitedSub(int limit) { 17 | int sub = a - b; 18 | if (sub >= limit) { 19 | return sub; 20 | } 21 | return limit; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/mixed/SerializableExample.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.mixed; 2 | 3 | import java.io.File; 4 | 5 | public class SerializableExample { 6 | @SuppressWarnings({"unchecked", "ResultOfMethodCallIgnored"}) 7 | public void example() { 8 | join("string", File.separator, System.currentTimeMillis()); 9 | } 10 | 11 | @SuppressWarnings({"unchecked", "UnusedReturnValue"}) 12 | public static String join(T... elements) { 13 | return null; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/mixed/SimpleNoCondition.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.mixed; 2 | 3 | public class SimpleNoCondition { 4 | 5 | public int basicAdd(int a, int b) { 6 | return a + b; 7 | } 8 | 9 | public int basicXorInt(int a, int b) { 10 | return a ^ b; 11 | } 12 | 13 | public boolean basicXorBoolean(boolean a, boolean b) { 14 | return a ^ b; 15 | } 16 | } -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/mixed/Simplifier.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.mixed; 2 | 3 | import static org.usvm.api.mock.UMockKt.assume; 4 | import org.usvm.samples.objects.ObjectWithPrimitivesClass; 5 | 6 | public class Simplifier { 7 | public ObjectWithPrimitivesClass simplifyAdditionWithZero(ObjectWithPrimitivesClass fst) { 8 | assume(fst != null); 9 | 10 | fst.x = 0; 11 | 12 | fst.x += fst.shortValue; 13 | 14 | return fst; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/mixed/StaticMethodExamples.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.mixed; 2 | 3 | public class StaticMethodExamples { 4 | public static boolean complement(int x) { 5 | return (~x) == 1; 6 | } 7 | 8 | public static int max2(int x, short y) { 9 | if (x > y) { 10 | return x; 11 | } else { 12 | return y; 13 | } 14 | } 15 | 16 | public static long sum(int x, short y, byte z) { 17 | int sum = x + y + z; 18 | if (sum > 20 | sum < -20) { 19 | return sum * 2L; 20 | } 21 | return sum; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/mock/InnerMockWithFieldExample.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.mock; 2 | 3 | import org.usvm.samples.mock.others.VersionStamp; 4 | 5 | public class InnerMockWithFieldExample { 6 | public VersionStamp stamp; 7 | 8 | public static VersionStamp checkAndUpdate(InnerMockWithFieldExample example) { 9 | if (example.stamp.initial > example.stamp.version) { 10 | example.stamp.version = example.stamp.initial; 11 | } else { 12 | example.stamp.version = example.stamp.version + 1; 13 | } 14 | return example.stamp; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/mock/InterfaceWithoutImplementors.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.mock; 2 | 3 | public interface InterfaceWithoutImplementors { 4 | Object visit(Object value); 5 | } 6 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/mock/MockFinalClassExample.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.mock; 2 | 3 | import org.usvm.samples.mock.others.FinalClass; 4 | 5 | public class MockFinalClassExample { 6 | FinalClass intProvider; 7 | 8 | int useFinalClass() { 9 | int x = intProvider.provideInt(); 10 | if (x == 1) { 11 | return 1; 12 | } else { 13 | return 2; 14 | } 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/mock/MockStaticMethodExample.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.mock; 2 | 3 | import org.usvm.samples.mock.others.Random; 4 | 5 | public class MockStaticMethodExample { 6 | public int useStaticMethod() { 7 | int value = Random.nextRandomInt(); 8 | if (value > 50) { 9 | return 100; 10 | } 11 | 12 | return 0; 13 | } 14 | 15 | public void mockStaticMethodFromAlwaysMockClass() { 16 | System.out.println("example"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/mock/MockWithFieldExample.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.mock; 2 | 3 | import org.usvm.samples.mock.others.VersionStamp; 4 | 5 | public class MockWithFieldExample { 6 | public VersionStamp checkAndUpdate(VersionStamp stamp) { 7 | if (stamp.initial > stamp.version) { 8 | stamp.version = stamp.initial; 9 | } else { 10 | stamp.version = stamp.version + 1; 11 | } 12 | return stamp; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/mock/UseNetwork.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.mock; 2 | 3 | import static org.usvm.api.mock.UMockKt.assume; 4 | import org.usvm.samples.mock.others.Network; 5 | 6 | public class UseNetwork { 7 | public static int readBytes(byte[] packet, Network network) { 8 | int res = 0; 9 | int c; 10 | while ((c = network.nextByte()) != -1) { 11 | packet[res++] = (byte)c; 12 | } 13 | return res; 14 | } 15 | 16 | public void mockVoidMethod(Network network) { 17 | assume(network != null); 18 | 19 | network.voidMethod(); 20 | } 21 | } -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/mock/aliasing/AliasingInParamsExample.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.mock.aliasing; 2 | 3 | import static org.usvm.api.mock.UMockKt.assume; 4 | import org.usvm.samples.mock.aliasing.parent.InterfaceFromAnotherPackage; 5 | 6 | public class AliasingInParamsExample { 7 | int example(InterfaceFromAnotherPackage fst, ClassFromTheSamePackage snd, int x) { 8 | assume(fst != null && snd != null); 9 | if (fst == snd) { 10 | return fst.foo(x); // unreachable with package based mock approach 11 | } else { 12 | return snd.foo(x); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/mock/aliasing/ClassFromTheSamePackage.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.mock.aliasing; 2 | 3 | import org.usvm.samples.mock.aliasing.parent.InterfaceFromAnotherPackage; 4 | 5 | public class ClassFromTheSamePackage implements InterfaceFromAnotherPackage { 6 | @Override 7 | public int foo(int x) { 8 | return x; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/mock/aliasing/parent/InterfaceFromAnotherPackage.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.mock.aliasing.parent; 2 | 3 | public interface InterfaceFromAnotherPackage { 4 | int foo(int x); 5 | } 6 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/mock/fields/ClassUsingClassWithRandomField.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.mock.fields; 2 | 3 | public class ClassUsingClassWithRandomField { 4 | public int useClassWithRandomField() { 5 | ClassWithRandomField classWithRandomField = new ClassWithRandomField(); 6 | 7 | return classWithRandomField.nextInt(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/mock/fields/ClassWithRandomField.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.mock.fields; 2 | 3 | import java.util.Random; 4 | 5 | public class ClassWithRandomField { 6 | public Random random = new Random(); 7 | 8 | public int nextInt() { 9 | return random.nextInt(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/mock/others/ClassWithStaticField.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.mock.others; 2 | 3 | public class ClassWithStaticField { 4 | public int intField; 5 | public int anotherIntField; 6 | 7 | public int foo() { 8 | return 5; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/mock/others/FinalClass.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.mock.others; 2 | 3 | final public class FinalClass { 4 | public int provideInt() { 5 | return 1; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/mock/others/Generator.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.mock.others; 2 | 3 | /** 4 | * Simple interface, used in scenarios: 5 | * - mock classes/interfaces from another package; 6 | * - mock fields, static or non-static. 7 | */ 8 | public interface Generator { 9 | int generateInt(); 10 | } -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/mock/others/Locator.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.mock.others; 2 | 3 | /** 4 | * Simple interface, used in scenarios: 5 | * - mock classes/interfaces from another package; 6 | * - mock object returned by another mock; 7 | * - mock fields, static or non-static. 8 | */ 9 | public interface Locator { 10 | Generator locate(); 11 | } -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/mock/others/Network.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.mock.others; 2 | 3 | public abstract class Network { 4 | public abstract int nextByte(); 5 | 6 | public abstract void voidMethod(); 7 | } 8 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/mock/others/Random.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.mock.others; 2 | 3 | public class Random { 4 | public static int nextRandomInt() { 5 | return 42; 6 | } 7 | } 8 | 9 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/mock/others/SideEffectApplier.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.mock.others; 2 | 3 | import org.usvm.samples.mock.service.impl.ExampleClass; 4 | 5 | public class SideEffectApplier { 6 | public void applySideEffect(ExampleClass a) { 7 | a.field += 1; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/mock/others/VersionStamp.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.mock.others; 2 | 3 | public class VersionStamp { 4 | public int initial = 0; 5 | public int version; 6 | } 7 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/mock/provider/Provider.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.mock.provider; 2 | 3 | import org.usvm.samples.mock.service.impl.ExampleClass; 4 | 5 | public interface Provider { 6 | 7 | ExampleClass provideObject(); 8 | 9 | boolean provideBoolean(); 10 | 11 | char provideCharacter(); 12 | 13 | byte provideByte(); 14 | 15 | short provideShort(); 16 | 17 | int provideInteger(); 18 | 19 | long provideLong(); 20 | 21 | float provideFloat(); 22 | 23 | double provideDouble(); 24 | 25 | int provideGiven(int i); 26 | 27 | int provideOverloaded(); 28 | 29 | int provideOverloaded(int i); 30 | 31 | int provideGivenObject(ExampleClass object); 32 | } 33 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/mock/service/Service.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.mock.service; 2 | 3 | import org.usvm.samples.mock.provider.impl.ProviderImpl; 4 | 5 | public interface Service { 6 | 7 | int calculateBasedOnShort(ProviderImpl provider); 8 | 9 | int inconsistentBoolean(ProviderImpl provider); 10 | 11 | int calculateBasedOnInteger(ProviderImpl provider); 12 | 13 | int calculateBasedOnBoolean(ProviderImpl provider); 14 | 15 | int calculateBasedOnCharacter(ProviderImpl provider); 16 | 17 | int calculateBasedOnByte(ProviderImpl provider); 18 | 19 | int calculateBasedOnLong(ProviderImpl provider); 20 | 21 | int calculateBasedOnFloat(ProviderImpl provider); 22 | 23 | int calculateBasedOnDouble(ProviderImpl provider); 24 | } 25 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/mock/service/impl/ExampleClass.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.mock.service.impl; 2 | 3 | public class ExampleClass { 4 | public int field; 5 | 6 | public ExampleClass(int a) { 7 | this.field = a; 8 | } 9 | 10 | static public void staticIncrementField(ExampleClass a) { 11 | a.field++; 12 | } 13 | 14 | public void incrementField() { 15 | field++; 16 | } 17 | 18 | @Override 19 | public boolean equals(Object o) { 20 | if (this == o) return true; 21 | if (o == null || getClass() != o.getClass()) return false; 22 | ExampleClass that = (ExampleClass) o; 23 | return field == that.field; 24 | } 25 | 26 | @Override 27 | public int hashCode() { 28 | return field * 31; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/models/ObjectWithRefFieldClass.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.models; 2 | 3 | import org.usvm.samples.objects.SimpleDataClass; 4 | 5 | public class ObjectWithRefFieldClass { 6 | public SimpleDataClass refField; 7 | public int[] arrayField; 8 | } 9 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/natives/NativeExamples.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.natives; 2 | 3 | /** 4 | * A class with test cases containing calls to java.lang code 5 | * which uses static fields like System.out 6 | */ 7 | public class NativeExamples { 8 | 9 | public int findAndPrintSum(int a, int b) { 10 | int sum = a + b; 11 | System.out.println("Sum: " + sum); 12 | System.err.print(sum); 13 | return sum; 14 | } 15 | 16 | public double findSumWithMathRandom(double a) { 17 | double b = Math.random(); 18 | return a + b; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/nested/DeepNested.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.nested; 2 | 3 | public class DeepNested { 4 | public class Nested1 { 5 | public class Nested2 { 6 | public int f(int i) { 7 | if (i > 0) { 8 | return 10; 9 | } 10 | return 0; 11 | } 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/objects/ClassForTestClinitSections.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.objects; 2 | 3 | public class ClassForTestClinitSections { 4 | private static int x = 5; 5 | 6 | public int resultDependingOnStaticSection() { 7 | if (x == 5) { 8 | return -1; 9 | } 10 | 11 | return 1; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/objects/ClassWithClassRef.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.objects; 2 | 3 | import java.util.List; 4 | 5 | public class ClassWithClassRef { 6 | protected Class> someListClass; 7 | 8 | public String classRefName() { 9 | return someListClass.getName(); 10 | } 11 | } -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/objects/ClassWithPrivateField.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.objects; 2 | 3 | public class ClassWithPrivateField { 4 | private int a; 5 | 6 | public int getA() { 7 | return a; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/objects/HiddenFieldAccessModifiersExample.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.objects; 2 | 3 | public class HiddenFieldAccessModifiersExample { 4 | public boolean checkSuperFieldEqualsOne(HiddenFieldAccessModifiersSucc b) { 5 | return b.getF() == 1; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/objects/HiddenFieldAccessModifiersSucc.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.objects; 2 | 3 | public class HiddenFieldAccessModifiersSucc extends HiddenFieldAccessModifiersSuper { 4 | private int f; 5 | } 6 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/objects/HiddenFieldAccessModifiersSuper.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.objects; 2 | 3 | public class HiddenFieldAccessModifiersSuper { 4 | public int f; 5 | public int getF() { 6 | return this.f; 7 | } 8 | public void setF(int val) { 9 | this.f = val; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/objects/HiddenFieldExample.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.objects; 2 | 3 | public class HiddenFieldExample { 4 | public int checkHiddenField(HiddenFieldSuperClass o) { 5 | if (o instanceof HiddenFieldSuccClass) { 6 | return 0; 7 | } 8 | 9 | if (o.a == 1 && o.b == 2) { 10 | return 1; 11 | } 12 | return 2; 13 | } 14 | 15 | public int checkSuccField(HiddenFieldSuccClass o) { 16 | if (o.a == 1) { 17 | return 1; 18 | } 19 | if (o.b == 2) { 20 | return 2; 21 | } 22 | if (((HiddenFieldSuperClass) o).b == 3) { 23 | return 3; 24 | } 25 | return 4; 26 | } 27 | } -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/objects/HiddenFieldSuccClass.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.objects; 2 | 3 | public class HiddenFieldSuccClass extends HiddenFieldSuperClass { 4 | public double b; 5 | } -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/objects/HiddenFieldSuperClass.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.objects; 2 | 3 | public class HiddenFieldSuperClass { 4 | public int a, b; 5 | } -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/objects/Id.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.objects; 2 | 3 | @SuppressWarnings("RedundantIfStatement") 4 | public class Id { 5 | public int id; 6 | boolean isOne() { 7 | if (id == 1) { 8 | return true; 9 | } 10 | return false; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/objects/LocalClassExample.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.objects; 2 | 3 | public class LocalClassExample { 4 | int localClassFieldExample(int y) { 5 | class LocalClass { 6 | final int x; 7 | 8 | public LocalClass(int x) { 9 | this.x = x; 10 | } 11 | } 12 | 13 | LocalClass localClass = new LocalClass(42); 14 | 15 | return localClass.x + y; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/objects/ObjectWithFinalStatic.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.objects; 2 | 3 | public class ObjectWithFinalStatic { 4 | public final static Integer keyValue = 420; 5 | 6 | public int parameterEqualsFinalStatic(Integer key, int value) { 7 | if (key == keyValue) { 8 | return value; 9 | } 10 | return -420; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/objects/ObjectWithPrimitivesClassSucc.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.objects; 2 | 3 | public class ObjectWithPrimitivesClassSucc extends ObjectWithPrimitivesClass { 4 | public int anotherX; //, y; TODO: hidden field disabled, we do not support it yet 5 | 6 | public ObjectWithPrimitivesClassSucc() { 7 | } 8 | 9 | public ObjectWithPrimitivesClassSucc(int x, int y, double weight, int anotherX) { 10 | super(x, y, weight); 11 | this.anotherX = anotherX; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/objects/ObjectWithRefFieldClass.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.objects; 2 | 3 | public class ObjectWithRefFieldClass { 4 | public int x, y; 5 | public double weight; 6 | public SimpleDataClass refField; 7 | public int[] arrayField; 8 | } 9 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/objects/ObjectWithStaticFieldsClass.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.objects; 2 | 3 | public class ObjectWithStaticFieldsClass { 4 | public static int defaultValue = 5; 5 | public static int staticValue; 6 | public static int[] staticArrayValue; 7 | public static int[] initializedArray = {1, 2, 3}; 8 | public static int[] elevenElements = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; 9 | public int x, y; 10 | } 11 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/objects/ObjectWithThrowableConstructor.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.objects; 2 | 3 | public class ObjectWithThrowableConstructor { 4 | public int x; 5 | 6 | public ObjectWithThrowableConstructor(int numerator, int denominator) { 7 | x = numerator / denominator; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/objects/PrivateFields.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.objects; 2 | 3 | public class PrivateFields { 4 | public boolean accessWithGetter(ClassWithPrivateField foo) { 5 | return foo.getA() == 1; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/objects/RecursiveType.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.objects; 2 | 3 | public class RecursiveType { 4 | public RecursiveTypeClass nextValue(RecursiveTypeClass node, int value) { 5 | if (value == 0) { 6 | throw new IllegalArgumentException(); 7 | } 8 | if (node.next.value == value) { 9 | return node.next; 10 | } 11 | return null; 12 | } 13 | 14 | public RecursiveTypeClass writeObjectField(RecursiveTypeClass node) { 15 | if (node.next == null) { 16 | node.next = new RecursiveTypeClass(); 17 | } 18 | node.next.value = node.next.value + 1; 19 | return node; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/objects/RecursiveTypeClass.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.objects; 2 | 3 | public class RecursiveTypeClass { 4 | public RecursiveTypeClass next; 5 | public int value; 6 | } 7 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/objects/SemiImmutableClass.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.objects; 2 | 3 | public class SemiImmutableClass { 4 | public final int a; 5 | public int b; 6 | 7 | public SemiImmutableClass(int a, int b) { 8 | this.a = a; 9 | this.b = b; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/objects/SimpleClassMultiInstanceExample.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.objects; 2 | 3 | public class SimpleClassMultiInstanceExample { 4 | public int singleObjectChange(SimpleDataClass first, SimpleDataClass second) { 5 | if (first.a < 5) { 6 | first.b = 3; 7 | } 8 | 9 | return first.b; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/objects/SimpleDataClass.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.objects; 2 | 3 | public class SimpleDataClass { 4 | public int a; 5 | public int b; 6 | 7 | public static SimpleDataClass staticField; 8 | 9 | public SimpleDataClass() { 10 | } 11 | 12 | public SimpleDataClass(int a, int b) { 13 | this.a = a; 14 | this.b = b; 15 | } 16 | } -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/objects/Vector2D.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.objects; 2 | 3 | @SuppressWarnings("RedundantIfStatement") 4 | public class Vector2D { 5 | int x; 6 | int y; 7 | 8 | boolean isPerpendicularTo(Vector2D other) { 9 | long scalar = (long)x * other.x + (long)y * other.y; 10 | if (scalar == 0) { 11 | return true; 12 | } else { 13 | return false; 14 | } 15 | } 16 | 17 | boolean isCollinearTo(Vector2D other) { 18 | long cross = (long)x * other.y - (long)y * other.x; 19 | if (cross == 0) { 20 | return true; 21 | } else { 22 | return false; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/objects/WrappedIntQuad.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.objects; 2 | 3 | public class WrappedIntQuad { 4 | public WrappedInt a; 5 | public WrappedInt b; 6 | public WrappedInt c; 7 | public WrappedInt d; 8 | 9 | public WrappedIntQuad() { 10 | this.a = new WrappedInt(); 11 | this.b = new WrappedInt(); 12 | this.c = new WrappedInt(); 13 | this.d = new WrappedInt(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/operators/Logic.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.operators; 2 | 3 | @SuppressWarnings({"PointlessBooleanExpression", "RedundantIfStatement"}) 4 | public class Logic { 5 | boolean complexWithLocals(int x, short y, long z) { 6 | boolean equalsXY = x == y; 7 | boolean equalsYZ = y == z; 8 | boolean equalsZX = z == x; 9 | 10 | if (((x | y | z) != 1337) ^ true) { 11 | return false; 12 | } 13 | 14 | if ((equalsXY || equalsYZ || equalsZX) && !(equalsXY ^ equalsYZ ^ equalsZX)) { 15 | return false; 16 | } 17 | return true; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/operators/Overflow.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.operators; 2 | 3 | @SuppressWarnings("ConstantValue") 4 | public class Overflow { 5 | int shortOverflow(short x, int y) { 6 | if (y > 10 || y <= 0) { 7 | return 0; 8 | } 9 | if (x + y < 0 && x > 0) { 10 | throw new IllegalStateException(); 11 | } 12 | return x + y; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/primitives/ByteExamples.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.primitives; 2 | 3 | public class ByteExamples { 4 | public int negByte(byte b) { 5 | int a = -b; 6 | if (a < b) { 7 | return 0; 8 | } else { 9 | return 1; 10 | } 11 | } 12 | 13 | public int negConstByte(byte b) { 14 | byte a = 10; 15 | int c = -a; 16 | if (a > b && c < b) { 17 | return 0; 18 | } else { 19 | return 1; 20 | } 21 | } 22 | 23 | public int sumTwoBytes(byte a, byte b) { 24 | int s = a + b; 25 | if (s > Byte.MAX_VALUE) { 26 | return 1; 27 | } 28 | if (s < Byte.MIN_VALUE) { 29 | return 2; 30 | } 31 | return 3; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/primitives/CharAsFieldObject.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.primitives; 2 | 3 | public class CharAsFieldObject { 4 | public char c; 5 | } -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/primitives/FloatExamples.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.primitives; 2 | 3 | public class FloatExamples { 4 | public int floatInfinity(float f) { 5 | if (f == Float.POSITIVE_INFINITY) { 6 | return 1; 7 | } 8 | if (f == Float.NEGATIVE_INFINITY) { 9 | return 2; 10 | } 11 | return 3; 12 | } 13 | } -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/reflection/NewInstanceExample.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.reflection; 2 | 3 | public class NewInstanceExample { 4 | @SuppressWarnings("deprecation") 5 | int createWithReflectionExample() throws ClassNotFoundException, InstantiationException, IllegalAccessException { 6 | Class cls = Class.forName("org.usvm.samples.reflection.ClassWithDefaultConstructor"); 7 | ClassWithDefaultConstructor classWithDefaultConstructor = (ClassWithDefaultConstructor) cls.newInstance(); 8 | 9 | return classWithDefaultConstructor.x; 10 | } 11 | } 12 | 13 | class ClassWithDefaultConstructor { 14 | 15 | int x; 16 | } 17 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/stdlib/DateExample.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.stdlib; 2 | 3 | import java.util.Date; 4 | 5 | public class DateExample { 6 | public boolean getTime(Date date) { 7 | return date.getTime() == 100; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/stdlib/JavaIOFileInputStreamCheck.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.stdlib; 2 | 3 | import java.io.FileInputStream; 4 | import java.io.IOException; 5 | 6 | public class JavaIOFileInputStreamCheck { 7 | public int read(String s) throws IOException { 8 | FileInputStream fis = new FileInputStream(s); 9 | byte[] b = new byte[1000]; 10 | return fis.read(b); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/strings/GenericExamples.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.strings; 2 | 3 | public class GenericExamples { 4 | public boolean containsOk(T obj) { 5 | return obj.toString().contains("ok"); 6 | } 7 | 8 | public boolean containsOkExample() { 9 | return new GenericExamples().containsOk("Elders have spoken"); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/structures/Pair.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.structures; 2 | 3 | 4 | public class Pair { 5 | private long first, second; 6 | 7 | public Pair() { 8 | } 9 | 10 | public Pair(long first, long second) { 11 | this.first = first; 12 | this.second = second; 13 | } 14 | 15 | public long getFirst() { 16 | return first; 17 | } 18 | 19 | public void setFirst(long first) { 20 | this.first = first; 21 | } 22 | 23 | public long getSecond() { 24 | return second; 25 | } 26 | 27 | public void setSecond(long second) { 28 | this.second = second; 29 | } 30 | } -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/substitution/StaticSubstitution.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.substitution; 2 | 3 | /** 4 | * A class with static fields. 5 | * If a field is not final, we have two options: 6 | * - to use value from static initializer only 7 | * - to replace this value with symbolic variable 8 | * This setting is configured in UtSettings. 9 | */ 10 | public class StaticSubstitution { 11 | public static int mutableValue; 12 | public static final int finalValue = 5; 13 | 14 | static { 15 | mutableValue = finalValue; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/substitution/StaticSubstitutionExamples.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.substitution; 2 | 3 | public class StaticSubstitutionExamples { 4 | 5 | public int lessThanZero() { 6 | int value = StaticSubstitution.mutableValue; 7 | return value > 0 ? value : 0; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/threads/ExecutorServiceExamples.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.threads; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.concurrent.Executors; 6 | 7 | public class ExecutorServiceExamples { 8 | public void throwingInExecute() { 9 | Executors.newSingleThreadExecutor().execute(() -> { 10 | throw new IllegalStateException(); 11 | }); 12 | } 13 | 14 | public int changingCollectionInExecute() { 15 | List list = new ArrayList<>(); 16 | 17 | Executors.newSingleThreadExecutor().execute(() -> { 18 | list.add(42); 19 | }); 20 | 21 | return list.get(0); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/types/CollectionAsField.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.types; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | public class CollectionAsField { 7 | public static Map staticMap = new HashMap<>(); 8 | public Map nonStaticMap = new HashMap<>(); 9 | public T field; 10 | } 11 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/types/GenericWithUpperBound.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.types; 2 | 3 | public class GenericWithUpperBound> { 4 | @SuppressWarnings({"DataFlowIssue"}) 5 | public int excludeComparable(C value) { 6 | if (!(value instanceof Comparable)) { 7 | return 0; 8 | } 9 | 10 | return 1; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/unsafe/UnsafeOperations.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.unsafe; 2 | 3 | import sun.misc.Unsafe; 4 | 5 | import java.lang.reflect.Field; 6 | 7 | public class UnsafeOperations { 8 | public int getAddressSizeOrZero() { 9 | try { 10 | Field f = Unsafe.class.getDeclaredField("theUnsafe"); 11 | f.setAccessible(true); 12 | Unsafe unsafe = (Unsafe) f.get(null); 13 | return unsafe.addressSize(); 14 | } catch (NoSuchFieldException | IllegalAccessException e) { 15 | throw new RuntimeException("Reflection failed"); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/unsafe/UnsafeWithField.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.unsafe; 2 | 3 | import java.text.NumberFormat.Field; 4 | 5 | public class UnsafeWithField { 6 | Field field; 7 | 8 | public Field setField(Field f) { 9 | field = f; 10 | return Field.INTEGER; 11 | } 12 | } -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/wrappers/DoubleWrapper.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.wrappers; 2 | 3 | public class DoubleWrapper { 4 | public Double primitiveToWrapper(double i) { 5 | Double a = i; 6 | if (a >= 0) { 7 | return a; 8 | } else { 9 | return -a; 10 | } 11 | } 12 | 13 | public double wrapperToPrimitive(Double i) { 14 | double a = i; 15 | if (a >= 0) { 16 | return a; 17 | } else { 18 | return -a; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/java/org/usvm/samples/wrappers/FloatWrapper.java: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.wrappers; 2 | 3 | public class FloatWrapper { 4 | Float primitiveToWrapper(float i) { 5 | Float a = i; 6 | if (a >= 0) { 7 | return a; 8 | } else { 9 | return -a; 10 | } 11 | } 12 | 13 | float wrapperToPrimitive(Float i) { 14 | float a = i; 15 | if (a >= 0) { 16 | return a; 17 | } else { 18 | return -a; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /usvm-jvm/src/samples/kotlin/org/usvm/examples/codegen/FileWithTopLevelFunctions.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.examples.codegen 2 | 3 | class KotlinCustomClass 4 | 5 | fun topLevelSum(a: Int, b: Int): Int { 6 | return a + b 7 | } 8 | 9 | fun Int.extensionOnBasicType(other: Int): Int { 10 | return this + other 11 | } 12 | 13 | fun KotlinCustomClass.extensionOnCustomClass(other: KotlinCustomClass): Boolean { 14 | return this === other 15 | } -------------------------------------------------------------------------------- /usvm-jvm/src/test/kotlin/org/usvm/samples/annotations/lombok/EnumWithoutAnnotationsTest.kt: -------------------------------------------------------------------------------- 1 | //package org.usvm.samples.annotations.lombok 2 | // 3 | //import org.junit.jupiter.api.Test 4 | //import org.usvm.samples.JavaMethodTestRunner 5 | //import org.usvm.test.util.checkers.eq 6 | //import org.usvm.samples.JavaMethodTestRunner 7 | // 8 | //import org.usvm.test.util.checkers.ignoreNumberOfAnalysisResults 9 | //import org.usvm.util.isException 10 | //import org.usvm.test.util.checkers.eq 11 | // 12 | // 13 | //internal class EnumWithoutAnnotationsTest : JavaMethodTestRunner() { 14 | // @Test 15 | // fun testGetterWithoutAnnotations() { 16 | // checkExecutionMatches( 17 | // EnumWithoutAnnotations::getConstant, 18 | // eq(1), 19 | // { _, r -> r == "Constant_1" }, 20 | // ) 21 | // } 22 | //} -------------------------------------------------------------------------------- /usvm-jvm/src/test/kotlin/org/usvm/samples/arrays/FinalStaticFieldArrayTest.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.arrays 2 | 3 | import org.junit.jupiter.api.Test 4 | import org.usvm.samples.JavaMethodTestRunner 5 | import org.usvm.test.util.checkers.ignoreNumberOfAnalysisResults 6 | 7 | 8 | internal class FinalStaticFieldArrayTest : JavaMethodTestRunner() { 9 | @Test 10 | fun testFactorial() { 11 | checkDiscoveredProperties( 12 | FinalStaticFieldArray::factorial, 13 | ignoreNumberOfAnalysisResults, 14 | { n, r -> n >= 0 && n < FinalStaticFieldArray.MAX_FACTORIAL && r == FinalStaticFieldArray.factorial(n) }, 15 | { n, _ -> n < 0 }, 16 | { n, r -> n > FinalStaticFieldArray.MAX_FACTORIAL && r == FinalStaticFieldArray.factorial(n) }, 17 | ) 18 | } 19 | } -------------------------------------------------------------------------------- /usvm-jvm/src/test/kotlin/org/usvm/samples/casts/CastClassTest.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.casts 2 | 3 | 4 | import org.junit.jupiter.api.Test 5 | import org.usvm.samples.JavaMethodTestRunner 6 | import org.usvm.test.util.checkers.eq 7 | 8 | 9 | internal class CastClassTest : JavaMethodTestRunner() { 10 | @Test 11 | fun testThisTypeChoice() { 12 | checkDiscoveredProperties( 13 | CastClass::castToInheritor, 14 | eq(0), 15 | ) 16 | } 17 | } -------------------------------------------------------------------------------- /usvm-jvm/src/test/kotlin/org/usvm/samples/codegen/JavaAssertTest.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.codegen 2 | 3 | import org.junit.jupiter.api.Test 4 | import org.usvm.samples.JavaMethodTestRunner 5 | import org.usvm.test.util.checkers.eq 6 | import org.usvm.util.isException 7 | 8 | class JavaAssertTest : JavaMethodTestRunner() { 9 | @Test 10 | //TODO! Decide if -ea (assertions) flag should be enabled (now it's enabled) 11 | fun testAssertPositive() { 12 | checkDiscoveredPropertiesWithExceptions( 13 | JavaAssert::assertPositive, 14 | eq(2), 15 | { _, value, result -> value > 0 && result.isSuccess && result.getOrNull() == value }, 16 | { _, value, result -> value <= 0 && result.isException() } 17 | ) 18 | } 19 | } -------------------------------------------------------------------------------- /usvm-jvm/src/test/kotlin/org/usvm/samples/codegen/deepequals/ClassWithCrossReferenceRelationshipTest.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.codegen.deepequals 2 | 3 | import org.junit.jupiter.api.Test 4 | import org.usvm.samples.JavaMethodTestRunner 5 | import org.usvm.test.util.checkers.eq 6 | 7 | import org.usvm.test.util.checkers.eq 8 | 9 | 10 | class ClassWithCrossReferenceRelationshipTest : JavaMethodTestRunner() { 11 | @Test 12 | fun testClassWithCrossReferenceRelationship() { 13 | checkDiscoveredProperties( 14 | ClassWithCrossReferenceRelationship::returnFirstClass, 15 | eq(2), 16 | ) 17 | } 18 | } -------------------------------------------------------------------------------- /usvm-jvm/src/test/kotlin/org/usvm/samples/collections/ListsPart1Test.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.collections 2 | 3 | import org.junit.jupiter.api.Disabled 4 | import org.junit.jupiter.api.Test 5 | import org.usvm.samples.JavaMethodTestRunner 6 | import org.usvm.test.util.checkers.ignoreNumberOfAnalysisResults 7 | 8 | 9 | @Disabled("Unsupported") 10 | internal class ListsPart1Test : JavaMethodTestRunner() { 11 | @Test 12 | fun testIterableContains() { 13 | checkDiscoveredProperties( 14 | Lists::iterableContains, 15 | ignoreNumberOfAnalysisResults, 16 | { _, iterable, _ -> iterable == null }, 17 | { _, iterable, r -> 1 in iterable && r != null && r }, 18 | { _, iterable, r -> 1 !in iterable && r != null && !r }, 19 | ) 20 | } 21 | } -------------------------------------------------------------------------------- /usvm-jvm/src/test/kotlin/org/usvm/samples/collections/ListsPart2Test.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.collections 2 | 3 | import org.junit.jupiter.api.Disabled 4 | import org.junit.jupiter.api.Test 5 | import org.usvm.samples.JavaMethodTestRunner 6 | import org.usvm.test.util.checkers.ignoreNumberOfAnalysisResults 7 | 8 | 9 | @Disabled("Unsupported") 10 | internal class ListsPart2Test : JavaMethodTestRunner() { 11 | @Test 12 | fun testCollectionContains() { 13 | checkDiscoveredProperties( 14 | Lists::collectionContains, 15 | ignoreNumberOfAnalysisResults, 16 | { _, collection, _ -> collection == null }, 17 | { _, collection, r -> 1 in collection && r != null && r }, 18 | { _, collection, r -> 1 !in collection && r != null && !r }, 19 | ) 20 | } 21 | } -------------------------------------------------------------------------------- /usvm-jvm/src/test/kotlin/org/usvm/samples/functions/TestThrowing.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.functions 2 | 3 | import org.junit.jupiter.api.Test 4 | import org.usvm.samples.JavaMethodTestRunner 5 | import org.usvm.test.util.checkers.ignoreNumberOfAnalysisResults 6 | 7 | class TestThrowing : JavaMethodTestRunner() { 8 | @Test 9 | fun `Test throwSometimes`() { 10 | checkDiscoveredPropertiesWithExceptions( 11 | Throwing::throwSometimes, 12 | ignoreNumberOfAnalysisResults, 13 | { _, x, r -> x == 1 && r.isFailure && r.exceptionOrNull() is IllegalArgumentException }, 14 | { _, x, r -> x != 1 && r.isSuccess }, 15 | ) 16 | } 17 | 18 | } -------------------------------------------------------------------------------- /usvm-jvm/src/test/kotlin/org/usvm/samples/invokes/ObjectExampleTest.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.invokes 2 | 3 | import org.junit.jupiter.api.Test 4 | import org.usvm.samples.JavaMethodTestRunner 5 | import org.usvm.test.util.checkers.ge 6 | 7 | internal class ObjectExampleTest : JavaMethodTestRunner() { 8 | @Test 9 | fun testObjectToStringVirtualInvoke() { 10 | checkDiscoveredProperties( 11 | ObjectExample::objectToStringVirtualInvokeExample, 12 | ge(2), 13 | { _, x, r -> x == null && r == null }, 14 | { _, x, _ -> x != null }, 15 | ) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /usvm-jvm/src/test/kotlin/org/usvm/samples/lambda/PredicateNotExampleTest.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.lambda 2 | 3 | import org.junit.jupiter.api.Disabled 4 | import org.junit.jupiter.api.Test 5 | import org.usvm.samples.JavaMethodTestRunner 6 | import org.usvm.test.util.checkers.eq 7 | 8 | 9 | class PredicateNotExampleTest : JavaMethodTestRunner() { 10 | @Test 11 | @Disabled("class org.jacodb.api.PredefinedPrimitive cannot be cast to class org.jacodb.api.JcRefType") 12 | fun testPredicateNotExample() { 13 | checkDiscoveredProperties( 14 | PredicateNotExample::predicateNotExample, 15 | eq(2), 16 | { _, a, r -> a == 5 && r == false }, 17 | { _, a, r -> a != 5 && r == true }, 18 | ) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /usvm-jvm/src/test/kotlin/org/usvm/samples/mixed/MonitorUsageTest.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.mixed 2 | 3 | import org.junit.jupiter.api.Test 4 | import org.usvm.samples.JavaMethodTestRunner 5 | import org.usvm.test.util.checkers.ignoreNumberOfAnalysisResults 6 | 7 | 8 | internal class MonitorUsageTest : JavaMethodTestRunner() { 9 | @Test 10 | fun testSimpleMonitor() { 11 | checkDiscoveredProperties( 12 | MonitorUsage::simpleMonitor, 13 | ignoreNumberOfAnalysisResults, 14 | { _, x, r -> x <= 0 && r == 0 }, 15 | { _, x, r -> x > 0 && x <= Int.MAX_VALUE - 1 && r == 1 }, 16 | ) 17 | } 18 | } -------------------------------------------------------------------------------- /usvm-jvm/src/test/kotlin/org/usvm/samples/mixed/SerializableExampleTest.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.mixed 2 | 3 | import org.junit.jupiter.api.Disabled 4 | import org.junit.jupiter.api.Test 5 | import org.usvm.samples.JavaMethodTestRunner 6 | import org.usvm.test.util.checkers.eq 7 | 8 | internal class SerializableExampleTest : JavaMethodTestRunner() { 9 | @Test 10 | @Disabled("Only 1 execution - NPE") 11 | fun testExample() { 12 | checkDiscoveredPropertiesWithExceptions( 13 | SerializableExample::example, 14 | eq(1), 15 | { _, r -> r.isSuccess } 16 | ) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /usvm-jvm/src/test/kotlin/org/usvm/samples/mixed/SimplifierTest.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.mixed 2 | 3 | import org.junit.jupiter.api.Test 4 | import org.usvm.samples.JavaMethodTestRunner 5 | import org.usvm.test.util.checkers.eq 6 | 7 | 8 | internal class SimplifierTest: JavaMethodTestRunner() { 9 | @Test 10 | fun testSimplifyAdditionWithZero() { 11 | checkDiscoveredProperties( 12 | Simplifier::simplifyAdditionWithZero, 13 | eq(1), 14 | { _, fst, r -> r != null && r.x == fst.shortValue.toInt() }, 15 | ) 16 | } 17 | } -------------------------------------------------------------------------------- /usvm-jvm/src/test/kotlin/org/usvm/samples/objects/ClassWithClassRefTest.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.objects 2 | 3 | import org.usvm.samples.JavaMethodTestRunner 4 | 5 | internal class ClassWithClassRefTest : JavaMethodTestRunner() { 6 | 7 | // TODO unsupported 8 | // @Test 9 | // fun testClassRefGetName() { 10 | // checkWithThisAndException( 11 | // ClassWithClassRef::classRefName, 12 | // eq(2), 13 | // { _, instance, r -> instance.someListClass == null && r.isException() }, 14 | // { _, instance, r -> instance.someListClass != null && r.getOrNull() == "" }, // TODO: Method coverage with `this` parameter isn't supported 15 | // ) 16 | // } 17 | } -------------------------------------------------------------------------------- /usvm-jvm/src/test/kotlin/org/usvm/samples/objects/HiddenFieldAccessModifiersTest.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.objects 2 | 3 | import org.junit.jupiter.api.Disabled 4 | import org.junit.jupiter.api.Test 5 | import org.usvm.samples.JavaMethodTestRunner 6 | import org.usvm.test.util.checkers.ignoreNumberOfAnalysisResults 7 | 8 | 9 | internal class HiddenFieldAccessModifiersTest : JavaMethodTestRunner() { 10 | @Test 11 | fun testCheckSuperFieldEqualsOne() { 12 | checkDiscoveredProperties( 13 | HiddenFieldAccessModifiersExample::checkSuperFieldEqualsOne, 14 | ignoreNumberOfAnalysisResults, 15 | { _, o, _ -> o == null }, 16 | { _, _, r -> r != null && r }, 17 | { _, _, r -> r != null && !r }, 18 | ) 19 | } 20 | } -------------------------------------------------------------------------------- /usvm-jvm/src/test/kotlin/org/usvm/samples/objects/LocalClassExampleTest.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.objects 2 | 3 | import org.junit.jupiter.api.Test 4 | import org.usvm.samples.JavaMethodTestRunner 5 | import org.usvm.test.util.checkers.eq 6 | 7 | 8 | class LocalClassExampleTest : JavaMethodTestRunner() { 9 | @Test 10 | fun testLocalClassFieldExample() { 11 | checkDiscoveredProperties( 12 | LocalClassExample::localClassFieldExample, 13 | eq(1), 14 | { _, y, r -> r == y + 42 } 15 | ) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /usvm-jvm/src/test/kotlin/org/usvm/samples/objects/ObjectWithFinalStaticTest.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.objects 2 | 3 | // TODO unsupported 4 | //class ObjectWithFinalStaticTest : JavaMethodTestRunner() { 5 | // @Test 6 | // fun testParameterEqualsFinalStatic() { 7 | // checkStatics( 8 | // ObjectWithFinalStatic::parameterEqualsFinalStatic, 9 | // eq(2), 10 | // { key, _, statics, result -> key != statics.singleValue() as Int && result == -420 }, 11 | // // matcher checks equality by value, but branch is executed if objects are equal by reference 12 | // { key, i, statics, result -> key == statics.singleValue() && i == result }, 13 | // ) 14 | // } 15 | //} -------------------------------------------------------------------------------- /usvm-jvm/src/test/kotlin/org/usvm/samples/objects/ObjectWithThrowableConstructorTest.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.objects 2 | 3 | import org.junit.jupiter.api.Disabled 4 | import org.junit.jupiter.api.Test 5 | import org.usvm.samples.JavaMethodTestRunner 6 | import org.usvm.test.util.checkers.eq 7 | 8 | import kotlin.reflect.KFunction2 9 | 10 | internal class ObjectWithThrowableConstructorTest : JavaMethodTestRunner() { 11 | @Test 12 | @Disabled("Support constructors in matchers") 13 | fun testThrowableConstructor() { 14 | val method: KFunction2 = ::ObjectWithThrowableConstructor 15 | checkDiscoveredProperties( 16 | method, 17 | eq(2), 18 | // TODO: SAT-933 Add support for constructor testing 19 | ) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /usvm-jvm/src/test/kotlin/org/usvm/samples/objects/SimpleClassMultiInstanceExampleTest.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.objects 2 | 3 | import org.junit.jupiter.api.Disabled 4 | import org.junit.jupiter.api.Test 5 | import org.usvm.samples.JavaMethodTestRunner 6 | import org.usvm.test.util.checkers.ignoreNumberOfAnalysisResults 7 | 8 | 9 | internal class SimpleClassMultiInstanceExampleTest : JavaMethodTestRunner() { 10 | @Test 11 | fun singleObjectChangeTest() { 12 | checkDiscoveredProperties( 13 | SimpleClassMultiInstanceExample::singleObjectChange, 14 | ignoreNumberOfAnalysisResults, 15 | { _, first, _, _ -> first == null }, // NPE 16 | { _, first, _, r -> first.a < 5 && r == 3 }, 17 | { _, first, _, r -> first.a >= 5 && r == first.b }, 18 | ) 19 | } 20 | } -------------------------------------------------------------------------------- /usvm-jvm/src/test/kotlin/org/usvm/samples/objects/TestId.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.objects 2 | 3 | import org.junit.jupiter.api.Test 4 | import org.usvm.samples.JavaMethodTestRunner 5 | import org.usvm.test.util.checkers.ignoreNumberOfAnalysisResults 6 | 7 | class TestId : JavaMethodTestRunner() { 8 | @Test 9 | fun `Test isOne`() { 10 | checkDiscoveredProperties( 11 | Id::isOne, 12 | ignoreNumberOfAnalysisResults, 13 | { x, r -> x.isOne && r != null && r }, 14 | { x, r -> !x.isOne && r != null && !r }, 15 | ) 16 | } 17 | } -------------------------------------------------------------------------------- /usvm-jvm/src/test/kotlin/org/usvm/samples/operators/TestLogic.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.operators 2 | 3 | import org.junit.jupiter.api.Test 4 | import org.usvm.samples.JavaMethodTestRunner 5 | import org.usvm.test.util.checkers.ignoreNumberOfAnalysisResults 6 | 7 | class TestLogic : JavaMethodTestRunner() { 8 | @Test 9 | fun `Test complexWithLocals`() { 10 | checkDiscoveredProperties( 11 | Logic::complexWithLocals, 12 | ignoreNumberOfAnalysisResults, 13 | { _, x, y, z, r -> r != null && r && (x.toLong() or y.toLong() or z) != 1337.toLong() }, 14 | { _, x, y, z, r -> r != null && !r && (x.toLong() or y.toLong() or z) == 1337.toLong() }, 15 | ) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /usvm-jvm/src/test/kotlin/org/usvm/samples/operators/TestOverflow.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.operators 2 | 3 | import org.junit.jupiter.api.Disabled 4 | import org.junit.jupiter.api.Test 5 | import org.usvm.samples.JavaMethodTestRunner 6 | import org.usvm.test.util.checkers.ignoreNumberOfAnalysisResults 7 | 8 | class TestOverflow : JavaMethodTestRunner() { 9 | @Test 10 | fun `Test shortOverflow`() { 11 | checkDiscoveredPropertiesWithExceptions( 12 | Overflow::shortOverflow, 13 | ignoreNumberOfAnalysisResults, 14 | { _, _, _, r -> 15 | require(r.isSuccess) 16 | true 17 | } 18 | ) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /usvm-jvm/src/test/kotlin/org/usvm/samples/primitives/FloatExamplesTest.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.primitives 2 | 3 | import org.junit.jupiter.api.Test 4 | import org.usvm.samples.JavaMethodTestRunner 5 | import org.usvm.test.util.checkers.eq 6 | 7 | 8 | internal class FloatExamplesTest : JavaMethodTestRunner() { 9 | @Test 10 | fun testFloatInfinity() { 11 | checkDiscoveredProperties( 12 | FloatExamples::floatInfinity, 13 | eq(3), 14 | { _, f, r -> f == Float.POSITIVE_INFINITY && r == 1 }, 15 | { _, f, r -> f == Float.NEGATIVE_INFINITY && r == 2 }, 16 | { _, f, r -> !f.isInfinite() && r == 3 }, 17 | ) 18 | } 19 | } -------------------------------------------------------------------------------- /usvm-jvm/src/test/kotlin/org/usvm/samples/reflection/NewInstanceExampleTest.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.reflection 2 | 3 | import org.junit.jupiter.api.Disabled 4 | import org.junit.jupiter.api.Test 5 | import org.usvm.samples.JavaMethodTestRunner 6 | import org.usvm.test.util.checkers.eq 7 | 8 | 9 | class NewInstanceExampleTest : JavaMethodTestRunner() { 10 | @Test 11 | @Disabled("Not implemented: string constant") 12 | fun testNewInstanceExample() { 13 | checkDiscoveredProperties( 14 | NewInstanceExample::createWithReflectionExample, 15 | eq(1), 16 | { _, r -> r == 0 } 17 | ) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /usvm-jvm/src/test/kotlin/org/usvm/samples/statics/StaticsTypesTest.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.statics 2 | 3 | import org.junit.jupiter.api.Test 4 | import org.usvm.samples.JavaMethodTestRunner 5 | import org.usvm.test.util.checkers.ignoreNumberOfAnalysisResults 6 | 7 | class StaticsTypesTest : JavaMethodTestRunner() { 8 | @Test 9 | fun test() { 10 | checkDiscoveredPropertiesWithExceptions( 11 | StaticsTypesExample::virtualInvokeOnInputFieldArrayReading, 12 | ignoreNumberOfAnalysisResults, 13 | { _, _, _, r -> r.isSuccess }, 14 | ) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /usvm-jvm/src/test/kotlin/org/usvm/samples/types/GenericWithUpperBoundTest.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.types 2 | 3 | import org.junit.jupiter.api.Disabled 4 | import org.usvm.samples.JavaMethodTestRunner 5 | import org.usvm.test.util.checkers.eq 6 | import kotlin.test.Test 7 | 8 | internal class GenericWithUpperBoundTest : JavaMethodTestRunner() { 9 | @Test 10 | @Disabled("We do not support generics, so we may generate `GenericWithUpperBound` here that leads to fail") 11 | fun testExcludeComparable() { 12 | checkDiscoveredProperties( 13 | GenericWithUpperBound::excludeComparable, 14 | eq(2), 15 | { _, value, r -> value == null && r == 0 }, 16 | { _, value, r -> value != null && r == 1 }, 17 | ) 18 | } 19 | } -------------------------------------------------------------------------------- /usvm-jvm/src/test/kotlin/org/usvm/samples/unsafe/UnsafeWithFieldTest.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.samples.unsafe 2 | 3 | import org.junit.jupiter.api.Disabled 4 | import org.junit.jupiter.api.Test 5 | import org.usvm.samples.JavaMethodTestRunner 6 | import org.usvm.test.util.checkers.eq 7 | 8 | 9 | internal class UnsafeWithFieldTest : JavaMethodTestRunner() { 10 | 11 | @Test 12 | @Disabled("Complex logic with class instances") 13 | fun checkSetField() { 14 | checkDiscoveredProperties( 15 | UnsafeWithField::setField, 16 | eq(1) 17 | ) 18 | } 19 | } -------------------------------------------------------------------------------- /usvm-jvm/src/test/kotlin/org/usvm/util/TestResolvingOptions.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.util 2 | 3 | enum class JcTestResolverType { 4 | /** 5 | * Uses reflection to resolve objects. 6 | */ 7 | INTERPRETER, 8 | /** 9 | * Uses concrete execution to resolve objects. 10 | */ 11 | CONCRETE_EXECUTOR 12 | } -------------------------------------------------------------------------------- /usvm-jvm/src/test/resources/burningwave.static.properties: -------------------------------------------------------------------------------- 1 | banner.hide=true 2 | managed-logger.repository.enabled=false -------------------------------------------------------------------------------- /usvm-jvm/src/test/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | %d{HH:mm:ss.SSS} |%.-1level| %replace(%c{0}){'(\$Companion)?\$logger\$1',''} - %msg%n 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /usvm-jvm/src/usvm-api/java/org/usvm/api/SymbolicIdentityMap.java: -------------------------------------------------------------------------------- 1 | package org.usvm.api; 2 | 3 | public interface SymbolicIdentityMap { 4 | int size(); 5 | 6 | V get(K key); 7 | 8 | K anyKey(); 9 | 10 | void set(K key, V value); 11 | 12 | void remove(K key); 13 | 14 | boolean containsKey(K key); 15 | 16 | void merge(SymbolicIdentityMap src); 17 | } 18 | -------------------------------------------------------------------------------- /usvm-jvm/src/usvm-api/java/org/usvm/api/SymbolicList.java: -------------------------------------------------------------------------------- 1 | package org.usvm.api; 2 | 3 | public interface SymbolicList { 4 | int size(); 5 | 6 | E get(int idx); 7 | 8 | void set(int idx, E obj); 9 | 10 | void insert(int idx, E obj); 11 | 12 | void remove(int idx); 13 | 14 | void copy(SymbolicList dst, int srcFrom, int dstFrom, int length); 15 | } 16 | -------------------------------------------------------------------------------- /usvm-jvm/src/usvm-api/java/org/usvm/api/SymbolicMap.java: -------------------------------------------------------------------------------- 1 | package org.usvm.api; 2 | 3 | public interface SymbolicMap { 4 | int size(); 5 | 6 | V get(K key); 7 | 8 | K anyKey(); 9 | 10 | void set(K key, V value); 11 | 12 | void remove(K key); 13 | 14 | boolean containsKey(K key); 15 | 16 | void merge(SymbolicMap src); 17 | } 18 | -------------------------------------------------------------------------------- /usvm-jvm/src/usvm-api/java/org/usvm/api/decoder/DecoderFor.java: -------------------------------------------------------------------------------- 1 | package org.usvm.api.decoder; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Target; 5 | 6 | @Target({ElementType.TYPE}) 7 | public @interface DecoderFor { 8 | Class value(); 9 | } 10 | -------------------------------------------------------------------------------- /usvm-jvm/src/usvm-api/java/org/usvm/api/decoder/ObjectDecoder.java: -------------------------------------------------------------------------------- 1 | package org.usvm.api.decoder; 2 | 3 | import org.jacodb.api.jvm.JcClassOrInterface; 4 | 5 | public interface ObjectDecoder { 6 | T createInstance( 7 | final JcClassOrInterface type, 8 | final ObjectData objectData, 9 | final DecoderApi decoder 10 | ); 11 | 12 | void initializeInstance( 13 | final JcClassOrInterface type, 14 | final ObjectData objectData, 15 | final T instance, 16 | final DecoderApi decoder 17 | ); 18 | } 19 | -------------------------------------------------------------------------------- /usvm-jvm/src/usvm-api/java/org/usvm/api/encoder/EncoderFor.java: -------------------------------------------------------------------------------- 1 | package org.usvm.api.encoder; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Target; 5 | 6 | @Target({ElementType.TYPE}) 7 | public @interface EncoderFor { 8 | Class value(); 9 | } 10 | -------------------------------------------------------------------------------- /usvm-jvm/src/usvm-api/java/org/usvm/api/encoder/ObjectEncoder.java: -------------------------------------------------------------------------------- 1 | package org.usvm.api.encoder; 2 | 3 | public interface ObjectEncoder { 4 | Object encode(Object object); 5 | } 6 | -------------------------------------------------------------------------------- /usvm-python/buildDistWithoutPip.sh: -------------------------------------------------------------------------------- 1 | ../gradlew -PcpythonActivated=true :usvm-python:cpythonadapter:CPythonClean &&\ 2 | ../gradlew -PcpythonActivated=true :usvm-python:cpythonadapter:CPythonDistclean &&\ 3 | ../gradlew -PcpythonActivated=true :usvm-python:cpythonadapter:clean &&\ 4 | ../gradlew -PcpythonActivated=true :usvm-python:clean &&\ 5 | echo "false" > cpythonadapter/include_pip_in_build &&\ 6 | ../gradlew -PcpythonActivated=true :usvm-python:cpythonadapter:linkDebug &&\ 7 | ../gradlew -PcpythonActivated=true :usvm-util:jar &&\ 8 | ../gradlew -PcpythonActivated=true :usvm-core:jar &&\ 9 | ../gradlew -PcpythonActivated=true :usvm-python:jar &&\ 10 | ../gradlew -PcpythonActivated=true :usvm-python:distZip &&\ 11 | echo "true" > cpythonadapter/include_pip_in_build -------------------------------------------------------------------------------- /usvm-python/cpythonadapter/cpython_check/.gitignore: -------------------------------------------------------------------------------- 1 | check -------------------------------------------------------------------------------- /usvm-python/cpythonadapter/cpython_check/run_check.sh: -------------------------------------------------------------------------------- 1 | export LD_LIBRARY_PATH=../build/cpython_build/lib 2 | ./check 3 | -------------------------------------------------------------------------------- /usvm-python/cpythonadapter/include_pip_in_build: -------------------------------------------------------------------------------- 1 | true 2 | -------------------------------------------------------------------------------- /usvm-python/cpythonadapter/src/main/c/descriptors.c: -------------------------------------------------------------------------------- 1 | #include "descriptors.h" 2 | #include "approximation_defs.h" 3 | #include "classnames.h" 4 | 5 | #include "MethodDescriptors.h" // generated 6 | #include "MemberDescriptors.h" // generated 7 | 8 | jobject 9 | get_symbolic_descriptor(JNIEnv *env, jobject cpython_adapter, PyObject *concrete_descriptor) { 10 | jclass cpython_adapter_cls = (*env)->GetObjectClass(env, cpython_adapter); 11 | 12 | if (PyFunction_Check(concrete_descriptor)) { 13 | jfieldID field_id = (*env)->GetFieldID(env, cpython_adapter_cls, "pythonMethodDescriptor", member_descriptor_sig); 14 | return (*env)->GetObjectField(env, cpython_adapter, field_id); 15 | } 16 | 17 | METHOD_DESCRIPTORS 18 | MEMBER_DESCRIPTORS 19 | return 0; 20 | } -------------------------------------------------------------------------------- /usvm-python/cpythonadapter/src/main/c/include/classnames.h: -------------------------------------------------------------------------------- 1 | #define symbol_for_cpython_cls "org/usvm/machine/interpreters/concrete/utils/SymbolForCPython" 2 | #define symbol_for_cpython_cls_sig "Lorg/usvm/machine/interpreters/concrete/utils/SymbolForCPython;" 3 | #define virtual_object_cls "org/usvm/machine/interpreters/concrete/utils/VirtualPythonObject" 4 | #define named_symbol_for_cpython_cls "org/usvm/machine/interpreters/concrete/utils/NamedSymbolForCPython" 5 | #define member_descriptor_sig "Lorg/usvm/machine/interpreters/symbolic/operations/descriptors/MemberDescriptor;" 6 | -------------------------------------------------------------------------------- /usvm-python/cpythonadapter/src/main/c/include/descriptors.h: -------------------------------------------------------------------------------- 1 | #ifndef _Included_CPythonAdapter_descriptors 2 | #define _Included_CPythonAdapter_descriptors 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | #include 8 | #include "Python.h" 9 | #include "utils.h" 10 | 11 | jobject get_symbolic_descriptor(JNIEnv *env, jobject cpython_adapter, PyObject *concrete_descriptor); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | #endif -------------------------------------------------------------------------------- /usvm-python/docs/structure.md: -------------------------------------------------------------------------------- 1 | # Communication between CPython and USVM 2 | 3 |

4 | usvm_python_scheme 5 |

6 | 7 | ## API that is provided by patched CPython 8 | 9 | See [API.md](./API.md). 10 | -------------------------------------------------------------------------------- /usvm-python/docs/usvm_python_scheme.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UnitTestBot/usvm/f7bb9d710003dd8aff7befa83e7e47c0a8239387/usvm-python/docs/usvm_python_scheme.png -------------------------------------------------------------------------------- /usvm-python/python_approximations/approximations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UnitTestBot/usvm/f7bb9d710003dd8aff7befa83e7e47c0a8239387/usvm-python/python_approximations/approximations/__init__.py -------------------------------------------------------------------------------- /usvm-python/python_approximations/approximations/api.py: -------------------------------------------------------------------------------- 1 | from abc import ABC, abstractmethod 2 | from typing import Any, Callable 3 | 4 | 5 | class ApproximationForMethod(ABC): 6 | @staticmethod 7 | @abstractmethod 8 | def accept(self, *args) -> bool: # TODO: support kwargs 9 | ... 10 | 11 | @staticmethod 12 | @abstractmethod 13 | def run(self, *args) -> Any: # TODO: support kwargs 14 | ... 15 | 16 | 17 | class ApproximationForFunction(ABC): 18 | @staticmethod 19 | @abstractmethod 20 | def accept(*args) -> bool: # TODO: support kwargs 21 | ... 22 | 23 | @staticmethod 24 | @abstractmethod 25 | def run(*args) -> Any: # TODO: support kwargs 26 | ... 27 | 28 | 29 | class SpecialApproximation(ABC): 30 | run: Callable -------------------------------------------------------------------------------- /usvm-python/python_approximations/approximations/implementations/__init__.py: -------------------------------------------------------------------------------- 1 | from approximations.api import SpecialApproximation 2 | 3 | 4 | class ContainsOpApproximation(SpecialApproximation): 5 | @staticmethod 6 | def run(storage, item) -> bool: 7 | for elem in storage: 8 | if elem == item: 9 | return True 10 | return False -------------------------------------------------------------------------------- /usvm-python/python_approximations/approximations/implementations/set.py: -------------------------------------------------------------------------------- 1 | from approximations.api import * 2 | 3 | 4 | class ConstructorApproximation(ApproximationForFunction): 5 | @staticmethod 6 | def accept(*args) -> bool: 7 | return len(args) == 1 8 | 9 | @staticmethod 10 | def run(*args) -> set: 11 | result = set() 12 | x = args[0] 13 | for elem in x: 14 | result.add(elem) 15 | return result -------------------------------------------------------------------------------- /usvm-python/run_cpython.sh: -------------------------------------------------------------------------------- 1 | export LD_LIBRARY_PATH=./cpythonadapter/build/cpython_build/lib 2 | export PYTHONHOME=./cpythonadapter/build/cpython_build 3 | ./cpythonadapter/build/cpython_build/bin/python3 -s 4 | -------------------------------------------------------------------------------- /usvm-python/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | %d{HH:mm:ss.SSS} |%.-1level| %replace(%c{0}){'(\$Companion)?\$logger\$1',''} - %msg%n 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /usvm-python/src/test/kotlin/org/usvm/runner/SamplesBuild.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.runner 2 | 3 | import org.usvm.language.StructuredPyProgram 4 | import org.utpython.types.mypy.MypyBuildDirectory 5 | import org.utpython.types.mypy.readMypyInfoBuild 6 | import java.io.File 7 | 8 | object SamplesBuild { 9 | private val mypyBuildRoot = System.getProperty("samples.build.path")!! 10 | private val sourcesRoot = System.getProperty("samples.sources.path")!! 11 | private val mypyDirectory = MypyBuildDirectory(File(mypyBuildRoot), setOf(sourcesRoot)) 12 | val mypyBuild = readMypyInfoBuild(mypyDirectory) 13 | val program = StructuredPyProgram(setOf(File(sourcesRoot))) 14 | } 15 | -------------------------------------------------------------------------------- /usvm-python/src/test/kotlin/org/usvm/runner/manual/analyzers/ProgramAnalyzer.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.runner.manual.analyzers 2 | 3 | import org.usvm.runner.manual.program.ProgramProvider 4 | 5 | interface ProgramAnalyzer { 6 | fun run(provider: ProgramProvider) 7 | } 8 | -------------------------------------------------------------------------------- /usvm-python/src/test/kotlin/org/usvm/runner/manual/program/PrimitivePrograms.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.runner.manual.program 2 | 3 | import org.usvm.machine.types.PythonAnyType 4 | 5 | /** 6 | * Use this declaration for simple manual checks. 7 | * */ 8 | val sampleStringFunction = StringProgramProvider( 9 | """ 10 | def f(x): 11 | assert x != [1, 2, 3] 12 | """.trimIndent(), 13 | "f" 14 | ) { typeSystem -> listOf(typeSystem.pythonList) } 15 | 16 | /** 17 | * Sample of a function that cannot be covered right now. 18 | * */ 19 | val tupleConcatProgram = StringProgramProvider( 20 | """ 21 | def tuple_concat(x, y): 22 | z = x + y 23 | return z + (1, 2, 3) 24 | """.trimIndent(), 25 | "tuple_concat", 26 | ) { listOf(PythonAnyType, PythonAnyType) } 27 | -------------------------------------------------------------------------------- /usvm-python/src/test/kotlin/org/usvm/runner/manual/program/ProgramProvider.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.runner.manual.program 2 | 3 | import org.usvm.language.PyProgram 4 | import org.usvm.language.PyUnpinnedCallable 5 | import org.usvm.machine.types.PythonTypeSystem 6 | 7 | interface ProgramProvider { 8 | val program: PyProgram 9 | val typeSystem: PythonTypeSystem 10 | val functions: List 11 | } 12 | -------------------------------------------------------------------------------- /usvm-python/src/test/kotlin/org/usvm/runner/manual/program/SampleProgram.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.runner.manual.program 2 | 3 | import org.usvm.machine.types.PythonAnyType 4 | 5 | /** 6 | * Use this for manual tests of samples. 7 | * */ 8 | val sampleFunction = SampleProgramProvider( 9 | "SimpleTypeInference", 10 | "use_str_eq", 11 | ) { listOf(PythonAnyType) } 12 | -------------------------------------------------------------------------------- /usvm-python/src/test/kotlin/org/usvm/utils/PathUtils.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.utils 2 | 3 | import java.io.File 4 | import java.nio.file.Files 5 | import java.nio.file.Paths 6 | import kotlin.streams.asSequence 7 | 8 | fun getPythonFilesFromRoot(path: String): List { 9 | return Files.find( 10 | Paths.get(path), 11 | Integer.MAX_VALUE, 12 | { _, fileAttr -> fileAttr.isRegularFile } 13 | ).map { it.toFile() }.filter { it.name.endsWith(".py") }.asSequence().toList() 14 | } 15 | 16 | fun getModulesFromFiles(root: String, files: List): List { 17 | return files.map { 18 | File(root).toURI().relativize(it.toURI()).path 19 | .removeSuffix(".py") 20 | .replace("/", ".") 21 | .replace("\\", ",") 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /usvm-python/src/test/resources/samples/BadProgram.py: -------------------------------------------------------------------------------- 1 | name = input("Enter your name >> ") -------------------------------------------------------------------------------- /usvm-python/src/test/resources/samples/Enumerate.py: -------------------------------------------------------------------------------- 1 | def use_enumerate(x): 2 | sum_ = 0 3 | for i, a in enumerate(x): 4 | sum_ += i + a 5 | assert sum_ == 239 -------------------------------------------------------------------------------- /usvm-python/src/test/resources/samples/Generators.py: -------------------------------------------------------------------------------- 1 | def simple_generator(x: int): 2 | if x == 1: 3 | yield "one" 4 | elif x == 2: 5 | yield "two" 6 | else: 7 | yield "other" 8 | 9 | 10 | def generator_usage(x: int): 11 | for elem in simple_generator(x): 12 | return elem -------------------------------------------------------------------------------- /usvm-python/src/test/resources/samples/PathDiversionExample.py: -------------------------------------------------------------------------------- 1 | # we probably won't approximate pickle, so this is used for testing path diversion detection 2 | import pickle 3 | 4 | 5 | def pickle_path_diversion(x: int): 6 | y = pickle.loads(pickle.dumps(x)) # y is equal to x 7 | if y >= 0: 8 | if x >= 0: 9 | return 1 10 | return 2 # unreachable 11 | else: 12 | if x >= 0: 13 | return 3 # unreachable 14 | return 4 15 | -------------------------------------------------------------------------------- /usvm-python/src/test/resources/samples/Sets.py: -------------------------------------------------------------------------------- 1 | def expect_set(x): 2 | assert isinstance(x, set) 3 | 4 | 5 | def use_constructor_with_arg(x): 6 | set(x) 7 | 8 | 9 | def input_set_int_check(s: set): 10 | assert 1 in s 11 | 12 | 13 | def input_set_str_check(s: set): 14 | assert "aaa" in s 15 | 16 | 17 | def input_set_virtual_check(s: set, x): 18 | assert x in s 19 | 20 | 21 | def construct_set_with_call(x: int): 22 | s = set([1, 2, 3]) 23 | assert x in s 24 | 25 | 26 | def add_str_to_set(x): 27 | s = set() 28 | s.add("bbb") 29 | assert x in s 30 | 31 | # TODO: from frosetset 32 | def construct_set_with_syntax(x, y): 33 | s = {y} 34 | assert x in s 35 | 36 | 37 | def empty_check(s: set): 38 | assert s -------------------------------------------------------------------------------- /usvm-python/src/test/resources/samples/sample_submodule/SimpleUsageOfModules.py: -------------------------------------------------------------------------------- 1 | import sample_submodule.structures as structures 2 | 3 | 4 | def construct_class_instance(x: int): 5 | if x < 0: 6 | x = -x 7 | return structures.SimpleClass(x) 8 | 9 | 10 | def inner_import(x: int): 11 | import sample_submodule.sample_functions as module 12 | return module.my_abs(x) 13 | 14 | 15 | def simple_class_isinstance(x): 16 | if isinstance(x, structures.SimpleClass): 17 | return 1 18 | elif isinstance(x, int): 19 | assert x > 100 20 | return 2 21 | return 3 22 | -------------------------------------------------------------------------------- /usvm-python/src/test/resources/samples/sample_submodule/sample_functions.py: -------------------------------------------------------------------------------- 1 | def my_abs(x): 2 | if x >= 0: 3 | return x 4 | else: 5 | return -x -------------------------------------------------------------------------------- /usvm-python/src/test/resources/samples/sample_submodule/structures.py: -------------------------------------------------------------------------------- 1 | class SimpleClass: 2 | def __init__(self, x): 3 | self.x = x 4 | -------------------------------------------------------------------------------- /usvm-python/src/test/resources/samples/tricky/UnsafeCode.py: -------------------------------------------------------------------------------- 1 | class RawCommand: 2 | def __init__(self, cmd): 3 | self.cmd = cmd 4 | 5 | def run(self, globals_, locals_): 6 | assert globals_ is not None 7 | assert locals_ is not None 8 | eval(self.cmd, globals_, locals_) 9 | 10 | 11 | def run(commands, globals_, locals_): 12 | for cmd in commands: 13 | cmd.run(globals_, locals_) -------------------------------------------------------------------------------- /usvm-python/usvm-python-annotations/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("usvm.kotlin-conventions") 3 | } -------------------------------------------------------------------------------- /usvm-python/usvm-python-annotations/src/main/java/org/usvm/annotations/CPythonAdapterJavaMethod.java: -------------------------------------------------------------------------------- 1 | package org.usvm.annotations; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target(ElementType.METHOD) 9 | @Retention(RetentionPolicy.SOURCE) 10 | public @interface CPythonAdapterJavaMethod { 11 | String cName(); 12 | } 13 | -------------------------------------------------------------------------------- /usvm-python/usvm-python-annotations/src/main/java/org/usvm/annotations/CPythonFunction.java: -------------------------------------------------------------------------------- 1 | package org.usvm.annotations; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target(ElementType.METHOD) 9 | @Retention(RetentionPolicy.SOURCE) 10 | public @interface CPythonFunction { 11 | CType[] argCTypes(); 12 | ObjectConverter[] argConverters(); 13 | boolean addToSymbolicAdapter() default true; 14 | } 15 | -------------------------------------------------------------------------------- /usvm-python/usvm-python-annotations/src/main/java/org/usvm/annotations/SymbolicMemberDescriptor.java: -------------------------------------------------------------------------------- 1 | package org.usvm.annotations; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target(ElementType.FIELD) 9 | @Retention(RetentionPolicy.SOURCE) 10 | public @interface SymbolicMemberDescriptor { 11 | String nativeTypeName(); 12 | String nativeMemberName(); 13 | } 14 | -------------------------------------------------------------------------------- /usvm-python/usvm-python-annotations/src/main/java/org/usvm/annotations/SymbolicMethod.java: -------------------------------------------------------------------------------- 1 | package org.usvm.annotations; 2 | 3 | import org.usvm.annotations.ids.SymbolicMethodId; 4 | 5 | import java.lang.annotation.ElementType; 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.RetentionPolicy; 8 | import java.lang.annotation.Target; 9 | 10 | @Target(ElementType.METHOD) 11 | @Retention(RetentionPolicy.SOURCE) 12 | public @interface SymbolicMethod { 13 | SymbolicMethodId id(); 14 | } 15 | -------------------------------------------------------------------------------- /usvm-python/usvm-python-annotations/src/main/java/org/usvm/annotations/SymbolicMethodDescriptor.java: -------------------------------------------------------------------------------- 1 | package org.usvm.annotations; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target(ElementType.FIELD) 9 | @Retention(RetentionPolicy.SOURCE) 10 | public @interface SymbolicMethodDescriptor { 11 | String nativeTypeName(); 12 | String nativeMemberName(); 13 | } 14 | -------------------------------------------------------------------------------- /usvm-python/usvm-python-annotations/src/main/kotlin/org/usvm/annotations/Utils.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.annotations 2 | 3 | import java.io.File 4 | import javax.annotation.processing.ProcessingEnvironment 5 | import javax.lang.model.element.VariableElement 6 | import javax.lang.model.type.TypeMirror 7 | 8 | fun getHeaderPath(processingEnv: ProcessingEnvironment): File { 9 | val headerPath = processingEnv.options["headerPath"] ?: error("Header path not specified") 10 | val result = File(headerPath) 11 | result.mkdirs() 12 | return result 13 | } 14 | 15 | fun TypeMirror.getTypeName(): String = 16 | toString().split('.').last().split(' ').last() 17 | -------------------------------------------------------------------------------- /usvm-python/usvm-python-annotations/src/main/kotlin/org/usvm/annotations/ids/NativeId.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.annotations.ids 2 | 3 | enum class NativeId( 4 | val pythonModule: String, 5 | val pythonName: String, 6 | var cRef: Long = 0L, // will be set during Python initialization 7 | ) { 8 | Eval("builtins", "eval"), 9 | OsSystem("os", "system"), 10 | } 11 | -------------------------------------------------------------------------------- /usvm-python/usvm-python-annotations/src/main/kotlin/org/usvm/annotations/ids/SymbolicMethodId.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.annotations.ids 2 | 3 | enum class SymbolicMethodId( 4 | var cName: String? = null, // will be set based on @CPythonAdapterJavaMethod 5 | var cRef: Long = 0L, // will be set in native code during Python initialization 6 | ) { 7 | Int, 8 | Float, 9 | Enumerate, 10 | ListAppend, 11 | ListInsert, 12 | ListPop, 13 | ListExtend, 14 | ListClear, 15 | SetAdd, 16 | } 17 | -------------------------------------------------------------------------------- /usvm-python/usvm-python-annotations/src/main/resources/META-INF/services/javax.annotation.processing.Processor: -------------------------------------------------------------------------------- 1 | org.usvm.annotations.CPythonAdapterJavaMethodProcessor 2 | org.usvm.annotations.CPythonFunctionProcessor 3 | org.usvm.annotations.SymbolicMemberDescriptorProcessor 4 | org.usvm.annotations.SymbolicMethodDescriptorProcessor 5 | org.usvm.annotations.SymbolicMethodProcessor -------------------------------------------------------------------------------- /usvm-python/usvm-python-commons/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("usvm.kotlin-conventions") 3 | `maven-publish` 4 | } 5 | 6 | publishing { 7 | repositories { 8 | maven { 9 | name = "GitHubPackages" 10 | url = uri("https://maven.pkg.github.com/UnitTestBot/usvm") 11 | credentials { 12 | username = System.getenv("GITHUB_ACTOR") 13 | password = System.getenv("GITHUB_TOKEN") 14 | } 15 | } 16 | } 17 | publications { 18 | create("jar") { 19 | from(components["java"]) 20 | groupId = "org.usvm" 21 | artifactId = project.name 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /usvm-python/usvm-python-commons/src/main/kotlin/org/usvm/python/model/PyTest.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.python.model 2 | 3 | class PyTest( 4 | val inputModel: PyInputModel, 5 | val inputArgs: List, 6 | val result: PyResult, 7 | ) 8 | 9 | class PyInputModel( 10 | val inputArgs: List, 11 | ) 12 | 13 | sealed class PyResult 14 | 15 | class PyResultSuccess( 16 | val output: PyObjectRepr, 17 | ) : PyResult() 18 | 19 | class PyResultFailure( 20 | val exception: PyObjectRepr, 21 | ) : PyResult() 22 | -------------------------------------------------------------------------------- /usvm-python/usvm-python-commons/src/main/kotlin/org/usvm/python/model/Utils.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.python.model 2 | 3 | fun calculateNumberOfMocks(obj: PyValue): Int { 4 | val visitor = object : PyValueVisitor() { 5 | var result = 0 6 | override fun visit(obj: PyMockObject) { 7 | result += 1 8 | super.visit(obj) 9 | } 10 | } 11 | visitor.visit(obj) 12 | return visitor.result 13 | } 14 | -------------------------------------------------------------------------------- /usvm-python/usvm-python-main/src/main/kotlin/org/usvm/language/Utils.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.language 2 | 3 | import org.usvm.machine.interpreters.concrete.ConcretePythonInterpreter 4 | 5 | fun PyCodeObject.prettyPrint(): String { 6 | val namespace = ConcretePythonInterpreter.getNewNamespace() 7 | ConcretePythonInterpreter.addObjectToNamespace(namespace, codeObject, "code") 8 | val name = ConcretePythonInterpreter.eval(namespace, "code.co_name") 9 | val nameAsStr = ConcretePythonInterpreter.getPythonObjectStr(name) 10 | ConcretePythonInterpreter.decref(namespace) 11 | 12 | return "$nameAsStr(address=${codeObject.address})" 13 | } 14 | -------------------------------------------------------------------------------- /usvm-python/usvm-python-main/src/main/kotlin/org/usvm/machine/ConcolicRunContextUtils.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.machine 2 | 3 | fun ConcolicRunContext.extractCurState(): PyState { 4 | val result = curState 5 | requireNotNull(result) { 6 | "`extractCurState` should be called when you are sure that " + 7 | "curState is non-null. It is null now." 8 | } 9 | return result 10 | } 11 | -------------------------------------------------------------------------------- /usvm-python/usvm-python-main/src/main/kotlin/org/usvm/machine/PyExecutionException.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.machine 2 | 3 | import org.usvm.machine.interpreters.concrete.PyObject 4 | 5 | sealed class PyExecutionException : RuntimeException() 6 | 7 | class CPythonExecutionException( 8 | val pythonExceptionValue: PyObject? = null, 9 | val pythonExceptionType: PyObject? = null, 10 | ) : PyExecutionException() 11 | 12 | sealed class PyExecutionExceptionFromJava : PyExecutionException() 13 | 14 | class UnregisteredVirtualOperation : PyExecutionExceptionFromJava() 15 | 16 | class BadModelException : PyExecutionExceptionFromJava() 17 | 18 | class InstructionLimitExceededException : PyExecutionExceptionFromJava() 19 | 20 | class CancelledExecutionException : PyExecutionExceptionFromJava() 21 | -------------------------------------------------------------------------------- /usvm-python/usvm-python-main/src/main/kotlin/org/usvm/machine/interpreters/concrete/utils/NamedSymbolForCPython.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.machine.interpreters.concrete.utils 2 | 3 | @Suppress("unused") 4 | class NamedSymbolForCPython( 5 | @JvmField 6 | var name: String, 7 | @JvmField 8 | var symbol: SymbolForCPython, 9 | ) 10 | -------------------------------------------------------------------------------- /usvm-python/usvm-python-main/src/main/kotlin/org/usvm/machine/interpreters/concrete/utils/SymbolForCPython.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.machine.interpreters.concrete.utils 2 | 3 | import org.usvm.machine.symbolicobjects.UninterpretedSymbolicPythonObject 4 | 5 | class SymbolForCPython( 6 | @JvmField 7 | val obj: UninterpretedSymbolicPythonObject?, 8 | @JvmField 9 | val symbolicTpCall: Long, 10 | ) { 11 | 12 | override fun equals(other: Any?): Boolean { 13 | if (other !is SymbolForCPython) return false 14 | return obj == other.obj && symbolicTpCall == other.symbolicTpCall 15 | } 16 | 17 | override fun hashCode(): Int { 18 | return obj.hashCode() 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /usvm-python/usvm-python-main/src/main/kotlin/org/usvm/machine/interpreters/concrete/utils/VirtualPythonObject.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.machine.interpreters.concrete.utils 2 | 3 | private const val MAX_NEEDED_MASK_BYTE_NUMBER: Int = 12 4 | private const val ALL_SLOTS_BYTE: Int = 0b11111111 5 | 6 | class VirtualPythonObject( 7 | @JvmField 8 | val interpretedObjRef: Int, 9 | val slotMask: ByteArray = List(MAX_NEEDED_MASK_BYTE_NUMBER) { ALL_SLOTS_BYTE.toByte() }.toByteArray(), 10 | ) 11 | -------------------------------------------------------------------------------- /usvm-python/usvm-python-main/src/main/kotlin/org/usvm/machine/interpreters/concrete/venv/VenvConfig.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.machine.interpreters.concrete.venv 2 | 3 | import java.io.File 4 | 5 | data class VenvConfig( 6 | val basePath: File, 7 | val libPath: File, 8 | val binPath: File, 9 | ) 10 | -------------------------------------------------------------------------------- /usvm-python/usvm-python-main/src/main/kotlin/org/usvm/machine/interpreters/symbolic/operations/descriptors/MemberDescriptor.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.machine.interpreters.symbolic.operations.descriptors 2 | 3 | import org.usvm.machine.ConcolicRunContext 4 | import org.usvm.machine.interpreters.concrete.utils.SymbolForCPython 5 | import org.usvm.machine.symbolicobjects.UninterpretedSymbolicPythonObject 6 | 7 | interface MemberDescriptor { 8 | fun getMember(ctx: ConcolicRunContext, owner: UninterpretedSymbolicPythonObject?): SymbolForCPython? 9 | } 10 | -------------------------------------------------------------------------------- /usvm-python/usvm-python-main/src/main/kotlin/org/usvm/machine/interpreters/symbolic/operations/symbolicmethods/Utils.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.machine.interpreters.symbolic.operations.symbolicmethods 2 | 3 | import org.usvm.machine.ConcolicRunContext 4 | import org.usvm.machine.interpreters.concrete.ConcretePythonInterpreter 5 | import org.usvm.machine.interpreters.concrete.PyObject 6 | import org.usvm.machine.interpreters.concrete.utils.SymbolForCPython 7 | import org.usvm.machine.interpreters.symbolic.operations.basic.handlerLoadConstKt 8 | 9 | fun generateNone(ctx: ConcolicRunContext): SymbolForCPython = 10 | SymbolForCPython(handlerLoadConstKt(ctx, PyObject(ConcretePythonInterpreter.pyNoneRef)), 0) 11 | -------------------------------------------------------------------------------- /usvm-python/usvm-python-main/src/main/kotlin/org/usvm/machine/ps/Utils.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.machine.ps 2 | 3 | import kotlin.random.Random 4 | 5 | fun weightedRandom(random: Random, items: List, weighter: (T) -> Double): T { 6 | require(items.isNotEmpty()) 7 | val prefixSum = items.map(weighter).runningFold(0.0) { acc, item -> acc + item }.drop(1) 8 | val sum = prefixSum.last() 9 | require(sum > 0) 10 | val borders = prefixSum.map { it / sum } 11 | val key = random.nextDouble() 12 | require(borders.last() > key) 13 | val idx = borders.indexOfFirst { it > key } 14 | return items[idx] 15 | } 16 | -------------------------------------------------------------------------------- /usvm-python/usvm-python-main/src/main/kotlin/org/usvm/machine/ps/strategies/impls/Action.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.machine.ps.strategies.impls 2 | 3 | import org.usvm.machine.ps.strategies.DelayedForkGraph 4 | import org.usvm.machine.ps.strategies.DelayedForkState 5 | import org.usvm.machine.ps.strategies.PyPathSelectorAction 6 | import kotlin.random.Random 7 | 8 | 9 | interface Action> { 10 | fun isAvailable(graph: DFGraph): Boolean 11 | fun makeAction(graph: DFGraph, random: Random): PyPathSelectorAction 12 | } 13 | -------------------------------------------------------------------------------- /usvm-python/usvm-python-main/src/main/kotlin/org/usvm/machine/ps/strategies/impls/TypeRatingByNumberOfHints.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.machine.ps.strategies.impls 2 | 3 | import org.usvm.machine.ps.strategies.DelayedForkState 4 | import org.usvm.machine.ps.strategies.DelayedForkStrategy 5 | import org.usvm.machine.ps.strategies.TypeRating 6 | 7 | class TypeRatingByNumberOfHints : DelayedForkStrategy { 8 | override fun chooseTypeRating(state: DFState): TypeRating { 9 | require(state.size > 0) 10 | val idx = List(state.size) { it }.maxBy { 11 | val rating = state.getAt(it) 12 | rating.numberOfHints - rating.numberOfUsed 13 | } 14 | return state.getAt(idx) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /usvm-python/usvm-python-main/src/main/kotlin/org/usvm/machine/results/observers/InputModelObserver.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.machine.results.observers 2 | 3 | import org.usvm.python.model.PyInputModel 4 | 5 | interface InputModelObserver { 6 | fun onInputModel(inputModel: PyInputModel) 7 | } 8 | 9 | object EmptyInputModelObserver : InputModelObserver { 10 | override fun onInputModel(inputModel: PyInputModel) = run {} 11 | } 12 | -------------------------------------------------------------------------------- /usvm-python/usvm-python-main/src/main/kotlin/org/usvm/machine/results/observers/InputPythonObjectObserver.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.machine.results.observers 2 | 3 | import org.usvm.machine.interpreters.concrete.PyObject 4 | 5 | interface InputPythonObjectObserver { 6 | fun onInputObjects(inputObjects: List) 7 | } 8 | 9 | object EmptyInputPythonObjectObserver : InputPythonObjectObserver { 10 | override fun onInputObjects(inputObjects: List) = run {} 11 | } 12 | -------------------------------------------------------------------------------- /usvm-python/usvm-python-main/src/main/kotlin/org/usvm/machine/results/observers/NewStateObserver.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.machine.results.observers 2 | 3 | import org.usvm.machine.PyState 4 | 5 | interface NewStateObserver { 6 | fun onNewState(state: PyState) 7 | } 8 | 9 | object EmptyNewStateObserver : NewStateObserver { 10 | override fun onNewState(state: PyState) = run {} 11 | } 12 | -------------------------------------------------------------------------------- /usvm-python/usvm-python-main/src/main/kotlin/org/usvm/machine/results/observers/PyTestObserver.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.machine.results.observers 2 | 3 | import org.usvm.python.model.PyTest 4 | 5 | interface PyTestObserver { 6 | fun onPyTest(pyTest: PyTest) 7 | } 8 | 9 | class EmptyPyTestObserver : PyTestObserver { 10 | override fun onPyTest(pyTest: PyTest) = run {} 11 | } 12 | 13 | class DefaultPyTestObserver : PyTestObserver { 14 | val tests: MutableList> = mutableListOf() 15 | override fun onPyTest(pyTest: PyTest) { 16 | tests.add(pyTest) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /usvm-python/usvm-python-main/src/main/kotlin/org/usvm/machine/results/serialization/EmptyObjectSerializer.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.machine.results.serialization 2 | 3 | import org.usvm.machine.interpreters.concrete.PyObject 4 | 5 | object EmptyObjectSerializer : PythonObjectSerializer { 6 | override fun serialize(obj: PyObject) = run {} 7 | } 8 | -------------------------------------------------------------------------------- /usvm-python/usvm-python-main/src/main/kotlin/org/usvm/machine/results/serialization/PythonObjectSerializer.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.machine.results.serialization 2 | 3 | import org.usvm.machine.interpreters.concrete.PyObject 4 | 5 | interface PythonObjectSerializer { 6 | fun serialize(obj: PyObject): PythonObjectRepresentation 7 | } 8 | -------------------------------------------------------------------------------- /usvm-python/usvm-python-main/src/main/kotlin/org/usvm/machine/results/serialization/ReprObjectSerializer.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.machine.results.serialization 2 | 3 | import org.usvm.machine.interpreters.concrete.ConcretePythonInterpreter 4 | import org.usvm.machine.interpreters.concrete.PyObject 5 | 6 | object ReprObjectSerializer : PythonObjectSerializer { 7 | override fun serialize(obj: PyObject): String { 8 | return runCatching { 9 | ConcretePythonInterpreter.getPythonObjectRepr(obj) 10 | }.getOrDefault( 11 | "" 14 | ) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /usvm-python/usvm-python-main/src/main/kotlin/org/usvm/machine/symbolicobjects/memory/Str.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.machine.symbolicobjects.memory 2 | 3 | import org.usvm.machine.symbolicobjects.PreallocatedObjects 4 | import org.usvm.machine.symbolicobjects.UninterpretedSymbolicPythonObject 5 | 6 | fun UninterpretedSymbolicPythonObject.getConcreteStrIfDefined(preallocatedObjects: PreallocatedObjects): String? = 7 | preallocatedObjects.concreteString(this) 8 | -------------------------------------------------------------------------------- /usvm-python/usvm-python-main/src/main/kotlin/org/usvm/machine/utils/GlobalParameters.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.machine.utils 2 | 3 | const val MAX_CONCRETE_TYPES_TO_CONSIDER = 1000 4 | const val MAX_INPUT_ARRAY_LENGTH = 1_000 5 | -------------------------------------------------------------------------------- /usvm-python/usvm-python-main/src/main/kotlin/org/usvm/runner/PickledObjectCommunicator.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.runner 2 | 3 | import java.io.PrintWriter 4 | import java.net.Socket 5 | 6 | class PickledObjectCommunicator( 7 | ip: String, 8 | port: Int, 9 | ) : AutoCloseable { 10 | private val clientSocket = Socket(ip, port) 11 | private val writer = PrintWriter(clientSocket.getOutputStream()) 12 | 13 | fun sendPickledInputs(pickledInput: String) { 14 | writer.println(pickledInput) 15 | writer.flush() 16 | } 17 | 18 | override fun close() { 19 | writer.close() 20 | clientSocket.close() 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /usvm-python/usvm-python-runner/src/main/kotlin/org/usvm/runner/DebugRunner.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.runner 2 | 3 | import mu.KLogging 4 | 5 | private val logger = object : KLogging() {}.logger 6 | 7 | class DebugRunner(config: USVMPythonConfig) : USVMPythonRunner(config) { 8 | fun runProcessAndPrintInfo(runConfig: USVMPythonRunConfig) { 9 | val builder = setupEnvironment(runConfig) 10 | builder.redirectError(ProcessBuilder.Redirect.INHERIT) 11 | builder.redirectOutput(ProcessBuilder.Redirect.INHERIT) 12 | val process = builder.start() 13 | process.waitFor() 14 | when (val status = process.exitValue()) { 15 | 0 -> logger.info("Exit status: 0 (Success)") 16 | else -> logger.info("Exit status: $status (Failure)") 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /usvm-python/usvm-python-runner/src/main/kotlin/org/usvm/runner/DistributionLayout.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.runner 2 | 3 | import java.io.File 4 | 5 | interface DistributionLayout { 6 | val cpythonPath: File 7 | val approximationsPath: File 8 | val nativeLibPath: File 9 | val jarPath: File 10 | } 11 | 12 | class StandardLayout(distributionPath: File) : DistributionLayout { 13 | override val cpythonPath: File = File(distributionPath, "cpython") 14 | override val approximationsPath: File = File(distributionPath, "lib") 15 | override val nativeLibPath: File = File(distributionPath, "lib") 16 | override val jarPath: File = File(distributionPath, "jar/usvm-python.jar") 17 | } 18 | -------------------------------------------------------------------------------- /usvm-python/usvm-python-runner/src/main/kotlin/org/usvm/runner/USVMPythonAnalysisResultReceiver.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.runner 2 | 3 | interface USVMPythonAnalysisResultReceiver { 4 | fun receivePickledInputValues(pickledTuple: String) 5 | } 6 | -------------------------------------------------------------------------------- /usvm-python/usvm-python-runner/src/main/kotlin/org/usvm/runner/venv/VenvConfig.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.runner.venv 2 | 3 | import java.io.File 4 | 5 | data class VenvConfig( 6 | val basePath: File, 7 | val libPath: File, 8 | val binPath: File, 9 | ) 10 | -------------------------------------------------------------------------------- /usvm-python/usvm-python-runner/src/test/kotlin/org/usvm/runner/PrintingResultReceiver.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.runner 2 | 3 | import mu.KLogging 4 | 5 | private val logger = object : KLogging() {}.logger 6 | 7 | class PrintingResultReceiver : USVMPythonAnalysisResultReceiver { 8 | var cnt: Int = 0 9 | override fun receivePickledInputValues(pickledTuple: String) { 10 | logger.info(pickledTuple) 11 | cnt += 1 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /usvm-python/usvm-python-runner/src/test/kotlin/org/usvm/runner/TestingLayout.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.runner 2 | 3 | import java.io.File 4 | 5 | class TestingLayout(basePath: String) : DistributionLayout { 6 | override val cpythonPath = File(basePath, "cpythonadapter/build/cpython_build") 7 | override val approximationsPath = File(basePath, "python_approximations") 8 | override val nativeLibPath = File(basePath, "cpythonadapter/build/lib/main/debug") 9 | override val jarPath = File(basePath, "build/libs/usvm-python.jar") 10 | } 11 | -------------------------------------------------------------------------------- /usvm-sample-language/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("usvm.kotlin-conventions") 3 | } 4 | 5 | dependencies { 6 | implementation(project(":usvm-core")) 7 | 8 | implementation(Libs.ksmt_yices) 9 | // uncomment for experiments 10 | // implementation(Libs.ksmt_cvc5) 11 | // implementation(Libs.ksmt_bitwuzla) 12 | 13 | testImplementation(Libs.logback) 14 | } 15 | -------------------------------------------------------------------------------- /usvm-sample-language/src/main/kotlin/org/usvm/language/Types.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.language 2 | 3 | sealed interface SampleType 4 | 5 | sealed interface PrimitiveType : SampleType 6 | 7 | object IntType : PrimitiveType { 8 | override fun toString(): String = "Int" 9 | } 10 | 11 | object BooleanType : PrimitiveType { 12 | override fun toString(): String = "Boolean" 13 | } 14 | 15 | sealed interface RefType : SampleType 16 | 17 | data class StructType( 18 | val struct: Struct 19 | ) : RefType { 20 | override fun toString(): String = struct.name 21 | } 22 | 23 | val Null = Struct("null", emptySet()) 24 | 25 | data class ArrayType( 26 | val elementType: T 27 | ) : RefType { 28 | override fun toString(): String = "[]$elementType" 29 | } -------------------------------------------------------------------------------- /usvm-sample-language/src/main/kotlin/org/usvm/language/Utils.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.language 2 | 3 | inline val Method<*>.argumentCount get() = argumentsTypes.size 4 | inline val Method<*>.registersCount get() = body?.registersCount ?: argumentCount 5 | inline val Method<*>.localsCount get() = registersCount - argumentCount -------------------------------------------------------------------------------- /usvm-sample-language/src/main/kotlin/org/usvm/machine/SampleTarget.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.machine 2 | 3 | import org.usvm.language.Stmt 4 | import org.usvm.targets.UTarget 5 | 6 | /** 7 | * Base class for SampleMachine targets. 8 | */ 9 | abstract class SampleTarget( 10 | location: Stmt, 11 | ) : UTarget(location) 12 | -------------------------------------------------------------------------------- /usvm-sample-language/src/test/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | %d{HH:mm:ss.SSS} |%.-1level| %replace(%c{0}){'(\$Companion)?\$logger\$1',''} - %msg%n 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /usvm-ts-dataflow/.gitignore: -------------------------------------------------------------------------------- 1 | logs/ 2 | -------------------------------------------------------------------------------- /usvm-ts-dataflow/src/main/kotlin/org/usvm/dataflow/ts/infer/KnownType.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.dataflow.ts.infer 2 | 3 | import org.jacodb.ets.model.EtsEntity 4 | import org.jacodb.ets.model.EtsLocal 5 | import org.jacodb.ets.model.EtsMethod 6 | import org.jacodb.ets.model.EtsParameterRef 7 | import org.jacodb.ets.model.EtsThis 8 | import org.jacodb.ets.model.EtsType 9 | import org.jacodb.ets.model.EtsUnknownType 10 | import org.usvm.dataflow.ts.util.type 11 | 12 | fun EtsEntity.tryGetKnownType(method: EtsMethod): EtsType { 13 | if (this is EtsLocal) { 14 | return type 15 | } 16 | 17 | if (this is EtsParameterRef) { 18 | return method.parameters[index].type 19 | } 20 | 21 | if (this is EtsThis) { 22 | method.enclosingClass?.type?.let { return it } 23 | } 24 | 25 | return EtsUnknownType 26 | } 27 | -------------------------------------------------------------------------------- /usvm-ts-dataflow/src/main/kotlin/org/usvm/dataflow/ts/infer/TypeDomainFact.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.dataflow.ts.infer 2 | 3 | sealed interface BackwardTypeDomainFact { 4 | data object Zero : BackwardTypeDomainFact 5 | 6 | // Requirement 7 | data class TypedVariable( 8 | val variable: AccessPathBase, 9 | val type: EtsTypeFact, 10 | ) : BackwardTypeDomainFact 11 | } 12 | 13 | sealed interface ForwardTypeDomainFact { 14 | data object Zero : ForwardTypeDomainFact 15 | 16 | // Exact type 17 | data class TypedVariable( 18 | val variable: AccessPath, 19 | val type: EtsTypeFact, // primitive or Object 20 | ) : ForwardTypeDomainFact 21 | } 22 | -------------------------------------------------------------------------------- /usvm-ts-dataflow/src/main/kotlin/org/usvm/dataflow/ts/util/RealLocals.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.dataflow.ts.util 2 | 3 | import org.jacodb.ets.model.EtsAssignStmt 4 | import org.jacodb.ets.model.EtsLocal 5 | import org.jacodb.ets.model.EtsMethod 6 | 7 | private val realLocalsCache: MutableMap> = hashMapOf() 8 | 9 | /** 10 | * Returns the set of "real" locals in this method, i.e. the locals that are assigned to in the method. 11 | */ 12 | fun EtsMethod.getRealLocals(): Set = 13 | realLocalsCache.computeIfAbsent(this) { 14 | cfg.stmts 15 | .asSequence() 16 | .filterIsInstance() 17 | .map { it.lhv } 18 | .filterIsInstance() 19 | .toHashSet() 20 | } 21 | -------------------------------------------------------------------------------- /usvm-ts-dataflow/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | %highlight([%level]) %replace(%c{0}){'(\$Companion)?\$logger\$1',''} - %msg%n 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /usvm-ts-dataflow/src/test/kotlin/org/usvm/dataflow/ts/test/utils/ExpectedTypesExtractor.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.dataflow.ts.test.utils 2 | 3 | import org.jacodb.ets.model.EtsMethod 4 | import org.jacodb.ets.model.EtsScene 5 | 6 | class ExpectedTypesExtractor( 7 | private val scene: EtsScene, 8 | ) { 9 | fun extractTypes(method: EtsMethod): MethodTypes { 10 | val returnType = method.returnType 11 | val argumentsTypes = method.parameters.map { it.type } 12 | val thisType = scene.getEtsClassType(method.signature.enclosingClass) 13 | return MethodTypes(thisType, argumentsTypes, returnType) 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /usvm-ts-dataflow/src/test/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | %highlight([%level]) %replace(%c{0}){'(\$Companion)?\$logger\$1',''} - %msg%n 5 | 6 | 7 | 8 | 9 | logs/app.log 10 | false 11 | 12 | [%level] %replace(%c{0}){'(\$Companion)?\$logger\$1',''} - %msg%n 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /usvm-ts-dataflow/src/test/resources/ts/call.ts: -------------------------------------------------------------------------------- 1 | function entrypoint() { 2 | f(42); 3 | let x= 7 4 | g(x); 5 | } 6 | 7 | function f(x: any) { 8 | console.log(x); 9 | } 10 | 11 | function g(x: any) { 12 | console.log(x); 13 | } 14 | -------------------------------------------------------------------------------- /usvm-ts-dataflow/src/test/resources/ts/cast.ts: -------------------------------------------------------------------------------- 1 | declare function getData(): any; 2 | 3 | interface Data {} 4 | 5 | function entrypoint() { 6 | let x = getData() as Data; 7 | infer(x); 8 | } 9 | 10 | function infer(arg: any) { 11 | console.log(arg); 12 | } 13 | -------------------------------------------------------------------------------- /usvm-ts-dataflow/src/test/resources/ts/data.ts: -------------------------------------------------------------------------------- 1 | class Data { 2 | a: number; 3 | b: number; 4 | constructor(a: number, b: number) { 5 | this.a = a; 6 | this.b = b; 7 | } 8 | } 9 | 10 | function entrypoint() { 11 | let data = new Data(7, 42); 12 | process(data); 13 | } 14 | 15 | function process(data: any) { 16 | console.log(data); 17 | } 18 | -------------------------------------------------------------------------------- /usvm-ts-dataflow/src/test/resources/ts/microphone.ts: -------------------------------------------------------------------------------- 1 | interface Microphone { 2 | uuid: string 3 | } 4 | 5 | class VirtualMicro implements Microphone { 6 | uuid: string = "virtual_micro_v3" 7 | } 8 | 9 | interface Devices { 10 | microphone: Microphone 11 | } 12 | 13 | class VirtualDevices implements Devices { 14 | microphone: Microphone = new VirtualMicro() 15 | } 16 | 17 | function getMicrophoneUuid(device: Devices): string { 18 | return device.microphone.uuid 19 | } 20 | 21 | function entrypoint() { 22 | let devices = new VirtualDevices() 23 | let uuid = getMicrophoneUuid(devices) 24 | console.log(uuid) 25 | } 26 | -------------------------------------------------------------------------------- /usvm-ts-dataflow/src/test/resources/ts/microphone_ctor.ts: -------------------------------------------------------------------------------- 1 | interface Microphone { 2 | uuid: string 3 | } 4 | 5 | class VirtualMicro implements Microphone { 6 | uuid: string; 7 | 8 | constructor() { 9 | this.uuid = "virtual_micro_v3" 10 | } 11 | } 12 | 13 | interface Devices { 14 | microphone: Microphone 15 | } 16 | 17 | class VirtualDevices implements Devices { 18 | microphone: Microphone; 19 | 20 | constructor() { 21 | this.microphone = new VirtualMicro(); 22 | } 23 | } 24 | 25 | function getMicrophoneUuid(devices: Devices): string { 26 | return devices.microphone.uuid; 27 | } 28 | 29 | function entrypoint() { 30 | let devices = new VirtualDevices() 31 | let uuid = getMicrophoneUuid(devices) 32 | console.log(uuid) 33 | } 34 | -------------------------------------------------------------------------------- /usvm-ts-dataflow/src/test/resources/ts/nested_init.ts: -------------------------------------------------------------------------------- 1 | class Foo { 2 | } 3 | 4 | class Cat { 5 | foo: Foo = new Foo(); 6 | } 7 | 8 | // class Cat { 9 | // foo: Foo; 10 | // 11 | // constructor() { 12 | // this.foo = new Foo(); 13 | // } 14 | // } 15 | 16 | function entrypoint() { 17 | let cat = new Cat(); 18 | infer(cat); 19 | } 20 | 21 | function infer(x: any) { 22 | console.log(x); 23 | } 24 | -------------------------------------------------------------------------------- /usvm-ts-dataflow/src/test/resources/ts/taint.ts: -------------------------------------------------------------------------------- 1 | function source(): number | null { 2 | return null; 3 | } 4 | 5 | function pass(data: number | null): number | null { 6 | return data; 7 | } 8 | 9 | function validate(data: number | null): number { 10 | if (data == null) { 11 | return 0; 12 | } 13 | return data; 14 | } 15 | 16 | function sink(data: number | null) { 17 | if (data == null) { 18 | throw new Error("Error!"); 19 | } 20 | } 21 | 22 | function bad() { 23 | let data = source(); 24 | data = pass(data); 25 | sink(data); 26 | } 27 | 28 | function good() { 29 | let data = source(); 30 | data = validate(data); 31 | sink(data); 32 | } 33 | -------------------------------------------------------------------------------- /usvm-ts-dataflow/src/testFixtures/kotlin/org/usvm/dataflow/ts/Resources.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.dataflow.ts 2 | 3 | import java.io.InputStream 4 | import java.nio.file.Path 5 | import kotlin.io.path.toPath 6 | 7 | fun getResourcePathOrNull(res: String): Path? { 8 | require(res.startsWith("/")) { "Resource path must start with '/': '$res'" } 9 | return object {}::class.java.getResource(res)?.toURI()?.toPath() 10 | } 11 | 12 | fun getResourcePath(res: String): Path { 13 | return getResourcePathOrNull(res) ?: error("Resource not found: '$res'") 14 | } 15 | 16 | fun getResourceStream(res: String): InputStream { 17 | require(res.startsWith("/")) { "Resource path must start with '/': '$res'" } 18 | return object {}::class.java.getResourceAsStream(res) 19 | ?: error("Resource not found: '$res'") 20 | } 21 | -------------------------------------------------------------------------------- /usvm-ts/.gitignore: -------------------------------------------------------------------------------- 1 | src/test/resources/sdk 2 | -------------------------------------------------------------------------------- /usvm-ts/src/main/kotlin/org/usvm/api/targets/TsTarget.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.api.targets 2 | 3 | import org.jacodb.ets.model.EtsStmt 4 | import org.usvm.targets.UTarget 5 | 6 | class TsTarget : UTarget() 7 | -------------------------------------------------------------------------------- /usvm-ts/src/main/kotlin/org/usvm/machine/TsOptions.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.machine 2 | 3 | data class TsOptions( 4 | val interproceduralAnalysis: Boolean = true, 5 | ) 6 | -------------------------------------------------------------------------------- /usvm-ts/src/main/kotlin/org/usvm/machine/TsTransformer.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.machine 2 | 3 | import org.jacodb.ets.model.EtsType 4 | import org.usvm.UComposer 5 | import org.usvm.UContext 6 | import org.usvm.UTransformer 7 | import org.usvm.collections.immutable.internal.MutabilityOwnership 8 | import org.usvm.memory.UReadOnlyMemory 9 | import org.usvm.solver.UExprTranslator 10 | 11 | interface TsTransformer : UTransformer 12 | 13 | class TsComposer( 14 | ctx: UContext, 15 | memory: UReadOnlyMemory, 16 | ownership: MutabilityOwnership, 17 | ) : UComposer(ctx, memory, ownership), TsTransformer 18 | 19 | class TsExprTranslator( 20 | ctx: UContext, 21 | ) : UExprTranslator(ctx), TsTransformer 22 | -------------------------------------------------------------------------------- /usvm-ts/src/main/kotlin/org/usvm/machine/types/EtsAuxiliaryType.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.machine.types 2 | 3 | import org.jacodb.ets.model.EtsType 4 | 5 | /** 6 | * An auxiliary type is a type that is not directly represented in the TS class hierarchy. 7 | * Can be used as a JS-like type containing set of properties. 8 | */ 9 | class EtsAuxiliaryType(val properties: Set) : EtsType { 10 | override val typeName: String 11 | get() = "AuxiliaryType ${properties.toSortedSet()}" 12 | 13 | override fun toString(): String { 14 | return typeName 15 | } 16 | 17 | override fun accept(visitor: EtsType.Visitor): R { 18 | error("Should not be called") 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /usvm-ts/src/test/kotlin/org/usvm/samples/MinValue.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.samples 2 | 3 | import org.jacodb.ets.model.EtsScene 4 | import org.junit.jupiter.api.Disabled 5 | import org.usvm.api.TsTestValue 6 | import org.usvm.util.TsMethodTestRunner 7 | import kotlin.test.Test 8 | 9 | class MinValue : TsMethodTestRunner() { 10 | 11 | private val className = this::class.simpleName!! 12 | 13 | override val scene: EtsScene = loadSampleScene(className) 14 | 15 | @Test 16 | @Disabled 17 | fun `test findMinValue`() { 18 | val method = getMethod(className, "findMinValue") 19 | discoverProperties, TsTestValue.TsNumber>( 20 | method, 21 | ) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /usvm-ts/src/test/kotlin/org/usvm/samples/Null.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.samples 2 | 3 | import org.jacodb.ets.model.EtsScene 4 | import org.junit.jupiter.api.Test 5 | import org.usvm.api.TsTestValue 6 | import org.usvm.util.TsMethodTestRunner 7 | 8 | class Null : TsMethodTestRunner() { 9 | 10 | private val className = this::class.simpleName!! 11 | 12 | override val scene: EtsScene = loadSampleScene(className) 13 | 14 | @Test 15 | fun `test isNull`() { 16 | val method = getMethod(className, "isNull") 17 | discoverProperties( 18 | method, 19 | { a, r -> (a is TsTestValue.TsNull) && (r.number == 1.0) }, 20 | { a, r -> (a !is TsTestValue.TsNull) && (r.number == 2.0) }, 21 | ) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /usvm-ts/src/test/kotlin/org/usvm/samples/Truthy.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.samples 2 | 3 | import org.jacodb.ets.model.EtsScene 4 | import org.usvm.api.TsTestValue 5 | import org.usvm.util.TsMethodTestRunner 6 | import kotlin.test.Test 7 | 8 | class Truthy : TsMethodTestRunner() { 9 | 10 | private val className = this::class.simpleName!! 11 | 12 | override val scene: EtsScene = loadSampleScene(className) 13 | 14 | @Test 15 | fun `test arrayTruthy`() { 16 | val method = getMethod(className, "arrayTruthy") 17 | discoverProperties( 18 | method, 19 | { r -> r.number == 0.0 }, 20 | invariants = arrayOf( 21 | { r -> r.number != -1.0 }, 22 | ) 23 | ) 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /usvm-ts/src/test/kotlin/org/usvm/samples/Undefined.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.samples 2 | 3 | import org.jacodb.ets.model.EtsScene 4 | import org.junit.jupiter.api.Test 5 | import org.usvm.api.TsTestValue 6 | import org.usvm.util.TsMethodTestRunner 7 | 8 | class Undefined : TsMethodTestRunner() { 9 | 10 | private val className = this::class.simpleName!! 11 | 12 | override val scene: EtsScene = loadSampleScene(className) 13 | 14 | @Test 15 | fun `test isUndefined`() { 16 | val method = getMethod(className, "isUndefined") 17 | discoverProperties( 18 | method = method, 19 | { a, r -> (a is TsTestValue.TsUndefined) && (r.number == 1.0) }, 20 | { a, r -> (a !is TsTestValue.TsUndefined) && (r.number == 2.0) }, 21 | ) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /usvm-ts/src/test/kotlin/org/usvm/util/ObjectClass.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.util 2 | 3 | import org.jacodb.ets.model.EtsClass 4 | import org.jacodb.ets.model.EtsClassImpl 5 | import org.jacodb.ets.model.EtsClassSignature 6 | import org.jacodb.ets.model.EtsFileSignature 7 | import org.jacodb.ets.utils.createConstructor 8 | 9 | fun createObjectClass(): EtsClass { 10 | val cls = EtsClassSignature("Object", EtsFileSignature.UNKNOWN) 11 | val ctor = createConstructor(cls) 12 | return EtsClassImpl( 13 | signature = cls, 14 | fields = emptyList(), 15 | methods = listOf(ctor), 16 | ) 17 | } 18 | -------------------------------------------------------------------------------- /usvm-ts/src/test/kotlin/org/usvm/util/PathUtils.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.util 2 | 3 | import java.nio.file.Path 4 | import kotlin.io.path.div 5 | 6 | fun Path.resolveHome(): Path = 7 | if (startsWith("~" + fileSystem.separator)) { 8 | fileSystem.getPath(System.getProperty("user.home")) / subpath(1, nameCount) 9 | } else { 10 | this 11 | } 12 | -------------------------------------------------------------------------------- /usvm-ts/src/test/kotlin/org/usvm/util/Truthy.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.util 2 | 3 | import org.usvm.api.TsTestValue 4 | 5 | fun isTruthy(x: Double): Boolean { 6 | return x != 0.0 && !x.isNaN() 7 | } 8 | 9 | fun isTruthy(x: TsTestValue.TsNumber): Boolean { 10 | return isTruthy(x.number) 11 | } 12 | 13 | fun isTruthy(x: TsTestValue.TsClass): Boolean { 14 | return true 15 | } 16 | 17 | fun isTruthy(x: TsTestValue.TsObject): Boolean { 18 | return x.addr != 0 19 | } 20 | -------------------------------------------------------------------------------- /usvm-ts/src/test/kotlin/org/usvm/util/Util.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.util 2 | 3 | fun Boolean.toDouble() = if (this) 1.0 else 0.0 4 | -------------------------------------------------------------------------------- /usvm-ts/src/test/resources/checkers/UnreachableCode.ts: -------------------------------------------------------------------------------- 1 | class UnreachableCode { 2 | simpleUnreachableBranch(value: number): number { 3 | if (value > 4) { 4 | if (value < 2) { 5 | return -1 6 | } else { 7 | return 1 8 | } 9 | } else { 10 | return 2 11 | } 12 | } 13 | 14 | unreachableCodeWithCallsInside(value: number): number { 15 | let anotherValue = this.simpleUnreachableBranch(value) 16 | if (anotherValue > 2) { 17 | if (anotherValue < 1) { 18 | return -1 // Unreachable code 19 | } else { 20 | return 1 // Unreachable if we execute simpleUnreachableBranch call and reachable otherwise 21 | } 22 | } 23 | 24 | return 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /usvm-ts/src/test/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | %highlight([%level]) %replace(%c{0}){'(\$Companion)?\$logger\$1',''} - %msg%n 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /usvm-ts/src/test/resources/samples/InstanceFields.ts: -------------------------------------------------------------------------------- 1 | // @ts-nocheck 2 | // noinspection JSUnusedGlobalSymbols 3 | 4 | class InstanceFields { 5 | returnSingleField(x: { a: number }): number { 6 | return x.a 7 | } 8 | 9 | dispatchOverField(x: { a: number }): number { 10 | if (x.a == 1) return 1 11 | if (x.a == 2) return 2 12 | return 100 13 | } 14 | 15 | returnSumOfTwoFields(x: { a: number, b: number }): number { 16 | return x.a + x.b 17 | } 18 | 19 | assignField(x: { a: number }): number { 20 | x.a = 10 21 | return x.a 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /usvm-ts/src/test/resources/samples/InstanceMethods.ts: -------------------------------------------------------------------------------- 1 | // @ts-nocheck 2 | // noinspection JSUnusedGlobalSymbols 3 | 4 | class InstanceMethods { 5 | noArguments(): number { 6 | return 42 7 | } 8 | 9 | singleArgument(a: number): number { 10 | if (a != a) return a 11 | if (a == 1) return a 12 | if (a == 2) return a 13 | return 100 14 | } 15 | 16 | manyArguments(a: number, b: number, c: number, d: number): number { 17 | if (a == 1) return a 18 | if (b == 2) return b 19 | if (c == 3) return c 20 | if (d == 4) return d 21 | return 100 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /usvm-ts/src/test/resources/samples/MinValue.ts: -------------------------------------------------------------------------------- 1 | function findMinValue(arr: number[]): number { 2 | if (arr.length === 0) throw new Error("Array is empty!"); 3 | 4 | let minValue = arr[0]; 5 | for (let i = 1; i < arr.length; i++) { 6 | if (arr[i] < minValue) { 7 | minValue = arr[i]; 8 | } 9 | } 10 | return minValue; 11 | } 12 | -------------------------------------------------------------------------------- /usvm-ts/src/test/resources/samples/Null.ts: -------------------------------------------------------------------------------- 1 | // @ts-nocheck 2 | // noinspection JSUnusedGlobalSymbols 3 | 4 | class Null { 5 | isNull(x): number { 6 | if (x === null) return 1 7 | return 2 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /usvm-ts/src/test/resources/samples/StaticMethods.ts: -------------------------------------------------------------------------------- 1 | // @ts-nocheck 2 | // noinspection JSUnusedGlobalSymbols 3 | 4 | class StaticMethods { 5 | static noArguments(): number { 6 | return 42 7 | } 8 | 9 | static singleArgument(a: number): number { 10 | if (a != a) return a 11 | if (a == 1) return a 12 | if (a == 2) return a 13 | return 100 14 | } 15 | 16 | static manyArguments(a: number, b: number, c: number, d: number): number { 17 | if (a == 1) return a 18 | if (b == 2) return b 19 | if (c == 3) return c 20 | if (d == 4) return d 21 | return 100 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /usvm-ts/src/test/resources/samples/Truthy.ts: -------------------------------------------------------------------------------- 1 | // @ts-nocheck 2 | // noinspection JSUnusedGlobalSymbols 3 | 4 | class Truthy { 5 | arrayTruthy() { 6 | if (![]) return -1 // unreachable 7 | if (![0]) return -1 // unreachable 8 | if (![1]) return -1 // unreachable 9 | return 0 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /usvm-ts/src/test/resources/samples/Undefined.ts: -------------------------------------------------------------------------------- 1 | // @ts-nocheck 2 | // noinspection JSUnusedGlobalSymbols 3 | 4 | class Undefined { 5 | isUndefined(x): number { 6 | if (x === undefined) return 1 7 | return 2 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /usvm-ts/src/test/resources/samples/operators/Neg.ts: -------------------------------------------------------------------------------- 1 | // @ts-nocheck 2 | // noinspection JSUnusedGlobalSymbols 3 | 4 | class Neg { 5 | negateNumber(x: number): number { 6 | let y = -x 7 | if (x != x) return y // -NaN == NaN 8 | if (x == 0) return y // -0 == 0 9 | if (x > 0) return y // -(x>0) == (x<0) 10 | if (x < 0) return y // -(x<0) == (x>0) 11 | // unreachable 12 | } 13 | 14 | negateBoolean(x: boolean): number { 15 | let y = -x 16 | if (x) return y // -true == -1 17 | if (!x) return y // -false == -0 18 | // unreachable 19 | } 20 | 21 | negateUndefined(): number { 22 | let x = undefined 23 | return -x // -undefined == NaN 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /usvm-ts/src/test/resources/samples/types/ObjectUsage.ts: -------------------------------------------------------------------------------- 1 | // @ts-nocheck 2 | // noinspection JSUnusedGlobalSymbols 3 | 4 | class ObjectUsage { 5 | objectAsParameter(object: Object): number { 6 | if (object == undefined) { 7 | return -1 8 | } 9 | 10 | return 42 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /usvm-ts/src/test/resources/samples/types/StructuralEquality.ts: -------------------------------------------------------------------------------- 1 | class A { 2 | x: number; 3 | 4 | constructor(x: number) { 5 | this.x = x; 6 | } 7 | 8 | foo (): number { 9 | return 21; 10 | } 11 | } 12 | 13 | class B { 14 | x: number; 15 | 16 | constructor(x: number) { 17 | this.x = x; 18 | } 19 | 20 | foo (): number { 21 | return this.x; 22 | } 23 | } 24 | 25 | class C { 26 | x: A; 27 | 28 | constructor(x: A) { 29 | this.x = x; 30 | } 31 | } 32 | 33 | class D { 34 | x: B; 35 | 36 | constructor(x: B) { 37 | this.x = x; 38 | } 39 | } 40 | 41 | class Example { 42 | testFunction() : C { 43 | const obj: A = new B(11); 44 | const number = obj.foo(); 45 | 46 | const aaa: C = new D(new A(number)); 47 | return aaa 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /usvm-util/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("usvm.kotlin-conventions") 3 | } 4 | 5 | dependencies { 6 | implementation(Libs.kotlinx_collections) 7 | 8 | testImplementation(Libs.mockk) 9 | testImplementation(Libs.junit_jupiter_params) 10 | } 11 | 12 | publishing { 13 | publications { 14 | create("maven") { 15 | from(components["java"]) 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /usvm-util/src/main/kotlin/org/usvm/collections/immutable/internal/ForEachOneBit.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2020 JetBrains s.r.o. 3 | * Use of this source code is governed by the Apache 2.0 License that can be found in the LICENSE.txt file. 4 | */ 5 | 6 | package org.usvm.collections.immutable.internal 7 | 8 | // 'iterate' all the bits set to one in a given integer, in the form of one-bit masks 9 | internal inline fun Int.forEachOneBit(body: (mask: Int, index: Int) -> Unit) { 10 | var mask = this 11 | var index = 0 12 | while (mask != 0) { 13 | val bit = mask.takeLowestOneBit() 14 | body(bit, index) 15 | index++ 16 | mask = mask xor bit 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /usvm-util/src/main/kotlin/org/usvm/collections/immutable/internal/MutabilityOwnership.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2019 JetBrains s.r.o. 3 | * Use of this source code is governed by the Apache 2.0 License that can be found in the LICENSE.txt file. 4 | */ 5 | 6 | package org.usvm.collections.immutable.internal 7 | 8 | /** 9 | * The mutability ownership token of a persistent collection builder. 10 | * 11 | * Used to mark persistent data structures, that are owned by a collection builder and can be mutated by it. 12 | */ 13 | class MutabilityOwnership 14 | -------------------------------------------------------------------------------- /usvm-util/src/main/kotlin/org/usvm/regions/Region.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.regions 2 | 3 | interface Region { 4 | val isEmpty: Boolean 5 | fun compare(other: T): ComparisonResult 6 | fun union(other: T): T 7 | fun subtract(other: T): T 8 | fun intersect(other: T): T 9 | 10 | enum class ComparisonResult { 11 | INCLUDES, INTERSECTS, DISJOINT 12 | } 13 | } 14 | 15 | 16 | -------------------------------------------------------------------------------- /usvm-util/src/main/kotlin/org/usvm/regions/TrivialRegion.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.regions 2 | 3 | class TrivialRegion : Region { 4 | override val isEmpty = false 5 | override fun union(other: TrivialRegion): TrivialRegion = this 6 | 7 | override fun intersect(other: TrivialRegion): TrivialRegion = this 8 | override fun subtract(other: TrivialRegion): TrivialRegion = 9 | throw UnsupportedOperationException("TrivialRegion.subtract should not be called") 10 | 11 | override fun compare(other: TrivialRegion): Region.ComparisonResult = Region.ComparisonResult.INCLUDES 12 | } -------------------------------------------------------------------------------- /usvm-util/src/main/kotlin/org/usvm/util/Assertions.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.util 2 | 3 | @PublishedApi 4 | internal object Assertions { 5 | @JvmField 6 | @PublishedApi 7 | internal val ENABLED: Boolean = javaClass.desiredAssertionStatus() 8 | } 9 | 10 | /** 11 | * Assert that evaluates [condition] only if assertions are enabled (e.g. during tests) 12 | * */ 13 | inline fun assert(condition: () -> Boolean, message: () -> String) { 14 | if (Assertions.ENABLED) { 15 | assert(condition()) { message() } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /usvm-util/src/main/kotlin/org/usvm/util/MathUtils.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.util 2 | 3 | /** 4 | * Unsigned integer logarithm base 2 (more effective version than floor(log2(n.toDouble()))). 5 | * Zero evaluates to zero, UInt.MAX_VALUE evaluates to 32u. 6 | */ 7 | fun log2(n: UInt): UInt { 8 | if (n == UInt.MAX_VALUE) { 9 | return 32u 10 | } 11 | 12 | if (n == 0u) { 13 | return 0u 14 | } 15 | 16 | return 31u - Integer.numberOfLeadingZeros(n.toInt()).toUInt() 17 | } 18 | -------------------------------------------------------------------------------- /usvm-util/src/main/kotlin/org/usvm/util/Stopwatch.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.util 2 | 3 | import kotlin.time.Duration 4 | 5 | /** 6 | * Measures elapsed time. 7 | */ 8 | interface Stopwatch { 9 | /** 10 | * Starts time measurement. 11 | */ 12 | fun start() 13 | 14 | /** 15 | * Stops time measurement. Current measurement is not discarded so 16 | * [start] can be run again. 17 | */ 18 | fun stop() 19 | 20 | /** 21 | * Stops time measurement and discards results. 22 | */ 23 | fun reset() 24 | 25 | /** 26 | * Total elapsed time. 27 | */ 28 | val elapsed: Duration 29 | 30 | /** 31 | * Indicates if time measurement is in process. 32 | */ 33 | val isRunning: Boolean 34 | } 35 | -------------------------------------------------------------------------------- /usvm-util/src/test/kotlin/org/usvm/algorithms/Utils.kt: -------------------------------------------------------------------------------- 1 | package org.usvm.algorithms 2 | 3 | /** 4 | * Pseudo random function for tests. 5 | * Random with constant seed can return different values in different Kotlin versions. This 6 | * implementation should not have this problem. 7 | */ 8 | internal fun pseudoRandom(i: Int): Int { 9 | var res = ((i shr 16) xor i) * 0x45d9f3b 10 | res = ((res shr 16) xor res) * 0x45d9f3b 11 | res = (res shr 16) xor res 12 | return res 13 | } 14 | --------------------------------------------------------------------------------