From 7c89d92851e758ce43742bf7558a4db95153442b Mon Sep 17 00:00:00 2001 From: Mehdi Bouaziz Date: Thu, 27 Sep 2018 04:05:12 -0700 Subject: [PATCH] [RFC] Format all java files Reviewed By: jeremydubreil Differential Revision: D10067033 fbshipit-source-id: 73975664e --- .../inferandroidexample/ApplicationTest.java | 10 +- .../infer/inferandroidexample/Generated.java | 1 - .../inferandroidexample/MainActivity.java | 95 +++--- .../main/java/infer/other/MainActivity.java | 3 +- examples/java_hello/Hello.java | 14 +- examples/java_hello/Pointers.java | 4 +- examples/java_hello/Resources.java | 1 - .../facebook/infer/annotation/Assertions.java | 8 +- .../facebook/infer/annotation/Expensive.java | 2 +- .../infer/annotation/FalseOnNull.java | 4 +- .../facebook/infer/annotation/Functional.java | 40 ++- .../infer/annotation/Initializer.java | 10 +- .../infer/annotation/IntegritySink.java | 9 +- .../infer/annotation/IntegritySource.java | 15 +- .../infer/annotation/NonBlocking.java | 6 +- .../facebook/infer/annotation/OkToExtend.java | 10 +- .../infer/annotation/PerformanceCritical.java | 2 +- .../facebook/infer/annotation/Present.java | 15 +- .../infer/annotation/PrivacySink.java | 9 +- .../infer/annotation/PrivacySource.java | 15 +- .../infer/annotation/PropagatesNullable.java | 7 +- .../infer/annotation/ReturnsOwnership.java | 7 +- .../infer/annotation/SuppressLint.java | 5 +- .../annotation/SuppressViewNullability.java | 4 +- .../annotation/SynchronizedCollection.java | 12 +- .../infer/annotation/ThreadConfined.java | 13 +- .../facebook/infer/annotation/ThreadSafe.java | 3 +- .../facebook/infer/annotation/TrueOnNull.java | 4 +- .../com/facebook/infer/annotation/Verify.java | 12 +- .../infer/builtins/InferBuiltins.java | 31 +- .../infer/builtins/InferCloseables.java | 4 +- .../facebook/infer/builtins/InferTaint.java | 9 +- .../infer/builtins/InferUndefined.java | 270 ++++++++---------- .../facebook/infer/builtins/InferUtils.java | 1 - .../models/java/src/android/app/Activity.java | 44 ++- .../java/src/android/app/AlarmManager.java | 1 - .../java/src/android/app/DownloadManager.java | 23 +- .../content/ContentProviderClient.java | 63 ++-- .../src/android/content/ContentResolver.java | 58 ++-- .../java/src/android/content/Context.java | 51 ++-- .../src/android/content/IContentProvider.java | 3 +- .../src/android/content/IContentService.java | 3 +- .../src/android/content/res/Resources.java | 51 ++-- .../src/android/content/res/TypedArray.java | 39 ++- .../src/android/database/AbstractCursor.java | 3 +- .../android/database/CrossProcessCursor.java | 3 +- .../database/CrossProcessCursorWrapper.java | 3 +- .../src/android/database/CursorWrapper.java | 6 +- .../database/sqlite/SQLiteConnectionPool.java | 4 +- .../android/database/sqlite/SQLiteCursor.java | 26 +- .../database/sqlite/SQLiteDatabase.java | 233 +++++++++------ .../sqlite/SQLiteDatabaseConfiguration.java | 3 +- .../database/sqlite/SQLiteQueryBuilder.java | 67 +++-- .../java/src/android/provider/MediaStore.java | 40 +-- .../java/src/android/text/TextUtils.java | 12 +- .../facebook/infer/annotation/Assertions.java | 1 - .../fasterxml/jackson/core/JsonFactory.java | 73 ++--- .../fasterxml/jackson/core/JsonParser.java | 35 +-- .../core/json/UTF8StreamJsonParser.java | 219 +++++++------- .../src/com/google/common/base/Optional.java | 3 +- .../com/google/common/base/Preconditions.java | 18 +- .../com/google/common/collect/Iterators.java | 5 +- .../src/com/google/common/io/Closeables.java | 17 +- .../java/src/dalvik/system/CloseGuard.java | 7 +- .../java/src/java/io/BufferedInputStream.java | 1 - .../src/java/io/BufferedOutputStream.java | 45 ++- .../java/src/java/io/BufferedWriter.java | 44 ++- .../java/src/java/io/DataInputStream.java | 104 ++++--- .../java/src/java/io/DataOutputStream.java | 98 ++++--- infer/models/java/src/java/io/File.java | 13 +- .../java/src/java/io/FileInputStream.java | 109 ++++--- .../java/src/java/io/FileOutputStream.java | 102 ++++--- .../java/src/java/io/FilterInputStream.java | 38 ++- .../java/src/java/io/FilterOutputStream.java | 45 ++- .../models/java/src/java/io/FilterReader.java | 37 ++- .../models/java/src/java/io/InputStream.java | 33 ++- .../java/src/java/io/InputStreamReader.java | 54 ++-- .../java/src/java/io/ObjectInputStream.java | 9 +- .../java/src/java/io/ObjectOutputStream.java | 136 ++++----- .../models/java/src/java/io/OutputStream.java | 1 - .../java/src/java/io/OutputStreamWriter.java | 68 ++--- .../java/src/java/io/PipedInputStream.java | 82 +++--- .../java/src/java/io/PipedOutputStream.java | 65 +++-- .../models/java/src/java/io/PipedReader.java | 77 +++-- .../models/java/src/java/io/PipedWriter.java | 119 ++++---- .../models/java/src/java/io/PrintWriter.java | 4 +- .../java/src/java/io/PushbackInputStream.java | 2 - .../java/src/java/io/PushbackReader.java | 55 ++-- .../java/src/java/io/RandomAccessFile.java | 244 ++++++++-------- infer/models/java/src/java/io/Reader.java | 65 +++-- infer/models/java/src/java/io/Writer.java | 78 +++-- infer/models/java/src/java/lang/Class.java | 32 +-- infer/models/java/src/java/lang/Integer.java | 5 +- .../src/java/lang/NullPointerException.java | 7 +- infer/models/java/src/java/lang/Object.java | 16 +- infer/models/java/src/java/lang/Process.java | 3 - .../java/src/java/lang/ProcessManager.java | 14 +- infer/models/java/src/java/lang/Runtime.java | 11 +- infer/models/java/src/java/lang/String.java | 86 +++--- infer/models/java/src/java/lang/System.java | 40 ++- infer/models/java/src/java/lang/Thread.java | 12 +- .../java/src/java/lang/reflect/Array.java | 48 ++-- .../java/src/java/net/HttpURLConnection.java | 14 +- .../java/src/java/net/JarURLConnection.java | 6 +- .../java/src/java/net/PlainSocketImpl.java | 170 ++++++----- .../java/src/java/net/ServerSocket.java | 12 +- infer/models/java/src/java/net/Socket.java | 4 +- infer/models/java/src/java/net/URL.java | 99 +++---- .../java/src/java/net/URLConnection.java | 37 ++- .../java/src/java/nio/FileChannelImpl.java | 122 ++++---- .../src/java/nio/channels/FileChannel.java | 38 +-- .../spi/AbstractInterruptibleChannel.java | 9 +- .../src/java/security/DigestInputStream.java | 5 - .../src/java/security/DigestOutputStream.java | 25 +- .../java/src/java/util/AbstractList.java | 1 - .../models/java/src/java/util/ArrayList.java | 2 - infer/models/java/src/java/util/HashMap.java | 32 +-- .../models/java/src/java/util/LinkedList.java | 6 +- infer/models/java/src/java/util/List.java | 2 - .../models/java/src/java/util/Properties.java | 61 ++-- infer/models/java/src/java/util/Scanner.java | 8 +- infer/models/java/src/java/util/Vector.java | 59 ++-- .../java/src/java/util/concurrent/Lock.java | 74 +++-- .../java/util/concurrent/ReentrantLock.java | 108 ++++--- .../java/src/java/util/jar/JarFile.java | 45 ++- .../src/java/util/jar/JarInputStream.java | 3 - .../src/java/util/jar/JarOutputStream.java | 4 - .../src/java/util/zip/CheckedInputStream.java | 4 - .../java/util/zip/CheckedOutputStream.java | 25 +- .../java/src/java/util/zip/Deflater.java | 1 - .../java/util/zip/DeflaterInputStream.java | 6 - .../java/util/zip/DeflaterOutputStream.java | 64 ++--- .../src/java/util/zip/GZIPInputStream.java | 3 - .../src/java/util/zip/GZIPOutputStream.java | 23 +- .../java/src/java/util/zip/Inflater.java | 1 - .../java/util/zip/InflaterInputStream.java | 39 ++- .../java/util/zip/InflaterOutputStream.java | 56 ++-- .../java/src/java/util/zip/ZipFile.java | 8 +- .../src/java/util/zip/ZipInputStream.java | 8 +- .../src/java/util/zip/ZipOutputStream.java | 20 +- .../src/javax/crypto/CipherInputStream.java | 4 - .../src/javax/crypto/CipherOutputStream.java | 44 ++- .../src/javax/net/ssl/HttpsURLConnection.java | 25 +- .../src/javax/net/ssl/SSLSocketFactory.java | 7 +- .../java/src/junit/framework/Assert.java | 25 +- .../org/assertj/core/util/Preconditions.java | 1 - infer/tests/build_systems/ant/issues.exp | 68 ++--- .../buck_cross_module/module1/Class1.java | 1 - .../buck_cross_module/module2/Class2.java | 1 - .../codetoanalyze/make/Hello.java | 9 +- .../codetoanalyze/make/Pointers.java | 4 +- .../codetoanalyze/make/Resources.java | 1 - .../src/main/java/com/mycompany/Hello2.java | 14 +- .../src/main/java/com/mycompany/Hello.java | 9 +- .../src/main/java/com/mycompany/Pointers.java | 4 +- .../main/java/com/mycompany/Resources.java | 1 - .../src/SimpleInterfaceExample.java | 2 +- .../src/SimpleNestedInterface.java | 2 +- .../genrule/annotations/Nullable.java | 3 +- .../module1/SkipImplementationClass1.java | 1 - infer/tests/build_systems/gradle/issues.exp | 2 +- infer/tests/build_systems/make/issues.exp | 2 +- infer/tests/build_systems/mvn/issues.exp | 10 +- .../build_systems/racerd_dedup/issues.exp | 14 +- .../build_systems/racerd_dedup/src/DeDup.java | 47 ++- .../racerd_dedup/src/Locals.java | 4 +- .../racerd_traces/module1/Class1.java | 1 - .../racerd_traces/module2/Class2.java | 1 - .../racerd_traces/module3/Class3.java | 12 +- .../SimpleLeak.java | 22 +- .../build_systems/utf8_in_pwd/issues.exp | 4 +- infer/tests/build_systems/waf/issues.exp | 2 +- ...notationReachabilityDuplicatesExample.java | 6 +- .../codetoanalyze/java/checkers/Branch.java | 1 - .../java/checkers/CustomAnnotations.java | 15 +- .../java/checkers/ExpensiveCallExample.java | 27 +- .../checkers/ExpensiveInheritanceExample.java | 3 - .../checkers/ExpensiveInterfaceExample.java | 14 +- .../checkers/ExpensiveSubtypingExample.java | 1 - .../FragmentDoesNotRetainViewExample.java | 3 - .../checkers/FragmentRetainsViewExample.java | 2 - .../java/checkers/ImmutableCast.java | 2 - .../java/checkers/NoAllocationExample.java | 3 +- .../java/checkers/NullableSuggest.java | 33 ++- .../java/checkers/PrintfArgsChecker.java | 7 +- .../java/checkers/TraceCallSequence.java | 7 +- .../java/checkers/TwoCheckersExample.java | 5 +- .../java/checkers/UiThreads.java | 11 +- .../crashcontext/BranchingCallsExample.java | 1 - .../crashcontext/MethodNameClashExample.java | 3 - .../crashcontext/MinimalCrashExample.java | 1 - .../MultiStackFrameCrashExample.java | 1 - .../crashcontext/NativeMethodExample.java | 3 +- .../ActivityFieldNotInitialized.java | 5 +- .../java/eradicate/CustomAnnotations.java | 5 +- .../java/eradicate/FieldNotInitialized.java | 22 +- .../java/eradicate/FieldNotNullable.java | 94 +++--- .../InconsistentSubclassAnnotation.java | 27 +- ...consistentSubclassAnnotationInterface.java | 1 - .../java/eradicate/JunitExample.java | 1 - .../java/eradicate/LibraryCalls.java | 1 - .../java/eradicate/MyPreconditions.java | 1 - .../eradicate/NoReuseUndefFunctionValues.java | 1 - .../java/eradicate/NullFieldAccess.java | 11 +- .../java/eradicate/NullMethodCall.java | 51 ++-- .../java/eradicate/ParameterNotNullable.java | 19 +- .../java/eradicate/PresentTest.java | 24 +- .../java/eradicate/ReturnNotNullable.java | 21 +- .../SuppressedFieldNotInitializedExample.java | 13 +- .../codetoanalyze/java/eradicate/issues.exp | 106 +++---- .../codetoanalyze/java/hoisting/Hoist.java | 7 +- .../java/infer/AnalysisStops.java | 1 - .../java/infer/ArrayOutOfBounds.java | 2 - .../codetoanalyze/java/infer/Builtins.java | 1 - .../java/infer/ClassCastExceptions.java | 11 +- .../infer/CloseableAsResourceExample.java | 29 +- .../codetoanalyze/java/infer/CursorLeaks.java | 75 ++--- .../codetoanalyze/java/infer/CursorNPEs.java | 21 +- .../java/infer/DivideByZero.java | 6 +- .../java/infer/DynamicDispatch.java | 13 +- .../java/infer/FilterInputStreamLeaks.java | 27 +- .../java/infer/FilterOutputStreamLeaks.java | 59 ++-- .../java/infer/GuardedByExample.java | 85 +++--- .../java/infer/HashMapExample.java | 43 ++- .../java/infer/IntegerExample.java | 24 +- .../java/infer/InvokeDynamic.java | 29 +- .../java/infer/JunitAssertion.java | 3 +- .../tests/codetoanalyze/java/infer/Lists.java | 2 - .../java/infer/NeverNullSource.java | 4 +- .../java/infer/NullPointerExceptions.java | 71 ++--- .../codetoanalyze/java/infer/ReaderLeaks.java | 22 +- .../java/infer/ResourceLeaks.java | 108 +++---- .../java/infer/ReturnValueIgnored.java | 2 - .../java/infer/SkippedSourceFile.java | 2 - .../codetoanalyze/java/infer/SomeLibrary.java | 1 - .../java/infer/SuppressLintExample.java | 9 +- infer/tests/codetoanalyze/java/infer/T.java | 3 +- .../tests/codetoanalyze/java/infer/Utils.java | 13 +- .../codetoanalyze/java/infer/WriterLeaks.java | 38 +-- .../tests/codetoanalyze/java/infer/issues.exp | 28 +- infer/tests/codetoanalyze/java/lab/Leaks.java | 1 - .../java/litho/RequiredProps.java | 83 ++---- .../java/litho/ShouldUpdate.java | 27 +- .../codetoanalyze/java/performance/Array.java | 1 + .../java/performance/ArrayListTest.java | 1 - .../codetoanalyze/java/performance/Break.java | 53 ++-- .../java/performance/CollectionTest.java | 4 +- .../java/performance/Compound_loop.java | 51 ++-- .../java/performance/Continue.java | 18 +- .../java/performance/Cost_test_deps.java | 154 +++++----- .../java/performance/FieldAccess.java | 17 +- .../java/performance/IteratorTest.java | 1 + .../java/performance/JsonArray.java | 2 - .../java/performance/JsonMap.java | 3 +- .../java/performance/JsonString.java | 1 - .../java/performance/JsonType.java | 4 +- .../java/performance/JsonUtils.java | 12 +- .../codetoanalyze/java/performance/Loops.java | 36 +-- .../java/performance/Switch.java | 47 +-- .../codetoanalyze/java/performance/issues.exp | 8 +- .../tests/codetoanalyze/java/purity/Test.java | 6 +- .../codetoanalyze/java/quandary/Arrays.java | 3 - .../codetoanalyze/java/quandary/Basics.java | 60 ++-- .../java/quandary/ContentProviders.java | 18 +- .../java/quandary/DynamicDispatch.java | 16 +- .../java/quandary/Exceptions.java | 5 +- .../java/quandary/ExternalSpecs.java | 9 +- .../codetoanalyze/java/quandary/Fields.java | 3 - .../codetoanalyze/java/quandary/Files.java | 1 - .../java/quandary/FlowSensitivity.java | 2 - .../codetoanalyze/java/quandary/Intents.java | 41 ++- .../java/quandary/Interprocedural.java | 13 +- .../java/quandary/LoggingPrivateData.java | 62 ++-- .../java/quandary/Recursion.java | 1 - .../java/quandary/Serialization.java | 4 +- .../codetoanalyze/java/quandary/Services.java | 17 +- .../codetoanalyze/java/quandary/Strings.java | 13 +- .../java/quandary/TaintExample.java | 54 ++-- .../java/quandary/TaintedFormals.java | 7 +- .../codetoanalyze/java/quandary/Traces.java | 1 - .../java/quandary/UnknownCode.java | 7 +- .../java/quandary/UserControlledStrings.java | 10 +- .../codetoanalyze/java/quandary/WebViews.java | 9 +- .../codetoanalyze/java/quandary/issues.exp | 4 +- .../codetoanalyze/java/racerd/Alias.java | 24 +- .../java/racerd/AndroidModels.java | 12 +- .../java/racerd/Annotations.java | 126 ++++---- .../codetoanalyze/java/racerd/Arrays.java | 7 +- .../codetoanalyze/java/racerd/Builders.java | 4 - .../java/racerd/Constructors.java | 1 - .../codetoanalyze/java/racerd/Containers.java | 50 ++-- .../java/racerd/DeepOwnership.java | 20 +- .../codetoanalyze/java/racerd/Dispatch.java | 25 +- .../codetoanalyze/java/racerd/Escape.java | 4 +- .../codetoanalyze/java/racerd/Inference.java | 4 +- .../codetoanalyze/java/racerd/Locks.java | 12 +- .../java/racerd/NotThreadSafeExample.java | 6 +- .../codetoanalyze/java/racerd/Ownership.java | 46 +-- .../java/racerd/RaceWithMainThread.java | 216 +++++++------- .../java/racerd/ReadWriteRaces.java | 31 +- .../java/racerd/SkippedClass.java | 1 - .../codetoanalyze/java/racerd/SubFld.java | 8 +- .../codetoanalyze/java/racerd/SwitchEnum.java | 17 +- .../java/racerd/ThreadSafeExample.java | 28 +- .../java/racerd/ThreadSafeMethods.java | 6 +- .../codetoanalyze/java/racerd/issues.exp | 188 ++++++------ .../java/stability/Interprocedural.java | 117 ++++---- .../java/stability/Intraprocedural.java | 115 ++++---- .../codetoanalyze/java/stability/issues.exp | 4 +- .../codetoanalyze/java/starvation/AccMgr.java | 5 +- .../java/starvation/AsyncTaskGet.java | 31 +- .../java/starvation/Countdwn.java | 2 +- .../codetoanalyze/java/starvation/Dedup.java | 17 +- .../java/starvation/FutureGet.java | 34 ++- .../java/starvation/IndirectBlock.java | 14 +- .../java/starvation/InnerClass.java | 10 +- .../java/starvation/Interclass.java | 9 +- .../java/starvation/Interproc.java | 15 +- .../java/starvation/Intraproc.java | 27 +- .../codetoanalyze/java/starvation/JavaIO.java | 6 +- .../java/starvation/LegacySync.java | 8 +- .../java/starvation/LocalLock.java | 10 +- .../java/starvation/MainThreadTest.java | 4 +- .../java/starvation/MyActivity.java | 5 +- .../codetoanalyze/java/starvation/NonBlk.java | 13 +- .../java/starvation/ObjWait.java | 15 +- .../java/starvation/OurThreadUtils.java | 10 +- .../java/starvation/PubPriv.java | 10 +- .../java/starvation/ServiceOnUIThread.java | 12 +- .../java/starvation/StaticLock.java | 9 +- .../java/starvation/SuppLint.java | 8 +- .../java/starvation/ThreadSleep.java | 7 +- .../java/starvation/UIDeadlock.java | 16 +- .../codetoanalyze/java/starvation/issues.exp | 48 ++-- ...ArrayIndexOutOfBoundsExceptionExample.java | 1 - .../tracing/ClassCastExceptionExample.java | 1 - .../tracing/LazyDynamicDispatchExample.java | 3 - .../LocallyDefinedExceptionExample.java | 3 - .../tracing/NullPointerExceptionExample.java | 1 - .../java/tracing/ReportOnMainExample.java | 1 - .../tests/codetoanalyze/java/tracing/T2.java | 5 +- .../tracing/UnavoidableExceptionExample.java | 1 - 342 files changed, 4113 insertions(+), 4823 deletions(-) diff --git a/examples/android_hello/app/src/androidTest/java/infer/inferandroidexample/ApplicationTest.java b/examples/android_hello/app/src/androidTest/java/infer/inferandroidexample/ApplicationTest.java index fed216471..bc29537b5 100644 --- a/examples/android_hello/app/src/androidTest/java/infer/inferandroidexample/ApplicationTest.java +++ b/examples/android_hello/app/src/androidTest/java/infer/inferandroidexample/ApplicationTest.java @@ -10,11 +10,9 @@ package infer.inferandroidexample; import android.app.Application; import android.test.ApplicationTestCase; -/** - * Testing Fundamentals - */ +/** Testing Fundamentals */ public class ApplicationTest extends ApplicationTestCase { - public ApplicationTest() { - super(Application.class); - } + public ApplicationTest() { + super(Application.class); + } } diff --git a/examples/android_hello/app/src/main/java/infer/inferandroidexample/Generated.java b/examples/android_hello/app/src/main/java/infer/inferandroidexample/Generated.java index 9d18fe717..20cba1c0c 100644 --- a/examples/android_hello/app/src/main/java/infer/inferandroidexample/Generated.java +++ b/examples/android_hello/app/src/main/java/infer/inferandroidexample/Generated.java @@ -14,5 +14,4 @@ public class Generated { static Object returnsNull() { return null; } - } diff --git a/examples/android_hello/app/src/main/java/infer/inferandroidexample/MainActivity.java b/examples/android_hello/app/src/main/java/infer/inferandroidexample/MainActivity.java index 1786ef18e..8d77ed5de 100644 --- a/examples/android_hello/app/src/main/java/infer/inferandroidexample/MainActivity.java +++ b/examples/android_hello/app/src/main/java/infer/inferandroidexample/MainActivity.java @@ -7,73 +7,71 @@ package infer.inferandroidexample; -import android.support.v7.app.ActionBarActivity; import android.os.Bundle; +import android.support.v7.app.ActionBarActivity; import android.view.Menu; import android.view.MenuItem; - import java.io.FileOutputStream; import java.io.IOException; import java.util.Calendar; - public class MainActivity extends ActionBarActivity { - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); - String s = getDay(); - int length = s.length(); - writeToFile(); - } - - private String getDay() { - if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY) { - return "Wednesday"; - } else { - return otherOutput(); - } - } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + String s = getDay(); + int length = s.length(); + writeToFile(); + } - private String otherOutput() { - return null; + private String getDay() { + if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY) { + return "Wednesday"; + } else { + return otherOutput(); } + } - private void writeToFile() { - byte[] arr = {1, 2, 3}; - FileOutputStream fis; - try { - fis = new FileOutputStream("file.txt"); - fis.write(arr); - fis.close(); - } catch (IOException e) { - //Deal with exception - } - } + private String otherOutput() { + return null; + } - @Override - public boolean onCreateOptionsMenu(Menu menu) { - // Inflate the menu; this adds items to the action bar if it is present. - getMenuInflater().inflate(R.menu.menu_main, menu); - return true; + private void writeToFile() { + byte[] arr = {1, 2, 3}; + FileOutputStream fis; + try { + fis = new FileOutputStream("file.txt"); + fis.write(arr); + fis.close(); + } catch (IOException e) { + // Deal with exception } + } - @Override - public boolean onOptionsItemSelected(MenuItem item) { - // Handle action bar item clicks here. The action bar will - // automatically handle clicks on the Home/Up button, so long - // as you specify a parent activity in AndroidManifest.xml. - int id = item.getItemId(); + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_main, menu); + return true; + } - //noinspection SimplifiableIfStatement - if (id == R.id.action_settings) { - return true; - } + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); - return super.onOptionsItemSelected(item); + //noinspection SimplifiableIfStatement + if (id == R.id.action_settings) { + return true; } + return super.onOptionsItemSelected(item); + } + private void inferShouldNotReport() { // Generated.java is supposed to be skipped by infer, thus even though // Generated.returnsNull() returns null, infer is not supposed to know @@ -81,5 +79,4 @@ public class MainActivity extends ActionBarActivity { Object o = Generated.returnsNull(); o.toString(); } - } diff --git a/examples/android_hello/app/src/main/java/infer/other/MainActivity.java b/examples/android_hello/app/src/main/java/infer/other/MainActivity.java index 82f09c9af..e59d83d36 100644 --- a/examples/android_hello/app/src/main/java/infer/other/MainActivity.java +++ b/examples/android_hello/app/src/main/java/infer/other/MainActivity.java @@ -8,8 +8,8 @@ package infer.other; import android.annotation.SuppressLint; -import android.support.v7.app.ActionBarActivity; import android.os.Bundle; +import android.support.v7.app.ActionBarActivity; public class MainActivity extends ActionBarActivity { @@ -26,5 +26,4 @@ public class MainActivity extends ActionBarActivity { void shouldNotBeReported() { source().toString(); } - } diff --git a/examples/java_hello/Hello.java b/examples/java_hello/Hello.java index 99d40ae4a..e51e8ca4b 100644 --- a/examples/java_hello/Hello.java +++ b/examples/java_hello/Hello.java @@ -42,9 +42,8 @@ class Hello { } /** - * This method should be rewritten with nested try { ... } finally { - * ... } statements, or the possible exception raised by fis.close() - * should be swallowed. + * This method should be rewritten with nested try { ... } finally { ... } statements, or the + * possible exception raised by fis.close() should be swallowed. */ void twoResources() throws IOException { FileInputStream fis = null; @@ -54,9 +53,12 @@ class Hello { fos = new FileOutputStream(new File("everwhat.txt")); fos.write(fis.read()); } finally { - if (fis != null) { fis.close(); } - if (fos != null) { fos.close(); } + if (fis != null) { + fis.close(); + } + if (fos != null) { + fos.close(); + } } } - } diff --git a/examples/java_hello/Pointers.java b/examples/java_hello/Pointers.java index 240f9a03a..4f0001187 100644 --- a/examples/java_hello/Pointers.java +++ b/examples/java_hello/Pointers.java @@ -10,8 +10,7 @@ package hello; public class Pointers { public static class A { - public void method() { - } + public void method() {} } public static A mayReturnNull(int i) { @@ -20,5 +19,4 @@ public class Pointers { } return null; } - } diff --git a/examples/java_hello/Resources.java b/examples/java_hello/Resources.java index feda5e458..0f4f7201d 100644 --- a/examples/java_hello/Resources.java +++ b/examples/java_hello/Resources.java @@ -21,5 +21,4 @@ public class Resources { return null; } } - } diff --git a/infer/annotations/src/main/java/com/facebook/infer/annotation/Assertions.java b/infer/annotations/src/main/java/com/facebook/infer/annotation/Assertions.java index 3cffc1607..c950ac7da 100644 --- a/infer/annotations/src/main/java/com/facebook/infer/annotation/Assertions.java +++ b/infer/annotations/src/main/java/com/facebook/infer/annotation/Assertions.java @@ -7,9 +7,9 @@ package com.facebook.infer.annotation; -import javax.annotation.Nullable; import java.util.List; import java.util.Map; +import javax.annotation.Nullable; public class Assertions { @@ -53,11 +53,9 @@ public class Assertions { return assertNotNull(map.get(key)); } - public static void assumeCondition(boolean condition) { - } + public static void assumeCondition(boolean condition) {} - public static void assumeCondition(boolean condition, String explanation) { - } + public static void assumeCondition(boolean condition, String explanation) {} public static void assertCondition(boolean condition) { if (!condition) { diff --git a/infer/annotations/src/main/java/com/facebook/infer/annotation/Expensive.java b/infer/annotations/src/main/java/com/facebook/infer/annotation/Expensive.java index 6577d2f21..0c4febe0a 100644 --- a/infer/annotations/src/main/java/com/facebook/infer/annotation/Expensive.java +++ b/infer/annotations/src/main/java/com/facebook/infer/annotation/Expensive.java @@ -13,5 +13,5 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @Retention(RetentionPolicy.CLASS) -@Target({ ElementType.METHOD, ElementType.TYPE }) +@Target({ElementType.METHOD, ElementType.TYPE}) public @interface Expensive {} diff --git a/infer/annotations/src/main/java/com/facebook/infer/annotation/FalseOnNull.java b/infer/annotations/src/main/java/com/facebook/infer/annotation/FalseOnNull.java index 021b73949..ec3cb3a62 100644 --- a/infer/annotations/src/main/java/com/facebook/infer/annotation/FalseOnNull.java +++ b/infer/annotations/src/main/java/com/facebook/infer/annotation/FalseOnNull.java @@ -12,9 +12,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -/** - * Annotation for a boolean function returning false when the argument is null. - */ +/** Annotation for a boolean function returning false when the argument is null. */ @Retention(RetentionPolicy.CLASS) @Target({ElementType.METHOD}) public @interface FalseOnNull {} diff --git a/infer/annotations/src/main/java/com/facebook/infer/annotation/Functional.java b/infer/annotations/src/main/java/com/facebook/infer/annotation/Functional.java index e68ebb946..de47fe182 100644 --- a/infer/annotations/src/main/java/com/facebook/infer/annotation/Functional.java +++ b/infer/annotations/src/main/java/com/facebook/infer/annotation/Functional.java @@ -12,29 +12,23 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -/** Annotation for methods that always return the same value. The annotation is inherited by - * overrides of methods. - * - * This annotation is used to suppress benign race warnings on fields assigned to methods annotated - * with {@literal @Functional} in the thread-safety analysis. For example: - * - * T mField; - * {@literal @Functional} T someMethod(); - * public void getField() { - * if (mField == null) { - * mField = someMethod(); - * } - * return mField; - * } - * - * Normally, we'd report that the access to mField is unsafe, but we won't report here because of - * the {@literal @Functional} annotation. - * - * If the return value of the annotated function is a double or long, the annotation will be - * ignored because writes to doubles/longs are not guaranteed to be atomic. That is, if type T was - * `long` in the example above, the write-write race on mField would no longer be benign. -*/ - +/** + * Annotation for methods that always return the same value. The annotation is inherited by + * overrides of methods. + * + *

This annotation is used to suppress benign race warnings on fields assigned to methods + * annotated with {@literal @Functional} in the thread-safety analysis. For example: + * + *

T mField; {@literal @Functional} T someMethod(); public void getField() { if (mField == null) + * { mField = someMethod(); } return mField; } + * + *

Normally, we'd report that the access to mField is unsafe, but we won't report here because of + * the {@literal @Functional} annotation. + * + *

If the return value of the annotated function is a double or long, the annotation will be + * ignored because writes to doubles/longs are not guaranteed to be atomic. That is, if type T was + * `long` in the example above, the write-write race on mField would no longer be benign. + */ @Target({ElementType.METHOD}) @Retention(RetentionPolicy.CLASS) public @interface Functional {} diff --git a/infer/annotations/src/main/java/com/facebook/infer/annotation/Initializer.java b/infer/annotations/src/main/java/com/facebook/infer/annotation/Initializer.java index cd1d9001c..8909669e9 100644 --- a/infer/annotations/src/main/java/com/facebook/infer/annotation/Initializer.java +++ b/infer/annotations/src/main/java/com/facebook/infer/annotation/Initializer.java @@ -13,11 +13,11 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** - * A method annotated with @Initializer should always be be called before the object is used. - * Users of the class and static checkers must enforce, and can rely on, this invariant. - * Examples include methods called indirectly by the constructor, protocols of init-then-use - * where some values are initialized after construction but before the first use, - * and builder classes where an object initialization must complete before build() is called. + * A method annotated with @Initializer should always be be called before the object is used. Users + * of the class and static checkers must enforce, and can rely on, this invariant. Examples include + * methods called indirectly by the constructor, protocols of init-then-use where some values are + * initialized after construction but before the first use, and builder classes where an object + * initialization must complete before build() is called. */ @Retention(RetentionPolicy.CLASS) @Target({ElementType.TYPE, ElementType.FIELD, ElementType.CONSTRUCTOR, ElementType.METHOD}) diff --git a/infer/annotations/src/main/java/com/facebook/infer/annotation/IntegritySink.java b/infer/annotations/src/main/java/com/facebook/infer/annotation/IntegritySink.java index 2baef6148..5d5b367cd 100644 --- a/infer/annotations/src/main/java/com/facebook/infer/annotation/IntegritySink.java +++ b/infer/annotations/src/main/java/com/facebook/infer/annotation/IntegritySink.java @@ -13,9 +13,6 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @Retention(RetentionPolicy.CLASS) -@Target( - ElementType.PARAMETER // a user-controlled should not flow to this parameter - ) - -public @interface IntegritySink { -} +@Target(ElementType.PARAMETER // a user-controlled should not flow to this parameter +) +public @interface IntegritySink {} diff --git a/infer/annotations/src/main/java/com/facebook/infer/annotation/IntegritySource.java b/infer/annotations/src/main/java/com/facebook/infer/annotation/IntegritySource.java index 9162c36dc..a745c9e23 100644 --- a/infer/annotations/src/main/java/com/facebook/infer/annotation/IntegritySource.java +++ b/infer/annotations/src/main/java/com/facebook/infer/annotation/IntegritySource.java @@ -13,11 +13,10 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @Retention(RetentionPolicy.CLASS) -@Target(value={ - ElementType.METHOD, // method returns something user-controlled - ElementType.PARAMETER, // parameter is user-controlled - ElementType.FIELD, // field is user-controlled - }) - -public @interface IntegritySource { -} +@Target( + value = { + ElementType.METHOD, // method returns something user-controlled + ElementType.PARAMETER, // parameter is user-controlled + ElementType.FIELD, // field is user-controlled + }) +public @interface IntegritySource {} diff --git a/infer/annotations/src/main/java/com/facebook/infer/annotation/NonBlocking.java b/infer/annotations/src/main/java/com/facebook/infer/annotation/NonBlocking.java index 507caa389..d1a09e8c5 100644 --- a/infer/annotations/src/main/java/com/facebook/infer/annotation/NonBlocking.java +++ b/infer/annotations/src/main/java/com/facebook/infer/annotation/NonBlocking.java @@ -13,11 +13,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @Retention(RetentionPolicy.CLASS) -@Target({ - ElementType.CONSTRUCTOR, - ElementType.METHOD, - ElementType.TYPE -}) +@Target({ElementType.CONSTRUCTOR, ElementType.METHOD, ElementType.TYPE}) // Signal to the starvation checker that the method (or all the methods of the class, // if at class level) does not perform any potentially blocking operations. Can be used to diff --git a/infer/annotations/src/main/java/com/facebook/infer/annotation/OkToExtend.java b/infer/annotations/src/main/java/com/facebook/infer/annotation/OkToExtend.java index 7b26b4a1d..352d9d1ed 100644 --- a/infer/annotations/src/main/java/com/facebook/infer/annotation/OkToExtend.java +++ b/infer/annotations/src/main/java/com/facebook/infer/annotation/OkToExtend.java @@ -13,12 +13,10 @@ import java.lang.annotation.RetentionPolicy; /** * Marks a class as one that is expected to be extended. * - * This annotation is meant to counter common misuses of subclassing. Annotate your class with this - * only if it was built with the purpose of being extended. + *

This annotation is meant to counter common misuses of subclassing. Annotate your class with + * this only if it was built with the purpose of being extended. * - * Avoid adding this to classes that have existed for a long time without needing it. + *

Avoid adding this to classes that have existed for a long time without needing it. */ @Retention(RetentionPolicy.SOURCE) -public @interface OkToExtend { - -} +public @interface OkToExtend {} diff --git a/infer/annotations/src/main/java/com/facebook/infer/annotation/PerformanceCritical.java b/infer/annotations/src/main/java/com/facebook/infer/annotation/PerformanceCritical.java index 5f47614bf..030c186f7 100644 --- a/infer/annotations/src/main/java/com/facebook/infer/annotation/PerformanceCritical.java +++ b/infer/annotations/src/main/java/com/facebook/infer/annotation/PerformanceCritical.java @@ -13,5 +13,5 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @Retention(RetentionPolicy.CLASS) -@Target(value={ElementType.METHOD, ElementType.TYPE}) +@Target(value = {ElementType.METHOD, ElementType.TYPE}) public @interface PerformanceCritical {} diff --git a/infer/annotations/src/main/java/com/facebook/infer/annotation/Present.java b/infer/annotations/src/main/java/com/facebook/infer/annotation/Present.java index 3e4282c7e..ba6e531b0 100644 --- a/infer/annotations/src/main/java/com/facebook/infer/annotation/Present.java +++ b/infer/annotations/src/main/java/com/facebook/infer/annotation/Present.java @@ -13,11 +13,16 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** - * A class field, or method return/parameter type, of Optional type is annotated @Present - * to indicate that its value cannot be absent. - * Users of the method/field and static checkers must enforce, and can rely on, this invariant. + * A class field, or method return/parameter type, of Optional type is annotated @Present to + * indicate that its value cannot be absent. Users of the method/field and static checkers must + * enforce, and can rely on, this invariant. */ @Retention(RetentionPolicy.CLASS) -@Target({ElementType.TYPE, ElementType.FIELD, ElementType.CONSTRUCTOR, - ElementType.METHOD, ElementType.PARAMETER}) +@Target({ + ElementType.TYPE, + ElementType.FIELD, + ElementType.CONSTRUCTOR, + ElementType.METHOD, + ElementType.PARAMETER +}) public @interface Present {} diff --git a/infer/annotations/src/main/java/com/facebook/infer/annotation/PrivacySink.java b/infer/annotations/src/main/java/com/facebook/infer/annotation/PrivacySink.java index dc211f3c3..50f76990e 100644 --- a/infer/annotations/src/main/java/com/facebook/infer/annotation/PrivacySink.java +++ b/infer/annotations/src/main/java/com/facebook/infer/annotation/PrivacySink.java @@ -13,9 +13,6 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @Retention(RetentionPolicy.CLASS) -@Target( - ElementType.PARAMETER // a privacy source should not flow to this parameter - ) - -public @interface PrivacySink { -} +@Target(ElementType.PARAMETER // a privacy source should not flow to this parameter +) +public @interface PrivacySink {} diff --git a/infer/annotations/src/main/java/com/facebook/infer/annotation/PrivacySource.java b/infer/annotations/src/main/java/com/facebook/infer/annotation/PrivacySource.java index b59b5f586..4abd800e5 100644 --- a/infer/annotations/src/main/java/com/facebook/infer/annotation/PrivacySource.java +++ b/infer/annotations/src/main/java/com/facebook/infer/annotation/PrivacySource.java @@ -13,11 +13,10 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @Retention(RetentionPolicy.CLASS) -@Target(value={ - ElementType.METHOD, // method returns something private - ElementType.PARAMETER, // parameter is private - ElementType.FIELD, // field is private - }) - -public @interface PrivacySource { -} +@Target( + value = { + ElementType.METHOD, // method returns something private + ElementType.PARAMETER, // parameter is private + ElementType.FIELD, // field is private + }) +public @interface PrivacySource {} diff --git a/infer/annotations/src/main/java/com/facebook/infer/annotation/PropagatesNullable.java b/infer/annotations/src/main/java/com/facebook/infer/annotation/PropagatesNullable.java index d910e69b6..ef60d4892 100644 --- a/infer/annotations/src/main/java/com/facebook/infer/annotation/PropagatesNullable.java +++ b/infer/annotations/src/main/java/com/facebook/infer/annotation/PropagatesNullable.java @@ -12,10 +12,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -/** - * Annotation to indicate that when the parameter is null, the result is also null. - */ +/** Annotation to indicate that when the parameter is null, the result is also null. */ @Retention(RetentionPolicy.CLASS) @Target({ElementType.PARAMETER}) -public @interface PropagatesNullable { -} +public @interface PropagatesNullable {} diff --git a/infer/annotations/src/main/java/com/facebook/infer/annotation/ReturnsOwnership.java b/infer/annotations/src/main/java/com/facebook/infer/annotation/ReturnsOwnership.java index 124e7cead..26d761562 100644 --- a/infer/annotations/src/main/java/com/facebook/infer/annotation/ReturnsOwnership.java +++ b/infer/annotations/src/main/java/com/facebook/infer/annotation/ReturnsOwnership.java @@ -15,10 +15,9 @@ import java.lang.annotation.Target; /** * Tell the thread-safety analysis that this method transfers ownership of its return value to its * caller. Ownership means that the caller is allowed to both read and write the value outside of - * synchronization. The annotated method should not retain any references to the value. - * This annotation is trusted for now, but may be checked eventually. + * synchronization. The annotated method should not retain any references to the value. This + * annotation is trusted for now, but may be checked eventually. */ @Target(ElementType.METHOD) @Retention(RetentionPolicy.CLASS) -public @interface ReturnsOwnership { -} +public @interface ReturnsOwnership {} diff --git a/infer/annotations/src/main/java/com/facebook/infer/annotation/SuppressLint.java b/infer/annotations/src/main/java/com/facebook/infer/annotation/SuppressLint.java index 504b81c87..6fda01453 100644 --- a/infer/annotations/src/main/java/com/facebook/infer/annotation/SuppressLint.java +++ b/infer/annotations/src/main/java/com/facebook/infer/annotation/SuppressLint.java @@ -14,10 +14,9 @@ import java.lang.annotation.Target; @Retention(RetentionPolicy.CLASS) @Target({ - ElementType.CONSTRUCTOR, - ElementType.METHOD, + ElementType.CONSTRUCTOR, + ElementType.METHOD, }) - public @interface SuppressLint { String[] value(); } diff --git a/infer/annotations/src/main/java/com/facebook/infer/annotation/SuppressViewNullability.java b/infer/annotations/src/main/java/com/facebook/infer/annotation/SuppressViewNullability.java index a6f0a0021..176230822 100644 --- a/infer/annotations/src/main/java/com/facebook/infer/annotation/SuppressViewNullability.java +++ b/infer/annotations/src/main/java/com/facebook/infer/annotation/SuppressViewNullability.java @@ -13,8 +13,8 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** - * View can be annotated with @SuppressViewNullability to silence warnings when - * a view is set to null in a destructor, and created in an initializer. + * View can be annotated with @SuppressViewNullability to silence warnings when a view is set to + * null in a destructor, and created in an initializer. */ @Retention(RetentionPolicy.CLASS) @Target(ElementType.FIELD) diff --git a/infer/annotations/src/main/java/com/facebook/infer/annotation/SynchronizedCollection.java b/infer/annotations/src/main/java/com/facebook/infer/annotation/SynchronizedCollection.java index a28a898d4..e1bbe5a0c 100644 --- a/infer/annotations/src/main/java/com/facebook/infer/annotation/SynchronizedCollection.java +++ b/infer/annotations/src/main/java/com/facebook/infer/annotation/SynchronizedCollection.java @@ -13,12 +13,10 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** - * Tell the analysis that a collection is thread-safe when this information is not already - * reflected in the collection's type. For example: - * private {@literal @SynchronizedCollection} Map mMap = Collections.synchronizedMap(...); + * Tell the analysis that a collection is thread-safe when this information is not already reflected + * in the collection's type. For example: private {@literal @SynchronizedCollection} Map mMap = + * Collections.synchronizedMap(...); */ - -@Target({ ElementType.FIELD }) +@Target({ElementType.FIELD}) @Retention(RetentionPolicy.CLASS) -public @interface SynchronizedCollection { -} +public @interface SynchronizedCollection {} diff --git a/infer/annotations/src/main/java/com/facebook/infer/annotation/ThreadConfined.java b/infer/annotations/src/main/java/com/facebook/infer/annotation/ThreadConfined.java index 5bbfd9e61..58b6125f2 100644 --- a/infer/annotations/src/main/java/com/facebook/infer/annotation/ThreadConfined.java +++ b/infer/annotations/src/main/java/com/facebook/infer/annotation/ThreadConfined.java @@ -17,12 +17,13 @@ import java.lang.annotation.Target; * class/field/method are confined to the given thread name. For the thread name, you can either use * the default constants UI/ANY or add your own. */ - -@Target({ ElementType.TYPE, ElementType.FIELD, ElementType.METHOD }) +@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD}) @Retention(RetentionPolicy.CLASS) public @interface ThreadConfined { - String value(); /** the thread that the mutations should be confined to */ - public static String UI = "UI"; /** confined to the UI thread */ - public static String ANY = "ANY"; /** confined to any thread (but only that thread!) */ - + String value(); + /** the thread that the mutations should be confined to */ + public static String UI = "UI"; + /** confined to the UI thread */ + public static String ANY = "ANY"; + /** confined to any thread (but only that thread!) */ } diff --git a/infer/annotations/src/main/java/com/facebook/infer/annotation/ThreadSafe.java b/infer/annotations/src/main/java/com/facebook/infer/annotation/ThreadSafe.java index 9f906a0a2..b04d62099 100644 --- a/infer/annotations/src/main/java/com/facebook/infer/annotation/ThreadSafe.java +++ b/infer/annotations/src/main/java/com/facebook/infer/annotation/ThreadSafe.java @@ -17,8 +17,7 @@ import java.lang.annotation.Target; * applied to methods. In addition, you can ask Infer to assume thread-safety rather than checking * it by using {@literal @ThreadSafe(enableChecks = false)}. */ - -@Target({ ElementType.CONSTRUCTOR, ElementType.METHOD, ElementType.TYPE }) +@Target({ElementType.CONSTRUCTOR, ElementType.METHOD, ElementType.TYPE}) @Retention(RetentionPolicy.CLASS) public @interface ThreadSafe { boolean enableChecks() default true; diff --git a/infer/annotations/src/main/java/com/facebook/infer/annotation/TrueOnNull.java b/infer/annotations/src/main/java/com/facebook/infer/annotation/TrueOnNull.java index 11de52011..4b181a0a3 100644 --- a/infer/annotations/src/main/java/com/facebook/infer/annotation/TrueOnNull.java +++ b/infer/annotations/src/main/java/com/facebook/infer/annotation/TrueOnNull.java @@ -12,9 +12,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -/** - * Annotation for a boolean function returning true when the argument is null. - */ +/** Annotation for a boolean function returning true when the argument is null. */ @Retention(RetentionPolicy.CLASS) @Target({ElementType.METHOD}) public @interface TrueOnNull {} diff --git a/infer/annotations/src/main/java/com/facebook/infer/annotation/Verify.java b/infer/annotations/src/main/java/com/facebook/infer/annotation/Verify.java index ea62006f2..c75cd15b1 100644 --- a/infer/annotations/src/main/java/com/facebook/infer/annotation/Verify.java +++ b/infer/annotations/src/main/java/com/facebook/infer/annotation/Verify.java @@ -14,11 +14,9 @@ import java.lang.annotation.Target; @Retention(RetentionPolicy.CLASS) @Target({ - ElementType.CONSTRUCTOR, - ElementType.METHOD, - ElementType.PACKAGE, - ElementType.TYPE, + ElementType.CONSTRUCTOR, + ElementType.METHOD, + ElementType.PACKAGE, + ElementType.TYPE, }) - -public @interface Verify { -} +public @interface Verify {} diff --git a/infer/models/java/builtins/com/facebook/infer/builtins/InferBuiltins.java b/infer/models/java/builtins/com/facebook/infer/builtins/InferBuiltins.java index 98a67c1f4..d72f64c58 100644 --- a/infer/models/java/builtins/com/facebook/infer/builtins/InferBuiltins.java +++ b/infer/models/java/builtins/com/facebook/infer/builtins/InferBuiltins.java @@ -10,28 +10,27 @@ package com.facebook.infer.builtins; public class InferBuiltins { - public native static void __set_file_attribute(Object o); + public static native void __set_file_attribute(Object o); - public native static void __set_mem_attribute(Object o); + public static native void __set_mem_attribute(Object o); - public native static void __set_locked_attribute(Object o); + public static native void __set_locked_attribute(Object o); - public native static void __delete_locked_attribute(Object o); + public static native void __delete_locked_attribute(Object o); - public native static void _exit(); + public static native void _exit(); - private native static void __infer_assume(boolean condition); + private static native void __infer_assume(boolean condition); - public static void assume(boolean condition) { - __infer_assume(condition); - } + public static void assume(boolean condition) { + __infer_assume(condition); + } - // use this instead of "assume o != null". being non-null and allocated are different to Infer - public static void assume_allocated(Object o) { - assume(o != null); - o.hashCode(); - } - - public native static String __split_get_nth(String s, String sep, int n); + // use this instead of "assume o != null". being non-null and allocated are different to Infer + public static void assume_allocated(Object o) { + assume(o != null); + o.hashCode(); + } + public static native String __split_get_nth(String s, String sep, int n); } diff --git a/infer/models/java/builtins/com/facebook/infer/builtins/InferCloseables.java b/infer/models/java/builtins/com/facebook/infer/builtins/InferCloseables.java index c6a952ea6..76ad015ca 100644 --- a/infer/models/java/builtins/com/facebook/infer/builtins/InferCloseables.java +++ b/infer/models/java/builtins/com/facebook/infer/builtins/InferCloseables.java @@ -12,8 +12,7 @@ import java.io.Closeable; public final class InferCloseables { - private InferCloseables() { - } + private InferCloseables() {} public static void close(Closeable closeable) { if (closeable != null) { @@ -24,5 +23,4 @@ public final class InferCloseables { public static void closeQuietly(Closeable closeable) { close(closeable); } - } diff --git a/infer/models/java/builtins/com/facebook/infer/builtins/InferTaint.java b/infer/models/java/builtins/com/facebook/infer/builtins/InferTaint.java index 60458d890..7318f0a09 100644 --- a/infer/models/java/builtins/com/facebook/infer/builtins/InferTaint.java +++ b/infer/models/java/builtins/com/facebook/infer/builtins/InferTaint.java @@ -7,10 +7,10 @@ package com.facebook.infer.builtins; -/** WARNING! These methods are for testing the taint analysis only! Don't use them in models or in +/** + * WARNING! These methods are for testing the taint analysis only! Don't use them in models or in * real code. */ - public class InferTaint { // these are to test whether we can add a taint spec to methods that have an implementation @@ -20,13 +20,10 @@ public class InferTaint { return o; } - public static void inferSensitiveSink(Object iMightBeTainted) { - - } + public static void inferSensitiveSink(Object iMightBeTainted) {} // these are to test whether we can add a taint spec to undefined methods public static native Object inferSecretSourceUndefined(); public static native void inferSensitiveSinkUndefined(Object iMightBeTainted); - } diff --git a/infer/models/java/builtins/com/facebook/infer/builtins/InferUndefined.java b/infer/models/java/builtins/com/facebook/infer/builtins/InferUndefined.java index eb86a2f5d..3fbf06fe6 100644 --- a/infer/models/java/builtins/com/facebook/infer/builtins/InferUndefined.java +++ b/infer/models/java/builtins/com/facebook/infer/builtins/InferUndefined.java @@ -12,149 +12,133 @@ import java.io.IOException; import java.net.SocketException; import java.sql.SQLException; - public class InferUndefined { - public static native boolean boolean_undefined(); - - public static native int int_undefined(); - - public static native long long_undefined(); - - public static native byte byte_undefined(); - - public static native void void_undefined(); - - public static native char char_undefined(); - - public static native short short_undefined(); - - public static native double double_undefined(); - - public static native float float_undefined(); - - public static native Object object_undefined(); - - public static void can_throw_ioexception_void() throws IOException { - boolean undef = boolean_undefined(); - if (undef) { - } else - throw new IOException(); - } - - public static boolean can_throw_ioexception_boolean() throws IOException { - boolean undef = boolean_undefined(); - if (undef) { - return undef; - } else - throw new IOException(); - } - - public static int can_throw_ioexception_int() throws IOException { - boolean undef = boolean_undefined(); - if (undef) { - return int_undefined(); - } else - throw new IOException(); - } - - public static long can_throw_ioexception_long() throws IOException { - boolean undef = boolean_undefined(); - if (undef) { - return long_undefined(); - } else - throw new IOException(); - } - - public static byte can_throw_ioexception_byte() throws IOException { - boolean undef = boolean_undefined(); - if (undef) { - return byte_undefined(); - } else - throw new IOException(); - } - - public static short can_throw_ioexception_short() throws IOException { - boolean undef = boolean_undefined(); - if (undef) { - return short_undefined(); - } else - throw new IOException(); - } - - public static float can_throw_ioexception_float() throws IOException { - boolean undef = boolean_undefined(); - if (undef) { - return float_undefined(); - } else - throw new IOException(); - } - - public static double can_throw_ioexception_double() throws IOException { - boolean undef = boolean_undefined(); - if (undef) { - return double_undefined(); - } else - throw new IOException(); - } - - public static char can_throw_ioexception_char() throws IOException { - boolean undef = boolean_undefined(); - if (undef) { - return char_undefined(); - } else - throw new IOException(); - } - - public static String can_throw_ioexception_string() throws IOException { - boolean undef = boolean_undefined(); - if (undef) { - return (String)object_undefined(); - } else - throw new IOException(); - } - - public static Object can_throw_ioexception_object() throws IOException { - boolean undef = boolean_undefined(); - if (undef) { - return object_undefined(); - } else - throw new IOException(); - } - - public static void can_throw_sqlexception_void() throws SQLException { - boolean undef = boolean_undefined(); - if (undef) { - } else - throw new SQLException(); - } - - public static int nonneg_int() { - int res = int_undefined(); - InferBuiltins.assume(res >= 0); - return res; - } - - public static void can_throw_socketexception_void() throws SocketException { - boolean undef = boolean_undefined(); - if (undef) { - } else - throw new SocketException(); - } - - public static int can_throw_socketexception_int() throws SocketException { - boolean undef = boolean_undefined(); - if (undef) { - return int_undefined(); - } else - throw new SocketException(); - } - - public static Object can_throw_socketexception_object() throws SocketException { - boolean undef = boolean_undefined(); - if (undef) { - return object_undefined(); - } else - throw new SocketException(); - } + public static native boolean boolean_undefined(); + + public static native int int_undefined(); + + public static native long long_undefined(); + + public static native byte byte_undefined(); + + public static native void void_undefined(); + + public static native char char_undefined(); + + public static native short short_undefined(); + + public static native double double_undefined(); + + public static native float float_undefined(); + + public static native Object object_undefined(); + + public static void can_throw_ioexception_void() throws IOException { + boolean undef = boolean_undefined(); + if (undef) { + } else throw new IOException(); + } + + public static boolean can_throw_ioexception_boolean() throws IOException { + boolean undef = boolean_undefined(); + if (undef) { + return undef; + } else throw new IOException(); + } + + public static int can_throw_ioexception_int() throws IOException { + boolean undef = boolean_undefined(); + if (undef) { + return int_undefined(); + } else throw new IOException(); + } + + public static long can_throw_ioexception_long() throws IOException { + boolean undef = boolean_undefined(); + if (undef) { + return long_undefined(); + } else throw new IOException(); + } + + public static byte can_throw_ioexception_byte() throws IOException { + boolean undef = boolean_undefined(); + if (undef) { + return byte_undefined(); + } else throw new IOException(); + } + + public static short can_throw_ioexception_short() throws IOException { + boolean undef = boolean_undefined(); + if (undef) { + return short_undefined(); + } else throw new IOException(); + } + + public static float can_throw_ioexception_float() throws IOException { + boolean undef = boolean_undefined(); + if (undef) { + return float_undefined(); + } else throw new IOException(); + } + + public static double can_throw_ioexception_double() throws IOException { + boolean undef = boolean_undefined(); + if (undef) { + return double_undefined(); + } else throw new IOException(); + } + + public static char can_throw_ioexception_char() throws IOException { + boolean undef = boolean_undefined(); + if (undef) { + return char_undefined(); + } else throw new IOException(); + } + + public static String can_throw_ioexception_string() throws IOException { + boolean undef = boolean_undefined(); + if (undef) { + return (String) object_undefined(); + } else throw new IOException(); + } + + public static Object can_throw_ioexception_object() throws IOException { + boolean undef = boolean_undefined(); + if (undef) { + return object_undefined(); + } else throw new IOException(); + } + + public static void can_throw_sqlexception_void() throws SQLException { + boolean undef = boolean_undefined(); + if (undef) { + } else throw new SQLException(); + } + + public static int nonneg_int() { + int res = int_undefined(); + InferBuiltins.assume(res >= 0); + return res; + } + + public static void can_throw_socketexception_void() throws SocketException { + boolean undef = boolean_undefined(); + if (undef) { + } else throw new SocketException(); + } + + public static int can_throw_socketexception_int() throws SocketException { + boolean undef = boolean_undefined(); + if (undef) { + return int_undefined(); + } else throw new SocketException(); + } + + public static Object can_throw_socketexception_object() throws SocketException { + boolean undef = boolean_undefined(); + if (undef) { + return object_undefined(); + } else throw new SocketException(); + } } diff --git a/infer/models/java/builtins/com/facebook/infer/builtins/InferUtils.java b/infer/models/java/builtins/com/facebook/infer/builtins/InferUtils.java index 0fbcbbfe4..db1e2edc5 100644 --- a/infer/models/java/builtins/com/facebook/infer/builtins/InferUtils.java +++ b/infer/models/java/builtins/com/facebook/infer/builtins/InferUtils.java @@ -25,5 +25,4 @@ public class InferUtils { || charsetName == "UTF-16" || charsetName == "utf-16"; } - } diff --git a/infer/models/java/src/android/app/Activity.java b/infer/models/java/src/android/app/Activity.java index 3d04adc05..e4ef14bae 100644 --- a/infer/models/java/src/android/app/Activity.java +++ b/infer/models/java/src/android/app/Activity.java @@ -10,39 +10,35 @@ package android.app; import android.content.res.TypedArray; import android.util.AttributeSet; import android.view.ContextThemeWrapper; - import com.facebook.infer.builtins.InferUndefined; public abstract class Activity extends ContextThemeWrapper { - public TypedArray obtainStyledAttributes(int[] attrs) { - return new TypedArray(null, attrs, attrs, 1); - } + public TypedArray obtainStyledAttributes(int[] attrs) { + return new TypedArray(null, attrs, attrs, 1); + } - public TypedArray obtainStyledAttributes(int resid, int[] attrs) - throws NotFoundException { - if (InferUndefined.boolean_undefined()) { - throw new NotFoundException(); - } - return new TypedArray(null, attrs, attrs, 1); + public TypedArray obtainStyledAttributes(int resid, int[] attrs) throws NotFoundException { + if (InferUndefined.boolean_undefined()) { + throw new NotFoundException(); } + return new TypedArray(null, attrs, attrs, 1); + } - public TypedArray obtainStyledAttributes(AttributeSet set, - int[] attrs, int defStyleAttr, int defStyleRes) { - return new TypedArray(null, attrs, attrs, 1); - } + public TypedArray obtainStyledAttributes( + AttributeSet set, int[] attrs, int defStyleAttr, int defStyleRes) { + return new TypedArray(null, attrs, attrs, 1); + } - public static class NotFoundException extends RuntimeException { - public NotFoundException() { - } - - public NotFoundException(String name) { - super(name); - } - } + public static class NotFoundException extends RuntimeException { + public NotFoundException() {} - public TypedArray obtainAttributes(AttributeSet set, int[] attrs) { - return new TypedArray(null, attrs, attrs, 1); + public NotFoundException(String name) { + super(name); } + } + public TypedArray obtainAttributes(AttributeSet set, int[] attrs) { + return new TypedArray(null, attrs, attrs, 1); + } } diff --git a/infer/models/java/src/android/app/AlarmManager.java b/infer/models/java/src/android/app/AlarmManager.java index d48827840..984bdb975 100644 --- a/infer/models/java/src/android/app/AlarmManager.java +++ b/infer/models/java/src/android/app/AlarmManager.java @@ -7,7 +7,6 @@ package android.app; -import android.app.PendingIntent; public abstract class AlarmManager { diff --git a/infer/models/java/src/android/app/DownloadManager.java b/infer/models/java/src/android/app/DownloadManager.java index 0d0c29441..0a54c4710 100644 --- a/infer/models/java/src/android/app/DownloadManager.java +++ b/infer/models/java/src/android/app/DownloadManager.java @@ -12,20 +12,17 @@ import android.database.Cursor; public class DownloadManager { - private ContentResolver mResolver; - private String mPackageName; + private ContentResolver mResolver; + private String mPackageName; - public DownloadManager(ContentResolver resolver, String packageName) { - mResolver = resolver; - mPackageName = packageName; - } - - public static class Query { - } - - public Cursor query(Query query) { - return mResolver.query(null, null, null, null, null); - } + public DownloadManager(ContentResolver resolver, String packageName) { + mResolver = resolver; + mPackageName = packageName; + } + public static class Query {} + public Cursor query(Query query) { + return mResolver.query(null, null, null, null, null); + } } diff --git a/infer/models/java/src/android/content/ContentProviderClient.java b/infer/models/java/src/android/content/ContentProviderClient.java index 0308e7ad8..3a25068ba 100644 --- a/infer/models/java/src/android/content/ContentProviderClient.java +++ b/infer/models/java/src/android/content/ContentProviderClient.java @@ -7,43 +7,44 @@ package android.content; -import com.facebook.infer.builtins.InferBuiltins; -import com.facebook.infer.builtins.InferUndefined; - import android.database.Cursor; import android.database.sqlite.SQLiteCursor; import android.net.Uri; import android.os.CancellationSignal; import android.os.RemoteException; - +import com.facebook.infer.builtins.InferUndefined; public class ContentProviderClient { - private ContentResolver mContentResolver; - private IContentProvider mContentProvider; - private String mPackageName; - private boolean mStable; - - ContentProviderClient( - ContentResolver contentResolver, IContentProvider contentProvider, boolean stable) { - mContentResolver = contentResolver; - mContentProvider = contentProvider; - mPackageName = (String)InferUndefined.object_undefined(); - mStable = stable; - } - - public Cursor query(Uri url, String[] projection, String selection, - String[] selectionArgs, String sortOrder) throws RemoteException { - return query(url, projection, selection, selectionArgs, sortOrder, null); - } - - public Cursor query(Uri url, String[] projection, String selection, String[] selectionArgs, - String sortOrder, CancellationSignal cancellationSignal) throws RemoteException { - return new SQLiteCursor(null, null, null); - } - - private class NotRespondingRunnable { - } - - + private ContentResolver mContentResolver; + private IContentProvider mContentProvider; + private String mPackageName; + private boolean mStable; + + ContentProviderClient( + ContentResolver contentResolver, IContentProvider contentProvider, boolean stable) { + mContentResolver = contentResolver; + mContentProvider = contentProvider; + mPackageName = (String) InferUndefined.object_undefined(); + mStable = stable; + } + + public Cursor query( + Uri url, String[] projection, String selection, String[] selectionArgs, String sortOrder) + throws RemoteException { + return query(url, projection, selection, selectionArgs, sortOrder, null); + } + + public Cursor query( + Uri url, + String[] projection, + String selection, + String[] selectionArgs, + String sortOrder, + CancellationSignal cancellationSignal) + throws RemoteException { + return new SQLiteCursor(null, null, null); + } + + private class NotRespondingRunnable {} } diff --git a/infer/models/java/src/android/content/ContentResolver.java b/infer/models/java/src/android/content/ContentResolver.java index 6966ff186..799510695 100644 --- a/infer/models/java/src/android/content/ContentResolver.java +++ b/infer/models/java/src/android/content/ContentResolver.java @@ -11,42 +11,44 @@ import android.database.Cursor; import android.database.sqlite.SQLiteCursor; import android.net.Uri; import android.os.CancellationSignal; - import com.facebook.infer.builtins.InferUndefined; - public class ContentResolver { - private final Context mContext; + private final Context mContext; - public ContentResolver(Context context) { - mContext = context; - } + public ContentResolver(Context context) { + mContext = context; + } - public final Cursor query(Uri uri, String[] projection, - String selection, String[] selectionArgs, String sortOrder) { - if (InferUndefined.boolean_undefined()) { - return null; - } else { - return query(uri, projection, selection, selectionArgs, sortOrder, null); - } + public final Cursor query( + Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { + if (InferUndefined.boolean_undefined()) { + return null; + } else { + return query(uri, projection, selection, selectionArgs, sortOrder, null); } - - public final Cursor query(final Uri uri, String[] projection, - String selection, String[] selectionArgs, String sortOrder, - CancellationSignal cancellationSignal) { - if (InferUndefined.boolean_undefined()) { - return null; - } else { - return new SQLiteCursor(null, null, null); - } + } + + public final Cursor query( + final Uri uri, + String[] projection, + String selection, + String[] selectionArgs, + String sortOrder, + CancellationSignal cancellationSignal) { + if (InferUndefined.boolean_undefined()) { + return null; + } else { + return new SQLiteCursor(null, null, null); } + } - public final ContentProviderClient acquireContentProviderClient(Uri uri) { - return new ContentProviderClient(this, null, true); - } + public final ContentProviderClient acquireContentProviderClient(Uri uri) { + return new ContentProviderClient(this, null, true); + } - public final ContentProviderClient acquireContentProviderClient(String name) { - return new ContentProviderClient(this, null, true); - } + public final ContentProviderClient acquireContentProviderClient(String name) { + return new ContentProviderClient(this, null, true); + } } diff --git a/infer/models/java/src/android/content/Context.java b/infer/models/java/src/android/content/Context.java index cb1d4758f..e1e2c6e5b 100644 --- a/infer/models/java/src/android/content/Context.java +++ b/infer/models/java/src/android/content/Context.java @@ -13,40 +13,35 @@ import com.facebook.infer.builtins.InferUndefined; public class Context { + public ContentResolver getContentResolver() { + return new ContentResolver(this); + } - public ContentResolver getContentResolver() { - return new ContentResolver(this); - } - - public TypedArray obtainStyledAttributes(int[] attrs) { - return new TypedArray(null, attrs, attrs, 1); - } + public TypedArray obtainStyledAttributes(int[] attrs) { + return new TypedArray(null, attrs, attrs, 1); + } - public TypedArray obtainStyledAttributes(int resid, int[] attrs) - throws NotFoundException { - if (InferUndefined.boolean_undefined()) { - throw new NotFoundException(); - } - return new TypedArray(null, attrs, attrs, 1); + public TypedArray obtainStyledAttributes(int resid, int[] attrs) throws NotFoundException { + if (InferUndefined.boolean_undefined()) { + throw new NotFoundException(); } + return new TypedArray(null, attrs, attrs, 1); + } - public TypedArray obtainStyledAttributes(AttributeSet set, - int[] attrs, int defStyleAttr, int defStyleRes) { - return new TypedArray(null, attrs, attrs, 1); - } + public TypedArray obtainStyledAttributes( + AttributeSet set, int[] attrs, int defStyleAttr, int defStyleRes) { + return new TypedArray(null, attrs, attrs, 1); + } - public static class NotFoundException extends RuntimeException { - public NotFoundException() { - } + public static class NotFoundException extends RuntimeException { + public NotFoundException() {} - public NotFoundException(String name) { - super(name); - } + public NotFoundException(String name) { + super(name); } + } - public TypedArray obtainAttributes(AttributeSet set, int[] attrs) { - return new TypedArray(null, attrs, attrs, 1); - } - - + public TypedArray obtainAttributes(AttributeSet set, int[] attrs) { + return new TypedArray(null, attrs, attrs, 1); + } } diff --git a/infer/models/java/src/android/content/IContentProvider.java b/infer/models/java/src/android/content/IContentProvider.java index 7c4f730e5..ab971129c 100644 --- a/infer/models/java/src/android/content/IContentProvider.java +++ b/infer/models/java/src/android/content/IContentProvider.java @@ -7,5 +7,4 @@ package android.content; -public interface IContentProvider { -} +public interface IContentProvider {} diff --git a/infer/models/java/src/android/content/IContentService.java b/infer/models/java/src/android/content/IContentService.java index 7526c9386..7f5a6d7ef 100644 --- a/infer/models/java/src/android/content/IContentService.java +++ b/infer/models/java/src/android/content/IContentService.java @@ -7,5 +7,4 @@ package android.content; -public interface IContentService { -} +public interface IContentService {} diff --git a/infer/models/java/src/android/content/res/Resources.java b/infer/models/java/src/android/content/res/Resources.java index de2af9756..aae9d1de8 100644 --- a/infer/models/java/src/android/content/res/Resources.java +++ b/infer/models/java/src/android/content/res/Resources.java @@ -8,44 +8,37 @@ package android.content.res; import android.util.AttributeSet; - import com.facebook.infer.builtins.InferUndefined; - public class Resources { - - public final class Theme { - public TypedArray obtainStyledAttributes(int[] attrs) { - return new TypedArray(null, attrs, attrs, 1); - } - - public TypedArray obtainStyledAttributes(int resid, int[] attrs) - throws NotFoundException { - if (InferUndefined.boolean_undefined()) { - throw new NotFoundException(); - } - return new TypedArray(null, attrs, attrs, 1); - } - - public TypedArray obtainStyledAttributes(AttributeSet set, - int[] attrs, int defStyleAttr, int defStyleRes) { - return new TypedArray(null, attrs, attrs, 1); - } - + public final class Theme { + public TypedArray obtainStyledAttributes(int[] attrs) { + return new TypedArray(null, attrs, attrs, 1); } - public static class NotFoundException extends RuntimeException { - public NotFoundException() { - } + public TypedArray obtainStyledAttributes(int resid, int[] attrs) throws NotFoundException { + if (InferUndefined.boolean_undefined()) { + throw new NotFoundException(); + } + return new TypedArray(null, attrs, attrs, 1); + } - public NotFoundException(String name) { - super(name); - } + public TypedArray obtainStyledAttributes( + AttributeSet set, int[] attrs, int defStyleAttr, int defStyleRes) { + return new TypedArray(null, attrs, attrs, 1); } + } + + public static class NotFoundException extends RuntimeException { + public NotFoundException() {} - public TypedArray obtainAttributes(AttributeSet set, int[] attrs) { - return new TypedArray(null, attrs, attrs, 1); + public NotFoundException(String name) { + super(name); } + } + public TypedArray obtainAttributes(AttributeSet set, int[] attrs) { + return new TypedArray(null, attrs, attrs, 1); + } } diff --git a/infer/models/java/src/android/content/res/TypedArray.java b/infer/models/java/src/android/content/res/TypedArray.java index 73aeebd94..8b5abc3ad 100644 --- a/infer/models/java/src/android/content/res/TypedArray.java +++ b/infer/models/java/src/android/content/res/TypedArray.java @@ -11,28 +11,27 @@ import com.facebook.infer.builtins.InferBuiltins; public class TypedArray { - private Resources mResources; - int[] mData; - int[] mIndices; - int mLength; - - public void recycle() { - // Release resource - if (mLength > 0) { - InferBuiltins.__set_mem_attribute(this); - } + private Resources mResources; + int[] mData; + int[] mIndices; + int mLength; + + public void recycle() { + // Release resource + if (mLength > 0) { + InferBuiltins.__set_mem_attribute(this); } + } - public TypedArray(Resources resources, int[] data, int[] indices, int len) { - mResources = resources; - mData = data; - mIndices = indices; - mLength = len; + public TypedArray(Resources resources, int[] data, int[] indices, int len) { + mResources = resources; + mData = data; + mIndices = indices; + mLength = len; - // Acquire resource - if (mLength > 0) { - InferBuiltins.__set_file_attribute(this); - } + // Acquire resource + if (mLength > 0) { + InferBuiltins.__set_file_attribute(this); } - + } } diff --git a/infer/models/java/src/android/database/AbstractCursor.java b/infer/models/java/src/android/database/AbstractCursor.java index 1d3c2cf86..2b674ba8b 100644 --- a/infer/models/java/src/android/database/AbstractCursor.java +++ b/infer/models/java/src/android/database/AbstractCursor.java @@ -7,5 +7,4 @@ package android.database; -public abstract class AbstractCursor implements CrossProcessCursor { -} +public abstract class AbstractCursor implements CrossProcessCursor {} diff --git a/infer/models/java/src/android/database/CrossProcessCursor.java b/infer/models/java/src/android/database/CrossProcessCursor.java index d1b7f2f52..e4ca42946 100644 --- a/infer/models/java/src/android/database/CrossProcessCursor.java +++ b/infer/models/java/src/android/database/CrossProcessCursor.java @@ -7,5 +7,4 @@ package android.database; -public interface CrossProcessCursor extends Cursor { -} +public interface CrossProcessCursor extends Cursor {} diff --git a/infer/models/java/src/android/database/CrossProcessCursorWrapper.java b/infer/models/java/src/android/database/CrossProcessCursorWrapper.java index 13fbd06f8..94345b042 100644 --- a/infer/models/java/src/android/database/CrossProcessCursorWrapper.java +++ b/infer/models/java/src/android/database/CrossProcessCursorWrapper.java @@ -7,5 +7,4 @@ package android.database; -public abstract class CrossProcessCursorWrapper implements CrossProcessCursor { -} +public abstract class CrossProcessCursorWrapper implements CrossProcessCursor {} diff --git a/infer/models/java/src/android/database/CursorWrapper.java b/infer/models/java/src/android/database/CursorWrapper.java index 639ea18a0..8eec33a5e 100644 --- a/infer/models/java/src/android/database/CursorWrapper.java +++ b/infer/models/java/src/android/database/CursorWrapper.java @@ -7,8 +7,6 @@ package android.database; -import com.facebook.infer.builtins.InferUndefined; -import com.facebook.infer.builtins.InferBuiltins; import java.io.IOException; @@ -22,7 +20,7 @@ public class CursorWrapper implements Cursor { public void close() { try { mCursor.close(); - } catch (IOException e) {} + } catch (IOException e) { + } } - } diff --git a/infer/models/java/src/android/database/sqlite/SQLiteConnectionPool.java b/infer/models/java/src/android/database/sqlite/SQLiteConnectionPool.java index dc45197f2..8f15be06b 100644 --- a/infer/models/java/src/android/database/sqlite/SQLiteConnectionPool.java +++ b/infer/models/java/src/android/database/sqlite/SQLiteConnectionPool.java @@ -7,6 +7,4 @@ package android.database.sqlite; -public final class SQLiteConnectionPool { - -} +public final class SQLiteConnectionPool {} diff --git a/infer/models/java/src/android/database/sqlite/SQLiteCursor.java b/infer/models/java/src/android/database/sqlite/SQLiteCursor.java index 6a9b9be25..7d98ce37e 100644 --- a/infer/models/java/src/android/database/sqlite/SQLiteCursor.java +++ b/infer/models/java/src/android/database/sqlite/SQLiteCursor.java @@ -9,24 +9,20 @@ package android.database.sqlite; import android.database.Cursor; import com.facebook.infer.builtins.InferBuiltins; -import com.facebook.infer.builtins.InferUndefined; - public class SQLiteCursor implements Cursor { - @Deprecated - public SQLiteCursor(SQLiteDatabase db, SQLiteCursorDriver driver, - String editTable, SQLiteQuery query) { - this(driver, editTable, query); - } - - - public SQLiteCursor(SQLiteCursorDriver driver, String editTable, SQLiteQuery query) { - InferBuiltins.__set_file_attribute(this); - } + @Deprecated + public SQLiteCursor( + SQLiteDatabase db, SQLiteCursorDriver driver, String editTable, SQLiteQuery query) { + this(driver, editTable, query); + } - public void close() { - InferBuiltins.__set_mem_attribute(this); - } + public SQLiteCursor(SQLiteCursorDriver driver, String editTable, SQLiteQuery query) { + InferBuiltins.__set_file_attribute(this); + } + public void close() { + InferBuiltins.__set_mem_attribute(this); + } } diff --git a/infer/models/java/src/android/database/sqlite/SQLiteDatabase.java b/infer/models/java/src/android/database/sqlite/SQLiteDatabase.java index 6e9ebdbf5..a6bead267 100644 --- a/infer/models/java/src/android/database/sqlite/SQLiteDatabase.java +++ b/infer/models/java/src/android/database/sqlite/SQLiteDatabase.java @@ -11,86 +11,159 @@ import android.database.Cursor; import android.database.DatabaseErrorHandler; import android.os.CancellationSignal; - public final class SQLiteDatabase { - private SQLiteDatabase(String path, int openFlags, CursorFactory cursorFactory, - DatabaseErrorHandler errorHandler) { - } - - - public Cursor query(boolean distinct, String table, String[] columns, - String selection, String[] selectionArgs, String groupBy, - String having, String orderBy, String limit) { - return queryWithFactory(null, distinct, table, columns, selection, selectionArgs, - groupBy, having, orderBy, limit, null); - } - - - public Cursor query(boolean distinct, String table, String[] columns, - String selection, String[] selectionArgs, String groupBy, - String having, String orderBy, String limit, CancellationSignal cancellationSignal) { - return queryWithFactory(null, distinct, table, columns, selection, selectionArgs, - groupBy, having, orderBy, limit, cancellationSignal); - } - - - public Cursor queryWithFactory(CursorFactory cursorFactory, - boolean distinct, String table, String[] columns, - String selection, String[] selectionArgs, String groupBy, - String having, String orderBy, String limit) { - return queryWithFactory(cursorFactory, distinct, table, columns, selection, - selectionArgs, groupBy, having, orderBy, limit, null); - } - - - public Cursor queryWithFactory(CursorFactory cursorFactory, - boolean distinct, String table, String[] columns, - String selection, String[] selectionArgs, String groupBy, - String having, String orderBy, String limit, CancellationSignal cancellationSignal) { - return rawQueryWithFactory(cursorFactory, null, selectionArgs, table, cancellationSignal); - } - - public Cursor query(String table, String[] columns, String selection, - String[] selectionArgs, String groupBy, String having, - String orderBy) { - - return query(false, table, columns, selection, selectionArgs, groupBy, - having, orderBy, null /* limit */); - } - - public Cursor query(String table, String[] columns, String selection, - String[] selectionArgs, String groupBy, String having, - String orderBy, String limit) { - - return query(false, table, columns, selection, selectionArgs, groupBy, - having, orderBy, limit); - } - - public Cursor rawQuery(String sql, String[] selectionArgs) { - return rawQueryWithFactory(null, sql, selectionArgs, null, null); - } - - public Cursor rawQuery(String sql, String[] selectionArgs, - CancellationSignal cancellationSignal) { - return rawQueryWithFactory(null, sql, selectionArgs, null, cancellationSignal); - } - - public Cursor rawQueryWithFactory( - CursorFactory cursorFactory, String sql, String[] selectionArgs, - String editTable) { - return rawQueryWithFactory(cursorFactory, sql, selectionArgs, editTable, null); - } - - public Cursor rawQueryWithFactory( - CursorFactory cursorFactory, String sql, String[] selectionArgs, - String editTable, CancellationSignal cancellationSignal) { - return new SQLiteCursor(null, editTable, null); - } - - public interface CursorFactory { - public Cursor newCursor(SQLiteDatabase db, - SQLiteCursorDriver masterQuery, String editTable, - SQLiteQuery query); - } + private SQLiteDatabase( + String path, int openFlags, CursorFactory cursorFactory, DatabaseErrorHandler errorHandler) {} + + public Cursor query( + boolean distinct, + String table, + String[] columns, + String selection, + String[] selectionArgs, + String groupBy, + String having, + String orderBy, + String limit) { + return queryWithFactory( + null, + distinct, + table, + columns, + selection, + selectionArgs, + groupBy, + having, + orderBy, + limit, + null); + } + + public Cursor query( + boolean distinct, + String table, + String[] columns, + String selection, + String[] selectionArgs, + String groupBy, + String having, + String orderBy, + String limit, + CancellationSignal cancellationSignal) { + return queryWithFactory( + null, + distinct, + table, + columns, + selection, + selectionArgs, + groupBy, + having, + orderBy, + limit, + cancellationSignal); + } + + public Cursor queryWithFactory( + CursorFactory cursorFactory, + boolean distinct, + String table, + String[] columns, + String selection, + String[] selectionArgs, + String groupBy, + String having, + String orderBy, + String limit) { + return queryWithFactory( + cursorFactory, + distinct, + table, + columns, + selection, + selectionArgs, + groupBy, + having, + orderBy, + limit, + null); + } + + public Cursor queryWithFactory( + CursorFactory cursorFactory, + boolean distinct, + String table, + String[] columns, + String selection, + String[] selectionArgs, + String groupBy, + String having, + String orderBy, + String limit, + CancellationSignal cancellationSignal) { + return rawQueryWithFactory(cursorFactory, null, selectionArgs, table, cancellationSignal); + } + + public Cursor query( + String table, + String[] columns, + String selection, + String[] selectionArgs, + String groupBy, + String having, + String orderBy) { + + return query( + false, + table, + columns, + selection, + selectionArgs, + groupBy, + having, + orderBy, + null /* limit */); + } + + public Cursor query( + String table, + String[] columns, + String selection, + String[] selectionArgs, + String groupBy, + String having, + String orderBy, + String limit) { + + return query(false, table, columns, selection, selectionArgs, groupBy, having, orderBy, limit); + } + + public Cursor rawQuery(String sql, String[] selectionArgs) { + return rawQueryWithFactory(null, sql, selectionArgs, null, null); + } + + public Cursor rawQuery( + String sql, String[] selectionArgs, CancellationSignal cancellationSignal) { + return rawQueryWithFactory(null, sql, selectionArgs, null, cancellationSignal); + } + + public Cursor rawQueryWithFactory( + CursorFactory cursorFactory, String sql, String[] selectionArgs, String editTable) { + return rawQueryWithFactory(cursorFactory, sql, selectionArgs, editTable, null); + } + + public Cursor rawQueryWithFactory( + CursorFactory cursorFactory, + String sql, + String[] selectionArgs, + String editTable, + CancellationSignal cancellationSignal) { + return new SQLiteCursor(null, editTable, null); + } + + public interface CursorFactory { + public Cursor newCursor( + SQLiteDatabase db, SQLiteCursorDriver masterQuery, String editTable, SQLiteQuery query); + } } diff --git a/infer/models/java/src/android/database/sqlite/SQLiteDatabaseConfiguration.java b/infer/models/java/src/android/database/sqlite/SQLiteDatabaseConfiguration.java index 71ca85461..131c21dac 100644 --- a/infer/models/java/src/android/database/sqlite/SQLiteDatabaseConfiguration.java +++ b/infer/models/java/src/android/database/sqlite/SQLiteDatabaseConfiguration.java @@ -7,5 +7,4 @@ package android.database.sqlite; -public final class SQLiteDatabaseConfiguration { -} +public final class SQLiteDatabaseConfiguration {} diff --git a/infer/models/java/src/android/database/sqlite/SQLiteQueryBuilder.java b/infer/models/java/src/android/database/sqlite/SQLiteQueryBuilder.java index 9a0f02a4c..08808febb 100644 --- a/infer/models/java/src/android/database/sqlite/SQLiteQueryBuilder.java +++ b/infer/models/java/src/android/database/sqlite/SQLiteQueryBuilder.java @@ -12,26 +12,49 @@ import android.os.CancellationSignal; public class SQLiteQueryBuilder { - public Cursor query(SQLiteDatabase db, String[] projectionIn, - String selection, String[] selectionArgs, String groupBy, - String having, String sortOrder) { - return query(db, projectionIn, selection, selectionArgs, groupBy, having, sortOrder, - null /* limit */, null /* cancellationSignal */); - } - - public Cursor query(SQLiteDatabase db, String[] projectionIn, - String selection, String[] selectionArgs, String groupBy, - String having, String sortOrder, String limit) { - return query(db, projectionIn, selection, selectionArgs, - groupBy, having, sortOrder, limit, null); - } - - public Cursor query(SQLiteDatabase db, String[] projectionIn, - String selection, String[] selectionArgs, String groupBy, - String having, String sortOrder, String limit, - CancellationSignal cancellationSignal) { - return new SQLiteCursor(null, null, null); - } - - + public Cursor query( + SQLiteDatabase db, + String[] projectionIn, + String selection, + String[] selectionArgs, + String groupBy, + String having, + String sortOrder) { + return query( + db, + projectionIn, + selection, + selectionArgs, + groupBy, + having, + sortOrder, + null /* limit */, + null /* cancellationSignal */); + } + + public Cursor query( + SQLiteDatabase db, + String[] projectionIn, + String selection, + String[] selectionArgs, + String groupBy, + String having, + String sortOrder, + String limit) { + return query( + db, projectionIn, selection, selectionArgs, groupBy, having, sortOrder, limit, null); + } + + public Cursor query( + SQLiteDatabase db, + String[] projectionIn, + String selection, + String[] selectionArgs, + String groupBy, + String having, + String sortOrder, + String limit, + CancellationSignal cancellationSignal) { + return new SQLiteCursor(null, null, null); + } } diff --git a/infer/models/java/src/android/provider/MediaStore.java b/infer/models/java/src/android/provider/MediaStore.java index 1959b8e0d..67fb69f5d 100644 --- a/infer/models/java/src/android/provider/MediaStore.java +++ b/infer/models/java/src/android/provider/MediaStore.java @@ -13,23 +13,27 @@ import android.net.Uri; public final class MediaStore { - public static final class Images { - - - public static final class Media { - public static final Cursor query(ContentResolver cr, Uri uri, String[] projection) { - return cr.query(uri, projection, null, null, null); - } - - public static final Cursor query(ContentResolver cr, Uri uri, String[] projection, - String where, String orderBy) { - return cr.query(uri, projection, where, null, orderBy); - } - - public static final Cursor query(ContentResolver cr, Uri uri, String[] projection, - String selection, String[] selectionArgs, String orderBy) { - return cr.query(uri, projection, selection, selectionArgs, orderBy); - } - } + public static final class Images { + + public static final class Media { + public static final Cursor query(ContentResolver cr, Uri uri, String[] projection) { + return cr.query(uri, projection, null, null, null); + } + + public static final Cursor query( + ContentResolver cr, Uri uri, String[] projection, String where, String orderBy) { + return cr.query(uri, projection, where, null, orderBy); + } + + public static final Cursor query( + ContentResolver cr, + Uri uri, + String[] projection, + String selection, + String[] selectionArgs, + String orderBy) { + return cr.query(uri, projection, selection, selectionArgs, orderBy); + } } + } } diff --git a/infer/models/java/src/android/text/TextUtils.java b/infer/models/java/src/android/text/TextUtils.java index 00033653f..4a3fe82da 100644 --- a/infer/models/java/src/android/text/TextUtils.java +++ b/infer/models/java/src/android/text/TextUtils.java @@ -18,11 +18,11 @@ package android.text; public class TextUtils { - public static boolean isEmpty(CharSequence str) { - if (str == null || str.length() == 0) { - return true; - } else { - return false; - } + public static boolean isEmpty(CharSequence str) { + if (str == null || str.length() == 0) { + return true; + } else { + return false; } + } } diff --git a/infer/models/java/src/com/facebook/infer/annotation/Assertions.java b/infer/models/java/src/com/facebook/infer/annotation/Assertions.java index 4aa7d7b19..382c506bc 100644 --- a/infer/models/java/src/com/facebook/infer/annotation/Assertions.java +++ b/infer/models/java/src/com/facebook/infer/annotation/Assertions.java @@ -8,7 +8,6 @@ package com.facebook.infer.annotation; import com.facebook.infer.builtins.InferBuiltins; - import javax.annotation.Nullable; public class Assertions { diff --git a/infer/models/java/src/com/fasterxml/jackson/core/JsonFactory.java b/infer/models/java/src/com/fasterxml/jackson/core/JsonFactory.java index f29d0a1be..e12a94185 100644 --- a/infer/models/java/src/com/fasterxml/jackson/core/JsonFactory.java +++ b/infer/models/java/src/com/fasterxml/jackson/core/JsonFactory.java @@ -9,7 +9,6 @@ package com.fasterxml.jackson.core; import com.fasterxml.jackson.core.json.PackageVersion; import com.fasterxml.jackson.core.json.UTF8StreamJsonParser; - import java.io.File; import java.io.FileInputStream; import java.io.IOException; @@ -17,47 +16,35 @@ import java.io.InputStream; import java.io.Reader; import java.net.URL; -public class JsonFactory - implements Versioned, java.io.Serializable { - - @Override - public Version version() { - return PackageVersion.VERSION; - } - - public JsonParser createParser(File f) - throws IOException, JsonParseException { - return createOwningParser(); - } - - public JsonParser createParser(URL url) - throws IOException, JsonParseException { - return createOwningParser(); - } - - public JsonParser createParser(InputStream in) - throws IOException, JsonParseException { - return createNonOwningParser(); - } - - public JsonParser createParser(Reader r) - throws IOException, JsonParseException { - return createNonOwningParser(); - } - - private JsonParser createOwningParser() - throws IOException, JsonParseException { - InputStream in = new FileInputStream(""); - return new UTF8StreamJsonParser(null, 0, in, null, null, - new byte[]{}, 0, 0, - false); - } - - private JsonParser createNonOwningParser() - throws IOException, JsonParseException { - return new UTF8StreamJsonParser(null, 0, null, null, null, - new byte[]{}, 0, 0, - false); - } +public class JsonFactory implements Versioned, java.io.Serializable { + + @Override + public Version version() { + return PackageVersion.VERSION; + } + + public JsonParser createParser(File f) throws IOException, JsonParseException { + return createOwningParser(); + } + + public JsonParser createParser(URL url) throws IOException, JsonParseException { + return createOwningParser(); + } + + public JsonParser createParser(InputStream in) throws IOException, JsonParseException { + return createNonOwningParser(); + } + + public JsonParser createParser(Reader r) throws IOException, JsonParseException { + return createNonOwningParser(); + } + + private JsonParser createOwningParser() throws IOException, JsonParseException { + InputStream in = new FileInputStream(""); + return new UTF8StreamJsonParser(null, 0, in, null, null, new byte[] {}, 0, 0, false); + } + private JsonParser createNonOwningParser() throws IOException, JsonParseException { + return new UTF8StreamJsonParser(null, 0, null, null, null, new byte[] {}, 0, 0, false); + } } diff --git a/infer/models/java/src/com/fasterxml/jackson/core/JsonParser.java b/infer/models/java/src/com/fasterxml/jackson/core/JsonParser.java index aee5c70df..f5c3412b2 100644 --- a/infer/models/java/src/com/fasterxml/jackson/core/JsonParser.java +++ b/infer/models/java/src/com/fasterxml/jackson/core/JsonParser.java @@ -9,32 +9,27 @@ package com.fasterxml.jackson.core; import com.facebook.infer.builtins.InferBuiltins; import com.facebook.infer.builtins.InferUndefined; - import java.io.Closeable; import java.io.IOException; -public abstract class JsonParser - implements Closeable, Versioned { +public abstract class JsonParser implements Closeable, Versioned { - public void close() throws IOException { - InferBuiltins.__set_mem_attribute(this); - InferUndefined.can_throw_ioexception_void(); - } + public void close() throws IOException { + InferBuiltins.__set_mem_attribute(this); + InferUndefined.can_throw_ioexception_void(); + } - private void throwExceptions() - throws JsonParseException, IOException { - if (InferUndefined.boolean_undefined()) { - throw new JsonParseException(null, null, null); - } - if (InferUndefined.boolean_undefined()) { - throw new IOException(); - } + private void throwExceptions() throws JsonParseException, IOException { + if (InferUndefined.boolean_undefined()) { + throw new JsonParseException(null, null, null); } - - public Object readValueAs(Class valueType) - throws IOException, JsonProcessingException { - throwExceptions(); - return InferUndefined.object_undefined(); + if (InferUndefined.boolean_undefined()) { + throw new IOException(); } + } + public Object readValueAs(Class valueType) throws IOException, JsonProcessingException { + throwExceptions(); + return InferUndefined.object_undefined(); + } } diff --git a/infer/models/java/src/com/fasterxml/jackson/core/json/UTF8StreamJsonParser.java b/infer/models/java/src/com/fasterxml/jackson/core/json/UTF8StreamJsonParser.java index ccf9d8d41..ee1088a29 100644 --- a/infer/models/java/src/com/fasterxml/jackson/core/json/UTF8StreamJsonParser.java +++ b/infer/models/java/src/com/fasterxml/jackson/core/json/UTF8StreamJsonParser.java @@ -15,7 +15,6 @@ import com.fasterxml.jackson.core.ObjectCodec; import com.fasterxml.jackson.core.base.ParserBase; import com.fasterxml.jackson.core.io.IOContext; import com.fasterxml.jackson.core.sym.BytesToNameCanonicalizer; - import java.io.IOException; import java.io.InputStream; @@ -24,120 +23,114 @@ import java.io.InputStream; * This class contains a minimum set of methods in order to compile it for the * models */ -public final class UTF8StreamJsonParser - extends ParserBase { - - - protected ObjectCodec _objectCodec; - - protected BytesToNameCanonicalizer _symbols; - - protected int[] _quadBuffer; - - protected boolean _tokenIncomplete; - - protected InputStream _inputStream; - - protected byte[] _inputBuffer; - - protected boolean _bufferRecyclable; - - public UTF8StreamJsonParser(IOContext ctxt, int features, InputStream in, - ObjectCodec codec, BytesToNameCanonicalizer sym, - byte[] inputBuffer, int start, int end, - boolean bufferRecyclable) { - super(ctxt, features); - _inputStream = in; - _objectCodec = codec; - _symbols = sym; - _inputBuffer = inputBuffer; - _inputPtr = start; - _inputEnd = end; - _bufferRecyclable = bufferRecyclable; - } - - @Override - public void close() throws IOException { - if (_inputStream != null) { - _inputStream.close(); - } - } - - private void throwExceptions() - throws JsonParseException, IOException { - if (InferUndefined.boolean_undefined()) { - throw new JsonParseException(null, null, null); - } - if (InferUndefined.boolean_undefined()) { - throw new IOException(); - } - } - - /* - * Methods from ParserBase - */ - - @Override - protected boolean loadMore() - throws IOException { - return InferUndefined.can_throw_ioexception_boolean(); - } - - @Override - protected void _finishString() - throws IOException, JsonParseException { - throwExceptions(); - } - - @Override - protected void _closeInput() throws IOException { - close(); - } - - /* - * Methods from ParserMinimalBase - */ - - @Override - public byte[] getBinaryValue(Base64Variant b64variant) - throws IOException, JsonParseException { - throwExceptions(); - return new byte[]{InferUndefined.byte_undefined()}; +public final class UTF8StreamJsonParser extends ParserBase { + + protected ObjectCodec _objectCodec; + + protected BytesToNameCanonicalizer _symbols; + + protected int[] _quadBuffer; + + protected boolean _tokenIncomplete; + + protected InputStream _inputStream; + + protected byte[] _inputBuffer; + + protected boolean _bufferRecyclable; + + public UTF8StreamJsonParser( + IOContext ctxt, + int features, + InputStream in, + ObjectCodec codec, + BytesToNameCanonicalizer sym, + byte[] inputBuffer, + int start, + int end, + boolean bufferRecyclable) { + super(ctxt, features); + _inputStream = in; + _objectCodec = codec; + _symbols = sym; + _inputBuffer = inputBuffer; + _inputPtr = start; + _inputEnd = end; + _bufferRecyclable = bufferRecyclable; + } + + @Override + public void close() throws IOException { + if (_inputStream != null) { + _inputStream.close(); } + } - @Override - public int getTextOffset() - throws IOException, JsonParseException { - throwExceptions(); - return InferUndefined.int_undefined(); + private void throwExceptions() throws JsonParseException, IOException { + if (InferUndefined.boolean_undefined()) { + throw new JsonParseException(null, null, null); } - - @Override - public int getTextLength() - throws IOException, JsonParseException { - throwExceptions(); - return InferUndefined.int_undefined(); - } - - @Override - public char[] getTextCharacters() - throws IOException, JsonParseException { - throwExceptions(); - return new char[]{InferUndefined.char_undefined()}; - } - - @Override - public String getText() - throws IOException, JsonParseException { - throwExceptions(); - return (String)InferUndefined.object_undefined(); - } - - @Override - public JsonToken nextToken() - throws IOException, JsonParseException { - throwExceptions(); - throw new IOException(); + if (InferUndefined.boolean_undefined()) { + throw new IOException(); } - + } + + /* + * Methods from ParserBase + */ + + @Override + protected boolean loadMore() throws IOException { + return InferUndefined.can_throw_ioexception_boolean(); + } + + @Override + protected void _finishString() throws IOException, JsonParseException { + throwExceptions(); + } + + @Override + protected void _closeInput() throws IOException { + close(); + } + + /* + * Methods from ParserMinimalBase + */ + + @Override + public byte[] getBinaryValue(Base64Variant b64variant) throws IOException, JsonParseException { + throwExceptions(); + return new byte[] {InferUndefined.byte_undefined()}; + } + + @Override + public int getTextOffset() throws IOException, JsonParseException { + throwExceptions(); + return InferUndefined.int_undefined(); + } + + @Override + public int getTextLength() throws IOException, JsonParseException { + throwExceptions(); + return InferUndefined.int_undefined(); + } + + @Override + public char[] getTextCharacters() throws IOException, JsonParseException { + throwExceptions(); + return new char[] {InferUndefined.char_undefined()}; + } + + @Override + public String getText() throws IOException, JsonParseException { + throwExceptions(); + return (String) InferUndefined.object_undefined(); + } + + @Override + public JsonToken nextToken() throws IOException, JsonParseException { + throwExceptions(); + throw new IOException(); + } } diff --git a/infer/models/java/src/com/google/common/base/Optional.java b/infer/models/java/src/com/google/common/base/Optional.java index 7d6303c68..02ca3e897 100644 --- a/infer/models/java/src/com/google/common/base/Optional.java +++ b/infer/models/java/src/com/google/common/base/Optional.java @@ -9,9 +9,8 @@ package com.google.common.base; import javax.annotation.Nullable; -public abstract class Optional { +public abstract class Optional { @Nullable public abstract T orNull(); - } diff --git a/infer/models/java/src/com/google/common/base/Preconditions.java b/infer/models/java/src/com/google/common/base/Preconditions.java index 636928fca..afa450bd2 100644 --- a/infer/models/java/src/com/google/common/base/Preconditions.java +++ b/infer/models/java/src/com/google/common/base/Preconditions.java @@ -7,9 +7,9 @@ package com.google.common.base; -import javax.annotation.Nullable; import static com.facebook.infer.builtins.InferBuiltins.assume; +import javax.annotation.Nullable; public final class Preconditions { @@ -22,9 +22,8 @@ public final class Preconditions { return checkNotNull(reference); } - public static T checkNotNull(T reference, - @Nullable String errorMessageTemplate, - @Nullable Object... errorMessageArgs) { + public static T checkNotNull( + T reference, @Nullable String errorMessageTemplate, @Nullable Object... errorMessageArgs) { return checkNotNull(reference); } @@ -32,14 +31,14 @@ public final class Preconditions { assume(expression); } - public static void checkState(boolean expression, - @Nullable Object errorMessage) { + public static void checkState(boolean expression, @Nullable Object errorMessage) { assume(expression); } - public static void checkState(boolean expression, - @Nullable String errorMessageTemplate, - @Nullable Object... errorMessageArgs) { + public static void checkState( + boolean expression, + @Nullable String errorMessageTemplate, + @Nullable Object... errorMessageArgs) { assume(expression); } @@ -57,5 +56,4 @@ public final class Preconditions { @Nullable Object... errorMessageArgs) { assume(expression); } - } diff --git a/infer/models/java/src/com/google/common/collect/Iterators.java b/infer/models/java/src/com/google/common/collect/Iterators.java index 6819a7479..305967050 100644 --- a/infer/models/java/src/com/google/common/collect/Iterators.java +++ b/infer/models/java/src/com/google/common/collect/Iterators.java @@ -7,10 +7,8 @@ package com.google.common.collect; -import java.util.NoSuchElementException; - import com.facebook.infer.builtins.InferBuiltins; - +import java.util.NoSuchElementException; import javax.annotation.Nullable; public class Iterators { @@ -35,5 +33,4 @@ public class Iterators { } }; } - } diff --git a/infer/models/java/src/com/google/common/io/Closeables.java b/infer/models/java/src/com/google/common/io/Closeables.java index ebbd2b2d7..2deea3059 100644 --- a/infer/models/java/src/com/google/common/io/Closeables.java +++ b/infer/models/java/src/com/google/common/io/Closeables.java @@ -9,20 +9,17 @@ package com.google.common.io; import com.facebook.infer.builtins.InferCloseables; import com.facebook.infer.builtins.InferUndefined; - import java.io.Closeable; import java.io.IOException; public final class Closeables { - public static void close(Closeable closeable, boolean swallowIOException) throws IOException { - InferCloseables.close(closeable); - if (!swallowIOException) - InferUndefined.can_throw_ioexception_void(); - } - - public static void closeQuietly(Closeable closeable) { - InferCloseables.closeQuietly(closeable); - } + public static void close(Closeable closeable, boolean swallowIOException) throws IOException { + InferCloseables.close(closeable); + if (!swallowIOException) InferUndefined.can_throw_ioexception_void(); + } + public static void closeQuietly(Closeable closeable) { + InferCloseables.closeQuietly(closeable); + } } diff --git a/infer/models/java/src/dalvik/system/CloseGuard.java b/infer/models/java/src/dalvik/system/CloseGuard.java index efa5af7e9..e3bf779f0 100644 --- a/infer/models/java/src/dalvik/system/CloseGuard.java +++ b/infer/models/java/src/dalvik/system/CloseGuard.java @@ -7,10 +7,9 @@ package dalvik.system; - public class CloseGuard { - public static interface Reporter { - public void report(String message, Throwable allocationSite); - } + public static interface Reporter { + public void report(String message, Throwable allocationSite); + } } diff --git a/infer/models/java/src/java/io/BufferedInputStream.java b/infer/models/java/src/java/io/BufferedInputStream.java index a966aaeee..0568b271d 100644 --- a/infer/models/java/src/java/io/BufferedInputStream.java +++ b/infer/models/java/src/java/io/BufferedInputStream.java @@ -34,5 +34,4 @@ public class BufferedInputStream { public long skip(long n) throws IOException { return InferUndefined.can_throw_ioexception_long(); } - } diff --git a/infer/models/java/src/java/io/BufferedOutputStream.java b/infer/models/java/src/java/io/BufferedOutputStream.java index 8976ff99f..97344e42e 100644 --- a/infer/models/java/src/java/io/BufferedOutputStream.java +++ b/infer/models/java/src/java/io/BufferedOutputStream.java @@ -11,34 +11,33 @@ import com.facebook.infer.builtins.InferUndefined; public class BufferedOutputStream extends FilterOutputStream { - public BufferedOutputStream(OutputStream out) { - super(out); - } + public BufferedOutputStream(OutputStream out) { + super(out); + } - public BufferedOutputStream(OutputStream out, int size) { - super(out); - } + public BufferedOutputStream(OutputStream out, int size) { + super(out); + } - public void close() throws IOException { - if (out != null) { - out.close(); - } + public void close() throws IOException { + if (out != null) { + out.close(); } + } - public void flush() throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void flush() throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void write(int b) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void write(int b) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void write(byte b[], int off, int len) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } - - public void write(byte b[]) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void write(byte b[], int off, int len) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } + public void write(byte b[]) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } } diff --git a/infer/models/java/src/java/io/BufferedWriter.java b/infer/models/java/src/java/io/BufferedWriter.java index 2051191de..0b7739d94 100644 --- a/infer/models/java/src/java/io/BufferedWriter.java +++ b/infer/models/java/src/java/io/BufferedWriter.java @@ -9,35 +9,33 @@ package java.io; import com.facebook.infer.builtins.InferUndefined; - public abstract class BufferedWriter extends Writer { - public void flush() throws IOException { - InferUndefined.can_throw_ioexception_void(); - } - - public void newLine() throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void flush() throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void write(char cbuf[]) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void newLine() throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void write(char cbuf[], int off, int len) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void write(char cbuf[]) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void write(int c) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void write(char cbuf[], int off, int len) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void write(String str) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void write(int c) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void write(String str, int off, int len) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void write(String str) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } + public void write(String str, int off, int len) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } } diff --git a/infer/models/java/src/java/io/DataInputStream.java b/infer/models/java/src/java/io/DataInputStream.java index 3bde22d29..182947076 100644 --- a/infer/models/java/src/java/io/DataInputStream.java +++ b/infer/models/java/src/java/io/DataInputStream.java @@ -9,75 +9,73 @@ package java.io; import com.facebook.infer.builtins.InferUndefined; - public class DataInputStream { - public int read(byte b[]) throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } - - public int read(byte b[], int off, int len) throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } + public int read(byte b[]) throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } - public final boolean readBoolean() throws IOException { - return InferUndefined.can_throw_ioexception_boolean(); - } + public int read(byte b[], int off, int len) throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } - public final byte readByte() throws IOException { - return InferUndefined.can_throw_ioexception_byte(); - } + public final boolean readBoolean() throws IOException { + return InferUndefined.can_throw_ioexception_boolean(); + } - public final char readChar() throws IOException { - return InferUndefined.can_throw_ioexception_char(); - } + public final byte readByte() throws IOException { + return InferUndefined.can_throw_ioexception_byte(); + } - public final double readDouble() throws IOException { - return InferUndefined.can_throw_ioexception_double(); - } + public final char readChar() throws IOException { + return InferUndefined.can_throw_ioexception_char(); + } - public final float readFloat() throws IOException { - return InferUndefined.can_throw_ioexception_float(); - } + public final double readDouble() throws IOException { + return InferUndefined.can_throw_ioexception_double(); + } - public final void readFully(byte b[]) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public final float readFloat() throws IOException { + return InferUndefined.can_throw_ioexception_float(); + } - public final void readFully(byte b[], int off, int len) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public final void readFully(byte b[]) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public final int readInt() throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } + public final void readFully(byte b[], int off, int len) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public final long readLong() throws IOException { - return InferUndefined.can_throw_ioexception_long(); - } + public final int readInt() throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } - public final short readShort() throws IOException { - return InferUndefined.can_throw_ioexception_short(); - } + public final long readLong() throws IOException { + return InferUndefined.can_throw_ioexception_long(); + } - public final int readUnsignedByte() throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } + public final short readShort() throws IOException { + return InferUndefined.can_throw_ioexception_short(); + } - public final int readUnsignedShort() throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } + public final int readUnsignedByte() throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } - public final String readUTF() throws IOException { - return InferUndefined.can_throw_ioexception_string(); - } + public final int readUnsignedShort() throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } - public static final String readUTF(DataInput in) throws IOException { - return InferUndefined.can_throw_ioexception_string(); - } + public final String readUTF() throws IOException { + return InferUndefined.can_throw_ioexception_string(); + } - public final int skipBytes(int n) throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } + public static final String readUTF(DataInput in) throws IOException { + return InferUndefined.can_throw_ioexception_string(); + } + public final int skipBytes(int n) throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } } diff --git a/infer/models/java/src/java/io/DataOutputStream.java b/infer/models/java/src/java/io/DataOutputStream.java index cbbb4c84d..b897f72f4 100644 --- a/infer/models/java/src/java/io/DataOutputStream.java +++ b/infer/models/java/src/java/io/DataOutputStream.java @@ -9,71 +9,69 @@ package java.io; import com.facebook.infer.builtins.InferUndefined; - public class DataOutputStream extends FilterOutputStream { - public DataOutputStream(OutputStream out) { - super(out); - } - - public void flush() throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public DataOutputStream(OutputStream out) { + super(out); + } - public void write(byte b[], int off, int len) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void flush() throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void write(byte b[]) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void write(byte b[], int off, int len) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void write(int b) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void write(byte b[]) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public final void writeBoolean(boolean v) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void write(int b) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public final void writeByte(int v) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public final void writeBoolean(boolean v) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public final void writeBytes(String s) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public final void writeByte(int v) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public final void writeChar(int v) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public final void writeBytes(String s) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public final void writeChars(String s) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public final void writeChar(int v) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public final void writeDouble(double v) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public final void writeChars(String s) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public final void writeFloat(float v) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public final void writeDouble(double v) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public final void writeInt(int v) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public final void writeFloat(float v) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public final void writeLong(long v) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public final void writeInt(int v) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public final void writeShort(int v) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public final void writeLong(long v) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public final void writeUTF(String str) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public final void writeShort(int v) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } + public final void writeUTF(String str) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } } diff --git a/infer/models/java/src/java/io/File.java b/infer/models/java/src/java/io/File.java index a7d91b74d..1f896081c 100644 --- a/infer/models/java/src/java/io/File.java +++ b/infer/models/java/src/java/io/File.java @@ -12,12 +12,11 @@ import javax.annotation.Nullable; public class File { - public @Nullable File[] listFiles() { - if (InferUndefined.boolean_undefined()) { - return null; - } else { - return (File[])InferUndefined.object_undefined(); - } + public @Nullable File[] listFiles() { + if (InferUndefined.boolean_undefined()) { + return null; + } else { + return (File[]) InferUndefined.object_undefined(); } - + } } diff --git a/infer/models/java/src/java/io/FileInputStream.java b/infer/models/java/src/java/io/FileInputStream.java index 7d91db675..cb24fafdf 100644 --- a/infer/models/java/src/java/io/FileInputStream.java +++ b/infer/models/java/src/java/io/FileInputStream.java @@ -9,70 +9,67 @@ package java.io; import com.facebook.infer.builtins.InferBuiltins; import com.facebook.infer.builtins.InferUndefined; - - import java.nio.FileChannelImpl; import java.nio.channels.FileChannel; public class FileInputStream extends InputStream { - private FileDescriptor fd; - private FileChannel channel; - - private void init() { - InferBuiltins.__set_file_attribute(this); - } - - public FileInputStream(String name) throws FileNotFoundException { - if (InferUndefined.boolean_undefined()) { - init(); - } else { - throw new FileNotFoundException(); - } - } - - public FileInputStream(File file) throws FileNotFoundException { - if (InferUndefined.boolean_undefined()) { - init(); - } else { - throw new FileNotFoundException(); - } - } - - public FileInputStream(FileDescriptor fdObj) { - init(); - } - - public void close() throws IOException { - super.close(); - } - - public FileChannel getChannel() { - channel = new FileChannelImpl(this, fd, InferUndefined.int_undefined()); - return channel; - } - - public int available() throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } + private FileDescriptor fd; + private FileChannel channel; - @Override - public int read() throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } + private void init() { + InferBuiltins.__set_file_attribute(this); + } - @Override - public int read(byte b[]) throws IOException { - return InferUndefined.can_throw_ioexception_int(); + public FileInputStream(String name) throws FileNotFoundException { + if (InferUndefined.boolean_undefined()) { + init(); + } else { + throw new FileNotFoundException(); } + } - @Override - public int read(byte b[], int off, int len) throws IOException { - return InferUndefined.can_throw_ioexception_int(); + public FileInputStream(File file) throws FileNotFoundException { + if (InferUndefined.boolean_undefined()) { + init(); + } else { + throw new FileNotFoundException(); } - - public long skip(int n) throws IOException { - return InferUndefined.can_throw_ioexception_long(); - } - + } + + public FileInputStream(FileDescriptor fdObj) { + init(); + } + + public void close() throws IOException { + super.close(); + } + + public FileChannel getChannel() { + channel = new FileChannelImpl(this, fd, InferUndefined.int_undefined()); + return channel; + } + + public int available() throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } + + @Override + public int read() throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } + + @Override + public int read(byte b[]) throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } + + @Override + public int read(byte b[], int off, int len) throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } + + public long skip(int n) throws IOException { + return InferUndefined.can_throw_ioexception_long(); + } } diff --git a/infer/models/java/src/java/io/FileOutputStream.java b/infer/models/java/src/java/io/FileOutputStream.java index f792f72dc..10d8f1127 100644 --- a/infer/models/java/src/java/io/FileOutputStream.java +++ b/infer/models/java/src/java/io/FileOutputStream.java @@ -9,77 +9,73 @@ package java.io; import com.facebook.infer.builtins.InferBuiltins; import com.facebook.infer.builtins.InferUndefined; - import java.nio.FileChannelImpl; import java.nio.channels.FileChannel; - public class FileOutputStream extends OutputStream { - private FileDescriptor fd; - private FileChannel channel; + private FileDescriptor fd; + private FileChannel channel; - private void init() { - InferBuiltins.__set_file_attribute(this); - } - - public FileOutputStream(String name) throws FileNotFoundException { - if (InferUndefined.boolean_undefined()) { - init(); - } else { - throw new FileNotFoundException(); - } - } + private void init() { + InferBuiltins.__set_file_attribute(this); + } - public FileOutputStream(String name, boolean append) throws FileNotFoundException { - if (InferUndefined.boolean_undefined()) { - init(); - } else { - throw new FileNotFoundException(); - } + public FileOutputStream(String name) throws FileNotFoundException { + if (InferUndefined.boolean_undefined()) { + init(); + } else { + throw new FileNotFoundException(); } + } - public FileOutputStream(File file) throws FileNotFoundException { - if (InferUndefined.boolean_undefined()) { - init(); - } else { - throw new FileNotFoundException(); - } + public FileOutputStream(String name, boolean append) throws FileNotFoundException { + if (InferUndefined.boolean_undefined()) { + init(); + } else { + throw new FileNotFoundException(); } + } - public FileOutputStream(File file, boolean append) - throws FileNotFoundException { - if (InferUndefined.boolean_undefined()) { - init(); - } else { - throw new FileNotFoundException(); - } + public FileOutputStream(File file) throws FileNotFoundException { + if (InferUndefined.boolean_undefined()) { + init(); + } else { + throw new FileNotFoundException(); } + } - public FileOutputStream(FileDescriptor fdObj) { - init(); + public FileOutputStream(File file, boolean append) throws FileNotFoundException { + if (InferUndefined.boolean_undefined()) { + init(); + } else { + throw new FileNotFoundException(); } + } - public FileChannel getChannel() { - channel = new FileChannelImpl(this, fd, InferUndefined.int_undefined()); - return channel; - } + public FileOutputStream(FileDescriptor fdObj) { + init(); + } - public void write(int b) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public FileChannel getChannel() { + channel = new FileChannelImpl(this, fd, InferUndefined.int_undefined()); + return channel; + } - public void write(byte b[]) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void write(int b) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void write(byte b[], int off, int len) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void write(byte b[]) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void close() throws IOException { - InferBuiltins.__set_mem_attribute(this); - InferUndefined.can_throw_ioexception_void(); - } + public void write(byte b[], int off, int len) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } + public void close() throws IOException { + InferBuiltins.__set_mem_attribute(this); + InferUndefined.can_throw_ioexception_void(); + } } diff --git a/infer/models/java/src/java/io/FilterInputStream.java b/infer/models/java/src/java/io/FilterInputStream.java index d4efaaec4..9cee59d1d 100644 --- a/infer/models/java/src/java/io/FilterInputStream.java +++ b/infer/models/java/src/java/io/FilterInputStream.java @@ -11,29 +11,27 @@ import com.facebook.infer.builtins.InferUndefined; public class FilterInputStream { - public int available() throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } + public int available() throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } - public int read() throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } + public int read() throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } - public int read(byte b[]) throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } + public int read(byte b[]) throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } - public int read(byte b[], int off, int len) throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } - - public void reset() throws IOException { - InferUndefined.can_throw_ioexception_void(); - } - - public long skip(long n) throws IOException { - return InferUndefined.can_throw_ioexception_long(); - } + public int read(byte b[], int off, int len) throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } + public void reset() throws IOException { + InferUndefined.can_throw_ioexception_void(); + } + public long skip(long n) throws IOException { + return InferUndefined.can_throw_ioexception_long(); + } } diff --git a/infer/models/java/src/java/io/FilterOutputStream.java b/infer/models/java/src/java/io/FilterOutputStream.java index 815eba013..7a764020d 100644 --- a/infer/models/java/src/java/io/FilterOutputStream.java +++ b/infer/models/java/src/java/io/FilterOutputStream.java @@ -11,36 +11,33 @@ import com.facebook.infer.builtins.InferUndefined; public class FilterOutputStream { - protected OutputStream out; + protected OutputStream out; - public FilterOutputStream() { - } - - public FilterOutputStream(OutputStream out) { - this.out = out; - } - - public void close() throws IOException { - if (out != null) { - out.close(); - } - } + public FilterOutputStream() {} - public void flush() throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public FilterOutputStream(OutputStream out) { + this.out = out; + } - public void write(int b) throws IOException { - InferUndefined.can_throw_ioexception_void(); + public void close() throws IOException { + if (out != null) { + out.close(); } + } - public void write(byte b[]) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void flush() throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void write(byte b[], int off, int len) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void write(int b) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } + public void write(byte b[]) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } + public void write(byte b[], int off, int len) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } } diff --git a/infer/models/java/src/java/io/FilterReader.java b/infer/models/java/src/java/io/FilterReader.java index fff47f350..649a7b467 100644 --- a/infer/models/java/src/java/io/FilterReader.java +++ b/infer/models/java/src/java/io/FilterReader.java @@ -11,28 +11,27 @@ import com.facebook.infer.builtins.InferUndefined; public abstract class FilterReader { - public int read() throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } + public int read() throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } - public int read(char cbuf[]) throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } + public int read(char cbuf[]) throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } - public int read(char cbuf[], int off, int len) throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } + public int read(char cbuf[], int off, int len) throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } - public boolean ready() throws IOException { - return InferUndefined.can_throw_ioexception_boolean(); - } + public boolean ready() throws IOException { + return InferUndefined.can_throw_ioexception_boolean(); + } - public void reset() throws IOException { - InferUndefined.can_throw_ioexception_void(); - } - - public long skip(long n) throws IOException { - return InferUndefined.can_throw_ioexception_long(); - } + public void reset() throws IOException { + InferUndefined.can_throw_ioexception_void(); + } + public long skip(long n) throws IOException { + return InferUndefined.can_throw_ioexception_long(); + } } diff --git a/infer/models/java/src/java/io/InputStream.java b/infer/models/java/src/java/io/InputStream.java index a92db0b8a..c76c89b0b 100644 --- a/infer/models/java/src/java/io/InputStream.java +++ b/infer/models/java/src/java/io/InputStream.java @@ -12,21 +12,20 @@ import com.facebook.infer.builtins.InferUndefined; public class InputStream { - public void close() throws IOException { - InferBuiltins.__set_mem_attribute(this); - InferUndefined.can_throw_ioexception_void(); - } - - public int read() throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } - - public int read(byte b[]) throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } - - public int read(byte b[], int off, int len) throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } - + public void close() throws IOException { + InferBuiltins.__set_mem_attribute(this); + InferUndefined.can_throw_ioexception_void(); + } + + public int read() throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } + + public int read(byte b[]) throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } + + public int read(byte b[], int off, int len) throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } } diff --git a/infer/models/java/src/java/io/InputStreamReader.java b/infer/models/java/src/java/io/InputStreamReader.java index 29c457f43..f563affc8 100644 --- a/infer/models/java/src/java/io/InputStreamReader.java +++ b/infer/models/java/src/java/io/InputStreamReader.java @@ -11,37 +11,29 @@ import com.facebook.infer.builtins.InferBuiltins; import com.facebook.infer.builtins.InferUndefined; import com.facebook.infer.builtins.InferUtils; -import java.nio.charset.Charset; -import java.nio.charset.CharsetDecoder; - public abstract class InputStreamReader { - public InputStreamReader(InputStream in, String charsetName) - throws UnsupportedEncodingException { - if (charsetName == null) - throw new NullPointerException("charsetName"); - else if (InferUtils.isValidCharset(charsetName)) { - InferBuiltins.__set_mem_attribute(in); - InferBuiltins.__set_file_attribute(this); - } else - throw new UnsupportedEncodingException(); - } - - public int read() throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } - - public int read(char cbuf[]) throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } - - public int read(char[] cbuf, int off, int len) throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } - - public boolean ready() throws IOException { - return InferUndefined.can_throw_ioexception_boolean(); - } - - + public InputStreamReader(InputStream in, String charsetName) throws UnsupportedEncodingException { + if (charsetName == null) throw new NullPointerException("charsetName"); + else if (InferUtils.isValidCharset(charsetName)) { + InferBuiltins.__set_mem_attribute(in); + InferBuiltins.__set_file_attribute(this); + } else throw new UnsupportedEncodingException(); + } + + public int read() throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } + + public int read(char cbuf[]) throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } + + public int read(char[] cbuf, int off, int len) throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } + + public boolean ready() throws IOException { + return InferUndefined.can_throw_ioexception_boolean(); + } } diff --git a/infer/models/java/src/java/io/ObjectInputStream.java b/infer/models/java/src/java/io/ObjectInputStream.java index c293bc5ef..778889861 100644 --- a/infer/models/java/src/java/io/ObjectInputStream.java +++ b/infer/models/java/src/java/io/ObjectInputStream.java @@ -7,10 +7,8 @@ package java.io; -import com.facebook.infer.builtins.InferBuiltins; import com.facebook.infer.builtins.InferUndefined; - public class ObjectInputStream { InputStream in; @@ -26,8 +24,7 @@ public class ObjectInputStream { } } - protected ObjectInputStream() throws IOException, SecurityException { - } + protected ObjectInputStream() throws IOException, SecurityException {} public int available() throws IOException { return InferUndefined.can_throw_ioexception_int(); @@ -117,7 +114,5 @@ public class ObjectInputStream { return InferUndefined.can_throw_ioexception_int(); } - public static abstract class GetField { - } - + public abstract static class GetField {} } diff --git a/infer/models/java/src/java/io/ObjectOutputStream.java b/infer/models/java/src/java/io/ObjectOutputStream.java index 956921dd4..bf5629ba9 100644 --- a/infer/models/java/src/java/io/ObjectOutputStream.java +++ b/infer/models/java/src/java/io/ObjectOutputStream.java @@ -11,94 +11,94 @@ import com.facebook.infer.builtins.InferUndefined; public class ObjectOutputStream extends OutputStream { - private DataOutputStream output; + private DataOutputStream output; - public ObjectOutputStream(OutputStream out) throws IOException { - this.output = new DataOutputStream(out); - InferUndefined.can_throw_ioexception_void(); - } + public ObjectOutputStream(OutputStream out) throws IOException { + this.output = new DataOutputStream(out); + InferUndefined.can_throw_ioexception_void(); + } - public void close() throws IOException { - output.close(); - } + public void close() throws IOException { + output.close(); + } - public void defaultWriteObject() throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void defaultWriteObject() throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void flush() throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void flush() throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void reset() throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void reset() throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void write(byte b[]) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void write(byte b[]) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void write(byte b[], int off, int len) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void write(byte b[], int off, int len) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void write(int b) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void write(int b) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void writeBoolean(boolean val) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void writeBoolean(boolean val) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void writeByte(int val) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void writeByte(int val) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void writeBytes(String str) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void writeBytes(String str) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void writeChar(int val) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void writeChar(int val) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void writeChars(String str) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void writeChars(String str) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void writeDouble(double val) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void writeDouble(double val) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void writeFields() throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void writeFields() throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void writeFloat(float val) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void writeFloat(float val) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void writeInt(int val) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void writeInt(int val) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void writeLong(long val) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void writeLong(long val) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public final void writeObject(Object obj) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public final void writeObject(Object obj) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void writeShort(int val) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void writeShort(int val) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void writeUnshared(Object obj) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void writeUnshared(Object obj) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void writeUTF(String str) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void writeUTF(String str) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } } diff --git a/infer/models/java/src/java/io/OutputStream.java b/infer/models/java/src/java/io/OutputStream.java index 27944e976..6303e0b29 100644 --- a/infer/models/java/src/java/io/OutputStream.java +++ b/infer/models/java/src/java/io/OutputStream.java @@ -31,5 +31,4 @@ public class OutputStream { public void close() throws IOException { InferBuiltins.__set_mem_attribute(this); } - } diff --git a/infer/models/java/src/java/io/OutputStreamWriter.java b/infer/models/java/src/java/io/OutputStreamWriter.java index 3f8a35876..6c3c5a5ee 100644 --- a/infer/models/java/src/java/io/OutputStreamWriter.java +++ b/infer/models/java/src/java/io/OutputStreamWriter.java @@ -11,43 +11,37 @@ import com.facebook.infer.builtins.InferBuiltins; import com.facebook.infer.builtins.InferUndefined; import com.facebook.infer.builtins.InferUtils; -import java.nio.charset.Charset; -import java.nio.charset.CharsetEncoder; - public class OutputStreamWriter extends Writer { - public OutputStreamWriter(OutputStream out, String charsetName) - throws UnsupportedEncodingException { - if (charsetName == null) - throw new NullPointerException("charsetName"); - else if (InferUtils.isValidCharset(charsetName)) { - InferBuiltins.__set_file_attribute(this); - } else - throw new UnsupportedEncodingException(); - } - - public void flush() throws IOException { - InferUndefined.can_throw_ioexception_void(); - } - - public void write(char cbuf[]) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } - - public void write(char cbuf[], int off, int len) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } - - public void write(int c) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } - - public void write(String str) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } - - public void write(String str, int off, int len) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } - + public OutputStreamWriter(OutputStream out, String charsetName) + throws UnsupportedEncodingException { + if (charsetName == null) throw new NullPointerException("charsetName"); + else if (InferUtils.isValidCharset(charsetName)) { + InferBuiltins.__set_file_attribute(this); + } else throw new UnsupportedEncodingException(); + } + + public void flush() throws IOException { + InferUndefined.can_throw_ioexception_void(); + } + + public void write(char cbuf[]) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } + + public void write(char cbuf[], int off, int len) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } + + public void write(int c) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } + + public void write(String str) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } + + public void write(String str, int off, int len) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } } diff --git a/infer/models/java/src/java/io/PipedInputStream.java b/infer/models/java/src/java/io/PipedInputStream.java index b898ccc6f..fc87b5539 100644 --- a/infer/models/java/src/java/io/PipedInputStream.java +++ b/infer/models/java/src/java/io/PipedInputStream.java @@ -12,46 +12,44 @@ import com.facebook.infer.builtins.InferUndefined; public class PipedInputStream extends InputStream { - public PipedInputStream(PipedOutputStream src) throws IOException { - this(); - } - - public PipedInputStream(PipedOutputStream src, int pipeSize) - throws IOException { - this(); - } - - public PipedInputStream() { - InferBuiltins.__set_file_attribute(this); - } - - public PipedInputStream(int pipeSize) { - this(); - } - - public void close() throws IOException { - InferBuiltins.__set_mem_attribute(this); - InferUndefined.can_throw_ioexception_void(); - } - - public void connect(PipedOutputStream src) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } - - public int available() throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } - - public int read() throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } - - public int read(byte b[]) throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } - - public int read(byte b[], int off, int len) throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } - + public PipedInputStream(PipedOutputStream src) throws IOException { + this(); + } + + public PipedInputStream(PipedOutputStream src, int pipeSize) throws IOException { + this(); + } + + public PipedInputStream() { + InferBuiltins.__set_file_attribute(this); + } + + public PipedInputStream(int pipeSize) { + this(); + } + + public void close() throws IOException { + InferBuiltins.__set_mem_attribute(this); + InferUndefined.can_throw_ioexception_void(); + } + + public void connect(PipedOutputStream src) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } + + public int available() throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } + + public int read() throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } + + public int read(byte b[]) throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } + + public int read(byte b[], int off, int len) throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } } diff --git a/infer/models/java/src/java/io/PipedOutputStream.java b/infer/models/java/src/java/io/PipedOutputStream.java index 4fbcf38fb..23cf85817 100644 --- a/infer/models/java/src/java/io/PipedOutputStream.java +++ b/infer/models/java/src/java/io/PipedOutputStream.java @@ -12,37 +12,36 @@ import com.facebook.infer.builtins.InferUndefined; public class PipedOutputStream extends OutputStream { - - public PipedOutputStream(PipedInputStream snk) throws IOException { - InferBuiltins.__set_file_attribute(this); - } - - public PipedOutputStream() { - InferBuiltins.__set_file_attribute(this); - } - - public void close() throws IOException { - InferBuiltins.__set_mem_attribute(this); - InferUndefined.can_throw_ioexception_void(); - } - - public void connect(PipedInputStream snk) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } - - public void flush() throws IOException { - InferUndefined.can_throw_ioexception_void(); - } - - public void write(byte b[]) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } - - public void write(byte b[], int off, int len) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } - - public void write(int b) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public PipedOutputStream(PipedInputStream snk) throws IOException { + InferBuiltins.__set_file_attribute(this); + } + + public PipedOutputStream() { + InferBuiltins.__set_file_attribute(this); + } + + public void close() throws IOException { + InferBuiltins.__set_mem_attribute(this); + InferUndefined.can_throw_ioexception_void(); + } + + public void connect(PipedInputStream snk) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } + + public void flush() throws IOException { + InferUndefined.can_throw_ioexception_void(); + } + + public void write(byte b[]) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } + + public void write(byte b[], int off, int len) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } + + public void write(int b) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } } diff --git a/infer/models/java/src/java/io/PipedReader.java b/infer/models/java/src/java/io/PipedReader.java index 20d734183..6a84fc88d 100644 --- a/infer/models/java/src/java/io/PipedReader.java +++ b/infer/models/java/src/java/io/PipedReader.java @@ -12,56 +12,53 @@ import com.facebook.infer.builtins.InferUndefined; public class PipedReader extends Reader { - private void init() throws IOException { - InferUndefined.can_throw_ioexception_void(); - InferBuiltins.__set_file_attribute(this); - } + private void init() throws IOException { + InferUndefined.can_throw_ioexception_void(); + InferBuiltins.__set_file_attribute(this); + } - public PipedReader() { - } + public PipedReader() {} - public PipedReader(int pipeSize) { - } + public PipedReader(int pipeSize) {} - public PipedReader(PipedWriter src) throws IOException { - init(); - } + public PipedReader(PipedWriter src) throws IOException { + init(); + } - public PipedReader(PipedWriter src, int pipeSize) throws IOException { - init(); - } + public PipedReader(PipedWriter src, int pipeSize) throws IOException { + init(); + } - public void connect(PipedWriter src) throws IOException { - init(); - } + public void connect(PipedWriter src) throws IOException { + init(); + } - public int read() throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } + public int read() throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } - public int read(char[] cbuf, int off, int len) throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } + public int read(char[] cbuf, int off, int len) throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } - public boolean ready() throws IOException { - return InferUndefined.can_throw_ioexception_boolean(); - } + public boolean ready() throws IOException { + return InferUndefined.can_throw_ioexception_boolean(); + } - public void mark(int readAheadLimit) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void mark(int readAheadLimit) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void reset() throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void reset() throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public long skip(long n) throws IOException { - return InferUndefined.can_throw_ioexception_long(); - } - - public void close() throws IOException { - InferBuiltins.__set_mem_attribute(this); - InferUndefined.can_throw_ioexception_void(); - } + public long skip(long n) throws IOException { + return InferUndefined.can_throw_ioexception_long(); + } + public void close() throws IOException { + InferBuiltins.__set_mem_attribute(this); + InferUndefined.can_throw_ioexception_void(); + } } diff --git a/infer/models/java/src/java/io/PipedWriter.java b/infer/models/java/src/java/io/PipedWriter.java index 87c900dd3..25da3ff19 100644 --- a/infer/models/java/src/java/io/PipedWriter.java +++ b/infer/models/java/src/java/io/PipedWriter.java @@ -12,65 +12,62 @@ import com.facebook.infer.builtins.InferUndefined; public abstract class PipedWriter extends Writer { - private void init() throws IOException { - InferUndefined.can_throw_ioexception_void(); - InferBuiltins.__set_file_attribute(this); - } - - public PipedWriter() { - } - - public PipedWriter(PipedReader snk) throws IOException { - init(); - } - - public void connect(PipedReader snk) throws IOException { - init(); - } - - public Writer append(char c) throws IOException { - InferUndefined.can_throw_ioexception_void(); - return this; - } - - public Writer append(CharSequence csq) throws IOException { - InferUndefined.can_throw_ioexception_void(); - return this; - } - - public Writer append(CharSequence csq, int start, int end) - throws IOException { - InferUndefined.can_throw_ioexception_void(); - return this; - } - - public void flush() throws IOException { - InferUndefined.can_throw_ioexception_void(); - } - - public void write(char cbuf[]) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } - - public void write(char cbuf[], int off, int len) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } - - public void write(int c) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } - - public void write(String str) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } - - public void write(String str, int off, int len) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } - - public void close() throws IOException { - InferBuiltins.__set_mem_attribute(this); - InferUndefined.can_throw_ioexception_void(); - } - + private void init() throws IOException { + InferUndefined.can_throw_ioexception_void(); + InferBuiltins.__set_file_attribute(this); + } + + public PipedWriter() {} + + public PipedWriter(PipedReader snk) throws IOException { + init(); + } + + public void connect(PipedReader snk) throws IOException { + init(); + } + + public Writer append(char c) throws IOException { + InferUndefined.can_throw_ioexception_void(); + return this; + } + + public Writer append(CharSequence csq) throws IOException { + InferUndefined.can_throw_ioexception_void(); + return this; + } + + public Writer append(CharSequence csq, int start, int end) throws IOException { + InferUndefined.can_throw_ioexception_void(); + return this; + } + + public void flush() throws IOException { + InferUndefined.can_throw_ioexception_void(); + } + + public void write(char cbuf[]) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } + + public void write(char cbuf[], int off, int len) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } + + public void write(int c) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } + + public void write(String str) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } + + public void write(String str, int off, int len) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } + + public void close() throws IOException { + InferBuiltins.__set_mem_attribute(this); + InferUndefined.can_throw_ioexception_void(); + } } diff --git a/infer/models/java/src/java/io/PrintWriter.java b/infer/models/java/src/java/io/PrintWriter.java index e0a791f9a..843c5e33f 100644 --- a/infer/models/java/src/java/io/PrintWriter.java +++ b/infer/models/java/src/java/io/PrintWriter.java @@ -32,8 +32,7 @@ public abstract class PrintWriter { return this; } - public PrintWriter append(CharSequence csq, int start, int end) - throws IOException { + public PrintWriter append(CharSequence csq, int start, int end) throws IOException { InferUndefined.can_throw_ioexception_void(); return this; } @@ -68,5 +67,4 @@ public abstract class PrintWriter { mOutputStream.close(); } } - } diff --git a/infer/models/java/src/java/io/PushbackInputStream.java b/infer/models/java/src/java/io/PushbackInputStream.java index a83bf9773..20a815770 100644 --- a/infer/models/java/src/java/io/PushbackInputStream.java +++ b/infer/models/java/src/java/io/PushbackInputStream.java @@ -9,7 +9,6 @@ package java.io; import com.facebook.infer.builtins.InferUndefined; - public class PushbackInputStream { public int available() throws IOException { @@ -47,5 +46,4 @@ public class PushbackInputStream { public void unread(int b) throws IOException { InferUndefined.can_throw_ioexception_void(); } - } diff --git a/infer/models/java/src/java/io/PushbackReader.java b/infer/models/java/src/java/io/PushbackReader.java index b8a534540..6c7d28750 100644 --- a/infer/models/java/src/java/io/PushbackReader.java +++ b/infer/models/java/src/java/io/PushbackReader.java @@ -11,40 +11,39 @@ import com.facebook.infer.builtins.InferUndefined; public abstract class PushbackReader { - public int read() throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } + public int read() throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } - public int read(char cbuf[]) throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } + public int read(char cbuf[]) throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } - public int read(char cbuf[], int off, int len) throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } + public int read(char cbuf[], int off, int len) throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } - public boolean ready() throws IOException { - return InferUndefined.can_throw_ioexception_boolean(); - } + public boolean ready() throws IOException { + return InferUndefined.can_throw_ioexception_boolean(); + } - public void reset() throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void reset() throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public long skip(long n) throws IOException { - return InferUndefined.can_throw_ioexception_long(); - } + public long skip(long n) throws IOException { + return InferUndefined.can_throw_ioexception_long(); + } - public void unread(char cbuf[]) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void unread(char cbuf[]) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void unread(char cbuf[], int off, int len) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } - - public void unread(int c) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void unread(char cbuf[], int off, int len) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } + public void unread(int c) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } } diff --git a/infer/models/java/src/java/io/RandomAccessFile.java b/infer/models/java/src/java/io/RandomAccessFile.java index 4cce040fd..3f6776395 100644 --- a/infer/models/java/src/java/io/RandomAccessFile.java +++ b/infer/models/java/src/java/io/RandomAccessFile.java @@ -9,165 +9,161 @@ package java.io; import com.facebook.infer.builtins.InferBuiltins; import com.facebook.infer.builtins.InferUndefined; - import java.nio.FileChannelImpl; import java.nio.channels.FileChannel; public class RandomAccessFile implements Closeable { - private FileDescriptor fd; - private FileChannel channel; - + private FileDescriptor fd; + private FileChannel channel; - public RandomAccessFile(String name, String mode) - throws FileNotFoundException { - InferBuiltins.__set_file_attribute(this); - } + public RandomAccessFile(String name, String mode) throws FileNotFoundException { + InferBuiltins.__set_file_attribute(this); + } - public RandomAccessFile(File file, String mode) - throws FileNotFoundException { - InferBuiltins.__set_file_attribute(this); - } + public RandomAccessFile(File file, String mode) throws FileNotFoundException { + InferBuiltins.__set_file_attribute(this); + } - public FileChannel getChannel() { - channel = new FileChannelImpl(this, fd, InferUndefined.int_undefined()); - return channel; - } + public FileChannel getChannel() { + channel = new FileChannelImpl(this, fd, InferUndefined.int_undefined()); + return channel; + } - public void close() throws IOException { - InferBuiltins.__set_mem_attribute(this); - InferUndefined.can_throw_ioexception_void(); - } + public void close() throws IOException { + InferBuiltins.__set_mem_attribute(this); + InferUndefined.can_throw_ioexception_void(); + } - public int read() throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } + public int read() throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } - public int read(byte b[], int off, int len) throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } + public int read(byte b[], int off, int len) throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } - public int read(byte b[]) throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } + public int read(byte b[]) throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } - public final void readFully(byte b[]) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public final void readFully(byte b[]) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public final void readFully(byte b[], int off, int len) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public final void readFully(byte b[], int off, int len) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void write(int b) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void write(int b) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void write(byte b[]) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void write(byte b[]) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void write(byte b[], int off, int len) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void write(byte b[], int off, int len) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void seek(long pos) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void seek(long pos) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public long length() throws IOException { - return InferUndefined.can_throw_ioexception_long(); - } + public long length() throws IOException { + return InferUndefined.can_throw_ioexception_long(); + } - public final boolean readBoolean() throws IOException { - return InferUndefined.can_throw_ioexception_boolean(); - } + public final boolean readBoolean() throws IOException { + return InferUndefined.can_throw_ioexception_boolean(); + } - public final byte readByte() throws IOException { - return InferUndefined.can_throw_ioexception_byte(); - } + public final byte readByte() throws IOException { + return InferUndefined.can_throw_ioexception_byte(); + } - public final int readUnsignedByte() throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } + public final int readUnsignedByte() throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } - public final short readShort() throws IOException { - return InferUndefined.can_throw_ioexception_short(); - } + public final short readShort() throws IOException { + return InferUndefined.can_throw_ioexception_short(); + } - public final int readUnsignedShort() throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } + public final int readUnsignedShort() throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } - public final char readChar() throws IOException { - return InferUndefined.can_throw_ioexception_char(); - } + public final char readChar() throws IOException { + return InferUndefined.can_throw_ioexception_char(); + } - public final int readInt() throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } + public final int readInt() throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } - public final long readLong() throws IOException { - return InferUndefined.can_throw_ioexception_long(); - } + public final long readLong() throws IOException { + return InferUndefined.can_throw_ioexception_long(); + } - public final float readFloat() throws IOException { - return InferUndefined.can_throw_ioexception_float(); - } + public final float readFloat() throws IOException { + return InferUndefined.can_throw_ioexception_float(); + } - public final double readDouble() throws IOException { - return InferUndefined.can_throw_ioexception_double(); - } - - public final String readLine() throws IOException { - return InferUndefined.can_throw_ioexception_string(); - } - - public final String readUTF() throws IOException { - return InferUndefined.can_throw_ioexception_string(); - } - - public final void writeBoolean(boolean v) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } - - public final void writeByte(int v) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } - - public final void writeShort(int v) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public final double readDouble() throws IOException { + return InferUndefined.can_throw_ioexception_double(); + } + + public final String readLine() throws IOException { + return InferUndefined.can_throw_ioexception_string(); + } + + public final String readUTF() throws IOException { + return InferUndefined.can_throw_ioexception_string(); + } + + public final void writeBoolean(boolean v) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } + + public final void writeByte(int v) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } + + public final void writeShort(int v) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public final void writeChar(int v) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public final void writeChar(int v) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public final void writeInt(int v) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public final void writeInt(int v) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public final void writeLong(long v) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public final void writeLong(long v) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public final void writeFloat(float v) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public final void writeFloat(float v) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public final void writeDouble(double v) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public final void writeDouble(double v) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public final void writeBytes(String s) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public final void writeBytes(String s) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public final void writeChars(String s) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public final void writeChars(String s) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public final void writeUTF(String str) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public final void writeUTF(String str) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } } diff --git a/infer/models/java/src/java/io/Reader.java b/infer/models/java/src/java/io/Reader.java index 581e97517..d5f3b58af 100644 --- a/infer/models/java/src/java/io/Reader.java +++ b/infer/models/java/src/java/io/Reader.java @@ -12,37 +12,36 @@ import com.facebook.infer.builtins.InferUndefined; public abstract class Reader { - public void close() throws IOException { - InferBuiltins.__set_mem_attribute(this); - InferUndefined.can_throw_ioexception_void(); - } - - public int read() throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } - - public int read(char cbuf[]) throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } - - public int read(char cbuf[], int off, int len) throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } - - public int read(java.nio.CharBuffer target) throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } - - public boolean ready() throws IOException { - return InferUndefined.can_throw_ioexception_boolean(); - } - - public void reset() throws IOException { - InferUndefined.can_throw_ioexception_void(); - } - - public long skip(long n) throws IOException { - return InferUndefined.can_throw_ioexception_long(); - } - + public void close() throws IOException { + InferBuiltins.__set_mem_attribute(this); + InferUndefined.can_throw_ioexception_void(); + } + + public int read() throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } + + public int read(char cbuf[]) throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } + + public int read(char cbuf[], int off, int len) throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } + + public int read(java.nio.CharBuffer target) throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } + + public boolean ready() throws IOException { + return InferUndefined.can_throw_ioexception_boolean(); + } + + public void reset() throws IOException { + InferUndefined.can_throw_ioexception_void(); + } + + public long skip(long n) throws IOException { + return InferUndefined.can_throw_ioexception_long(); + } } diff --git a/infer/models/java/src/java/io/Writer.java b/infer/models/java/src/java/io/Writer.java index 6360fb007..cac7a0202 100644 --- a/infer/models/java/src/java/io/Writer.java +++ b/infer/models/java/src/java/io/Writer.java @@ -11,44 +11,42 @@ import com.facebook.infer.builtins.InferUndefined; public abstract class Writer { - public Writer append(char c) throws IOException { - InferUndefined.can_throw_ioexception_void(); - return this; - } - - public Writer append(CharSequence csq) throws IOException { - InferUndefined.can_throw_ioexception_void(); - return this; - } - - public Writer append(CharSequence csq, int start, int end) - throws IOException { - InferUndefined.can_throw_ioexception_void(); - return this; - } - - public void flush() throws IOException { - InferUndefined.can_throw_ioexception_void(); - } - - public void write(char cbuf[]) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } - - public void write(char cbuf[], int off, int len) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } - - public void write(int c) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } - - public void write(String str) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } - - public void write(String str, int off, int len) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } - + public Writer append(char c) throws IOException { + InferUndefined.can_throw_ioexception_void(); + return this; + } + + public Writer append(CharSequence csq) throws IOException { + InferUndefined.can_throw_ioexception_void(); + return this; + } + + public Writer append(CharSequence csq, int start, int end) throws IOException { + InferUndefined.can_throw_ioexception_void(); + return this; + } + + public void flush() throws IOException { + InferUndefined.can_throw_ioexception_void(); + } + + public void write(char cbuf[]) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } + + public void write(char cbuf[], int off, int len) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } + + public void write(int c) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } + + public void write(String str) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } + + public void write(String str, int off, int len) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } } diff --git a/infer/models/java/src/java/lang/Class.java b/infer/models/java/src/java/lang/Class.java index 22b70f140..981b50523 100644 --- a/infer/models/java/src/java/lang/Class.java +++ b/infer/models/java/src/java/lang/Class.java @@ -9,25 +9,23 @@ package java.lang; public final class Class { - transient String name; + transient String name; - public String getName() { - return this.name; - } + public String getName() { + return this.name; + } - public static Class forName(String className) - throws ClassNotFoundException { - return new Class(); - } + public static Class forName(String className) throws ClassNotFoundException { + return new Class(); + } - public boolean isAssignableFrom(Class cls) { - return false; - } - - public static Class getPrimitiveClass(String name) { - Class c = new Class(); - c.name = name; - return c; - } + public boolean isAssignableFrom(Class cls) { + return false; + } + public static Class getPrimitiveClass(String name) { + Class c = new Class(); + c.name = name; + return c; + } } diff --git a/infer/models/java/src/java/lang/Integer.java b/infer/models/java/src/java/lang/Integer.java index 548ce3cb9..c75e8696c 100644 --- a/infer/models/java/src/java/lang/Integer.java +++ b/infer/models/java/src/java/lang/Integer.java @@ -24,12 +24,11 @@ public final class Integer { public boolean equals(Object anObject) { return anObject != null - && anObject instanceof Integer - && this.value == ((Integer) anObject).value; + && anObject instanceof Integer + && this.value == ((Integer) anObject).value; } public int intValue() { return this.value; } - } diff --git a/infer/models/java/src/java/lang/NullPointerException.java b/infer/models/java/src/java/lang/NullPointerException.java index 4f75211f6..fad7a7d85 100644 --- a/infer/models/java/src/java/lang/NullPointerException.java +++ b/infer/models/java/src/java/lang/NullPointerException.java @@ -9,10 +9,7 @@ package java.lang; public class NullPointerException extends RuntimeException { - public NullPointerException() { - } - - public NullPointerException(String s) { - } + public NullPointerException() {} + public NullPointerException(String s) {} } diff --git a/infer/models/java/src/java/lang/Object.java b/infer/models/java/src/java/lang/Object.java index 01e81bf12..7dac90a34 100644 --- a/infer/models/java/src/java/lang/Object.java +++ b/infer/models/java/src/java/lang/Object.java @@ -11,13 +11,13 @@ import com.facebook.infer.builtins.InferUndefined; public class Object { - public Class getClass() { - Class c = new Class(); - c.name = (String)InferUndefined.object_undefined(); - return c; - } + public Class getClass() { + Class c = new Class(); + c.name = (String) InferUndefined.object_undefined(); + return c; + } - public int hashCode() { - return InferUndefined.int_undefined(); - } + public int hashCode() { + return InferUndefined.int_undefined(); + } } diff --git a/infer/models/java/src/java/lang/Process.java b/infer/models/java/src/java/lang/Process.java index 8077c8ef4..7b9e2d581 100644 --- a/infer/models/java/src/java/lang/Process.java +++ b/infer/models/java/src/java/lang/Process.java @@ -8,8 +8,6 @@ package java.lang; import com.facebook.infer.builtins.InferBuiltins; -import com.facebook.infer.builtins.InferUndefined; - import java.io.FileDescriptor; public class Process { @@ -26,5 +24,4 @@ public class Process { destroy(); return this; } - } diff --git a/infer/models/java/src/java/lang/ProcessManager.java b/infer/models/java/src/java/lang/ProcessManager.java index 1168ab3be..28129d9c1 100644 --- a/infer/models/java/src/java/lang/ProcessManager.java +++ b/infer/models/java/src/java/lang/ProcessManager.java @@ -8,19 +8,18 @@ package java.lang; import com.facebook.infer.builtins.InferUndefined; - import java.io.File; import java.io.FileDescriptor; import java.io.IOException; -import java.lang.ref.ReferenceQueue; -import java.lang.ref.WeakReference; - - abstract class ProcessManager { - public Process exec(String[] taintedCommand, String[] taintedEnvironment, File workingDirectory, - boolean redirectErrorStream) throws IOException { + public Process exec( + String[] taintedCommand, + String[] taintedEnvironment, + File workingDirectory, + boolean redirectErrorStream) + throws IOException { FileDescriptor in = new FileDescriptor(); FileDescriptor out = new FileDescriptor(); @@ -30,5 +29,4 @@ abstract class ProcessManager { } public static native ProcessManager getInstance(); - } diff --git a/infer/models/java/src/java/lang/Runtime.java b/infer/models/java/src/java/lang/Runtime.java index 3f5be176b..1a08e4f94 100644 --- a/infer/models/java/src/java/lang/Runtime.java +++ b/infer/models/java/src/java/lang/Runtime.java @@ -10,11 +10,9 @@ package java.lang; import java.io.File; import java.io.IOException; - public class Runtime { - private Runtime() { - } + private Runtime() {} public Process exec(String command) throws IOException { return exec(command, null, null); @@ -24,8 +22,7 @@ public class Runtime { return exec(command, envp, null); } - public Process exec(String command, String[] envp, File dir) - throws IOException { + public Process exec(String command, String[] envp, File dir) throws IOException { return ProcessManager.getInstance().exec(null, envp, null, false); } @@ -37,9 +34,7 @@ public class Runtime { return exec(cmdarray, envp, null); } - public Process exec(String[] cmdarray, String[] envp, File dir) - throws IOException { + public Process exec(String[] cmdarray, String[] envp, File dir) throws IOException { return ProcessManager.getInstance().exec(cmdarray, envp, dir, false); } - } diff --git a/infer/models/java/src/java/lang/String.java b/infer/models/java/src/java/lang/String.java index e64faf7bb..e351f698e 100644 --- a/infer/models/java/src/java/lang/String.java +++ b/infer/models/java/src/java/lang/String.java @@ -8,56 +8,50 @@ package java.lang; import com.facebook.infer.builtins.InferUndefined; -import com.facebook.infer.builtins.InferBuiltins; public final class String { - private final char[] value; - private final int offset; - private final int count; + private final char[] value; + private final int offset; + private final int count; - public int length() { - if (this == "") - return 0; - else { - return InferUndefined.nonneg_int(); - } + public int length() { + if (this == "") return 0; + else { + return InferUndefined.nonneg_int(); } - - public String() { - this.offset = 0; - this.count = 0; - this.value = new char[0]; - } - - public String(byte bytes[]) { - this(bytes, 0, bytes.length); - } - - - public String(byte bytes[], int offset, int length) { - checkBounds(bytes, offset, length); - char[] v = new char[bytes[0]]; /** yes, this could be improved **/ - this.offset = 0; - this.count = v.length; - this.value = v; + } + + public String() { + this.offset = 0; + this.count = 0; + this.value = new char[0]; + } + + public String(byte bytes[]) { + this(bytes, 0, bytes.length); + } + + public String(byte bytes[], int offset, int length) { + checkBounds(bytes, offset, length); + char[] v = new char[bytes[0]]; + /** yes, this could be improved * */ + this.offset = 0; + this.count = v.length; + this.value = v; + } + + private static void checkBounds(byte[] bytes, int offset, int length) { + if (length < 0) throw new StringIndexOutOfBoundsException(length); + if (offset < 0) throw new StringIndexOutOfBoundsException(offset); + if (offset > bytes.length - length) throw new StringIndexOutOfBoundsException(offset + length); + } + + public boolean equals(Object anObject) { + if (this == anObject) { + return true; + } else { + return InferUndefined.boolean_undefined(); } - - private static void checkBounds(byte[] bytes, int offset, int length) { - if (length < 0) - throw new StringIndexOutOfBoundsException(length); - if (offset < 0) - throw new StringIndexOutOfBoundsException(offset); - if (offset > bytes.length - length) - throw new StringIndexOutOfBoundsException(offset + length); - } - - public boolean equals(Object anObject) { - if (this == anObject) { - return true; - } else { - return InferUndefined.boolean_undefined(); - } - } - + } } diff --git a/infer/models/java/src/java/lang/System.java b/infer/models/java/src/java/lang/System.java index 4de4082c1..f0388f1b1 100644 --- a/infer/models/java/src/java/lang/System.java +++ b/infer/models/java/src/java/lang/System.java @@ -9,41 +9,35 @@ package java.lang; import com.facebook.infer.builtins.InferBuiltins; import com.facebook.infer.builtins.InferUndefined; - import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.InputStream; import java.io.PrintStream; - public final class System { - private System() { - } + private System() {} - public final static InputStream in; + public static final InputStream in; - static { - byte[] arr = {0}; - in = new ByteArrayInputStream(arr); - } + static { + byte[] arr = {0}; + in = new ByteArrayInputStream(arr); + } - public final static PrintStream out = new PrintStream( - new ByteArrayOutputStream()); + public static final PrintStream out = new PrintStream(new ByteArrayOutputStream()); - public final static PrintStream err = new PrintStream( - new ByteArrayOutputStream()); + public static final PrintStream err = new PrintStream(new ByteArrayOutputStream()); - public static void exit(int status) { - InferBuiltins._exit(); - } + public static void exit(int status) { + InferBuiltins._exit(); + } - public static String getProperty(String key) { - int n = key.length(); // key must not be null - if (InferUndefined.boolean_undefined()) { - return null; - } - return (String)InferUndefined.object_undefined(); + public static String getProperty(String key) { + int n = key.length(); // key must not be null + if (InferUndefined.boolean_undefined()) { + return null; } - + return (String) InferUndefined.object_undefined(); + } } diff --git a/infer/models/java/src/java/lang/Thread.java b/infer/models/java/src/java/lang/Thread.java index cfa3bc91c..a6bd0e267 100644 --- a/infer/models/java/src/java/lang/Thread.java +++ b/infer/models/java/src/java/lang/Thread.java @@ -7,8 +7,8 @@ package java.lang; -import com.facebook.infer.builtins.InferUndefined; import com.facebook.infer.builtins.InferBuiltins; +import com.facebook.infer.builtins.InferUndefined; class Thread implements Runnable { @@ -25,12 +25,10 @@ class Thread implements Runnable { public static boolean holdsLock(Object obj) { if (InferUndefined.boolean_undefined()) { - InferBuiltins.__set_locked_attribute(obj); - return true; + InferBuiltins.__set_locked_attribute(obj); + return true; } else { - return false; - } - + return false; + } } - } diff --git a/infer/models/java/src/java/lang/reflect/Array.java b/infer/models/java/src/java/lang/reflect/Array.java index b3585c7ea..8d4652f97 100644 --- a/infer/models/java/src/java/lang/reflect/Array.java +++ b/infer/models/java/src/java/lang/reflect/Array.java @@ -11,30 +11,28 @@ import com.facebook.infer.builtins.InferUndefined; public final class Array { - public static Object newInstance(Class componentType, int length) - throws NegativeArraySizeException { - String name = componentType.getName(); - if (length < 0) { - throw new NegativeArraySizeException(); - } - if (name == "int") { - return new int[length]; - } else if (name == "short") { - return new short[length]; - } else if (name == "byte") { - return new byte[length]; - } else if (name == "boolean") { - return new boolean[length]; - } else if (name == "long") { - return new long[length]; - } else if (name == "float") { - return new float[length]; - } else if (name == "double") { - return new double[length]; - } else if (name == "char") { - return new char[length]; - } else - return InferUndefined.object_undefined(); + public static Object newInstance(Class componentType, int length) + throws NegativeArraySizeException { + String name = componentType.getName(); + if (length < 0) { + throw new NegativeArraySizeException(); } - + if (name == "int") { + return new int[length]; + } else if (name == "short") { + return new short[length]; + } else if (name == "byte") { + return new byte[length]; + } else if (name == "boolean") { + return new boolean[length]; + } else if (name == "long") { + return new long[length]; + } else if (name == "float") { + return new float[length]; + } else if (name == "double") { + return new double[length]; + } else if (name == "char") { + return new char[length]; + } else return InferUndefined.object_undefined(); + } } diff --git a/infer/models/java/src/java/net/HttpURLConnection.java b/infer/models/java/src/java/net/HttpURLConnection.java index c921e886b..4ed7ec4cd 100644 --- a/infer/models/java/src/java/net/HttpURLConnection.java +++ b/infer/models/java/src/java/net/HttpURLConnection.java @@ -11,12 +11,12 @@ import com.facebook.infer.builtins.InferBuiltins; public class HttpURLConnection extends URLConnection { - public HttpURLConnection(URL url) { - super(url); - InferBuiltins.__set_file_attribute(this); - } + public HttpURLConnection(URL url) { + super(url); + InferBuiltins.__set_file_attribute(this); + } - public void disconnect() { - InferBuiltins.__set_mem_attribute(this); - } + public void disconnect() { + InferBuiltins.__set_mem_attribute(this); + } } diff --git a/infer/models/java/src/java/net/JarURLConnection.java b/infer/models/java/src/java/net/JarURLConnection.java index c8ed59fe7..f4faa25ae 100644 --- a/infer/models/java/src/java/net/JarURLConnection.java +++ b/infer/models/java/src/java/net/JarURLConnection.java @@ -9,7 +9,7 @@ package java.net; public class JarURLConnection extends URLConnection { - protected JarURLConnection(URL url) throws MalformedURLException { - super(url); - } + protected JarURLConnection(URL url) throws MalformedURLException { + super(url); + } } diff --git a/infer/models/java/src/java/net/PlainSocketImpl.java b/infer/models/java/src/java/net/PlainSocketImpl.java index b7383c778..349c04883 100644 --- a/infer/models/java/src/java/net/PlainSocketImpl.java +++ b/infer/models/java/src/java/net/PlainSocketImpl.java @@ -9,123 +9,120 @@ package java.net; import com.facebook.infer.builtins.InferBuiltins; import com.facebook.infer.builtins.InferUndefined; - import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; - abstract class PlainSocketImpl extends SocketImpl { - PlainSocketImpl() { - InferBuiltins.__set_file_attribute(this); - } - - protected void create(boolean stream) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + PlainSocketImpl() { + InferBuiltins.__set_file_attribute(this); + } - protected void connect(String host, int port) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + protected void create(boolean stream) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - protected void connect(InetAddress address, int port) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + protected void connect(String host, int port) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - protected void connect(SocketAddress address, int timeout) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + protected void connect(InetAddress address, int port) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - protected void bind(InetAddress host, int port) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + protected void connect(SocketAddress address, int timeout) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - protected void listen(int backlog) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + protected void bind(InetAddress host, int port) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - protected void accept(SocketImpl s) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + protected void listen(int backlog) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public synchronized InputStream getInputStream() throws IOException { - return new PlainSocketInputStream(); - } + protected void accept(SocketImpl s) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public synchronized OutputStream getOutputStream() throws IOException { - return new PlainSocketOutputStream(); - } + public synchronized InputStream getInputStream() throws IOException { + return new PlainSocketInputStream(); + } - protected int available() throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } + public synchronized OutputStream getOutputStream() throws IOException { + return new PlainSocketOutputStream(); + } - protected void close() throws IOException { - InferBuiltins.__set_mem_attribute(this); - InferUndefined.can_throw_ioexception_void(); - } + protected int available() throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } - protected void finalize() throws IOException { - close(); - } + protected void close() throws IOException { + InferBuiltins.__set_mem_attribute(this); + InferUndefined.can_throw_ioexception_void(); + } - void socketCreate(boolean isServer) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + protected void finalize() throws IOException { + close(); + } - void socketConnect(InetAddress address, int port, int timeout) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + void socketCreate(boolean isServer) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - void socketBind(InetAddress address, int port) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + void socketConnect(InetAddress address, int port, int timeout) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - void socketListen(int count) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + void socketBind(InetAddress address, int port) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } + void socketListen(int count) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - void socketAccept(SocketImpl s) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + void socketAccept(SocketImpl s) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - int socketAvailable() throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } + int socketAvailable() throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } - void socketClose0(boolean useDeferredClose) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + void socketClose0(boolean useDeferredClose) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - void socketShutdown(int howto) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + void socketShutdown(int howto) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - void socketSetOption(int cmd, boolean on, Object value) throws SocketException { - InferUndefined.can_throw_socketexception_void(); - } + void socketSetOption(int cmd, boolean on, Object value) throws SocketException { + InferUndefined.can_throw_socketexception_void(); + } - int socketGetOption(int opt, Object iaContainerObj) throws SocketException { - return InferUndefined.can_throw_socketexception_int(); - } + int socketGetOption(int opt, Object iaContainerObj) throws SocketException { + return InferUndefined.can_throw_socketexception_int(); + } - void socketSendUrgentData(int data) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + void socketSendUrgentData(int data) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public Object getOption(int opt) throws SocketException { - return InferUndefined.can_throw_socketexception_object(); - } + public Object getOption(int opt) throws SocketException { + return InferUndefined.can_throw_socketexception_object(); + } - public void setOption(int opt, Object val) throws SocketException { - InferUndefined.can_throw_socketexception_void(); - } + public void setOption(int opt, Object val) throws SocketException { + InferUndefined.can_throw_socketexception_void(); + } - protected void sendUrgentData(int data) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + protected void sendUrgentData(int data) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } private static class PlainSocketInputStream extends InputStream { @@ -148,7 +145,6 @@ abstract class PlainSocketImpl extends SocketImpl { public void close() { InferBuiltins.__set_mem_attribute(this); } - } private static class PlainSocketOutputStream extends OutputStream { @@ -168,7 +164,5 @@ abstract class PlainSocketImpl extends SocketImpl { public void close() { InferBuiltins.__set_mem_attribute(this); } - } - } diff --git a/infer/models/java/src/java/net/ServerSocket.java b/infer/models/java/src/java/net/ServerSocket.java index c2753ec90..3eb254971 100644 --- a/infer/models/java/src/java/net/ServerSocket.java +++ b/infer/models/java/src/java/net/ServerSocket.java @@ -8,15 +8,13 @@ package java.net; import com.facebook.infer.builtins.InferUndefined; - import java.io.IOException; public class ServerSocket { - public Socket accept() throws IOException { - if (InferUndefined.boolean_undefined()) { - return new Socket(); - } else throw new IOException(); - } - + public Socket accept() throws IOException { + if (InferUndefined.boolean_undefined()) { + return new Socket(); + } else throw new IOException(); + } } diff --git a/infer/models/java/src/java/net/Socket.java b/infer/models/java/src/java/net/Socket.java index 0083d0168..10717c12d 100644 --- a/infer/models/java/src/java/net/Socket.java +++ b/infer/models/java/src/java/net/Socket.java @@ -7,12 +7,11 @@ package java.net; +import com.facebook.infer.builtins.InferBuiltins; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import com.facebook.infer.builtins.InferBuiltins; - public class Socket { InputStream inputStream; @@ -38,5 +37,4 @@ public class Socket { InferBuiltins.__set_mem_attribute(inputStream); InferBuiltins.__set_mem_attribute(outputStream); } - } diff --git a/infer/models/java/src/java/net/URL.java b/infer/models/java/src/java/net/URL.java index ac760a5a3..d35e6e4ca 100644 --- a/infer/models/java/src/java/net/URL.java +++ b/infer/models/java/src/java/net/URL.java @@ -8,60 +8,53 @@ package java.net; import javax.net.ssl.HttpsURLConnection; -import java.util.Hashtable; -import com.facebook.infer.builtins.InferBuiltins; public final class URL implements java.io.Serializable { - private String protocol; - private String host; - private int port; - private String file; - - public URL(String protocol, String host, int port, String file) throws MalformedURLException { - this(protocol, host, port, file, null); - } - - - public URL(String protocol, String host, String file) throws MalformedURLException { - this(protocol, host, -1, file); - } - - - public URL(String protocol, String host, int port, String file, - URLStreamHandler handler) throws MalformedURLException { - this.protocol = protocol; - this.host = host; - this.file = file; - this.port = port; - } - - public URL(String spec) throws MalformedURLException { - this(null, spec); - } - - public URL(URL context, String spec) throws MalformedURLException { - this(context, spec, null); - } - - public URL(URL context, String spec, URLStreamHandler handler) throws MalformedURLException { - protocol = spec; - } - - - public URLConnection openConnection(Proxy proxy) throws java.io.IOException { - if (protocol == "jar") { - return new JarURLConnection(this); - } else if (protocol == "http") { - return new HttpURLConnection(this); - } else if (protocol == "https") { - return new HttpsURLConnection(this); - } else - return new URLConnection(this); - } - - public URLConnection openConnection() throws java.io.IOException { - return openConnection(null); - } - + private String protocol; + private String host; + private int port; + private String file; + + public URL(String protocol, String host, int port, String file) throws MalformedURLException { + this(protocol, host, port, file, null); + } + + public URL(String protocol, String host, String file) throws MalformedURLException { + this(protocol, host, -1, file); + } + + public URL(String protocol, String host, int port, String file, URLStreamHandler handler) + throws MalformedURLException { + this.protocol = protocol; + this.host = host; + this.file = file; + this.port = port; + } + + public URL(String spec) throws MalformedURLException { + this(null, spec); + } + + public URL(URL context, String spec) throws MalformedURLException { + this(context, spec, null); + } + + public URL(URL context, String spec, URLStreamHandler handler) throws MalformedURLException { + protocol = spec; + } + + public URLConnection openConnection(Proxy proxy) throws java.io.IOException { + if (protocol == "jar") { + return new JarURLConnection(this); + } else if (protocol == "http") { + return new HttpURLConnection(this); + } else if (protocol == "https") { + return new HttpsURLConnection(this); + } else return new URLConnection(this); + } + + public URLConnection openConnection() throws java.io.IOException { + return openConnection(null); + } } diff --git a/infer/models/java/src/java/net/URLConnection.java b/infer/models/java/src/java/net/URLConnection.java index 2c59a78d8..dacf170cb 100644 --- a/infer/models/java/src/java/net/URLConnection.java +++ b/infer/models/java/src/java/net/URLConnection.java @@ -15,29 +15,28 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; - public class URLConnection { - protected URL url; + protected URL url; - public URLConnection(URL url) { - this.url = url; - } + public URLConnection(URL url) { + this.url = url; + } - public URL getURL() { - return url; - } + public URL getURL() { + return url; + } - public InputStream getInputStream() throws IOException { - if (this instanceof HttpURLConnection) { - byte[] arr = {1}; - return new ByteArrayInputStream(arr); - } else return new FileInputStream(""); - } + public InputStream getInputStream() throws IOException { + if (this instanceof HttpURLConnection) { + byte[] arr = {1}; + return new ByteArrayInputStream(arr); + } else return new FileInputStream(""); + } - public OutputStream getOutputStream() throws IOException { - if (this instanceof HttpURLConnection) { - return new ByteArrayOutputStream(); - } else return new FileOutputStream(""); - } + public OutputStream getOutputStream() throws IOException { + if (this instanceof HttpURLConnection) { + return new ByteArrayOutputStream(); + } else return new FileOutputStream(""); + } } diff --git a/infer/models/java/src/java/nio/FileChannelImpl.java b/infer/models/java/src/java/nio/FileChannelImpl.java index ae6416706..7547aef5c 100644 --- a/infer/models/java/src/java/nio/FileChannelImpl.java +++ b/infer/models/java/src/java/nio/FileChannelImpl.java @@ -8,7 +8,6 @@ package java.nio; import com.facebook.infer.builtins.InferUndefined; - import java.io.FileDescriptor; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -20,80 +19,77 @@ import java.nio.channels.WritableByteChannel; public class FileChannelImpl extends FileChannel { - private Object stream; - private FileDescriptor fd; - private int mode; - - public FileChannelImpl(Object stream, FileDescriptor fd, int mode) { - this.fd = fd; - this.stream = stream; - this.mode = mode; + private Object stream; + private FileDescriptor fd; + private int mode; + + public FileChannelImpl(Object stream, FileDescriptor fd, int mode) { + this.fd = fd; + this.stream = stream; + this.mode = mode; + } + + public void implCloseChannel() throws IOException { + if (stream instanceof FileInputStream) { + ((FileInputStream) stream).close(); + } else if (stream instanceof FileOutputStream) { + ((FileOutputStream) stream).close(); + } else if (stream instanceof RandomAccessFile) { + ((RandomAccessFile) stream).close(); } + } - public void implCloseChannel() throws IOException { - if (stream instanceof FileInputStream) { - ((FileInputStream) stream).close(); - } else if (stream instanceof FileOutputStream) { - ((FileOutputStream) stream).close(); - } else if (stream instanceof RandomAccessFile) { - ((RandomAccessFile) stream).close(); - } - } + public long position() throws IOException { + return InferUndefined.can_throw_ioexception_long(); + } - public long position() throws IOException { - return InferUndefined.can_throw_ioexception_long(); - } + public FileChannel position(long newPosition) throws IOException { + if (InferUndefined.boolean_undefined()) throw new IOException(); + else return this; + } - public FileChannel position(long newPosition) throws IOException { - if (InferUndefined.boolean_undefined()) - throw new IOException(); - else return this; - } - - public int read(ByteBuffer buffer, long position) throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } - - public int read(ByteBuffer buffer) throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } + public int read(ByteBuffer buffer, long position) throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } - public long read(ByteBuffer[] buffers, int offset, int length) throws IOException { - return InferUndefined.can_throw_ioexception_long(); - } + public int read(ByteBuffer buffer) throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } - public long size() throws IOException { - return InferUndefined.can_throw_ioexception_long(); - } + public long read(ByteBuffer[] buffers, int offset, int length) throws IOException { + return InferUndefined.can_throw_ioexception_long(); + } - public long transferFrom(ReadableByteChannel src, long position, long count) throws IOException { - return InferUndefined.can_throw_ioexception_long(); - } + public long size() throws IOException { + return InferUndefined.can_throw_ioexception_long(); + } - public long transferTo(long position, long count, WritableByteChannel target) throws IOException { - return InferUndefined.can_throw_ioexception_long(); - } + public long transferFrom(ReadableByteChannel src, long position, long count) throws IOException { + return InferUndefined.can_throw_ioexception_long(); + } - public FileChannel truncate(long size) throws IOException { - if (InferUndefined.boolean_undefined()) - throw new IOException(); - else return this; - } + public long transferTo(long position, long count, WritableByteChannel target) throws IOException { + return InferUndefined.can_throw_ioexception_long(); + } - public int write(ByteBuffer buffer, long position) throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } + public FileChannel truncate(long size) throws IOException { + if (InferUndefined.boolean_undefined()) throw new IOException(); + else return this; + } - public int write(ByteBuffer buffer) throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } + public int write(ByteBuffer buffer, long position) throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } - public long write(ByteBuffer[] buffers, int offset, int length) throws IOException { - return InferUndefined.can_throw_ioexception_long(); - } + public int write(ByteBuffer buffer) throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } - public FileDescriptor getFD() { - return fd; - } + public long write(ByteBuffer[] buffers, int offset, int length) throws IOException { + return InferUndefined.can_throw_ioexception_long(); + } + public FileDescriptor getFD() { + return fd; + } } diff --git a/infer/models/java/src/java/nio/channels/FileChannel.java b/infer/models/java/src/java/nio/channels/FileChannel.java index 6aa03d3de..e6599b3ba 100644 --- a/infer/models/java/src/java/nio/channels/FileChannel.java +++ b/infer/models/java/src/java/nio/channels/FileChannel.java @@ -8,35 +8,35 @@ package java.nio.channels; import com.facebook.infer.builtins.InferUndefined; -import javax.annotation.Nullable; import java.io.IOException; import java.nio.channels.spi.AbstractInterruptibleChannel; -import java.nio.channels.FileLock; +import javax.annotation.Nullable; public abstract class FileChannel extends AbstractInterruptibleChannel { - public static class MapMode { + public static class MapMode { - public static MapMode PRIVATE; + public static MapMode PRIVATE; - public static MapMode READ_ONLY; + public static MapMode READ_ONLY; - public static MapMode READ_WRITE; + public static MapMode READ_WRITE; - private String displayName; - } - - @Nullable FileLock tryLock() throws IOException { - InferUndefined.can_throw_ioexception_object(); - if (InferUndefined.boolean_undefined()) { - return null; - } else { - return (FileLock)InferUndefined.object_undefined(); - } - } + private String displayName; + } - @Nullable FileLock tryLock(long position, long size, boolean shared) throws IOException { - return tryLock(); + @Nullable + FileLock tryLock() throws IOException { + InferUndefined.can_throw_ioexception_object(); + if (InferUndefined.boolean_undefined()) { + return null; + } else { + return (FileLock) InferUndefined.object_undefined(); } + } + @Nullable + FileLock tryLock(long position, long size, boolean shared) throws IOException { + return tryLock(); + } } diff --git a/infer/models/java/src/java/nio/channels/spi/AbstractInterruptibleChannel.java b/infer/models/java/src/java/nio/channels/spi/AbstractInterruptibleChannel.java index ad05db8f8..1eb4b0a30 100644 --- a/infer/models/java/src/java/nio/channels/spi/AbstractInterruptibleChannel.java +++ b/infer/models/java/src/java/nio/channels/spi/AbstractInterruptibleChannel.java @@ -12,10 +12,9 @@ import java.nio.FileChannelImpl; public class AbstractInterruptibleChannel { - public final void close() throws IOException { - if (this instanceof FileChannelImpl) { - ((FileChannelImpl) this).implCloseChannel(); - } + public final void close() throws IOException { + if (this instanceof FileChannelImpl) { + ((FileChannelImpl) this).implCloseChannel(); } - + } } diff --git a/infer/models/java/src/java/security/DigestInputStream.java b/infer/models/java/src/java/security/DigestInputStream.java index 36c603573..544663d53 100644 --- a/infer/models/java/src/java/security/DigestInputStream.java +++ b/infer/models/java/src/java/security/DigestInputStream.java @@ -8,11 +8,7 @@ package java.security; import com.facebook.infer.builtins.InferUndefined; - -import java.io.FilterInputStream; import java.io.IOException; -import java.io.InputStream; - public class DigestInputStream { @@ -27,5 +23,4 @@ public class DigestInputStream { public int read(byte b[], int off, int len) throws IOException { return InferUndefined.can_throw_ioexception_int(); } - } diff --git a/infer/models/java/src/java/security/DigestOutputStream.java b/infer/models/java/src/java/security/DigestOutputStream.java index 772df8bbf..0d6ebc9ab 100644 --- a/infer/models/java/src/java/security/DigestOutputStream.java +++ b/infer/models/java/src/java/security/DigestOutputStream.java @@ -8,26 +8,25 @@ package java.security; import com.facebook.infer.builtins.InferUndefined; - import java.io.FilterOutputStream; import java.io.IOException; import java.io.OutputStream; public class DigestOutputStream extends FilterOutputStream { - public DigestOutputStream(OutputStream stream, MessageDigest digest) { - super(stream); - } + public DigestOutputStream(OutputStream stream, MessageDigest digest) { + super(stream); + } - public void write(byte b[], int off, int len) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void write(byte b[], int off, int len) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void write(byte b[]) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void write(byte b[]) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void write(int b) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void write(int b) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } } diff --git a/infer/models/java/src/java/util/AbstractList.java b/infer/models/java/src/java/util/AbstractList.java index 771ff2810..98947dbcd 100644 --- a/infer/models/java/src/java/util/AbstractList.java +++ b/infer/models/java/src/java/util/AbstractList.java @@ -54,5 +54,4 @@ public abstract class AbstractList { public void clear() { mIsEmpty = 1; } - } diff --git a/infer/models/java/src/java/util/ArrayList.java b/infer/models/java/src/java/util/ArrayList.java index 17584ea87..d1fd8d8b8 100644 --- a/infer/models/java/src/java/util/ArrayList.java +++ b/infer/models/java/src/java/util/ArrayList.java @@ -7,7 +7,6 @@ package java.util; -import java.io.Serializable; // abstract so we don't have to implement every method of List public abstract class ArrayList extends AbstractList { @@ -36,5 +35,4 @@ public abstract class ArrayList extends AbstractList { public void clear() { super.clear(); } - } diff --git a/infer/models/java/src/java/util/HashMap.java b/infer/models/java/src/java/util/HashMap.java index 673122d7a..0cd231946 100644 --- a/infer/models/java/src/java/util/HashMap.java +++ b/infer/models/java/src/java/util/HashMap.java @@ -6,24 +6,21 @@ */ package java.util; -import java.io.*; -import com.facebook.infer.builtins.InferUndefined; import com.facebook.infer.builtins.InferBuiltins; +import com.facebook.infer.builtins.InferUndefined; +import java.io.*; /** - * A recency abstraction for hashmaps that remembers only the last two - * keys known to exist in the map. + * A recency abstraction for hashmaps that remembers only the last two keys known to exist in the + * map. * - * get(key) can return null when key is not in the hashmap, and - * containsKey(key) and put(key, value) are used to protect against - * such nulls. Slightly unsound for the other reason get() can return - * null, when a pair (key,null) is in the map. Then when - * containsKey(key) is true, we will not report an NPE on a subsequent - * get(key). -*/ - -public abstract class HashMap { + *

get(key) can return null when key is not in the hashmap, and containsKey(key) and put(key, + * value) are used to protect against such nulls. Slightly unsound for the other reason get() can + * return null, when a pair (key,null) is in the map. Then when containsKey(key) is true, we will + * not report an NPE on a subsequent get(key). + */ +public abstract class HashMap { private K lastKey1 = null; private K lastKey2 = null; @@ -41,10 +38,10 @@ public abstract class HashMap { public V get(K key) { if (_containsKey(key)) { - return (V)InferUndefined.object_undefined(); + return (V) InferUndefined.object_undefined(); } else if (InferUndefined.boolean_undefined()) { pushKey(key); - return (V)InferUndefined.object_undefined(); + return (V) InferUndefined.object_undefined(); } return null; @@ -58,7 +55,7 @@ public abstract class HashMap { pushKey(key); if (InferUndefined.boolean_undefined()) { - return (V)InferUndefined.object_undefined(); + return (V) InferUndefined.object_undefined(); } return null; } @@ -81,7 +78,7 @@ public abstract class HashMap { } private boolean _containsKey(K key) { - return areEqual(key, lastKey1) || areEqual(key, lastKey2); + return areEqual(key, lastKey1) || areEqual(key, lastKey2); } private void removeKey(K key) { @@ -96,5 +93,4 @@ public abstract class HashMap { private boolean areEqual(K x, K y) { return x == y; } - } diff --git a/infer/models/java/src/java/util/LinkedList.java b/infer/models/java/src/java/util/LinkedList.java index 1a000ceec..e194b42b0 100644 --- a/infer/models/java/src/java/util/LinkedList.java +++ b/infer/models/java/src/java/util/LinkedList.java @@ -10,9 +10,8 @@ package java.util; import java.io.Serializable; // abstract so we don't have to implement every method of List -public abstract class LinkedList - extends AbstractList - implements Serializable, Cloneable, Iterable, Collection, Deque, Queue { +public abstract class LinkedList extends AbstractList + implements Serializable, Cloneable, Iterable, Collection, Deque, Queue { @Override public boolean isEmpty() { @@ -38,5 +37,4 @@ public abstract class LinkedList public void clear() { super.clear(); } - } diff --git a/infer/models/java/src/java/util/List.java b/infer/models/java/src/java/util/List.java index fd408c093..b333dccd2 100644 --- a/infer/models/java/src/java/util/List.java +++ b/infer/models/java/src/java/util/List.java @@ -7,7 +7,6 @@ package java.util; -import java.io.Serializable; // abstract so we don't have to implement every method of List public abstract class List extends AbstractList { @@ -36,5 +35,4 @@ public abstract class List extends AbstractList { public void clear() { super.clear(); } - } diff --git a/infer/models/java/src/java/util/Properties.java b/infer/models/java/src/java/util/Properties.java index 09da4546f..5f0ee24bc 100644 --- a/infer/models/java/src/java/util/Properties.java +++ b/infer/models/java/src/java/util/Properties.java @@ -8,50 +8,45 @@ package java.util; import com.facebook.infer.builtins.InferUndefined; - -import javax.xml.parsers.DocumentBuilder; import java.io.*; public class Properties extends Hashtable { - protected Properties defaults; - - public Properties() { - } + protected Properties defaults; - public Properties(Properties defaults) { - this.defaults = defaults; - } + public Properties() {} - public synchronized void load(Reader reader) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public Properties(Properties defaults) { + this.defaults = defaults; + } - public synchronized void load(InputStream inStream) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public synchronized void load(Reader reader) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void store(Writer writer, String comments) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public synchronized void load(InputStream inStream) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void store(OutputStream out, String comments) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void store(Writer writer, String comments) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public synchronized void loadFromXML(InputStream in) throws IOException, - InvalidPropertiesFormatException { - in.close(); - } + public void store(OutputStream out, String comments) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public synchronized void storeToXML(OutputStream os, String comment) - throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public synchronized void loadFromXML(InputStream in) + throws IOException, InvalidPropertiesFormatException { + in.close(); + } - public synchronized void storeToXML(OutputStream os, String comment, - String encoding) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public synchronized void storeToXML(OutputStream os, String comment) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } + public synchronized void storeToXML(OutputStream os, String comment, String encoding) + throws IOException { + InferUndefined.can_throw_ioexception_void(); + } } diff --git a/infer/models/java/src/java/util/Scanner.java b/infer/models/java/src/java/util/Scanner.java index 6d4677bdb..52c338688 100644 --- a/infer/models/java/src/java/util/Scanner.java +++ b/infer/models/java/src/java/util/Scanner.java @@ -11,17 +11,17 @@ import com.facebook.infer.builtins.InferUndefined; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; -import java.io.InputStream; import java.io.IOException; -import java.lang.IllegalArgumentException; - +import java.io.InputStream; public class Scanner { InputStream src; + private void init(InputStream source) { src = source; } + public Scanner(InputStream source) { init(source); } @@ -39,7 +39,7 @@ public class Scanner { } public Scanner(File source, String charsetName) - throws FileNotFoundException, IllegalArgumentException { + throws FileNotFoundException, IllegalArgumentException { if (InferUndefined.boolean_undefined()) { init(new FileInputStream(source)); } else { diff --git a/infer/models/java/src/java/util/Vector.java b/infer/models/java/src/java/util/Vector.java index 93a4417dd..ddd7d8737 100644 --- a/infer/models/java/src/java/util/Vector.java +++ b/infer/models/java/src/java/util/Vector.java @@ -11,35 +11,32 @@ import com.facebook.infer.builtins.InferUndefined; public abstract class Vector { - protected E[] elementData; - - E elementData(int index) { - return (E) elementData[index]; - } - - public Enumeration elements() { - return new Enumeration() { - int count; - - public boolean hasMoreElements() { - return count > 0; - } - - public E nextElement() { - if (count > 0) - return (E) InferUndefined.object_undefined(); - else - throw new NoSuchElementException(); - } - }; - } - - public E get(int index) { - return elementData(index); - } - - public int size() { - return InferUndefined.nonneg_int(); - } - + protected E[] elementData; + + E elementData(int index) { + return (E) elementData[index]; + } + + public Enumeration elements() { + return new Enumeration() { + int count; + + public boolean hasMoreElements() { + return count > 0; + } + + public E nextElement() { + if (count > 0) return (E) InferUndefined.object_undefined(); + else throw new NoSuchElementException(); + } + }; + } + + public E get(int index) { + return elementData(index); + } + + public int size() { + return InferUndefined.nonneg_int(); + } } diff --git a/infer/models/java/src/java/util/concurrent/Lock.java b/infer/models/java/src/java/util/concurrent/Lock.java index d2511f198..9802eca0f 100644 --- a/infer/models/java/src/java/util/concurrent/Lock.java +++ b/infer/models/java/src/java/util/concurrent/Lock.java @@ -6,9 +6,10 @@ */ package java.util.concurrent.locks; -import java.util.concurrent.TimeUnit; + import com.facebook.infer.builtins.InferBuiltins; import com.facebook.infer.builtins.InferUndefined; +import java.util.concurrent.TimeUnit; /* Lock is in actuality an interface, but is implemented here as an abstract class for @@ -17,50 +18,47 @@ modelling reasons. Note that we don't provide a model here for the newCondition( public abstract class Lock { - void lock() { - InferBuiltins.__set_locked_attribute(this); - } + void lock() { + InferBuiltins.__set_locked_attribute(this); + } - /** - Sometimes doesn't get a lock. - */ - public void lockInterruptibly() throws InterruptedException { - if (InferUndefined.boolean_undefined()) { - InferBuiltins.__set_locked_attribute(this); - } else { - throw new InterruptedException(); - } + /** Sometimes doesn't get a lock. */ + public void lockInterruptibly() throws InterruptedException { + if (InferUndefined.boolean_undefined()) { + InferBuiltins.__set_locked_attribute(this); + } else { + throw new InterruptedException(); } + } - /** - Again, doesn't always succeed - */ - public boolean tryLock() { - if (InferUndefined.boolean_undefined()) { - InferBuiltins.__set_locked_attribute(this); - return true; - } else { - return false; - } + /** Again, doesn't always succeed */ + public boolean tryLock() { + if (InferUndefined.boolean_undefined()) { + InferBuiltins.__set_locked_attribute(this); + return true; + } else { + return false; } + } - public boolean tryLock(long timeout, TimeUnit unit) throws InterruptedException { - if (InferUndefined.boolean_undefined()) {throw new InterruptedException();} - - if (InferUndefined.boolean_undefined()) { - InferBuiltins.__set_locked_attribute(this); - return true; - } else { - return false; - } + public boolean tryLock(long timeout, TimeUnit unit) throws InterruptedException { + if (InferUndefined.boolean_undefined()) { + throw new InterruptedException(); } - /** - * In some implementations (like ReentrantLock) an exception is thrown if the lock - * is not held by the current thread. This model does not consider that possibility. - */ - public void unlock() { - InferBuiltins.__delete_locked_attribute(this); + if (InferUndefined.boolean_undefined()) { + InferBuiltins.__set_locked_attribute(this); + return true; + } else { + return false; } + } + /** + * In some implementations (like ReentrantLock) an exception is thrown if the lock is not held by + * the current thread. This model does not consider that possibility. + */ + public void unlock() { + InferBuiltins.__delete_locked_attribute(this); + } } diff --git a/infer/models/java/src/java/util/concurrent/ReentrantLock.java b/infer/models/java/src/java/util/concurrent/ReentrantLock.java index 43ca159ab..f41138e91 100644 --- a/infer/models/java/src/java/util/concurrent/ReentrantLock.java +++ b/infer/models/java/src/java/util/concurrent/ReentrantLock.java @@ -6,78 +6,72 @@ */ /* Reentrant Lock model -* This is a partial model. Several methods such as getowner(), hasQueueThread(), -* getQueueLength() are not modelled. -* A reentrant lock is one where if you try to lock() a lock already held by -* the current thread, you succeed and continue. In a non-reentrant lock you could deadlock. -* This is not reflected. java.util.concurrent ReentrantLocks have some fairness -* guarantees and some things about scheduling -* when the lock is held by another thread, not considered here.. -* -*/ + * This is a partial model. Several methods such as getowner(), hasQueueThread(), + * getQueueLength() are not modelled. + * A reentrant lock is one where if you try to lock() a lock already held by + * the current thread, you succeed and continue. In a non-reentrant lock you could deadlock. + * This is not reflected. java.util.concurrent ReentrantLocks have some fairness + * guarantees and some things about scheduling + * when the lock is held by another thread, not considered here.. + * + */ package java.util.concurrent.locks; -import java.util.concurrent.TimeUnit; + import com.facebook.infer.builtins.InferBuiltins; import com.facebook.infer.builtins.InferUndefined; +import java.util.concurrent.TimeUnit; public abstract class ReentrantLock extends Lock implements java.io.Serializable { - /** - * We should be able to delete this and inherit from the modle in Lock.java, - * when improved treatment of dynamic dispatch lands - */ - public void lock() { + /** + * We should be able to delete this and inherit from the modle in Lock.java, when improved + * treatment of dynamic dispatch lands + */ + public void lock() { + InferBuiltins.__set_locked_attribute(this); + } + + /** Sometimes doesn't get a lock. */ + public void lockInterruptibly() throws InterruptedException { + if (InferUndefined.boolean_undefined()) { InferBuiltins.__set_locked_attribute(this); + } else { + throw new InterruptedException(); } + } - /** - Sometimes doesn't get a lock. - */ - public void lockInterruptibly() throws InterruptedException { - if (InferUndefined.boolean_undefined()) { - InferBuiltins.__set_locked_attribute(this); - } else { - throw new InterruptedException(); - } + /** Again, doesn't always succeed */ + public boolean tryLock() { + if (InferUndefined.boolean_undefined()) { + InferBuiltins.__set_locked_attribute(this); + return true; + } else { + return false; } + } - /** - Again, doesn't always succeed - */ - public boolean tryLock() { - if (InferUndefined.boolean_undefined()) { - InferBuiltins.__set_locked_attribute(this); - return true; - } else { - return false; - } + public boolean tryLock(long timeout, TimeUnit unit) throws InterruptedException { + if (InferUndefined.boolean_undefined()) { + throw new InterruptedException(); } - public boolean tryLock(long timeout, TimeUnit unit) throws InterruptedException { - if (InferUndefined.boolean_undefined()) {throw new InterruptedException();} - - if (InferUndefined.boolean_undefined()) { - InferBuiltins.__set_locked_attribute(this); - return true; - } else { - return false; - } + if (InferUndefined.boolean_undefined()) { + InferBuiltins.__set_locked_attribute(this); + return true; + } else { + return false; } + } + /** + * In some implementations (like ReentrantLock) an exception is thrown if the lock is not held by + * the current thread. This model does not consider that possibility. We should be able to delete + * this and inherit from the modle in Lock.java, when improved treatment of dynamic dispatch lands + */ + public void unlock() { + InferBuiltins.__delete_locked_attribute(this); + } - /** - * In some implementations (like ReentrantLock) an exception is thrown if the lock - * is not held by the current thread. This model does not consider that possibility. - * We should be able to delete this and inherit from the modle in Lock.java, - * when improved treatment of dynamic dispatch lands - */ - public void unlock() { - InferBuiltins.__delete_locked_attribute(this); - } - - /** - * TODO. This requires us to abduce lockedness. Do later. - public boolean isLocked() { - */ + /** TODO. This requires us to abduce lockedness. Do later. public boolean isLocked() { */ } diff --git a/infer/models/java/src/java/util/jar/JarFile.java b/infer/models/java/src/java/util/jar/JarFile.java index 1c3edba77..9ff2690e3 100644 --- a/infer/models/java/src/java/util/jar/JarFile.java +++ b/infer/models/java/src/java/util/jar/JarFile.java @@ -11,36 +11,33 @@ import java.io.File; import java.io.IOException; import java.util.zip.ZipFile; - public class JarFile extends ZipFile { + public JarFile(String name) throws IOException { + super(name); + } - public JarFile(String name) throws IOException { - super(name); - } - - public JarFile(String name, boolean verify) throws IOException { - super(name); - } - - public JarFile(File file) throws IOException { - super(""); - } + public JarFile(String name, boolean verify) throws IOException { + super(name); + } - public JarFile(File file, boolean verify) throws IOException { - this(file, verify, 0); - } + public JarFile(File file) throws IOException { + super(""); + } - public JarFile(File file, boolean verify, int mode) throws IOException { - super(""); - } + public JarFile(File file, boolean verify) throws IOException { + this(file, verify, 0); + } - public Manifest getManifest() throws IOException { - throw new IOException(); - } + public JarFile(File file, boolean verify, int mode) throws IOException { + super(""); + } - public void close() throws IOException { - super.close(); - } + public Manifest getManifest() throws IOException { + throw new IOException(); + } + public void close() throws IOException { + super.close(); + } } diff --git a/infer/models/java/src/java/util/jar/JarInputStream.java b/infer/models/java/src/java/util/jar/JarInputStream.java index 7d065db99..c2713bdd4 100644 --- a/infer/models/java/src/java/util/jar/JarInputStream.java +++ b/infer/models/java/src/java/util/jar/JarInputStream.java @@ -9,10 +9,8 @@ package java.util.jar; import com.facebook.infer.builtins.InferBuiltins; import com.facebook.infer.builtins.InferUndefined; - import java.io.IOException; import java.io.InputStream; -import java.util.zip.ZipInputStream; public class JarInputStream { @@ -25,5 +23,4 @@ public class JarInputStream { public JarInputStream(InputStream in, boolean verify) throws IOException { this(in); } - } diff --git a/infer/models/java/src/java/util/jar/JarOutputStream.java b/infer/models/java/src/java/util/jar/JarOutputStream.java index 74ac5e48a..71cbad254 100644 --- a/infer/models/java/src/java/util/jar/JarOutputStream.java +++ b/infer/models/java/src/java/util/jar/JarOutputStream.java @@ -9,12 +9,9 @@ package java.util.jar; import com.facebook.infer.builtins.InferBuiltins; import com.facebook.infer.builtins.InferUndefined; - import java.io.IOException; import java.io.OutputStream; import java.util.zip.ZipEntry; -import java.util.zip.ZipOutputStream; - public class JarOutputStream { @@ -31,5 +28,4 @@ public class JarOutputStream { public void putNextEntry(ZipEntry ze) throws IOException { InferUndefined.can_throw_ioexception_void(); } - } diff --git a/infer/models/java/src/java/util/zip/CheckedInputStream.java b/infer/models/java/src/java/util/zip/CheckedInputStream.java index 497ea5b95..756b47220 100644 --- a/infer/models/java/src/java/util/zip/CheckedInputStream.java +++ b/infer/models/java/src/java/util/zip/CheckedInputStream.java @@ -8,10 +8,7 @@ package java.util.zip; import com.facebook.infer.builtins.InferUndefined; - -import java.io.FilterInputStream; import java.io.IOException; -import java.io.InputStream; public class CheckedInputStream { @@ -30,5 +27,4 @@ public class CheckedInputStream { public long skip(long n) throws IOException { return InferUndefined.can_throw_ioexception_long(); } - } diff --git a/infer/models/java/src/java/util/zip/CheckedOutputStream.java b/infer/models/java/src/java/util/zip/CheckedOutputStream.java index aaf5c06fa..a3ee513e5 100644 --- a/infer/models/java/src/java/util/zip/CheckedOutputStream.java +++ b/infer/models/java/src/java/util/zip/CheckedOutputStream.java @@ -8,26 +8,25 @@ package java.util.zip; import com.facebook.infer.builtins.InferUndefined; - import java.io.FilterOutputStream; import java.io.IOException; import java.io.OutputStream; public class CheckedOutputStream extends FilterOutputStream { - public CheckedOutputStream(OutputStream out, Checksum cksum) { - super(out); - } + public CheckedOutputStream(OutputStream out, Checksum cksum) { + super(out); + } - public void write(int b) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void write(int b) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void write(byte b[], int off, int len) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void write(byte b[], int off, int len) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void write(byte b[]) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void write(byte b[]) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } } diff --git a/infer/models/java/src/java/util/zip/Deflater.java b/infer/models/java/src/java/util/zip/Deflater.java index 5644e6d75..aaf605bd9 100644 --- a/infer/models/java/src/java/util/zip/Deflater.java +++ b/infer/models/java/src/java/util/zip/Deflater.java @@ -26,5 +26,4 @@ public class Deflater { public void end() { InferBuiltins.__set_mem_attribute(this); } - } diff --git a/infer/models/java/src/java/util/zip/DeflaterInputStream.java b/infer/models/java/src/java/util/zip/DeflaterInputStream.java index a6648192c..8a43fca16 100644 --- a/infer/models/java/src/java/util/zip/DeflaterInputStream.java +++ b/infer/models/java/src/java/util/zip/DeflaterInputStream.java @@ -8,15 +8,10 @@ package java.util.zip; import com.facebook.infer.builtins.InferUndefined; - -import java.io.FilterInputStream; import java.io.IOException; -import java.io.InputStream; - public class DeflaterInputStream { - public int available() throws IOException { return InferUndefined.can_throw_ioexception_int(); } @@ -40,5 +35,4 @@ public class DeflaterInputStream { public long skip(long n) throws IOException { return InferUndefined.can_throw_ioexception_long(); } - } diff --git a/infer/models/java/src/java/util/zip/DeflaterOutputStream.java b/infer/models/java/src/java/util/zip/DeflaterOutputStream.java index b66aa8c6b..b0e0becf2 100644 --- a/infer/models/java/src/java/util/zip/DeflaterOutputStream.java +++ b/infer/models/java/src/java/util/zip/DeflaterOutputStream.java @@ -8,53 +8,51 @@ package java.util.zip; import com.facebook.infer.builtins.InferUndefined; - import java.io.FilterOutputStream; import java.io.IOException; import java.io.OutputStream; public class DeflaterOutputStream extends FilterOutputStream { - public DeflaterOutputStream(OutputStream out, Deflater def, int size) { - super(out); - } - - public DeflaterOutputStream(OutputStream out, Deflater def) { - super(out); - } + public DeflaterOutputStream(OutputStream out, Deflater def, int size) { + super(out); + } - boolean usesDefaultDeflater; + public DeflaterOutputStream(OutputStream out, Deflater def) { + super(out); + } - public DeflaterOutputStream(OutputStream out) { - super(out); - } + boolean usesDefaultDeflater; - public void close() throws IOException { - super.close(); - } + public DeflaterOutputStream(OutputStream out) { + super(out); + } - public void deflate() throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void close() throws IOException { + super.close(); + } - public void finish() throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void deflate() throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void flush() throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void finish() throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void write(byte b[], int off, int len) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void flush() throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void write(byte b[]) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void write(byte b[], int off, int len) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void write(int b) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void write(byte b[]) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } + public void write(int b) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } } diff --git a/infer/models/java/src/java/util/zip/GZIPInputStream.java b/infer/models/java/src/java/util/zip/GZIPInputStream.java index 3ab34f573..a88399451 100644 --- a/infer/models/java/src/java/util/zip/GZIPInputStream.java +++ b/infer/models/java/src/java/util/zip/GZIPInputStream.java @@ -9,11 +9,9 @@ package java.util.zip; import com.facebook.infer.builtins.InferBuiltins; import com.facebook.infer.builtins.InferUndefined; - import java.io.IOException; import java.io.InputStream; - public class GZIPInputStream { public GZIPInputStream(InputStream in) throws IOException { @@ -25,5 +23,4 @@ public class GZIPInputStream { public GZIPInputStream(InputStream in, int size) throws IOException { this(in); } - } diff --git a/infer/models/java/src/java/util/zip/GZIPOutputStream.java b/infer/models/java/src/java/util/zip/GZIPOutputStream.java index d54f04982..135b77912 100644 --- a/infer/models/java/src/java/util/zip/GZIPOutputStream.java +++ b/infer/models/java/src/java/util/zip/GZIPOutputStream.java @@ -8,25 +8,22 @@ package java.util.zip; import com.facebook.infer.builtins.InferUndefined; - import java.io.IOException; import java.io.OutputStream; public class GZIPOutputStream extends DeflaterOutputStream { - - public GZIPOutputStream(OutputStream out, int size) throws IOException { - super(out); - if (!InferUndefined.boolean_undefined()) { - throw new IOException(); - } + public GZIPOutputStream(OutputStream out, int size) throws IOException { + super(out); + if (!InferUndefined.boolean_undefined()) { + throw new IOException(); } + } - public GZIPOutputStream(OutputStream out) throws IOException { - super(out); - if (!InferUndefined.boolean_undefined()) { - throw new IOException(); - } + public GZIPOutputStream(OutputStream out) throws IOException { + super(out); + if (!InferUndefined.boolean_undefined()) { + throw new IOException(); } - + } } diff --git a/infer/models/java/src/java/util/zip/Inflater.java b/infer/models/java/src/java/util/zip/Inflater.java index bb0e1fb93..8f33a8ff2 100644 --- a/infer/models/java/src/java/util/zip/Inflater.java +++ b/infer/models/java/src/java/util/zip/Inflater.java @@ -22,5 +22,4 @@ public class Inflater { public void end() { InferBuiltins.__set_mem_attribute(this); } - } diff --git a/infer/models/java/src/java/util/zip/InflaterInputStream.java b/infer/models/java/src/java/util/zip/InflaterInputStream.java index 974b5c8e8..b400f695a 100644 --- a/infer/models/java/src/java/util/zip/InflaterInputStream.java +++ b/infer/models/java/src/java/util/zip/InflaterInputStream.java @@ -8,35 +8,32 @@ package java.util.zip; import com.facebook.infer.builtins.InferUndefined; - import java.io.FilterInputStream; import java.io.IOException; -import java.io.InputStream; public class InflaterInputStream extends FilterInputStream { - public int available() throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } - - public int read() throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } + public int available() throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } - public int read(byte b[]) throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } + public int read() throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } - public int read(byte b[], int off, int len) throws IOException { - return InferUndefined.can_throw_ioexception_int(); - } + public int read(byte b[]) throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } - public void reset() throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public int read(byte b[], int off, int len) throws IOException { + return InferUndefined.can_throw_ioexception_int(); + } - public long skip(long n) throws IOException { - return InferUndefined.can_throw_ioexception_long(); - } + public void reset() throws IOException { + InferUndefined.can_throw_ioexception_void(); + } + public long skip(long n) throws IOException { + return InferUndefined.can_throw_ioexception_long(); + } } diff --git a/infer/models/java/src/java/util/zip/InflaterOutputStream.java b/infer/models/java/src/java/util/zip/InflaterOutputStream.java index 84c17fe23..554d01e95 100644 --- a/infer/models/java/src/java/util/zip/InflaterOutputStream.java +++ b/infer/models/java/src/java/util/zip/InflaterOutputStream.java @@ -8,47 +8,45 @@ package java.util.zip; import com.facebook.infer.builtins.InferUndefined; - import java.io.FilterOutputStream; import java.io.IOException; import java.io.OutputStream; public class InflaterOutputStream extends FilterOutputStream { - public InflaterOutputStream(OutputStream out) { - super(out); - } - - public InflaterOutputStream(OutputStream out, Inflater infl) { - super(out); - } + public InflaterOutputStream(OutputStream out) { + super(out); + } - public InflaterOutputStream(OutputStream out, Inflater infl, int bufLen) { - super(out); - } + public InflaterOutputStream(OutputStream out, Inflater infl) { + super(out); + } - public void close() throws IOException { - super.close(); - } + public InflaterOutputStream(OutputStream out, Inflater infl, int bufLen) { + super(out); + } - public void finish() throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void close() throws IOException { + super.close(); + } - public void flush() throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void finish() throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void write(byte b[], int off, int len) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void flush() throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void write(byte b[]) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void write(byte b[], int off, int len) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void write(int b) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void write(byte b[]) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } + public void write(int b) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } } diff --git a/infer/models/java/src/java/util/zip/ZipFile.java b/infer/models/java/src/java/util/zip/ZipFile.java index 156089802..d3a621c42 100644 --- a/infer/models/java/src/java/util/zip/ZipFile.java +++ b/infer/models/java/src/java/util/zip/ZipFile.java @@ -9,7 +9,6 @@ package java.util.zip; import com.facebook.infer.builtins.InferBuiltins; import com.facebook.infer.builtins.InferUndefined; - import java.io.File; import java.io.IOException; import java.util.Enumeration; @@ -53,12 +52,9 @@ public class ZipFile { } public ZipEntry nextElement() throws NoSuchElementException { - if (hasEls) - return new ZipEntry(""); - else - throw new NoSuchElementException(); + if (hasEls) return new ZipEntry(""); + else throw new NoSuchElementException(); } }; } - } diff --git a/infer/models/java/src/java/util/zip/ZipInputStream.java b/infer/models/java/src/java/util/zip/ZipInputStream.java index c7677cc8b..6bfefe9b2 100644 --- a/infer/models/java/src/java/util/zip/ZipInputStream.java +++ b/infer/models/java/src/java/util/zip/ZipInputStream.java @@ -8,11 +8,7 @@ package java.util.zip; import com.facebook.infer.builtins.InferUndefined; - -import java.io.BufferedInputStream; -import java.io.FileInputStream; import java.io.IOException; -import java.io.InputStream; public class ZipInputStream { @@ -20,12 +16,10 @@ public class ZipInputStream { boolean undef = InferUndefined.boolean_undefined(); if (undef) { return new ZipEntry(""); - } else - throw new IOException(); + } else throw new IOException(); } public void closeEntry() throws IOException { InferUndefined.can_throw_ioexception_void(); } - } diff --git a/infer/models/java/src/java/util/zip/ZipOutputStream.java b/infer/models/java/src/java/util/zip/ZipOutputStream.java index 4c0990dc4..d060a2d32 100644 --- a/infer/models/java/src/java/util/zip/ZipOutputStream.java +++ b/infer/models/java/src/java/util/zip/ZipOutputStream.java @@ -7,22 +7,16 @@ package java.util.zip; -import java.io.BufferedOutputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; - import com.facebook.infer.builtins.InferUndefined; - +import java.io.IOException; public class ZipOutputStream { - public void putNextEntry(ZipEntry e) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } - - public void closeEntry() throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void putNextEntry(ZipEntry e) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } + public void closeEntry() throws IOException { + InferUndefined.can_throw_ioexception_void(); + } } diff --git a/infer/models/java/src/javax/crypto/CipherInputStream.java b/infer/models/java/src/javax/crypto/CipherInputStream.java index e3b586b37..783c20014 100644 --- a/infer/models/java/src/javax/crypto/CipherInputStream.java +++ b/infer/models/java/src/javax/crypto/CipherInputStream.java @@ -8,10 +8,7 @@ package javax.crypto; import com.facebook.infer.builtins.InferUndefined; - -import java.io.FilterInputStream; import java.io.IOException; -import java.io.InputStream; public class CipherInputStream { @@ -34,5 +31,4 @@ public class CipherInputStream { public long skip(long n) throws IOException { return InferUndefined.can_throw_ioexception_long(); } - } diff --git a/infer/models/java/src/javax/crypto/CipherOutputStream.java b/infer/models/java/src/javax/crypto/CipherOutputStream.java index 6d278abcb..819cc79bf 100644 --- a/infer/models/java/src/javax/crypto/CipherOutputStream.java +++ b/infer/models/java/src/javax/crypto/CipherOutputStream.java @@ -8,39 +8,37 @@ package javax.crypto; import com.facebook.infer.builtins.InferUndefined; - import java.io.FilterOutputStream; import java.io.IOException; import java.io.OutputStream; public class CipherOutputStream extends FilterOutputStream { + public CipherOutputStream(OutputStream os, Cipher c) { + super(os); + } - public CipherOutputStream(OutputStream os, Cipher c) { - super(os); - } - - protected CipherOutputStream(OutputStream os) { - super(os); - } + protected CipherOutputStream(OutputStream os) { + super(os); + } - public void close() throws IOException { - super.close(); - } + public void close() throws IOException { + super.close(); + } - public void write(int b) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void write(int b) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void write(byte b[]) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void write(byte b[]) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void write(byte b[], int off, int len) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void write(byte b[], int off, int len) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } - public void flush() throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public void flush() throws IOException { + InferUndefined.can_throw_ioexception_void(); + } } diff --git a/infer/models/java/src/javax/net/ssl/HttpsURLConnection.java b/infer/models/java/src/javax/net/ssl/HttpsURLConnection.java index 4e7510aa2..1d80fda9d 100644 --- a/infer/models/java/src/javax/net/ssl/HttpsURLConnection.java +++ b/infer/models/java/src/javax/net/ssl/HttpsURLConnection.java @@ -8,24 +8,21 @@ package javax.net.ssl; import com.facebook.infer.builtins.InferBuiltins; - import java.net.HttpURLConnection; import java.net.URL; public class HttpsURLConnection extends HttpURLConnection { - /** - * Creates an HttpsURLConnection using the - * URL specified. - * - * @param url the URL - */ - public HttpsURLConnection(URL url) { - super(url); - } - - public void disconnect() { - InferBuiltins.__set_mem_attribute(this); - } + /** + * Creates an HttpsURLConnection using the URL specified. + * + * @param url the URL + */ + public HttpsURLConnection(URL url) { + super(url); + } + public void disconnect() { + InferBuiltins.__set_mem_attribute(this); + } } diff --git a/infer/models/java/src/javax/net/ssl/SSLSocketFactory.java b/infer/models/java/src/javax/net/ssl/SSLSocketFactory.java index 3ea0d454a..4afa94f4c 100644 --- a/infer/models/java/src/javax/net/ssl/SSLSocketFactory.java +++ b/infer/models/java/src/javax/net/ssl/SSLSocketFactory.java @@ -10,11 +10,8 @@ package javax.net.ssl; import java.io.IOException; import java.net.InetAddress; import java.net.Socket; - import javax.net.SocketFactory; -import com.facebook.infer.builtins.InferBuiltins; - public class SSLSocketFactory extends SocketFactory { public Socket createSocket(InetAddress addr, int i) throws IOException { @@ -22,7 +19,8 @@ public class SSLSocketFactory extends SocketFactory { } @Override - public Socket createSocket(InetAddress addr1, int i, InetAddress addr2, int j) throws IOException { + public Socket createSocket(InetAddress addr1, int i, InetAddress addr2, int j) + throws IOException { return super.createSocket(); } @@ -41,5 +39,4 @@ public class SSLSocketFactory extends SocketFactory { public Socket createSocket(Socket s, String host, int i, boolean b) throws IOException { return super.createSocket(); } - } diff --git a/infer/models/java/src/junit/framework/Assert.java b/infer/models/java/src/junit/framework/Assert.java index 8eb006cea..3974d6811 100644 --- a/infer/models/java/src/junit/framework/Assert.java +++ b/infer/models/java/src/junit/framework/Assert.java @@ -11,20 +11,19 @@ import com.facebook.infer.builtins.InferBuiltins; public class Assert { - public static void assertTrue(boolean condition) { - InferBuiltins.assume(condition); - } + public static void assertTrue(boolean condition) { + InferBuiltins.assume(condition); + } - public static void assertTrue(String message, boolean condition) { - InferBuiltins.assume(condition); - } + public static void assertTrue(String message, boolean condition) { + InferBuiltins.assume(condition); + } - public static void assertFalse(boolean condition) { - InferBuiltins.assume(!condition); - } - - public static void assertFalse(String message, boolean condition) { - InferBuiltins.assume(!condition); - } + public static void assertFalse(boolean condition) { + InferBuiltins.assume(!condition); + } + public static void assertFalse(String message, boolean condition) { + InferBuiltins.assume(!condition); + } } diff --git a/infer/models/java/src/org/assertj/core/util/Preconditions.java b/infer/models/java/src/org/assertj/core/util/Preconditions.java index a41160a73..dffc58572 100644 --- a/infer/models/java/src/org/assertj/core/util/Preconditions.java +++ b/infer/models/java/src/org/assertj/core/util/Preconditions.java @@ -7,7 +7,6 @@ package org.assertj.core.util; -import javax.annotation.Nullable; import static com.facebook.infer.builtins.InferBuiltins.assume; diff --git a/infer/tests/build_systems/ant/issues.exp b/infer/tests/build_systems/ant/issues.exp index bdc76e781..edcf8f791 100644 --- a/infer/tests/build_systems/ant/issues.exp +++ b/infer/tests/build_systems/ant/issues.exp @@ -11,15 +11,15 @@ codetoanalyze/java/infer/CloseableAsResourceExample.java, codetoanalyze.java.inf codetoanalyze/java/infer/CloseableAsResourceExample.java, codetoanalyze.java.infer.CloseableAsResourceExample.sourceOfNullWithResourceLeak():codetoanalyze.java.infer.T, 1, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure sourceOfNullWithResourceLeak(),start of procedure SomeResource(),return from a call to SomeResource.()] codetoanalyze/java/infer/CloseableAsResourceExample.java, codetoanalyze.java.infer.CloseableAsResourceExample.withException():void, 4, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure withException(),start of procedure SomeResource(),return from a call to SomeResource.(),start of procedure doSomething(),Skipping star(): method has no implementation,Definition of star(),Taking true branch,start of procedure LocalException(),return from a call to LocalException.(),exception codetoanalyze.java.infer.LocalException,return from a call to void SomeResource.doSomething()] codetoanalyze/java/infer/CursorLeaks.java, codetoanalyze.java.infer.CursorLeaks.completeDownloadNotClosed(android.app.DownloadManager):int, 8, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure completeDownloadNotClosed(...),Taking false branch,Skipping getColumnIndex(...): unknown method] -codetoanalyze/java/infer/CursorLeaks.java, codetoanalyze.java.infer.CursorLeaks.cursorClosedCheckNullCheckClosed_FP(android.database.sqlite.SQLiteDatabase):java.lang.Object, 13, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure cursorClosedCheckNullCheckClosed_FP(...),Taking false branch,Skipping getString(...): unknown method,Taking true branch,Taking false branch] -codetoanalyze/java/infer/CursorLeaks.java, codetoanalyze.java.infer.CursorLeaks.cursorNotClosed(android.database.sqlite.SQLiteDatabase):int, 4, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure cursorNotClosed(...),Skipping getCount(): unknown method] -codetoanalyze/java/infer/CursorLeaks.java, codetoanalyze.java.infer.CursorLeaks.getBucketCountNotClosed():int, 10, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure getBucketCountNotClosed(),Taking false branch,Taking false branch] -codetoanalyze/java/infer/CursorLeaks.java, codetoanalyze.java.infer.CursorLeaks.getImageCountHelperNotClosed(java.lang.String):int, 13, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure getImageCountHelperNotClosed(...),Taking true branch,Skipping getInt(...): unknown method] -codetoanalyze/java/infer/CursorLeaks.java, codetoanalyze.java.infer.CursorLeaks.loadPrefsFromContentProviderNotClosed():void, 11, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure loadPrefsFromContentProviderNotClosed(),Taking false branch,Taking true branch] +codetoanalyze/java/infer/CursorLeaks.java, codetoanalyze.java.infer.CursorLeaks.cursorClosedCheckNullCheckClosed_FP(android.database.sqlite.SQLiteDatabase):java.lang.Object, 11, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure cursorClosedCheckNullCheckClosed_FP(...),Taking false branch,Skipping getString(...): unknown method,Taking true branch,Taking false branch] +codetoanalyze/java/infer/CursorLeaks.java, codetoanalyze.java.infer.CursorLeaks.cursorNotClosed(android.database.sqlite.SQLiteDatabase):int, 2, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure cursorNotClosed(...),Skipping getCount(): unknown method] +codetoanalyze/java/infer/CursorLeaks.java, codetoanalyze.java.infer.CursorLeaks.getBucketCountNotClosed():int, 9, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure getBucketCountNotClosed(),Taking false branch,Taking false branch] +codetoanalyze/java/infer/CursorLeaks.java, codetoanalyze.java.infer.CursorLeaks.getImageCountHelperNotClosed(java.lang.String):int, 9, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure getImageCountHelperNotClosed(...),Taking true branch,Skipping getInt(...): unknown method] +codetoanalyze/java/infer/CursorLeaks.java, codetoanalyze.java.infer.CursorLeaks.loadPrefsFromContentProviderNotClosed():void, 10, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure loadPrefsFromContentProviderNotClosed(),Taking false branch,Taking true branch] codetoanalyze/java/infer/CursorLeaks.java, codetoanalyze.java.infer.CursorLeaks.queryUVMLegacyDbNotClosed():void, 4, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure queryUVMLegacyDbNotClosed(),Skipping setTables(...): unknown method,Taking true branch] -codetoanalyze/java/infer/CursorNPEs.java, codetoanalyze.java.infer.CursorNPEs.cursorFromContentResolverNPE(java.lang.String):void, 12, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure cursorFromContentResolverNPE(...)] +codetoanalyze/java/infer/CursorNPEs.java, codetoanalyze.java.infer.CursorNPEs.cursorFromContentResolverNPE(java.lang.String):void, 8, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure cursorFromContentResolverNPE(...)] codetoanalyze/java/infer/CursorNPEs.java, codetoanalyze.java.infer.CursorNPEs.cursorFromDownloadManagerNPE(android.app.DownloadManager):int, 5, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure cursorFromDownloadManagerNPE(...)] -codetoanalyze/java/infer/CursorNPEs.java, codetoanalyze.java.infer.CursorNPEs.cursorFromMediaNPE():void, 3, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure cursorFromMediaNPE()] +codetoanalyze/java/infer/CursorNPEs.java, codetoanalyze.java.infer.CursorNPEs.cursorFromMediaNPE():void, 2, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure cursorFromMediaNPE()] codetoanalyze/java/infer/DynamicDispatch.java, codetoanalyze.java.infer.DynamicDispatch$WithField.dispatchOnFieldBad():void, 3, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure dispatchOnFieldBad(),start of procedure DynamicDispatch$Subtype(),start of procedure DynamicDispatch$Supertype(),return from a call to DynamicDispatch$Supertype.(),return from a call to DynamicDispatch$Subtype.(),start of procedure DynamicDispatch$WithField(...),return from a call to DynamicDispatch$WithField.(DynamicDispatch$Subtype),start of procedure foo(),return from a call to Object DynamicDispatch$Subtype.foo()] codetoanalyze/java/infer/DynamicDispatch.java, codetoanalyze.java.infer.DynamicDispatch.dynamicDispatchCallsWrapperWithSubtypeBad():void, 3, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure dynamicDispatchCallsWrapperWithSubtypeBad(),start of procedure DynamicDispatch$Subtype(),start of procedure DynamicDispatch$Supertype(),return from a call to DynamicDispatch$Supertype.(),return from a call to DynamicDispatch$Subtype.(),start of procedure dynamicDispatchWrapperFoo(...),start of procedure foo(),return from a call to Object DynamicDispatch$Subtype.foo(),return from a call to Object DynamicDispatch.dynamicDispatchWrapperFoo(DynamicDispatch$Subtype)] codetoanalyze/java/infer/DynamicDispatch.java, codetoanalyze.java.infer.DynamicDispatch.dynamicDispatchCallsWrapperWithSupertypeBad():void, 3, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure dynamicDispatchCallsWrapperWithSupertypeBad(),start of procedure DynamicDispatch$Supertype(),return from a call to DynamicDispatch$Supertype.(),start of procedure dynamicDispatchWrapperBar(...),start of procedure bar(),return from a call to Object DynamicDispatch$Supertype.bar(),return from a call to Object DynamicDispatch.dynamicDispatchWrapperBar(DynamicDispatch$Supertype)] @@ -52,50 +52,50 @@ codetoanalyze/java/infer/FilterOutputStreamLeaks.java, codetoanalyze.java.infer. codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample$3.readFromInnerClassBad1():java.lang.String, 2, UNSAFE_GUARDED_BY_ACCESS, no_bucket, ERROR, [start of procedure readFromInnerClassBad1()] codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample$4.readFromInnerClassBad2():java.lang.String, 1, UNSAFE_GUARDED_BY_ACCESS, no_bucket, ERROR, [start of procedure readFromInnerClassBad2()] codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample$Sub.badSub():void, 1, UNSAFE_GUARDED_BY_ACCESS, no_bucket, ERROR, [start of procedure badSub()] -codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample$Sub.badSub():void, 493, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.infer.GuardedByExample.xForSub`,,access to `this.codetoanalyze.java.infer.GuardedByExample.xForSub`] +codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample$Sub.badSub():void, 491, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.infer.GuardedByExample.xForSub`,,access to `this.codetoanalyze.java.infer.GuardedByExample.xForSub`] codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.badGuardedByNormalLock():void, 1, UNSAFE_GUARDED_BY_ACCESS, no_bucket, ERROR, [start of procedure badGuardedByNormalLock()] -codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.badGuardedByNormalLock():void, 530, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.infer.GuardedByExample.guardedbynl`,,access to `this.codetoanalyze.java.infer.GuardedByExample.guardedbynl`] +codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.badGuardedByNormalLock():void, 526, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.infer.GuardedByExample.guardedbynl`,,access to `this.codetoanalyze.java.infer.GuardedByExample.guardedbynl`] codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.badGuardedByReentrantLock():void, 1, UNSAFE_GUARDED_BY_ACCESS, no_bucket, ERROR, [start of procedure badGuardedByReentrantLock()] -codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.badGuardedByReentrantLock():void, 534, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.infer.GuardedByExample.guardedbyrel`,,access to `this.codetoanalyze.java.infer.GuardedByExample.guardedbyrel`] +codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.badGuardedByReentrantLock():void, 530, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.infer.GuardedByExample.guardedbyrel`,,access to `this.codetoanalyze.java.infer.GuardedByExample.guardedbyrel`] codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.byRefTrickyBad():java.lang.Object, 5, UNSAFE_GUARDED_BY_ACCESS, no_bucket, ERROR, [start of procedure byRefTrickyBad()] -codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.byRefTrickyBad():java.lang.Object, 286, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.infer.GuardedByExample.g`,,access to `this.codetoanalyze.java.infer.GuardedByExample.g`] +codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.byRefTrickyBad():java.lang.Object, 281, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.infer.GuardedByExample.g`,,access to `this.codetoanalyze.java.infer.GuardedByExample.g`] codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.guardedByTypeSyntaxBad():void, 1, UNSAFE_GUARDED_BY_ACCESS, no_bucket, ERROR, [start of procedure guardedByTypeSyntaxBad()] codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.guardedByTypeSyntaxBad():void, 2, UNSAFE_GUARDED_BY_ACCESS, no_bucket, ERROR, [start of procedure guardedByTypeSyntaxBad()] -codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.guardedByTypeSyntaxBad():void, 577, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.infer.GuardedByExample.guardedByLock1`,,access to `this.codetoanalyze.java.infer.GuardedByExample.guardedByLock1`] -codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.guardedByTypeSyntaxBad():void, 578, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.infer.GuardedByExample.guardedByLock2`,,access to `this.codetoanalyze.java.infer.GuardedByExample.guardedByLock2`] +codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.guardedByTypeSyntaxBad():void, 573, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.infer.GuardedByExample.guardedByLock1`,,access to `this.codetoanalyze.java.infer.GuardedByExample.guardedByLock1`] +codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.guardedByTypeSyntaxBad():void, 574, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.infer.GuardedByExample.guardedByLock2`,,access to `this.codetoanalyze.java.infer.GuardedByExample.guardedByLock2`] codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.readFAfterBlockBad():void, 3, UNSAFE_GUARDED_BY_ACCESS, no_bucket, ERROR, [start of procedure readFAfterBlockBad()] -codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.readFAfterBlockBad():void, 103, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.infer.GuardedByExample.f`,,access to `this.codetoanalyze.java.infer.GuardedByExample.f`] +codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.readFAfterBlockBad():void, 98, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.infer.GuardedByExample.f`,,access to `this.codetoanalyze.java.infer.GuardedByExample.f`] codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.readFBad():void, 1, UNSAFE_GUARDED_BY_ACCESS, no_bucket, ERROR, [start of procedure readFBad()] -codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.readFBad():void, 71, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.infer.GuardedByExample.f`,,access to `this.codetoanalyze.java.infer.GuardedByExample.f`] -codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.readFBadButSuppressed():void, 76, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.infer.GuardedByExample.f`,,access to `this.codetoanalyze.java.infer.GuardedByExample.f`] -codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.readFBadButSuppressedOther():void, 81, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.infer.GuardedByExample.f`,,access to `this.codetoanalyze.java.infer.GuardedByExample.f`] +codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.readFBad():void, 66, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.infer.GuardedByExample.f`,,access to `this.codetoanalyze.java.infer.GuardedByExample.f`] +codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.readFBadButSuppressed():void, 71, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.infer.GuardedByExample.f`,,access to `this.codetoanalyze.java.infer.GuardedByExample.f`] +codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.readFBadButSuppressedOther():void, 76, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.infer.GuardedByExample.f`,,access to `this.codetoanalyze.java.infer.GuardedByExample.f`] codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.readFBadWrongAnnotation():void, 1, UNSAFE_GUARDED_BY_ACCESS, no_bucket, ERROR, [start of procedure readFBadWrongAnnotation()] -codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.readFBadWrongAnnotation():void, 114, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.infer.GuardedByExample.f`,,access to `this.codetoanalyze.java.infer.GuardedByExample.f`] +codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.readFBadWrongAnnotation():void, 109, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.infer.GuardedByExample.f`,,access to `this.codetoanalyze.java.infer.GuardedByExample.f`] codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.readFBadWrongLock():void, 2, UNSAFE_GUARDED_BY_ACCESS, no_bucket, ERROR, [start of procedure readFBadWrongLock()] -codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.readFBadWrongLock():void, 90, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.infer.GuardedByExample.f`,,access to `this.codetoanalyze.java.infer.GuardedByExample.f`] -codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.readFOkMethodAnnotated():void, 119, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.infer.GuardedByExample.f`,,access to `this.codetoanalyze.java.infer.GuardedByExample.f`] -codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.readFOkSynchronized():void, 132, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.infer.GuardedByExample.f`,,access to `this.codetoanalyze.java.infer.GuardedByExample.f`] -codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.readGFromCopyOk():void, 272, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.infer.GuardedByExample.mCopyOfG`,,access to `this.codetoanalyze.java.infer.GuardedByExample.mCopyOfG`] +codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.readFBadWrongLock():void, 85, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.infer.GuardedByExample.f`,,access to `this.codetoanalyze.java.infer.GuardedByExample.f`] +codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.readFOkMethodAnnotated():void, 114, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.infer.GuardedByExample.f`,,access to `this.codetoanalyze.java.infer.GuardedByExample.f`] +codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.readFOkSynchronized():void, 127, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.infer.GuardedByExample.f`,,access to `this.codetoanalyze.java.infer.GuardedByExample.f`] +codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.readGFromCopyOk():void, 267, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.infer.GuardedByExample.mCopyOfG`,,access to `this.codetoanalyze.java.infer.GuardedByExample.mCopyOfG`] codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.readHBad():void, 2, UNSAFE_GUARDED_BY_ACCESS, no_bucket, ERROR, [start of procedure readHBad()] codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.readHBadSynchronizedMethodShouldntHelp():void, 1, UNSAFE_GUARDED_BY_ACCESS, no_bucket, ERROR, [start of procedure readHBadSynchronizedMethodShouldntHelp()] -codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.reassignCopyOk():void, 154, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.infer.GuardedByExample.mCopyOfG`] +codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.reassignCopyOk():void, 149, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.infer.GuardedByExample.mCopyOfG`] codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.synchronizedMethodReadBad():void, 1, UNSAFE_GUARDED_BY_ACCESS, no_bucket, ERROR, [start of procedure synchronizedMethodReadBad()] -codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.synchronizedMethodReadBad():void, 143, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.infer.GuardedByExample.f`,,access to `this.codetoanalyze.java.infer.GuardedByExample.f`] +codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.synchronizedMethodReadBad():void, 138, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.infer.GuardedByExample.f`,,access to `this.codetoanalyze.java.infer.GuardedByExample.f`] codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.synchronizedMethodWriteBad():void, 1, UNSAFE_GUARDED_BY_ACCESS, no_bucket, ERROR, [start of procedure synchronizedMethodWriteBad()] codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.synchronizedOnThisBad():void, 1, UNSAFE_GUARDED_BY_ACCESS, no_bucket, ERROR, [start of procedure synchronizedOnThisBad()] -codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.synchronizedOnThisBad():void, 210, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `infer.GuardedByExample.codetoanalyze.java.infer.GuardedByExample.sGuardedByClass`,,access to `infer.GuardedByExample.codetoanalyze.java.infer.GuardedByExample.sGuardedByClass`] +codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.synchronizedOnThisBad():void, 205, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `infer.GuardedByExample.codetoanalyze.java.infer.GuardedByExample.sGuardedByClass`,,access to `infer.GuardedByExample.codetoanalyze.java.infer.GuardedByExample.sGuardedByClass`] codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.writeFAfterBlockBad():void, 3, UNSAFE_GUARDED_BY_ACCESS, no_bucket, ERROR, [start of procedure writeFAfterBlockBad()] -codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.writeFAfterBlockBad():void, 109, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.infer.GuardedByExample.f`] +codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.writeFAfterBlockBad():void, 104, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.infer.GuardedByExample.f`] codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.writeFBad():void, 1, UNSAFE_GUARDED_BY_ACCESS, no_bucket, ERROR, [start of procedure writeFBad()] -codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.writeFBad():void, 85, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.infer.GuardedByExample.f`,,access to `this.codetoanalyze.java.infer.GuardedByExample.f`] +codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.writeFBad():void, 80, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.infer.GuardedByExample.f`,,access to `this.codetoanalyze.java.infer.GuardedByExample.f`] codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.writeFBadWrongLock():void, 2, UNSAFE_GUARDED_BY_ACCESS, no_bucket, ERROR, [start of procedure writeFBadWrongLock()] codetoanalyze/java/infer/HashMapExample.java, codetoanalyze.java.infer.HashMapExample.getAfterClearBad():void, 5, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure getAfterClearBad()] codetoanalyze/java/infer/HashMapExample.java, codetoanalyze.java.infer.HashMapExample.getAfterRemovingTheKeyBad():void, 5, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure getAfterRemovingTheKeyBad()] codetoanalyze/java/infer/HashMapExample.java, codetoanalyze.java.infer.HashMapExample.getFromKeySetGood_FP(java.util.HashMap):void, 3, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure getFromKeySetGood_FP(...),Taking true branch] codetoanalyze/java/infer/HashMapExample.java, codetoanalyze.java.infer.HashMapExample.getOneIntegerWithoutCheck():int, 6, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure getOneIntegerWithoutCheck()] -codetoanalyze/java/infer/HashMapExample.java, codetoanalyze.java.infer.HashMapExample.getTwoIntegersWithOneCheck(java.lang.Integer,java.lang.Integer):void, 11, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure getTwoIntegersWithOneCheck(...),Taking true branch,Taking true branch] +codetoanalyze/java/infer/HashMapExample.java, codetoanalyze.java.infer.HashMapExample.getTwoIntegersWithOneCheck(java.lang.Integer,java.lang.Integer):void, 8, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure getTwoIntegersWithOneCheck(...),Taking true branch,Taking true branch] codetoanalyze/java/infer/IntegerExample.java, codetoanalyze.java.infer.IntegerExample.testIntegerEqualsBad():void, 6, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure testIntegerEqualsBad(),Taking true branch] -codetoanalyze/java/infer/InvokeDynamic.java, codetoanalyze.java.infer.InvokeDynamic.invokeDynamicThenNpeBad(java.util.List):void, 5, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure invokeDynamicThenNpeBad(...),Skipping sort(...): unknown method] +codetoanalyze/java/infer/InvokeDynamic.java, codetoanalyze.java.infer.InvokeDynamic.invokeDynamicThenNpeBad(java.util.List):void, 7, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure invokeDynamicThenNpeBad(...),Skipping sort(...): unknown method] codetoanalyze/java/infer/InvokeDynamic.java, codetoanalyze.java.infer.InvokeDynamic.lambda$npeInLambdaBad$1(java.lang.String,java.lang.String):int, 1, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure lambda$npeInLambdaBad$1(...)] codetoanalyze/java/infer/Lists.java, codetoanalyze.java.infer.Lists.clearCausesEmptinessNPE(java.util.List,int):void, 5, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure clearCausesEmptinessNPE(...),Taking true branch,Taking true branch] codetoanalyze/java/infer/Lists.java, codetoanalyze.java.infer.Lists.getElementNPE(java.util.List):void, 4, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure getElementNPE(...),Taking false branch,start of procedure getElement(...),Taking true branch,return from a call to Object Lists.getElement(List)] @@ -105,7 +105,7 @@ codetoanalyze/java/infer/NullPointerExceptions.java, codetoanalyze.java.infer.Nu codetoanalyze/java/infer/NullPointerExceptions.java, codetoanalyze.java.infer.NullPointerExceptions.NPEvalueOfFromHashmapBad(java.util.HashMap,int):int, 1, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure NPEvalueOfFromHashmapBad(...)] codetoanalyze/java/infer/NullPointerExceptions.java, codetoanalyze.java.infer.NullPointerExceptions.addNullToImmutableListBuilderBad():void, 2, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure addNullToImmutableListBuilderBad(),Skipping builder(): unknown method,start of procedure getObject(),return from a call to Object NullPointerExceptions.getObject()] codetoanalyze/java/infer/NullPointerExceptions.java, codetoanalyze.java.infer.NullPointerExceptions.badCheckShouldCauseNPE():void, 1, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure badCheckShouldCauseNPE(),start of procedure getBool(),Skipping test(): method has no implementation,Definition of test(),Taking true branch,return from a call to Boolean NullPointerExceptions.getBool(),Taking true branch,start of procedure getObj(),Skipping test(): method has no implementation,Definition of test(),Taking false branch,return from a call to Object NullPointerExceptions.getObj()] -codetoanalyze/java/infer/NullPointerExceptions.java, codetoanalyze.java.infer.NullPointerExceptions.cursorFromContentResolverNPE(java.lang.String):void, 9, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure cursorFromContentResolverNPE(...)] +codetoanalyze/java/infer/NullPointerExceptions.java, codetoanalyze.java.infer.NullPointerExceptions.cursorFromContentResolverNPE(java.lang.String):void, 5, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure cursorFromContentResolverNPE(...)] codetoanalyze/java/infer/NullPointerExceptions.java, codetoanalyze.java.infer.NullPointerExceptions.deferenceNullableMethodCallingSkippedMethodBad():void, 1, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure deferenceNullableMethodCallingSkippedMethodBad(),start of procedure wrapUnknownFuncWithNullable(),Skipping unknownFunc(): method has no implementation,Definition of unknownFunc(),return from a call to Object NullPointerExceptions.wrapUnknownFuncWithNullable()] codetoanalyze/java/infer/NullPointerExceptions.java, codetoanalyze.java.infer.NullPointerExceptions.derefNull():void, 2, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure derefNull(),start of procedure derefUndefinedCallee(),start of procedure retUndefined(),return from a call to Object NullPointerExceptions.retUndefined(),Skipping toString(): unknown method,return from a call to Object NullPointerExceptions.derefUndefinedCallee()] codetoanalyze/java/infer/NullPointerExceptions.java, codetoanalyze.java.infer.NullPointerExceptions.derefNullableGetter():void, 2, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure derefNullableGetter(),start of procedure nullableGetter(),return from a call to Object NullPointerExceptions.nullableGetter()] @@ -151,8 +151,8 @@ codetoanalyze/java/infer/ReaderLeaks.java, codetoanalyze.java.infer.ReaderLeaks. codetoanalyze/java/infer/ReaderLeaks.java, codetoanalyze.java.infer.ReaderLeaks.readerNotClosedAfterRead():void, 6, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure readerNotClosedAfterRead(),Skipping FileReader(...): unknown method,exception java.io.IOException] codetoanalyze/java/infer/ResourceLeaks.java, codetoanalyze.java.infer.ResourceLeaks.activityObtainTypedArrayAndLeak(android.app.Activity):void, 2, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure activityObtainTypedArrayAndLeak(...),start of procedure ignore(...),return from a call to void ResourceLeaks.ignore(TypedArray)] codetoanalyze/java/infer/ResourceLeaks.java, codetoanalyze.java.infer.ResourceLeaks.contextObtainTypedArrayAndLeak(android.content.Context):void, 2, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure contextObtainTypedArrayAndLeak(...),start of procedure ignore(...),return from a call to void ResourceLeaks.ignore(TypedArray)] -codetoanalyze/java/infer/ResourceLeaks.java, codetoanalyze.java.infer.ResourceLeaks.copyFileLeak(java.io.File,java.io.File):void, 11, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure copyFileLeak(...),Skipping transferTo(...): unknown method,Taking true branch,exception java.io.IOException] -codetoanalyze/java/infer/ResourceLeaks.java, codetoanalyze.java.infer.ResourceLeaks.copyFileLeak(java.io.File,java.io.File):void, 11, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure copyFileLeak(...),exception java.io.FileNotFoundException] +codetoanalyze/java/infer/ResourceLeaks.java, codetoanalyze.java.infer.ResourceLeaks.copyFileLeak(java.io.File,java.io.File):void, 9, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure copyFileLeak(...),Skipping transferTo(...): unknown method,Taking true branch,exception java.io.IOException] +codetoanalyze/java/infer/ResourceLeaks.java, codetoanalyze.java.infer.ResourceLeaks.copyFileLeak(java.io.File,java.io.File):void, 9, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure copyFileLeak(...),exception java.io.FileNotFoundException] codetoanalyze/java/infer/ResourceLeaks.java, codetoanalyze.java.infer.ResourceLeaks.deflaterLeak():void, 1, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure deflaterLeak()] codetoanalyze/java/infer/ResourceLeaks.java, codetoanalyze.java.infer.ResourceLeaks.fileInputStreamNotClosedAfterRead():void, 6, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure fileInputStreamNotClosedAfterRead(),exception java.io.IOException] codetoanalyze/java/infer/ResourceLeaks.java, codetoanalyze.java.infer.ResourceLeaks.fileOutputStreamNotClosed():void, 1, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure fileOutputStreamNotClosed()] @@ -183,9 +183,9 @@ codetoanalyze/java/infer/ResourceLeaks.java, codetoanalyze.java.infer.ResourceLe codetoanalyze/java/infer/ResourceLeaks.java, codetoanalyze.java.infer.ResourceLeaks.pipedInputStreamNotClosedAfterRead(java.io.PipedOutputStream):void, 6, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure pipedInputStreamNotClosedAfterRead(...),exception java.io.IOException] codetoanalyze/java/infer/ResourceLeaks.java, codetoanalyze.java.infer.ResourceLeaks.pipedOutputStreamNotClosedAfterWrite():void, 7, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure pipedOutputStreamNotClosedAfterWrite(),exception java.io.IOException] codetoanalyze/java/infer/ResourceLeaks.java, codetoanalyze.java.infer.ResourceLeaks.readConfigNotCloseStream(java.lang.String):int, 5, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure readConfigNotCloseStream(...)] -codetoanalyze/java/infer/ResourceLeaks.java, codetoanalyze.java.infer.ResourceLeaks.readInstallationFileBad(java.io.File):java.lang.String, 6, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure readInstallationFileBad(...),exception java.io.IOException] +codetoanalyze/java/infer/ResourceLeaks.java, codetoanalyze.java.infer.ResourceLeaks.readInstallationFileBad(java.io.File):java.lang.String, 5, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure readInstallationFileBad(...),exception java.io.IOException] codetoanalyze/java/infer/ResourceLeaks.java, codetoanalyze.java.infer.ResourceLeaks.scannerNotClosed():void, 1, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure scannerNotClosed()] -codetoanalyze/java/infer/ResourceLeaks.java, codetoanalyze.java.infer.ResourceLeaks.serverSocketNotClosed():void, 12, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure serverSocketNotClosed(),Skipping ServerSocket(...): unknown method,exception java.io.IOException] +codetoanalyze/java/infer/ResourceLeaks.java, codetoanalyze.java.infer.ResourceLeaks.serverSocketNotClosed():void, 11, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure serverSocketNotClosed(),Skipping ServerSocket(...): unknown method,exception java.io.IOException] codetoanalyze/java/infer/ResourceLeaks.java, codetoanalyze.java.infer.ResourceLeaks.socketNotClosed():void, 1, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure socketNotClosed()] codetoanalyze/java/infer/ResourceLeaks.java, codetoanalyze.java.infer.ResourceLeaks.themeObtainTypedArrayAndLeak(android.content.res.Resources$Theme):void, 2, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure themeObtainTypedArrayAndLeak(...),start of procedure ignore(...),return from a call to void ResourceLeaks.ignore(TypedArray)] codetoanalyze/java/infer/ResourceLeaks.java, codetoanalyze.java.infer.ResourceLeaks.twoResources():void, 11, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure twoResources(),Taking true branch,exception java.io.IOException] diff --git a/infer/tests/build_systems/buck_cross_module/module1/Class1.java b/infer/tests/build_systems/buck_cross_module/module1/Class1.java index 584817733..a80178938 100644 --- a/infer/tests/build_systems/buck_cross_module/module1/Class1.java +++ b/infer/tests/build_systems/buck_cross_module/module1/Class1.java @@ -16,5 +16,4 @@ public class Class1 { } @Nullable public Object nullableField; - } diff --git a/infer/tests/build_systems/buck_cross_module/module2/Class2.java b/infer/tests/build_systems/buck_cross_module/module2/Class2.java index 6ca5fef32..a78bf74e4 100644 --- a/infer/tests/build_systems/buck_cross_module/module2/Class2.java +++ b/infer/tests/build_systems/buck_cross_module/module2/Class2.java @@ -18,5 +18,4 @@ public class Class2 { void crossModuleNPE2(Class1 c) { c.nullableField.toString(); } - } diff --git a/infer/tests/build_systems/codetoanalyze/make/Hello.java b/infer/tests/build_systems/codetoanalyze/make/Hello.java index cfed3dbd7..09c2442d9 100644 --- a/infer/tests/build_systems/codetoanalyze/make/Hello.java +++ b/infer/tests/build_systems/codetoanalyze/make/Hello.java @@ -49,9 +49,12 @@ class Hello { fos = new FileOutputStream(new File("everwhat.txt")); fos.write(fis.read()); } finally { - if (fis != null) { fis.close(); } // Resource leak - if (fos != null) { fos.close(); } + if (fis != null) { + fis.close(); + } // Resource leak + if (fos != null) { + fos.close(); + } } } - } diff --git a/infer/tests/build_systems/codetoanalyze/make/Pointers.java b/infer/tests/build_systems/codetoanalyze/make/Pointers.java index 240f9a03a..4f0001187 100644 --- a/infer/tests/build_systems/codetoanalyze/make/Pointers.java +++ b/infer/tests/build_systems/codetoanalyze/make/Pointers.java @@ -10,8 +10,7 @@ package hello; public class Pointers { public static class A { - public void method() { - } + public void method() {} } public static A mayReturnNull(int i) { @@ -20,5 +19,4 @@ public class Pointers { } return null; } - } diff --git a/infer/tests/build_systems/codetoanalyze/make/Resources.java b/infer/tests/build_systems/codetoanalyze/make/Resources.java index feda5e458..0f4f7201d 100644 --- a/infer/tests/build_systems/codetoanalyze/make/Resources.java +++ b/infer/tests/build_systems/codetoanalyze/make/Resources.java @@ -21,5 +21,4 @@ public class Resources { return null; } } - } diff --git a/infer/tests/build_systems/codetoanalyze/mvn/app_with_submodules/module2parent/module2/src/main/java/com/mycompany/Hello2.java b/infer/tests/build_systems/codetoanalyze/mvn/app_with_submodules/module2parent/module2/src/main/java/com/mycompany/Hello2.java index c4b887761..cd4925317 100644 --- a/infer/tests/build_systems/codetoanalyze/mvn/app_with_submodules/module2parent/module2/src/main/java/com/mycompany/Hello2.java +++ b/infer/tests/build_systems/codetoanalyze/mvn/app_with_submodules/module2parent/module2/src/main/java/com/mycompany/Hello2.java @@ -7,6 +7,8 @@ package hello2; +import hello.Pointers; +import hello.Resources; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -14,9 +16,6 @@ import java.io.IOException; import java.io.OutputStream; import java.util.Random; -import hello.Pointers; -import hello.Resources; - class Hello2 { void doesNotCauseNPE2() { @@ -52,9 +51,12 @@ class Hello2 { fos = new FileOutputStream(new File("everwhat.txt")); fos.write(fis.read()); } finally { - if (fis != null) { fis.close(); } // Resource leak - if (fos != null) { fos.close(); } + if (fis != null) { + fis.close(); + } // Resource leak + if (fos != null) { + fos.close(); + } } } - } diff --git a/infer/tests/build_systems/codetoanalyze/mvn/simple_app/src/main/java/com/mycompany/Hello.java b/infer/tests/build_systems/codetoanalyze/mvn/simple_app/src/main/java/com/mycompany/Hello.java index cfed3dbd7..09c2442d9 100644 --- a/infer/tests/build_systems/codetoanalyze/mvn/simple_app/src/main/java/com/mycompany/Hello.java +++ b/infer/tests/build_systems/codetoanalyze/mvn/simple_app/src/main/java/com/mycompany/Hello.java @@ -49,9 +49,12 @@ class Hello { fos = new FileOutputStream(new File("everwhat.txt")); fos.write(fis.read()); } finally { - if (fis != null) { fis.close(); } // Resource leak - if (fos != null) { fos.close(); } + if (fis != null) { + fis.close(); + } // Resource leak + if (fos != null) { + fos.close(); + } } } - } diff --git a/infer/tests/build_systems/codetoanalyze/mvn/simple_app/src/main/java/com/mycompany/Pointers.java b/infer/tests/build_systems/codetoanalyze/mvn/simple_app/src/main/java/com/mycompany/Pointers.java index 240f9a03a..4f0001187 100644 --- a/infer/tests/build_systems/codetoanalyze/mvn/simple_app/src/main/java/com/mycompany/Pointers.java +++ b/infer/tests/build_systems/codetoanalyze/mvn/simple_app/src/main/java/com/mycompany/Pointers.java @@ -10,8 +10,7 @@ package hello; public class Pointers { public static class A { - public void method() { - } + public void method() {} } public static A mayReturnNull(int i) { @@ -20,5 +19,4 @@ public class Pointers { } return null; } - } diff --git a/infer/tests/build_systems/codetoanalyze/mvn/simple_app/src/main/java/com/mycompany/Resources.java b/infer/tests/build_systems/codetoanalyze/mvn/simple_app/src/main/java/com/mycompany/Resources.java index feda5e458..0f4f7201d 100644 --- a/infer/tests/build_systems/codetoanalyze/mvn/simple_app/src/main/java/com/mycompany/Resources.java +++ b/infer/tests/build_systems/codetoanalyze/mvn/simple_app/src/main/java/com/mycompany/Resources.java @@ -21,5 +21,4 @@ public class Resources { return null; } } - } diff --git a/infer/tests/build_systems/differential_skip_anonymous_class_renamings/src/SimpleInterfaceExample.java b/infer/tests/build_systems/differential_skip_anonymous_class_renamings/src/SimpleInterfaceExample.java index 4f2e38ae6..b965cde24 100644 --- a/infer/tests/build_systems/differential_skip_anonymous_class_renamings/src/SimpleInterfaceExample.java +++ b/infer/tests/build_systems/differential_skip_anonymous_class_renamings/src/SimpleInterfaceExample.java @@ -8,5 +8,5 @@ // This example tests that anonymous class renaming does not affect the // computation of the pre-existing warnings public interface SimpleInterfaceExample { - public String getString(); + public String getString(); } diff --git a/infer/tests/build_systems/differential_skip_anonymous_class_renamings/src/SimpleNestedInterface.java b/infer/tests/build_systems/differential_skip_anonymous_class_renamings/src/SimpleNestedInterface.java index 7e105f26d..b1310b3ff 100644 --- a/infer/tests/build_systems/differential_skip_anonymous_class_renamings/src/SimpleNestedInterface.java +++ b/infer/tests/build_systems/differential_skip_anonymous_class_renamings/src/SimpleNestedInterface.java @@ -8,5 +8,5 @@ // This example tests that anonymous class renaming does not affect the // computation of the pre-existing warnings public interface SimpleNestedInterface { - public void doSomething(); + public void doSomething(); } diff --git a/infer/tests/build_systems/genrule/annotations/Nullable.java b/infer/tests/build_systems/genrule/annotations/Nullable.java index 9c8244375..429589abb 100644 --- a/infer/tests/build_systems/genrule/annotations/Nullable.java +++ b/infer/tests/build_systems/genrule/annotations/Nullable.java @@ -6,5 +6,4 @@ */ package genrule.annotations; -public @interface Nullable { -} +public @interface Nullable {} diff --git a/infer/tests/build_systems/genrule/module1/SkipImplementationClass1.java b/infer/tests/build_systems/genrule/module1/SkipImplementationClass1.java index 9ea4ed76d..e7cffcf4e 100644 --- a/infer/tests/build_systems/genrule/module1/SkipImplementationClass1.java +++ b/infer/tests/build_systems/genrule/module1/SkipImplementationClass1.java @@ -20,5 +20,4 @@ public class SkipImplementationClass1 { public Object notAnnotatedNullable() { return null; } - } diff --git a/infer/tests/build_systems/gradle/issues.exp b/infer/tests/build_systems/gradle/issues.exp index e6e7c729e..f10480d2e 100644 --- a/infer/tests/build_systems/gradle/issues.exp +++ b/infer/tests/build_systems/gradle/issues.exp @@ -1,3 +1,3 @@ Hello.java, hello.Hello.mayCauseNPE():void, 4, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure mayCauseNPE(),Skipping Random(): unknown method,start of procedure mayReturnNull(...),Taking false branch,return from a call to Pointers$A Pointers.mayReturnNull(int)] Hello.java, hello.Hello.mayLeakResource():void, 7, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure mayLeakResource(),start of procedure allocateResource(),Skipping File(...): unknown method,return from a call to FileOutputStream Resources.allocateResource(),Taking false branch] -Hello.java, hello.Hello.twoResources():void, 11, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure twoResources(),Taking true branch,exception java.io.IOException] +Hello.java, hello.Hello.twoResources():void, 15, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure twoResources(),Taking true branch,exception java.io.IOException] diff --git a/infer/tests/build_systems/make/issues.exp b/infer/tests/build_systems/make/issues.exp index 7735656cb..60dad2e21 100644 --- a/infer/tests/build_systems/make/issues.exp +++ b/infer/tests/build_systems/make/issues.exp @@ -1,4 +1,4 @@ build_systems/codetoanalyze/make/Hello.java, hello.Hello.mayCauseNPE():void, 4, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure mayCauseNPE(),Skipping Random(): unknown method,start of procedure mayReturnNull(...),Taking false branch,return from a call to Pointers$A Pointers.mayReturnNull(int)] build_systems/codetoanalyze/make/Hello.java, hello.Hello.mayLeakResource():void, 7, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure mayLeakResource(),start of procedure allocateResource(),Skipping File(...): unknown method,return from a call to FileOutputStream Resources.allocateResource(),Taking false branch] -build_systems/codetoanalyze/make/Hello.java, hello.Hello.twoResources():void, 11, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure twoResources(),Taking true branch,exception java.io.IOException] +build_systems/codetoanalyze/make/Hello.java, hello.Hello.twoResources():void, 15, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure twoResources(),Taking true branch,exception java.io.IOException] build_systems/codetoanalyze/make/utf8_in_function_names.c, test_성공, 2, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure test_성공()] diff --git a/infer/tests/build_systems/mvn/issues.exp b/infer/tests/build_systems/mvn/issues.exp index aa2f2fbe8..ee460e66c 100644 --- a/infer/tests/build_systems/mvn/issues.exp +++ b/infer/tests/build_systems/mvn/issues.exp @@ -1,19 +1,19 @@ -- app_with_submodules build_systems/codetoanalyze/mvn/app_with_submodules/module2parent/module2/src/main/java/com/mycompany/Hello2.java, hello2.Hello2.mayCauseNPE2():void, 4, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure mayCauseNPE2(),Skipping Random(): unknown method,start of procedure mayReturnNull(...),Taking false branch,return from a call to Pointers$A Pointers.mayReturnNull(int)] build_systems/codetoanalyze/mvn/app_with_submodules/module2parent/module2/src/main/java/com/mycompany/Hello2.java, hello2.Hello2.mayLeakResource2():void, 7, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure mayLeakResource2(),start of procedure allocateResource(),Skipping File(...): unknown method,return from a call to FileOutputStream Resources.allocateResource(),Taking false branch] -build_systems/codetoanalyze/mvn/app_with_submodules/module2parent/module2/src/main/java/com/mycompany/Hello2.java, hello2.Hello2.twoResources2():void, 11, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure twoResources2(),Taking true branch,exception java.io.IOException] +build_systems/codetoanalyze/mvn/app_with_submodules/module2parent/module2/src/main/java/com/mycompany/Hello2.java, hello2.Hello2.twoResources2():void, 15, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure twoResources2(),Taking true branch,exception java.io.IOException] build_systems/codetoanalyze/mvn/simple_app/src/main/java/com/mycompany/Hello.java, hello.Hello.mayCauseNPE():void, 4, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure mayCauseNPE(),Skipping Random(): unknown method,start of procedure mayReturnNull(...),Taking false branch,return from a call to Pointers$A Pointers.mayReturnNull(int)] build_systems/codetoanalyze/mvn/simple_app/src/main/java/com/mycompany/Hello.java, hello.Hello.mayLeakResource():void, 7, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure mayLeakResource(),start of procedure allocateResource(),Skipping File(...): unknown method,return from a call to FileOutputStream Resources.allocateResource(),Taking false branch] -build_systems/codetoanalyze/mvn/simple_app/src/main/java/com/mycompany/Hello.java, hello.Hello.twoResources():void, 11, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure twoResources(),Taking true branch,exception java.io.IOException] +build_systems/codetoanalyze/mvn/simple_app/src/main/java/com/mycompany/Hello.java, hello.Hello.twoResources():void, 15, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure twoResources(),Taking true branch,exception java.io.IOException] -- simple_app build_systems/codetoanalyze/mvn/simple_app/src/main/java/com/mycompany/Hello.java, hello.Hello.mayCauseNPE():void, 4, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure mayCauseNPE(),Skipping Random(): unknown method,start of procedure mayReturnNull(...),Taking false branch,return from a call to Pointers$A Pointers.mayReturnNull(int)] build_systems/codetoanalyze/mvn/simple_app/src/main/java/com/mycompany/Hello.java, hello.Hello.mayLeakResource():void, 7, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure mayLeakResource(),start of procedure allocateResource(),Skipping File(...): unknown method,return from a call to FileOutputStream Resources.allocateResource(),Taking false branch] -build_systems/codetoanalyze/mvn/simple_app/src/main/java/com/mycompany/Hello.java, hello.Hello.twoResources():void, 11, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure twoResources(),Taking true branch,exception java.io.IOException] +build_systems/codetoanalyze/mvn/simple_app/src/main/java/com/mycompany/Hello.java, hello.Hello.twoResources():void, 15, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure twoResources(),Taking true branch,exception java.io.IOException] -- app_with_infer_profile build_systems/codetoanalyze/mvn/simple_app/src/main/java/com/mycompany/Hello.java, hello.Hello.mayCauseNPE():void, 4, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure mayCauseNPE(),Skipping Random(): unknown method,start of procedure mayReturnNull(...),Taking false branch,return from a call to Pointers$A Pointers.mayReturnNull(int)] build_systems/codetoanalyze/mvn/simple_app/src/main/java/com/mycompany/Hello.java, hello.Hello.mayLeakResource():void, 7, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure mayLeakResource(),start of procedure allocateResource(),Skipping File(...): unknown method,return from a call to FileOutputStream Resources.allocateResource(),Taking false branch] -build_systems/codetoanalyze/mvn/simple_app/src/main/java/com/mycompany/Hello.java, hello.Hello.twoResources():void, 11, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure twoResources(),Taking true branch,exception java.io.IOException] +build_systems/codetoanalyze/mvn/simple_app/src/main/java/com/mycompany/Hello.java, hello.Hello.twoResources():void, 15, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure twoResources(),Taking true branch,exception java.io.IOException] -- app_with_profiles build_systems/codetoanalyze/mvn/simple_app/src/main/java/com/mycompany/Hello.java, hello.Hello.mayCauseNPE():void, 4, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure mayCauseNPE(),Skipping Random(): unknown method,start of procedure mayReturnNull(...),Taking false branch,return from a call to Pointers$A Pointers.mayReturnNull(int)] build_systems/codetoanalyze/mvn/simple_app/src/main/java/com/mycompany/Hello.java, hello.Hello.mayLeakResource():void, 7, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure mayLeakResource(),start of procedure allocateResource(),Skipping File(...): unknown method,return from a call to FileOutputStream Resources.allocateResource(),Taking false branch] -build_systems/codetoanalyze/mvn/simple_app/src/main/java/com/mycompany/Hello.java, hello.Hello.twoResources():void, 11, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure twoResources(),Taking true branch,exception java.io.IOException] +build_systems/codetoanalyze/mvn/simple_app/src/main/java/com/mycompany/Hello.java, hello.Hello.twoResources():void, 15, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure twoResources(),Taking true branch,exception java.io.IOException] diff --git a/infer/tests/build_systems/racerd_dedup/issues.exp b/infer/tests/build_systems/racerd_dedup/issues.exp index a6438bcf4..ea7619fce 100644 --- a/infer/tests/build_systems/racerd_dedup/issues.exp +++ b/infer/tests/build_systems/racerd_dedup/issues.exp @@ -1,8 +1,8 @@ -DeDup.java, build_systems.threadsafety.DeDup.colocated_read_write():void, 64, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,call to void DeDup.read_and_write(),access to `this.build_systems.threadsafety.DeDup.colocated_read`,,access to `this.build_systems.threadsafety.DeDup.colocated_read`] -DeDup.java, build_systems.threadsafety.DeDup.separate_write_to_colocated_read():void, 69, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.build_systems.threadsafety.DeDup.colocated_read`] -DeDup.java, build_systems.threadsafety.DeDup.twoWritesOneInCaller():void, 52, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.build_systems.threadsafety.DeDup.field`] +DeDup.java, build_systems.threadsafety.DeDup.colocated_read_write():void, 63, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,call to void DeDup.read_and_write(),access to `this.build_systems.threadsafety.DeDup.colocated_read`,,access to `this.build_systems.threadsafety.DeDup.colocated_read`] +DeDup.java, build_systems.threadsafety.DeDup.separate_write_to_colocated_read():void, 68, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.build_systems.threadsafety.DeDup.colocated_read`] +DeDup.java, build_systems.threadsafety.DeDup.twoWritesOneInCaller():void, 51, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.build_systems.threadsafety.DeDup.field`] DeDup.java, build_systems.threadsafety.DeDup.two_fields():void, 20, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [call to void DeDup.foo(),access to `this.build_systems.threadsafety.DeDup.fielda`] -DeDup.java, build_systems.threadsafety.DeDup.two_reads():void, 39, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.build_systems.threadsafety.DeDup.field`,,access to `this.build_systems.threadsafety.DeDup.field`] -DeDup.java, build_systems.threadsafety.DeDup.two_writes():void, 32, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.build_systems.threadsafety.DeDup.field`] -DeDup.java, build_systems.threadsafety.DeDup.write_read():void, 45, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.build_systems.threadsafety.DeDup.field`] -DeDup.java, build_systems.threadsafety.DeDup.write_read():void, 46, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.build_systems.threadsafety.DeDup.field`,,access to `this.build_systems.threadsafety.DeDup.field`] +DeDup.java, build_systems.threadsafety.DeDup.two_reads():void, 38, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.build_systems.threadsafety.DeDup.field`,,access to `this.build_systems.threadsafety.DeDup.field`] +DeDup.java, build_systems.threadsafety.DeDup.two_writes():void, 31, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.build_systems.threadsafety.DeDup.field`] +DeDup.java, build_systems.threadsafety.DeDup.write_read():void, 44, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.build_systems.threadsafety.DeDup.field`] +DeDup.java, build_systems.threadsafety.DeDup.write_read():void, 45, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.build_systems.threadsafety.DeDup.field`,,access to `this.build_systems.threadsafety.DeDup.field`] diff --git a/infer/tests/build_systems/racerd_dedup/src/DeDup.java b/infer/tests/build_systems/racerd_dedup/src/DeDup.java index a3c7bbb2a..5354fad19 100644 --- a/infer/tests/build_systems/racerd_dedup/src/DeDup.java +++ b/infer/tests/build_systems/racerd_dedup/src/DeDup.java @@ -10,40 +10,39 @@ package build_systems.threadsafety; import javax.annotation.concurrent.ThreadSafe; @ThreadSafe -class DeDup{ +class DeDup { -Integer field; -Integer fielda, fieldb; + Integer field; + Integer fielda, fieldb; /* Only want one rather than two reports */ - void two_fields(){ + void two_fields() { foo(); } private void foo() { fielda = 88; fieldb = 99; - } - + } /*Only the first write should be reported*/ - void two_writes(){ - field = 22; - field = 84; - } + void two_writes() { + field = 22; + field = 84; + } /*Only the first read should be reported*/ - void two_reads(){ //parallel reads are OK - Integer local; - local = field; - local = field+1; + void two_reads() { // parallel reads are OK + Integer local; + local = field; + local = field + 1; } /*Both accesses should be reported*/ - void write_read(){ //parallel reads are OK - Integer local; - field = 87; - local = field; + void write_read() { // parallel reads are OK + Integer local; + field = 87; + local = field; } /*Should only report the first write, which happens to be interprocedural*/ @@ -60,19 +59,17 @@ Integer fielda, fieldb; Integer colocated_read, colocated_write; /*Should only report colocated write, not read, from readandwrite()*/ - void colocated_read_write(){ + void colocated_read_write() { read_and_write(); } /*Should report*/ - void separate_write_to_colocated_read(){ - colocated_read= 88; + void separate_write_to_colocated_read() { + colocated_read = 88; } private void read_and_write() { Integer x = colocated_read; - colocated_write= 99; - } - - + colocated_write = 99; + } } diff --git a/infer/tests/build_systems/racerd_dedup/src/Locals.java b/infer/tests/build_systems/racerd_dedup/src/Locals.java index 29b55e055..ca3339fb7 100644 --- a/infer/tests/build_systems/racerd_dedup/src/Locals.java +++ b/infer/tests/build_systems/racerd_dedup/src/Locals.java @@ -13,7 +13,9 @@ import javax.annotation.concurrent.ThreadSafe; public class Locals { int f; - static Locals id(Locals o) { return o; } + static Locals id(Locals o) { + return o; + } static void FN_raceOnTemporary_bad(Locals o) { id(o).f = 5; diff --git a/infer/tests/build_systems/racerd_traces/module1/Class1.java b/infer/tests/build_systems/racerd_traces/module1/Class1.java index ce5127914..eb6cb1d99 100644 --- a/infer/tests/build_systems/racerd_traces/module1/Class1.java +++ b/infer/tests/build_systems/racerd_traces/module1/Class1.java @@ -14,5 +14,4 @@ public class Class1 { public static void method() { sField++; } - } diff --git a/infer/tests/build_systems/racerd_traces/module2/Class2.java b/infer/tests/build_systems/racerd_traces/module2/Class2.java index 29bac04ef..741a4a830 100644 --- a/infer/tests/build_systems/racerd_traces/module2/Class2.java +++ b/infer/tests/build_systems/racerd_traces/module2/Class2.java @@ -14,5 +14,4 @@ public class Class2 { public static void method() { Class1.method(); } - } diff --git a/infer/tests/build_systems/racerd_traces/module3/Class3.java b/infer/tests/build_systems/racerd_traces/module3/Class3.java index 4b71be555..43bd441a2 100644 --- a/infer/tests/build_systems/racerd_traces/module3/Class3.java +++ b/infer/tests/build_systems/racerd_traces/module3/Class3.java @@ -9,17 +9,17 @@ package threadsafety_traces.module3; import threadsafety_traces.module2.Class2; -@interface ThreadSafe { -} +@interface ThreadSafe {} @ThreadSafe public class Class3 { - /** this will produce a truncated trace that should bottom out in Class1.method, but will stop - short due to limitations in our Buck integration. test that we don't report a truncated - trace in this situation. */ + /** + * this will produce a truncated trace that should bottom out in Class1.method, but will stop + * short due to limitations in our Buck integration. test that we don't report a truncated trace + * in this situation. + */ public void callClass2() { Class2.method(); } - } diff --git a/infer/tests/build_systems/resource_leak_exception_lines/SimpleLeak.java b/infer/tests/build_systems/resource_leak_exception_lines/SimpleLeak.java index 46d02653a..7ce759429 100644 --- a/infer/tests/build_systems/resource_leak_exception_lines/SimpleLeak.java +++ b/infer/tests/build_systems/resource_leak_exception_lines/SimpleLeak.java @@ -9,16 +9,16 @@ import java.io.*; public class SimpleLeak { public void method(boolean v) { - try { - FileInputStream a = new FileInputStream("aaa"); - FileInputStream z = null; - if (v) { - z = new FileInputStream("bbb"); - z.read(); - } - z.close(); - } catch (IOException e) { - // do nothing - } + try { + FileInputStream a = new FileInputStream("aaa"); + FileInputStream z = null; + if (v) { + z = new FileInputStream("bbb"); + z.read(); + } + z.close(); + } catch (IOException e) { + // do nothing } + } } diff --git a/infer/tests/build_systems/utf8_in_pwd/issues.exp b/infer/tests/build_systems/utf8_in_pwd/issues.exp index 56abbdeeb..d2fdd100e 100644 --- a/infer/tests/build_systems/utf8_in_pwd/issues.exp +++ b/infer/tests/build_systems/utf8_in_pwd/issues.exp @@ -1,9 +1,9 @@ hello.c, test, 2, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure test()] Hello.java, hello.Hello.mayCauseNPE():void, 4, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure mayCauseNPE(),Skipping Random(): unknown method,start of procedure mayReturnNull(...),Taking false branch,return from a call to Pointers$A Pointers.mayReturnNull(int)] Hello.java, hello.Hello.mayLeakResource():void, 7, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure mayLeakResource(),start of procedure allocateResource(),Skipping File(...): unknown method,return from a call to FileOutputStream Resources.allocateResource(),Taking false branch] -Hello.java, hello.Hello.twoResources():void, 11, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure twoResources(),Taking true branch,exception java.io.IOException] +Hello.java, hello.Hello.twoResources():void, 15, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure twoResources(),Taking true branch,exception java.io.IOException] Hello.java, Hello.test():int, 2, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure test()] Hello.java, hello.Hello.mayCauseNPE():void, 4, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure mayCauseNPE(),Skipping Random(): unknown method,start of procedure mayReturnNull(...),Taking false branch,return from a call to Pointers$A Pointers.mayReturnNull(int)] Hello.java, hello.Hello.mayLeakResource():void, 7, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure mayLeakResource(),start of procedure allocateResource(),Skipping File(...): unknown method,return from a call to FileOutputStream Resources.allocateResource(),Taking false branch] -Hello.java, hello.Hello.twoResources():void, 11, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure twoResources(),Taking true branch,exception java.io.IOException] +Hello.java, hello.Hello.twoResources():void, 15, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure twoResources(),Taking true branch,exception java.io.IOException] utf8_in_function_names.c, test_성공, 2, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure test_성공()] diff --git a/infer/tests/build_systems/waf/issues.exp b/infer/tests/build_systems/waf/issues.exp index 134d4feff..cfcf1adc8 100644 --- a/infer/tests/build_systems/waf/issues.exp +++ b/infer/tests/build_systems/waf/issues.exp @@ -1,4 +1,4 @@ Hello.java, hello.Hello.mayCauseNPE():void, 4, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure mayCauseNPE(),Skipping Random(): unknown method,start of procedure mayReturnNull(...),Taking false branch,return from a call to Pointers$A Pointers.mayReturnNull(int)] Hello.java, hello.Hello.mayLeakResource():void, 7, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure mayLeakResource(),start of procedure allocateResource(),Skipping File(...): unknown method,return from a call to FileOutputStream Resources.allocateResource(),Taking false branch] -Hello.java, hello.Hello.twoResources():void, 11, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure twoResources(),Taking true branch,exception java.io.IOException] +Hello.java, hello.Hello.twoResources():void, 15, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure twoResources(),Taking true branch,exception java.io.IOException] utf8_in_function_names.c, test_성공, 2, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure test_성공()] diff --git a/infer/tests/codetoanalyze/java/checkers/AnnotationReachabilityDuplicatesExample.java b/infer/tests/codetoanalyze/java/checkers/AnnotationReachabilityDuplicatesExample.java index f83d58546..b11efe5ea 100644 --- a/infer/tests/codetoanalyze/java/checkers/AnnotationReachabilityDuplicatesExample.java +++ b/infer/tests/codetoanalyze/java/checkers/AnnotationReachabilityDuplicatesExample.java @@ -12,7 +12,6 @@ import com.facebook.infer.annotation.PerformanceCritical; public class AnnotationReachabilityDuplicatesExample { - @Expensive native void expensive(); @@ -31,7 +30,7 @@ public class AnnotationReachabilityDuplicatesExample { @PerformanceCritical void perfCriticalBad2() { - callsExpensiveTwice(); // should report here only once + callsExpensiveTwice(); // should report here only once } native boolean star(); @@ -46,7 +45,6 @@ public class AnnotationReachabilityDuplicatesExample { @PerformanceCritical void perfCriticalBad1() { - callsEitherExpensive(); // should report here only once + callsEitherExpensive(); // should report here only once } - } diff --git a/infer/tests/codetoanalyze/java/checkers/Branch.java b/infer/tests/codetoanalyze/java/checkers/Branch.java index ba9a26e56..8c620aae0 100644 --- a/infer/tests/codetoanalyze/java/checkers/Branch.java +++ b/infer/tests/codetoanalyze/java/checkers/Branch.java @@ -12,5 +12,4 @@ public class Branch { public static boolean unlikely(boolean value) { return value; } - } diff --git a/infer/tests/codetoanalyze/java/checkers/CustomAnnotations.java b/infer/tests/codetoanalyze/java/checkers/CustomAnnotations.java index f10066fa4..07f61e811 100644 --- a/infer/tests/codetoanalyze/java/checkers/CustomAnnotations.java +++ b/infer/tests/codetoanalyze/java/checkers/CustomAnnotations.java @@ -14,18 +14,15 @@ import java.lang.annotation.Target; @Target({ElementType.METHOD}) @Retention(RetentionPolicy.CLASS) -@interface UserDefinedSource1 { -} +@interface UserDefinedSource1 {} @Target({ElementType.METHOD}) @Retention(RetentionPolicy.CLASS) -@interface UserDefinedSource2 { -} +@interface UserDefinedSource2 {} @Target({ElementType.METHOD}) @Retention(RetentionPolicy.CLASS) -@interface UserDefinedSink { -} +@interface UserDefinedSink {} class CustomAnnotations { @@ -40,8 +37,7 @@ class CustomAnnotations { } @UserDefinedSink - void sink() { - } + void sink() {} @UserDefinedSource1 void source1Ok() { @@ -53,6 +49,5 @@ class CustomAnnotations { safeMethod(); } - void safeMethod() { - } + void safeMethod() {} } diff --git a/infer/tests/codetoanalyze/java/checkers/ExpensiveCallExample.java b/infer/tests/codetoanalyze/java/checkers/ExpensiveCallExample.java index 3f04f2298..d7df6a408 100644 --- a/infer/tests/codetoanalyze/java/checkers/ExpensiveCallExample.java +++ b/infer/tests/codetoanalyze/java/checkers/ExpensiveCallExample.java @@ -8,9 +8,8 @@ package codetoanalyze.java.checkers; import android.support.v4.app.FragmentActivity; -import android.widget.ImageView; import android.view.View; - +import android.widget.ImageView; import com.facebook.infer.annotation.Expensive; import com.facebook.infer.annotation.PerformanceCritical; import javax.annotation.Nullable; @@ -19,31 +18,24 @@ interface AnnotatedInterface { @PerformanceCritical void annotatedPerformanceCriticalInInterface(); - } - class Other { @Expensive - void expensive() { - } + void expensive() {} void callsExpensive1() { expensive(); } - void inexpensiveMethod() { - } - + void inexpensiveMethod() {} } @Expensive class ExpensiveClass { - void anExpensiveMethod() { - } - + void anExpensiveMethod() {} } @PerformanceCritical @@ -64,15 +56,11 @@ class PerformanceCriticalClass { void performanceCriticalMethod4(Other o) { o.inexpensiveMethod(); // should not report } - - } class ExpensiveSubclass extends ExpensiveClass { - void anotherExpensiveMethod() { - } - + void anotherExpensiveMethod() {} } class PerformanceCriticalSubclass extends PerformanceCriticalClass { @@ -92,10 +80,8 @@ class PerformanceCriticalSubclass extends PerformanceCriticalClass { void subclassPerformanceCriticalMethod4(Other o) { o.inexpensiveMethod(); // should not report; } - } - public class ExpensiveCallExample implements AnnotatedInterface { @Nullable Other mOther; @@ -179,7 +165,7 @@ public class ExpensiveCallExample implements AnnotatedInterface { void callsExpensiveInTheUnlikelyElseBranch() { if (Branch.unlikely(mOther != null)) { // Do nothing - } else { + } else { expensiveMethod(); } } @@ -216,5 +202,4 @@ public class ExpensiveCallExample implements AnnotatedInterface { expensiveMethod(); } } - } diff --git a/infer/tests/codetoanalyze/java/checkers/ExpensiveInheritanceExample.java b/infer/tests/codetoanalyze/java/checkers/ExpensiveInheritanceExample.java index 89714c028..c89945906 100644 --- a/infer/tests/codetoanalyze/java/checkers/ExpensiveInheritanceExample.java +++ b/infer/tests/codetoanalyze/java/checkers/ExpensiveInheritanceExample.java @@ -8,7 +8,6 @@ package codetoanalyze.java.checkers; import android.annotation.SuppressLint; - import com.facebook.infer.annotation.Expensive; import com.facebook.infer.annotation.PerformanceCritical; @@ -23,7 +22,6 @@ class A implements I { // in the interface. This report is legit but is not relevant for the current test. @Expensive public void foo() {} - } class B extends A implements I { @@ -70,5 +68,4 @@ public class ExpensiveInheritanceExample { a.foo(); } } - } diff --git a/infer/tests/codetoanalyze/java/checkers/ExpensiveInterfaceExample.java b/infer/tests/codetoanalyze/java/checkers/ExpensiveInterfaceExample.java index d69e43e09..8dce9e4c9 100644 --- a/infer/tests/codetoanalyze/java/checkers/ExpensiveInterfaceExample.java +++ b/infer/tests/codetoanalyze/java/checkers/ExpensiveInterfaceExample.java @@ -10,7 +10,6 @@ package codetoanalyze.java.checkers; import com.facebook.infer.annotation.Expensive; import com.facebook.infer.annotation.PerformanceCritical; - public interface ExpensiveInterfaceExample { interface I { @@ -19,7 +18,6 @@ public interface ExpensiveInterfaceExample { public void m1(); public void m2(); - } class C { @@ -27,24 +25,24 @@ public interface ExpensiveInterfaceExample { public void m3() {} public void m4() {} - } @Expensive public void m5(); interface I2 extends I { - @PerformanceCritical void m3(); + @PerformanceCritical + void m3(); } - abstract class ImplementsInterface implements I2 { - @Expensive void expensive() {} + @Expensive + void expensive() {} - @Override public void m1() { + @Override + public void m1() { expensive(); } } - } diff --git a/infer/tests/codetoanalyze/java/checkers/ExpensiveSubtypingExample.java b/infer/tests/codetoanalyze/java/checkers/ExpensiveSubtypingExample.java index ddb69ea0d..e182bd3c6 100644 --- a/infer/tests/codetoanalyze/java/checkers/ExpensiveSubtypingExample.java +++ b/infer/tests/codetoanalyze/java/checkers/ExpensiveSubtypingExample.java @@ -15,5 +15,4 @@ public class ExpensiveSubtypingExample extends ExpensiveInterfaceExample.C { public void m3() {} public void m4() {} - } diff --git a/infer/tests/codetoanalyze/java/checkers/FragmentDoesNotRetainViewExample.java b/infer/tests/codetoanalyze/java/checkers/FragmentDoesNotRetainViewExample.java index ee313ad65..d465771fb 100644 --- a/infer/tests/codetoanalyze/java/checkers/FragmentDoesNotRetainViewExample.java +++ b/infer/tests/codetoanalyze/java/checkers/FragmentDoesNotRetainViewExample.java @@ -14,7 +14,6 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ListView; -import javax.annotation.Nullable; public class FragmentDoesNotRetainViewExample extends Fragment { @@ -23,7 +22,6 @@ public class FragmentDoesNotRetainViewExample extends Fragment { public CustomView(Context c) { super(c); } - } View mView1; @@ -53,5 +51,4 @@ public class FragmentDoesNotRetainViewExample extends Fragment { mCustomView = null; mViewSubclass = null; } - } diff --git a/infer/tests/codetoanalyze/java/checkers/FragmentRetainsViewExample.java b/infer/tests/codetoanalyze/java/checkers/FragmentRetainsViewExample.java index 4f0285cd6..7d9ba4c92 100644 --- a/infer/tests/codetoanalyze/java/checkers/FragmentRetainsViewExample.java +++ b/infer/tests/codetoanalyze/java/checkers/FragmentRetainsViewExample.java @@ -22,7 +22,6 @@ public class FragmentRetainsViewExample extends Fragment { public CustomView(Context c) { super(c); } - } View mView; @@ -41,5 +40,4 @@ public class FragmentRetainsViewExample extends Fragment { public void onDestroyView() { // not nulling out anything } - } diff --git a/infer/tests/codetoanalyze/java/checkers/ImmutableCast.java b/infer/tests/codetoanalyze/java/checkers/ImmutableCast.java index 52364229a..23b925972 100644 --- a/infer/tests/codetoanalyze/java/checkers/ImmutableCast.java +++ b/infer/tests/codetoanalyze/java/checkers/ImmutableCast.java @@ -8,7 +8,6 @@ package codetoanalyze.java.checkers; import com.google.common.collect.ImmutableList; - import java.util.ArrayList; import java.util.List; @@ -27,5 +26,4 @@ public class ImmutableCast { List goodCast(ImmutableList list) { return new ArrayList(list); } - } diff --git a/infer/tests/codetoanalyze/java/checkers/NoAllocationExample.java b/infer/tests/codetoanalyze/java/checkers/NoAllocationExample.java index df36c595e..555971d24 100644 --- a/infer/tests/codetoanalyze/java/checkers/NoAllocationExample.java +++ b/infer/tests/codetoanalyze/java/checkers/NoAllocationExample.java @@ -7,8 +7,8 @@ package codetoanalyze.java.checkers; -import com.facebook.infer.annotation.NoAllocation; import com.facebook.infer.annotation.IgnoreAllocations; +import com.facebook.infer.annotation.NoAllocation; public class NoAllocationExample { @@ -83,5 +83,4 @@ public class NoAllocationExample { } } } - } diff --git a/infer/tests/codetoanalyze/java/checkers/NullableSuggest.java b/infer/tests/codetoanalyze/java/checkers/NullableSuggest.java index 938b421a1..b80f86bbb 100644 --- a/infer/tests/codetoanalyze/java/checkers/NullableSuggest.java +++ b/infer/tests/codetoanalyze/java/checkers/NullableSuggest.java @@ -19,8 +19,7 @@ public class NullableSuggest { @Nullable private Object obj3; } - public void noAssignNullOk() { - } + public void noAssignNullOk() {} public void assignNotNullOk() { obj0 = new Object(); @@ -93,8 +92,7 @@ public class NullableSuggest { OtherClass oc = new OtherClass(); if (obj0 == null) { // Pretend that we did something here... - } - else { + } else { // The analysis should not suggest @Nullable on OtherClass.obj2 here oc.obj2 = obj0; } @@ -107,23 +105,25 @@ public class NullableSuggest { } void methodWithCapturedNullableParameterOk(@Nullable Object parameter) { - Object object = new Object() { - void foo() { - if (parameter != null) { - parameter.toString(); + Object object = + new Object() { + void foo() { + if (parameter != null) { + parameter.toString(); + } } - } - }; + }; } void methodWithCapturednonNullableParameterBad_FN(Object parameter) { - Object object = new Object() { - void foo() { - if (parameter != null) { - parameter.toString(); + Object object = + new Object() { + void foo() { + if (parameter != null) { + parameter.toString(); + } } - } - }; + }; } boolean checkExternalFieldForNullOk(SomeExternalClass parameter) { @@ -134,5 +134,4 @@ public class NullableSuggest { } return false; } - } diff --git a/infer/tests/codetoanalyze/java/checkers/PrintfArgsChecker.java b/infer/tests/codetoanalyze/java/checkers/PrintfArgsChecker.java index 238a2fe44..a7d3cc023 100644 --- a/infer/tests/codetoanalyze/java/checkers/PrintfArgsChecker.java +++ b/infer/tests/codetoanalyze/java/checkers/PrintfArgsChecker.java @@ -7,11 +7,8 @@ package codetoanalyze.java.checkers; - -import java.io.PrintStream; - import android.annotation.SuppressLint; - +import java.io.PrintStream; public class PrintfArgsChecker { @@ -56,7 +53,6 @@ public class PrintfArgsChecker { String format = "%s %s"; out.printf(format, "hello", "world"); } - } @SuppressLint("checkers-printf-args") @@ -65,5 +61,4 @@ class SuppressedPrintfArgsChecker { void classSuppressed(PrintStream out) { out.printf("Hello %d", "world"); } - } diff --git a/infer/tests/codetoanalyze/java/checkers/TraceCallSequence.java b/infer/tests/codetoanalyze/java/checkers/TraceCallSequence.java index 65c0c9a5e..859423138 100644 --- a/infer/tests/codetoanalyze/java/checkers/TraceCallSequence.java +++ b/infer/tests/codetoanalyze/java/checkers/TraceCallSequence.java @@ -7,13 +7,10 @@ package codetoanalyze.java.checkers; - class TraceCallSequence { - static void begin() { - } + static void begin() {} - static void end() { - } + static void end() {} static void beginWrapper() { begin(); diff --git a/infer/tests/codetoanalyze/java/checkers/TwoCheckersExample.java b/infer/tests/codetoanalyze/java/checkers/TwoCheckersExample.java index 587ce322c..14fb657c1 100644 --- a/infer/tests/codetoanalyze/java/checkers/TwoCheckersExample.java +++ b/infer/tests/codetoanalyze/java/checkers/TwoCheckersExample.java @@ -7,11 +7,9 @@ package codetoanalyze.java.checkers; -import com.google.common.collect.ImmutableList; - import com.facebook.infer.annotation.Expensive; import com.facebook.infer.annotation.PerformanceCritical; - +import com.google.common.collect.ImmutableList; import java.util.List; public class TwoCheckersExample { @@ -25,5 +23,4 @@ public class TwoCheckersExample { static List shouldRaisePerformanceCriticalError() { return shouldRaiseImmutableCastError(); } - } diff --git a/infer/tests/codetoanalyze/java/checkers/UiThreads.java b/infer/tests/codetoanalyze/java/checkers/UiThreads.java index 7fb5ff07e..7049a3fef 100644 --- a/infer/tests/codetoanalyze/java/checkers/UiThreads.java +++ b/infer/tests/codetoanalyze/java/checkers/UiThreads.java @@ -8,7 +8,6 @@ package codetoanalyze.java.checkers; import android.support.annotation.UiThread; - import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -16,18 +15,15 @@ import java.lang.annotation.Target; @Target({ElementType.METHOD}) @Retention(RetentionPolicy.CLASS) -@interface AnyThread { -} +@interface AnyThread {} @Target({ElementType.METHOD}) @Retention(RetentionPolicy.CLASS) -@interface ForUiThread { -} +@interface ForUiThread {} @Target({ElementType.METHOD}) @Retention(RetentionPolicy.CLASS) -@interface ForNonUiThread { -} +@interface ForNonUiThread {} public class UiThreads { @@ -92,5 +88,4 @@ public class UiThreads { void callForNonUiThreadOk() { forNonUiThread(); } - } diff --git a/infer/tests/codetoanalyze/java/crashcontext/BranchingCallsExample.java b/infer/tests/codetoanalyze/java/crashcontext/BranchingCallsExample.java index 7fb1c651c..63401279d 100644 --- a/infer/tests/codetoanalyze/java/crashcontext/BranchingCallsExample.java +++ b/infer/tests/codetoanalyze/java/crashcontext/BranchingCallsExample.java @@ -31,5 +31,4 @@ public class BranchingCallsExample { public static void main(String[] args) { foo(); } - } diff --git a/infer/tests/codetoanalyze/java/crashcontext/MethodNameClashExample.java b/infer/tests/codetoanalyze/java/crashcontext/MethodNameClashExample.java index a78aeadd8..550d892a4 100644 --- a/infer/tests/codetoanalyze/java/crashcontext/MethodNameClashExample.java +++ b/infer/tests/codetoanalyze/java/crashcontext/MethodNameClashExample.java @@ -15,7 +15,6 @@ public class MethodNameClashExample { String s = null; s.toString(); } - } public static class B { @@ -23,11 +22,9 @@ public class MethodNameClashExample { public static void foo() { A.foo(); } - } public static void main(String[] args) { B.foo(); } - } diff --git a/infer/tests/codetoanalyze/java/crashcontext/MinimalCrashExample.java b/infer/tests/codetoanalyze/java/crashcontext/MinimalCrashExample.java index c533869e0..b4986d7f0 100644 --- a/infer/tests/codetoanalyze/java/crashcontext/MinimalCrashExample.java +++ b/infer/tests/codetoanalyze/java/crashcontext/MinimalCrashExample.java @@ -13,5 +13,4 @@ public class MinimalCrashExample { String s = null; s.toString(); } - } diff --git a/infer/tests/codetoanalyze/java/crashcontext/MultiStackFrameCrashExample.java b/infer/tests/codetoanalyze/java/crashcontext/MultiStackFrameCrashExample.java index 729f02ff2..fc745aa54 100644 --- a/infer/tests/codetoanalyze/java/crashcontext/MultiStackFrameCrashExample.java +++ b/infer/tests/codetoanalyze/java/crashcontext/MultiStackFrameCrashExample.java @@ -21,5 +21,4 @@ public class MultiStackFrameCrashExample { public static void main(String[] args) { foo(); } - } diff --git a/infer/tests/codetoanalyze/java/crashcontext/NativeMethodExample.java b/infer/tests/codetoanalyze/java/crashcontext/NativeMethodExample.java index d5052914b..6528d68ba 100644 --- a/infer/tests/codetoanalyze/java/crashcontext/NativeMethodExample.java +++ b/infer/tests/codetoanalyze/java/crashcontext/NativeMethodExample.java @@ -22,10 +22,9 @@ public class NativeMethodExample { // in the stack (from the implementation of reflection) between this // method and the target of the reflective invocation. Method method = NativeMethodExample.class.getDeclaredMethod("foo"); - Object o = method.invoke(new Object[] {} ); + Object o = method.invoke(new Object[] {}); } catch (ReflectiveOperationException e) { throw new Error(e); } } - } diff --git a/infer/tests/codetoanalyze/java/eradicate/ActivityFieldNotInitialized.java b/infer/tests/codetoanalyze/java/eradicate/ActivityFieldNotInitialized.java index 3e04ee7eb..6ecab43c3 100644 --- a/infer/tests/codetoanalyze/java/eradicate/ActivityFieldNotInitialized.java +++ b/infer/tests/codetoanalyze/java/eradicate/ActivityFieldNotInitialized.java @@ -16,9 +16,6 @@ public class ActivityFieldNotInitialized { private String field; - protected void onCreate(Bundle bundle) { - } - + protected void onCreate(Bundle bundle) {} } - } diff --git a/infer/tests/codetoanalyze/java/eradicate/CustomAnnotations.java b/infer/tests/codetoanalyze/java/eradicate/CustomAnnotations.java index 5dfb65cad..f23d49245 100644 --- a/infer/tests/codetoanalyze/java/eradicate/CustomAnnotations.java +++ b/infer/tests/codetoanalyze/java/eradicate/CustomAnnotations.java @@ -8,13 +8,11 @@ package codetoanalyze.java.eradicate; import android.text.TextUtils; - -import javax.annotation.Nullable; -import com.facebook.infer.annotation.Assertions; import com.facebook.infer.annotation.FalseOnNull; import com.facebook.infer.annotation.PropagatesNullable; import com.facebook.infer.annotation.TrueOnNull; import com.google.common.base.Strings; +import javax.annotation.Nullable; public class CustomAnnotations { @@ -55,6 +53,7 @@ public class CustomAnnotations { s.toString(); // BAD } } + void myTextUtilsIsNotEmpty(@Nullable CharSequence s) { if (MyTextUtils.isNotEmpty(s)) { s.toString(); // OK diff --git a/infer/tests/codetoanalyze/java/eradicate/FieldNotInitialized.java b/infer/tests/codetoanalyze/java/eradicate/FieldNotInitialized.java index b62707fb4..fae1efc2d 100644 --- a/infer/tests/codetoanalyze/java/eradicate/FieldNotInitialized.java +++ b/infer/tests/codetoanalyze/java/eradicate/FieldNotInitialized.java @@ -7,12 +7,9 @@ package codetoanalyze.java.eradicate; - import android.support.annotation.NonNull; import android.widget.EditText; - import com.facebook.infer.annotation.SuppressViewNullability; - import javax.annotation.Nonnull; import javax.annotation.Nullable; import javax.inject.Inject; @@ -44,7 +41,6 @@ public class FieldNotInitialized { g = null; // OK the framework could write null into the field } - class OnlyRead { Object o; @@ -81,7 +77,6 @@ public class FieldNotInitialized { } } - class OnlyReadIndirect { Object o1; Object o2; @@ -99,10 +94,11 @@ public class FieldNotInitialized { class ConditionalFieldInit { Object o1; @Nullable Object o2 = null; + public ConditionalFieldInit() { - if (o2 != null) { - o1 = new Object(); // Not always initialized - } + if (o2 != null) { + o1 = new Object(); // Not always initialized + } } } @@ -110,8 +106,7 @@ public class FieldNotInitialized { Object o; public InitIfNull() { - if (o == null) - o = new Object(); + if (o == null) o = new Object(); } } @@ -119,8 +114,7 @@ public class FieldNotInitialized { Object o; public InitIfNull2(Object x) { - if (o == null) - o = x; + if (o == null) o = x; } } @@ -132,8 +126,7 @@ public class FieldNotInitialized { } public InitIfNull3() { - if (o == null) - o = getNotNull(); + if (o == null) o = getNotNull(); } } @@ -166,5 +159,4 @@ public class FieldNotInitialized { s = x.s; } } - } diff --git a/infer/tests/codetoanalyze/java/eradicate/FieldNotNullable.java b/infer/tests/codetoanalyze/java/eradicate/FieldNotNullable.java index d568284b1..68e07a844 100644 --- a/infer/tests/codetoanalyze/java/eradicate/FieldNotNullable.java +++ b/infer/tests/codetoanalyze/java/eradicate/FieldNotNullable.java @@ -11,11 +11,8 @@ import android.app.Activity; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.View; - import com.facebook.infer.annotation.Assertions; import com.facebook.infer.annotation.Initializer; -import com.facebook.infer.annotation.SuppressFieldNotInitialized; - import javax.annotation.Nullable; abstract class A { @@ -40,8 +37,7 @@ class FragmentExample extends Fragment { } public class FieldNotNullable extends A { - @Nullable - String x; + @Nullable String x; String y; String fld; // Shadow the field defined in A String static_s = null; // Static initializer error @@ -89,27 +85,26 @@ class MixedInitializers extends Activity { protected void onCreate(Bundle bundle) { field3 = "3"; } - } - class TestInitializerBuilder { String required1; String required2; @Nullable String optional; // No FIELD_NOT_INITIALIZED error should be reported, because of the @Initializer annotations. - TestInitializerBuilder() { - } + TestInitializerBuilder() {} // This is an initializer and must always be called before build(). - @Initializer TestInitializerBuilder setRequired1(String required1) { + @Initializer + TestInitializerBuilder setRequired1(String required1) { this.required1 = required1; return this; } // This is an initializer and must always be called before build(). - @Initializer TestInitializerBuilder setRequired2(String required2) { + @Initializer + TestInitializerBuilder setRequired2(String required2) { this.required2 = required2; return this; } @@ -132,7 +127,7 @@ class TestInitializer { String required2; // should always be set @Nullable String optional; // optionally set - TestInitializer (TestInitializerBuilder b) { + TestInitializer(TestInitializerBuilder b) { required1 = b.required1; required2 = b.required2; optional = b.optional; @@ -154,28 +149,22 @@ class TestInitializer { } } - class NestedFieldAccess { class C { - @Nullable - String s; + @Nullable String s; } class CC { - @Nullable - C c; + @Nullable C c; } class CCC { - @Nullable - CC cc; + @Nullable CC cc; } - public class Test { - @Nullable - String s; + @Nullable String s; C myc; Test() { @@ -220,8 +209,7 @@ class NestedFieldAccess { } void test5(@Nullable CCC ccc) { - if (ccc == null || ccc.cc == null || - ccc.cc.c == null || ccc.cc.c.s == null) { + if (ccc == null || ccc.cc == null || ccc.cc.c == null || ccc.cc.c.s == null) { } else { int n = ccc.cc.c.s.length(); } @@ -236,7 +224,8 @@ class NestedFieldAccess { dontAssignNull = ""; } - @Nullable String getS(int n) { + @Nullable + String getS(int n) { return s; } @@ -245,68 +234,68 @@ class NestedFieldAccess { } void FlatOK1(TestFunctionsIdempotent x) { - if(getS(3) != null) { + if (getS(3) != null) { dontAssignNull = getS(3); } } void FlatOK2(TestFunctionsIdempotent x) { - if(x.getS(3) != null) { + if (x.getS(3) != null) { dontAssignNull = x.getS(3); } } void FlatBAD1(TestFunctionsIdempotent x) { - if(x.getS(3) != null) { + if (x.getS(3) != null) { dontAssignNull = getS(3); } } void FlatBAD2(TestFunctionsIdempotent x) { - if(x.getS(3) != null) { + if (x.getS(3) != null) { dontAssignNull = x.getS(4); } } void NestedOK1() { - if(getSelf().getS(3) != null) { + if (getSelf().getS(3) != null) { dontAssignNull = getSelf().getS(3); } } void NestedOK2() { - if(getSelf().getSelf().getS(3) != null) { + if (getSelf().getSelf().getS(3) != null) { dontAssignNull = getSelf().getSelf().getS(3); } } void NestedBAD1() { - if(getSelf().getS(3) != null) { + if (getSelf().getS(3) != null) { dontAssignNull = getSelf().getS(4); } } void NestedBAD2() { - if(getS(3) != null) { + if (getS(3) != null) { dontAssignNull = getSelf().getS(3); } } void NestedBAD3() { - if(getSelf().getSelf().getS(3) != null) { + if (getSelf().getSelf().getS(3) != null) { dontAssignNull = getSelf().getS(3); } } } class TestContainsKey { - void testMapContainsKey (java.util.Map m) { + void testMapContainsKey(java.util.Map m) { if (m.containsKey(3)) { m.get(3).isEmpty(); } } - void testMapContainsKeyInsideWhileLoop (java.util.Map m) { + void testMapContainsKeyInsideWhileLoop(java.util.Map m) { while (true) { if (m.containsKey(3)) { m.get(3).isEmpty(); @@ -314,7 +303,7 @@ class NestedFieldAccess { } } - void testImmutableMapContainsKey (com.google.common.collect.ImmutableMap m) { + void testImmutableMapContainsKey(com.google.common.collect.ImmutableMap m) { if (m.containsKey(3)) { m.get(3).isEmpty(); } @@ -340,32 +329,31 @@ class NestedFieldAccess { if (!map.containsKey(key)) { map.put(key, "abc"); } - dontAssignNull= map.get(key); + dontAssignNull = map.get(key); } } // support assignments of null to @InjectView fields, generated by butterknife class SupportButterKnife { - @InjectView String s; + @InjectView String s; - SupportButterKnife() { - } + SupportButterKnife() {} - void dereferencingIsOK() { - int n = s.length(); - } + void dereferencingIsOK() { + int n = s.length(); + } - void assignNullIsOK() { - s = null; - } + void assignNullIsOK() { + s = null; + } } void methodWithNullableCapturedParameterBad_FN(@Nullable Object parameter) { - Object object = new Object() { - void foo() { - parameter.toString(); - } - }; + Object object = + new Object() { + void foo() { + parameter.toString(); + } + }; } - } diff --git a/infer/tests/codetoanalyze/java/eradicate/InconsistentSubclassAnnotation.java b/infer/tests/codetoanalyze/java/eradicate/InconsistentSubclassAnnotation.java index a409a342f..3e507dfec 100644 --- a/infer/tests/codetoanalyze/java/eradicate/InconsistentSubclassAnnotation.java +++ b/infer/tests/codetoanalyze/java/eradicate/InconsistentSubclassAnnotation.java @@ -13,8 +13,7 @@ import javax.annotation.Nullable; class SubclassExample { class T { - public void f() { - } + public void f() {} } class A { @@ -23,9 +22,7 @@ class SubclassExample { return new T(); } - public - @Nullable - T bar() { + public @Nullable T bar() { return null; } @@ -35,23 +32,18 @@ class SubclassExample { } } - public void noDeref(T t) { - } - + public void noDeref(T t) {} } class B extends A { - public - @Nullable - T foo() { + public @Nullable T foo() { return null; } public T bar() { return new T(); } - } interface I { @@ -60,9 +52,7 @@ class SubclassExample { class C implements I { - public - @Nullable - T baz() { + public @Nullable T baz() { return null; } } @@ -78,18 +68,16 @@ class SubclassExample { t.f(); } } - } } class ConstructorsAreExcluded { class Base { - Base (@Nullable String s) { - } + Base(@Nullable String s) {} } class Derived extends Base { - Derived (String s) { // OK: there's no sub-typing between constructors + Derived(String s) { // OK: there's no sub-typing between constructors super(s); } } @@ -124,5 +112,4 @@ public class InconsistentSubclassAnnotation implements InconsistentSubclassAnnot public String implementInAnotherFile(String s) { return ""; } - } diff --git a/infer/tests/codetoanalyze/java/eradicate/InconsistentSubclassAnnotationInterface.java b/infer/tests/codetoanalyze/java/eradicate/InconsistentSubclassAnnotationInterface.java index dd3914152..f5c61254c 100644 --- a/infer/tests/codetoanalyze/java/eradicate/InconsistentSubclassAnnotationInterface.java +++ b/infer/tests/codetoanalyze/java/eradicate/InconsistentSubclassAnnotationInterface.java @@ -11,5 +11,4 @@ import javax.annotation.Nullable; public interface InconsistentSubclassAnnotationInterface { public String implementInAnotherFile(@Nullable String s); - } diff --git a/infer/tests/codetoanalyze/java/eradicate/JunitExample.java b/infer/tests/codetoanalyze/java/eradicate/JunitExample.java index da5475a1d..af591e55a 100644 --- a/infer/tests/codetoanalyze/java/eradicate/JunitExample.java +++ b/infer/tests/codetoanalyze/java/eradicate/JunitExample.java @@ -19,5 +19,4 @@ public class JunitExample extends TestCase { public void testSomething() { mField.toString(); } - } diff --git a/infer/tests/codetoanalyze/java/eradicate/LibraryCalls.java b/infer/tests/codetoanalyze/java/eradicate/LibraryCalls.java index 5a11d7fa0..7f15d2e5d 100644 --- a/infer/tests/codetoanalyze/java/eradicate/LibraryCalls.java +++ b/infer/tests/codetoanalyze/java/eradicate/LibraryCalls.java @@ -34,5 +34,4 @@ public class LibraryCalls { String badAtomicReferenceDereference(AtomicReference ref) { return ref.get().toString(); } - } diff --git a/infer/tests/codetoanalyze/java/eradicate/MyPreconditions.java b/infer/tests/codetoanalyze/java/eradicate/MyPreconditions.java index 5e8057f51..ca6d510f4 100644 --- a/infer/tests/codetoanalyze/java/eradicate/MyPreconditions.java +++ b/infer/tests/codetoanalyze/java/eradicate/MyPreconditions.java @@ -11,5 +11,4 @@ import javax.annotation.Nullable; public class MyPreconditions { public static native T checkNotNull(@Nullable T t); - } diff --git a/infer/tests/codetoanalyze/java/eradicate/NoReuseUndefFunctionValues.java b/infer/tests/codetoanalyze/java/eradicate/NoReuseUndefFunctionValues.java index 9f5ae6cfe..13891d50d 100644 --- a/infer/tests/codetoanalyze/java/eradicate/NoReuseUndefFunctionValues.java +++ b/infer/tests/codetoanalyze/java/eradicate/NoReuseUndefFunctionValues.java @@ -28,5 +28,4 @@ public class NoReuseUndefFunctionValues { this.mObject2 = this.create(); } } - } diff --git a/infer/tests/codetoanalyze/java/eradicate/NullFieldAccess.java b/infer/tests/codetoanalyze/java/eradicate/NullFieldAccess.java index 8e8ae06d6..9f656f486 100644 --- a/infer/tests/codetoanalyze/java/eradicate/NullFieldAccess.java +++ b/infer/tests/codetoanalyze/java/eradicate/NullFieldAccess.java @@ -15,17 +15,12 @@ public class NullFieldAccess { } interface I { - @Nullable - C c = null; + @Nullable C c = null; } - - @Nullable - C x; + @Nullable C x; C y; - static final - @Nullable - C z = null; + static final @Nullable C z = null; NullFieldAccess() { y = new C(); diff --git a/infer/tests/codetoanalyze/java/eradicate/NullMethodCall.java b/infer/tests/codetoanalyze/java/eradicate/NullMethodCall.java index b42a0dc5d..11fac7759 100644 --- a/infer/tests/codetoanalyze/java/eradicate/NullMethodCall.java +++ b/infer/tests/codetoanalyze/java/eradicate/NullMethodCall.java @@ -7,18 +7,15 @@ package codetoanalyze.java.eradicate; -import com.google.common.base.Preconditions; - import android.app.AlarmManager; import android.app.PendingIntent; import com.facebook.infer.annotation.Assertions; -import java.lang.System; -import java.util.Map; +import com.google.common.base.Preconditions; import java.util.HashMap; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import javax.annotation.Nullable; - public class NullMethodCall { void callOnNull() { @@ -58,16 +55,11 @@ public class NullMethodCall { } private static class S { - private static - @Nullable - String sfld; + private static @Nullable String sfld; } - @Nullable - String fld; - private - @Nullable - String pfld; + @Nullable String fld; + private @Nullable String pfld; public class Inner { int outerField() { @@ -221,8 +213,7 @@ public class NullMethodCall { } class CheckNotNullVararg { - void checkNotNull(String msg, Object ... objects) { - } + void checkNotNull(String msg, Object... objects) {} void testCheckNotNullVaratg(@Nullable String s1, @Nullable String s2) { checkNotNull("hello", s1, s2); @@ -254,30 +245,25 @@ public class NullMethodCall { String s = null; if (whoknows()) { s = "a"; - } - else { + } else { System.exit(1); } int n = s.length(); } } - public void testMapGetBad - (Map m, - HashMap hm, - ConcurrentHashMap chm) { - m.get("foo").toString(); - hm.get("foo").toString(); - chm.get("foo").toString(); + public void testMapGetBad( + Map m, HashMap hm, ConcurrentHashMap chm) { + m.get("foo").toString(); + hm.get("foo").toString(); + chm.get("foo").toString(); } - public void testMapRemoveBad - (Map m, - HashMap hm, - ConcurrentHashMap chm) { - m.remove("foo").toString(); - hm.remove("foo").toString(); - chm.remove("foo").toString(); + public void testMapRemoveBad( + Map m, HashMap hm, ConcurrentHashMap chm) { + m.remove("foo").toString(); + hm.remove("foo").toString(); + chm.remove("foo").toString(); } @Nullable Object nullableField; @@ -300,8 +286,7 @@ public class NullMethodCall { return nullableField.toString(); } - void nullMethodCallWithAlarmManager( - AlarmManager manager, @Nullable PendingIntent intent) { + void nullMethodCallWithAlarmManager(AlarmManager manager, @Nullable PendingIntent intent) { manager.cancel(intent); } diff --git a/infer/tests/codetoanalyze/java/eradicate/ParameterNotNullable.java b/infer/tests/codetoanalyze/java/eradicate/ParameterNotNullable.java index 672070712..413614bbd 100644 --- a/infer/tests/codetoanalyze/java/eradicate/ParameterNotNullable.java +++ b/infer/tests/codetoanalyze/java/eradicate/ParameterNotNullable.java @@ -7,12 +7,10 @@ package codetoanalyze.java.eradicate; -import java.lang.System; +import android.annotation.SuppressLint; import java.net.URL; import javax.annotation.Nullable; -import android.annotation.SuppressLint; - public class ParameterNotNullable { boolean field = false; @@ -21,8 +19,7 @@ public class ParameterNotNullable { testPrimitive(field); } - void testPrimitive(boolean f) { - } + void testPrimitive(boolean f) {} void test(String s) { int n = s.length(); @@ -56,8 +53,7 @@ public class ParameterNotNullable { testN(s); } - private ParameterNotNullable(@Nullable String s) { - } + private ParameterNotNullable(@Nullable String s) {} class Builder { ParameterNotNullable getEradicateParameterNotNullable() { @@ -70,7 +66,8 @@ public class ParameterNotNullable { return s; } - @Nullable String testSystemGetenvBad() { + @Nullable + String testSystemGetenvBad() { return System.getenv(null); } @@ -78,8 +75,7 @@ public class ParameterNotNullable { return cls.getResource(null); } - void threeParameters(String s1, String s2, String s3) { - } + void threeParameters(String s1, String s2, String s3) {} void testThreeParameters() { String s = ""; @@ -89,8 +85,7 @@ public class ParameterNotNullable { } class ConstructorCall { - ConstructorCall(int x, String s) { - } + ConstructorCall(int x, String s) {} ConstructorCall() { this(3, ""); // OK diff --git a/infer/tests/codetoanalyze/java/eradicate/PresentTest.java b/infer/tests/codetoanalyze/java/eradicate/PresentTest.java index 0f673a57a..c33278344 100644 --- a/infer/tests/codetoanalyze/java/eradicate/PresentTest.java +++ b/infer/tests/codetoanalyze/java/eradicate/PresentTest.java @@ -11,17 +11,15 @@ import com.facebook.infer.annotation.Assertions; import com.facebook.infer.annotation.Present; import com.google.common.base.Optional; - public class PresentTest { - void argPresent(@Present Optional present, Optional absent) { - } + void argPresent(@Present Optional present, Optional absent) {} void testPresent(@Present Optional present, Optional absent) { - argPresent(present, absent); // OK - argPresent(present, present); // OK - argPresent(present, absent); // OK - argPresent(absent, absent); // Bad + argPresent(present, absent); // OK + argPresent(present, present); // OK + argPresent(present, absent); // OK + argPresent(absent, absent); // Bad } class TestPresentAnnotationBasic { @@ -34,20 +32,20 @@ public class PresentTest { Optional absent = Optional.absent(); @Present Optional present = Optional.of("abc"); - @Present Optional returnPresent() { + @Present + Optional returnPresent() { if (absent.isPresent()) { return absent; - } - else return Optional.of("abc"); + } else return Optional.of("abc"); } - @Present Optional returnPresentBad() { + @Present + Optional returnPresentBad() { absent.get(); // Bad: get is unsafe return absent; // Bad: should return present } - void expectPresent(@Present Optional x) { - } + void expectPresent(@Present Optional x) {} void bar() { expectPresent(present); diff --git a/infer/tests/codetoanalyze/java/eradicate/ReturnNotNullable.java b/infer/tests/codetoanalyze/java/eradicate/ReturnNotNullable.java index 7818b2989..99d4438af 100644 --- a/infer/tests/codetoanalyze/java/eradicate/ReturnNotNullable.java +++ b/infer/tests/codetoanalyze/java/eradicate/ReturnNotNullable.java @@ -8,13 +8,11 @@ package codetoanalyze.java.eradicate; import com.google.common.base.Optional; - -import java.net.URL; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; +import java.net.URL; import java.util.stream.Stream; - import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -99,8 +97,7 @@ public class ReturnNotNullable { return os.orNull(); } - class E extends Exception { - } + class E extends Exception {} String return_null_in_catch() { try { @@ -128,7 +125,7 @@ public class ReturnNotNullable { @DefinitelyNotNullable Object definitelyDoesNotReturnNull() { - return new Object(); + return new Object(); } void callsnotnullableMethod() { @@ -137,12 +134,13 @@ public class ReturnNotNullable { static class ConditionalAssignment { @Nullable Object f1; + static Object test(boolean b) { - ConditionalAssignment x = new ConditionalAssignment(); - if (b) { - x.f1 = new Object(); - } - return x.f1; // can be null + ConditionalAssignment x = new ConditionalAssignment(); + if (b) { + x.f1 = new Object(); + } + return x.f1; // can be null } } @@ -160,5 +158,4 @@ public class ReturnNotNullable { field = 0; return field; } - } diff --git a/infer/tests/codetoanalyze/java/eradicate/SuppressedFieldNotInitializedExample.java b/infer/tests/codetoanalyze/java/eradicate/SuppressedFieldNotInitializedExample.java index dbe31dd3b..301549d0e 100644 --- a/infer/tests/codetoanalyze/java/eradicate/SuppressedFieldNotInitializedExample.java +++ b/infer/tests/codetoanalyze/java/eradicate/SuppressedFieldNotInitializedExample.java @@ -7,27 +7,22 @@ package codetoanalyze.java.eradicate; +import android.annotation.SuppressLint; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import android.annotation.SuppressLint; - @Retention(RetentionPolicy.CLASS) @Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD}) -@interface SuppressFieldNotInitialized { -} +@interface SuppressFieldNotInitialized {} public class SuppressedFieldNotInitializedExample { @SuppressLint("eradicate-field-not-initialized") String iKnowBetter; - @SuppressFieldNotInitialized - String annotationSuppressed; - - SuppressedFieldNotInitializedExample() { - } + @SuppressFieldNotInitialized String annotationSuppressed; + SuppressedFieldNotInitializedExample() {} } diff --git a/infer/tests/codetoanalyze/java/eradicate/issues.exp b/infer/tests/codetoanalyze/java/eradicate/issues.exp index 28a51338e..34e37a6dd 100644 --- a/infer/tests/codetoanalyze/java/eradicate/issues.exp +++ b/infer/tests/codetoanalyze/java/eradicate/issues.exp @@ -1,9 +1,9 @@ codetoanalyze/java/eradicate/ActivityFieldNotInitialized.java, codetoanalyze.java.eradicate.ActivityFieldNotInitialized$BadActivityWithOnCreate.(codetoanalyze.java.eradicate.ActivityFieldNotInitialized), 0, ERADICATE_FIELD_NOT_INITIALIZED, no_bucket, WARNING, [Field `ActivityFieldNotInitialized$BadActivityWithOnCreate.field` is not initialized in the constructor and is not declared `@Nullable`] codetoanalyze/java/eradicate/CustomAnnotations.java, codetoanalyze.java.eradicate.CustomAnnotations$TestModeledTrueOnNull.testIsEmptyOrNullBad(java.lang.String):void, 2, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [The value of `string` in the call to `contains(...)` could be null. (Origin: method parameter string)] -codetoanalyze/java/eradicate/CustomAnnotations.java, codetoanalyze.java.eradicate.CustomAnnotations$TestPropagatesNullable.m12Bad1():void, 1, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [origin,The value of `m12(...)` in the call to `length()` could be null. (Origin: call to m12(...) at line 115)] -codetoanalyze/java/eradicate/CustomAnnotations.java, codetoanalyze.java.eradicate.CustomAnnotations$TestPropagatesNullable.m12Bad2():void, 1, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [origin,The value of `m12(...)` in the call to `length()` could be null. (Origin: call to m12(...) at line 119)] -codetoanalyze/java/eradicate/CustomAnnotations.java, codetoanalyze.java.eradicate.CustomAnnotations$TestPropagatesNullable.m2Bad():void, 1, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [origin,The value of `m2(...)` in the call to `length()` could be null. (Origin: call to m2(...) at line 102)] -codetoanalyze/java/eradicate/CustomAnnotations.java, codetoanalyze.java.eradicate.CustomAnnotations$TestPropagatesNullable.mBad():void, 1, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [origin,The value of `m(...)` in the call to `length()` could be null. (Origin: call to m(...) at line 80)] +codetoanalyze/java/eradicate/CustomAnnotations.java, codetoanalyze.java.eradicate.CustomAnnotations$TestPropagatesNullable.m12Bad1():void, 1, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [origin,The value of `m12(...)` in the call to `length()` could be null. (Origin: call to m12(...) at line 114)] +codetoanalyze/java/eradicate/CustomAnnotations.java, codetoanalyze.java.eradicate.CustomAnnotations$TestPropagatesNullable.m12Bad2():void, 1, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [origin,The value of `m12(...)` in the call to `length()` could be null. (Origin: call to m12(...) at line 118)] +codetoanalyze/java/eradicate/CustomAnnotations.java, codetoanalyze.java.eradicate.CustomAnnotations$TestPropagatesNullable.m2Bad():void, 1, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [origin,The value of `m2(...)` in the call to `length()` could be null. (Origin: call to m2(...) at line 101)] +codetoanalyze/java/eradicate/CustomAnnotations.java, codetoanalyze.java.eradicate.CustomAnnotations$TestPropagatesNullable.mBad():void, 1, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [origin,The value of `m(...)` in the call to `length()` could be null. (Origin: call to m(...) at line 79)] codetoanalyze/java/eradicate/CustomAnnotations.java, codetoanalyze.java.eradicate.CustomAnnotations$TestTextUtilsIsEmpty.myTextUtilsIsEmpty(java.lang.CharSequence):void, 2, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [The value of `s` in the call to `toString()` could be null. (Origin: method parameter s)] codetoanalyze/java/eradicate/CustomAnnotations.java, codetoanalyze.java.eradicate.CustomAnnotations$TestTextUtilsIsEmpty.myTextUtilsNotIsNotEmpty(java.lang.CharSequence):void, 2, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [The value of `s` in the call to `toString()` could be null. (Origin: method parameter s)] codetoanalyze/java/eradicate/CustomAnnotations.java, codetoanalyze.java.eradicate.CustomAnnotations$TestTextUtilsIsEmpty.textUtilsIsEmpty(java.lang.CharSequence):void, 1, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`TextUtils.isEmpty(...)` needs a non-null value in parameter 1 but argument `s` can be null. (Origin: method parameter s)] @@ -16,18 +16,18 @@ codetoanalyze/java/eradicate/FieldNotInitialized.java, codetoanalyze.java.eradic codetoanalyze/java/eradicate/FieldNotInitialized.java, codetoanalyze.java.eradicate.FieldNotInitialized$Swap.(codetoanalyze.java.eradicate.FieldNotInitialized), 0, ERADICATE_FIELD_NOT_INITIALIZED, no_bucket, WARNING, [Field `FieldNotInitialized$Swap.o1` is not initialized in the constructor and is not declared `@Nullable`] codetoanalyze/java/eradicate/FieldNotInitialized.java, codetoanalyze.java.eradicate.FieldNotInitialized$WriteItself.(codetoanalyze.java.eradicate.FieldNotInitialized), 0, ERADICATE_FIELD_NOT_INITIALIZED, no_bucket, WARNING, [Field `FieldNotInitialized$WriteItself.o` is not initialized in the constructor and is not declared `@Nullable`] codetoanalyze/java/eradicate/FieldNotInitialized.java, codetoanalyze.java.eradicate.FieldNotInitialized.(), 0, ERADICATE_FIELD_NOT_INITIALIZED, no_bucket, WARNING, [Field `FieldNotInitialized.a` is not initialized in the constructor and is not declared `@Nullable`] -codetoanalyze/java/eradicate/FieldNotNullable.java, codetoanalyze.java.eradicate.FieldNotNullable.(java.lang.Integer), -25, ERADICATE_FIELD_NOT_NULLABLE, no_bucket, WARNING, [origin,Field `FieldNotNullable.static_s` can be null but is not declared `@Nullable`. (Origin: null constant at line 47)] -codetoanalyze/java/eradicate/FieldNotNullable.java, codetoanalyze.java.eradicate.FieldNotNullable.(java.lang.String), -2, ERADICATE_FIELD_NOT_NULLABLE, no_bucket, WARNING, [origin,Field `FieldNotNullable.static_s` can be null but is not declared `@Nullable`. (Origin: null constant at line 47)] -codetoanalyze/java/eradicate/FieldNotNullable.java, codetoanalyze.java.eradicate.FieldNotNullable.setYNull():void, 1, ERADICATE_FIELD_NOT_NULLABLE, no_bucket, WARNING, [origin,Field `FieldNotNullable.y` can be null but is not declared `@Nullable`. (Origin: null constant at line 65)] +codetoanalyze/java/eradicate/FieldNotNullable.java, codetoanalyze.java.eradicate.FieldNotNullable.(java.lang.Integer), -25, ERADICATE_FIELD_NOT_NULLABLE, no_bucket, WARNING, [origin,Field `FieldNotNullable.static_s` can be null but is not declared `@Nullable`. (Origin: null constant at line 43)] +codetoanalyze/java/eradicate/FieldNotNullable.java, codetoanalyze.java.eradicate.FieldNotNullable.(java.lang.String), -2, ERADICATE_FIELD_NOT_NULLABLE, no_bucket, WARNING, [origin,Field `FieldNotNullable.static_s` can be null but is not declared `@Nullable`. (Origin: null constant at line 43)] +codetoanalyze/java/eradicate/FieldNotNullable.java, codetoanalyze.java.eradicate.FieldNotNullable.setYNull():void, 1, ERADICATE_FIELD_NOT_NULLABLE, no_bucket, WARNING, [origin,Field `FieldNotNullable.y` can be null but is not declared `@Nullable`. (Origin: null constant at line 61)] codetoanalyze/java/eradicate/FieldNotNullable.java, codetoanalyze.java.eradicate.FieldNotNullable.setYNullable(java.lang.String):void, 1, ERADICATE_FIELD_NOT_NULLABLE, no_bucket, WARNING, [Field `FieldNotNullable.y` can be null but is not declared `@Nullable`. (Origin: method parameter s)] codetoanalyze/java/eradicate/FieldNotNullable.java, codetoanalyze.java.eradicate.FragmentExample.(), 0, ERADICATE_FIELD_NOT_INITIALIZED, no_bucket, WARNING, [Field `FragmentExample.view` is not initialized in the constructor and is not declared `@Nullable`] -codetoanalyze/java/eradicate/FieldNotNullable.java, codetoanalyze.java.eradicate.NestedFieldAccess$TestFunctionsIdempotent.FlatBAD1(codetoanalyze.java.eradicate.NestedFieldAccess$TestFunctionsIdempotent):void, 2, ERADICATE_FIELD_NOT_NULLABLE, no_bucket, WARNING, [origin,Field `NestedFieldAccess$TestFunctionsIdempotent.dontAssignNull` can be null but is not declared `@Nullable`. (Origin: call to getS(...) at line 261)] -codetoanalyze/java/eradicate/FieldNotNullable.java, codetoanalyze.java.eradicate.NestedFieldAccess$TestFunctionsIdempotent.FlatBAD2(codetoanalyze.java.eradicate.NestedFieldAccess$TestFunctionsIdempotent):void, 2, ERADICATE_FIELD_NOT_NULLABLE, no_bucket, WARNING, [origin,Field `NestedFieldAccess$TestFunctionsIdempotent.dontAssignNull` can be null but is not declared `@Nullable`. (Origin: call to getS(...) at line 267)] -codetoanalyze/java/eradicate/FieldNotNullable.java, codetoanalyze.java.eradicate.NestedFieldAccess$TestFunctionsIdempotent.NestedBAD1():void, 2, ERADICATE_FIELD_NOT_NULLABLE, no_bucket, WARNING, [origin,Field `NestedFieldAccess$TestFunctionsIdempotent.dontAssignNull` can be null but is not declared `@Nullable`. (Origin: call to getS(...) at line 285)] -codetoanalyze/java/eradicate/FieldNotNullable.java, codetoanalyze.java.eradicate.NestedFieldAccess$TestFunctionsIdempotent.NestedBAD2():void, 2, ERADICATE_FIELD_NOT_NULLABLE, no_bucket, WARNING, [origin,Field `NestedFieldAccess$TestFunctionsIdempotent.dontAssignNull` can be null but is not declared `@Nullable`. (Origin: call to getS(...) at line 291)] -codetoanalyze/java/eradicate/FieldNotNullable.java, codetoanalyze.java.eradicate.NestedFieldAccess$TestFunctionsIdempotent.NestedBAD3():void, 2, ERADICATE_FIELD_NOT_NULLABLE, no_bucket, WARNING, [origin,Field `NestedFieldAccess$TestFunctionsIdempotent.dontAssignNull` can be null but is not declared `@Nullable`. (Origin: call to getS(...) at line 297)] -codetoanalyze/java/eradicate/FieldNotNullable.java, codetoanalyze.java.eradicate.NestedFieldAccess$TestPut.putNull(java.util.Map,java.lang.String):void, 2, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [origin,`Map.put(...)` needs a non-null value in parameter 2 but argument `null` can be null. (Origin: null constant at line 335)] -codetoanalyze/java/eradicate/FieldNotNullable.java, codetoanalyze.java.eradicate.NestedFieldAccess$TestPut.putNull(java.util.Map,java.lang.String):void, 3, ERADICATE_FIELD_NOT_NULLABLE, no_bucket, WARNING, [origin,Field `NestedFieldAccess$TestPut.dontAssignNull` can be null but is not declared `@Nullable`. (Origin: null constant at line 335)] +codetoanalyze/java/eradicate/FieldNotNullable.java, codetoanalyze.java.eradicate.NestedFieldAccess$TestFunctionsIdempotent.FlatBAD1(codetoanalyze.java.eradicate.NestedFieldAccess$TestFunctionsIdempotent):void, 2, ERADICATE_FIELD_NOT_NULLABLE, no_bucket, WARNING, [origin,Field `NestedFieldAccess$TestFunctionsIdempotent.dontAssignNull` can be null but is not declared `@Nullable`. (Origin: call to getS(...) at line 250)] +codetoanalyze/java/eradicate/FieldNotNullable.java, codetoanalyze.java.eradicate.NestedFieldAccess$TestFunctionsIdempotent.FlatBAD2(codetoanalyze.java.eradicate.NestedFieldAccess$TestFunctionsIdempotent):void, 2, ERADICATE_FIELD_NOT_NULLABLE, no_bucket, WARNING, [origin,Field `NestedFieldAccess$TestFunctionsIdempotent.dontAssignNull` can be null but is not declared `@Nullable`. (Origin: call to getS(...) at line 256)] +codetoanalyze/java/eradicate/FieldNotNullable.java, codetoanalyze.java.eradicate.NestedFieldAccess$TestFunctionsIdempotent.NestedBAD1():void, 2, ERADICATE_FIELD_NOT_NULLABLE, no_bucket, WARNING, [origin,Field `NestedFieldAccess$TestFunctionsIdempotent.dontAssignNull` can be null but is not declared `@Nullable`. (Origin: call to getS(...) at line 274)] +codetoanalyze/java/eradicate/FieldNotNullable.java, codetoanalyze.java.eradicate.NestedFieldAccess$TestFunctionsIdempotent.NestedBAD2():void, 2, ERADICATE_FIELD_NOT_NULLABLE, no_bucket, WARNING, [origin,Field `NestedFieldAccess$TestFunctionsIdempotent.dontAssignNull` can be null but is not declared `@Nullable`. (Origin: call to getS(...) at line 280)] +codetoanalyze/java/eradicate/FieldNotNullable.java, codetoanalyze.java.eradicate.NestedFieldAccess$TestFunctionsIdempotent.NestedBAD3():void, 2, ERADICATE_FIELD_NOT_NULLABLE, no_bucket, WARNING, [origin,Field `NestedFieldAccess$TestFunctionsIdempotent.dontAssignNull` can be null but is not declared `@Nullable`. (Origin: call to getS(...) at line 286)] +codetoanalyze/java/eradicate/FieldNotNullable.java, codetoanalyze.java.eradicate.NestedFieldAccess$TestPut.putNull(java.util.Map,java.lang.String):void, 2, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [origin,`Map.put(...)` needs a non-null value in parameter 2 but argument `null` can be null. (Origin: null constant at line 324)] +codetoanalyze/java/eradicate/FieldNotNullable.java, codetoanalyze.java.eradicate.NestedFieldAccess$TestPut.putNull(java.util.Map,java.lang.String):void, 3, ERADICATE_FIELD_NOT_NULLABLE, no_bucket, WARNING, [origin,Field `NestedFieldAccess$TestPut.dontAssignNull` can be null but is not declared `@Nullable`. (Origin: null constant at line 324)] codetoanalyze/java/eradicate/FieldNotNullable.java, codetoanalyze.java.eradicate.TestInitializerBuilder.build():codetoanalyze.java.eradicate.TestInitializer, 2, ERADICATE_CONDITION_REDUNDANT, no_bucket, WARNING, [The condition TestInitializerBuilder.required1 is always true according to the existing annotations.] codetoanalyze/java/eradicate/FieldNotNullable.java, codetoanalyze.java.eradicate.TestInitializerBuilder.build():codetoanalyze.java.eradicate.TestInitializer, 2, ERADICATE_CONDITION_REDUNDANT, no_bucket, WARNING, [The condition TestInitializerBuilder.required2 is always true according to the existing annotations.] codetoanalyze/java/eradicate/InconsistentSubclassAnnotation.java, codetoanalyze.java.eradicate.ExtendsExternalLibrary.externalMethod2(java.lang.Object):void, 0, ERADICATE_INCONSISTENT_SUBCLASS_PARAMETER_ANNOTATION, no_bucket, WARNING, [First parameter `object` of method `ExtendsExternalLibrary.externalMethod2(...)` is not `@Nullable` but is declared `@Nullable`in the parent class method `SomeExternalClass.externalMethod2(...)`.] @@ -40,51 +40,51 @@ codetoanalyze/java/eradicate/LibraryCalls.java, codetoanalyze.java.eradicate.Lib codetoanalyze/java/eradicate/LibraryCalls.java, codetoanalyze.java.eradicate.LibraryCalls.badReferenceDereference(java.lang.ref.Reference):java.lang.String, 1, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [origin,The value of `ref.get()` in the call to `toString()` could be null. (Origin: call to get() modelled in modelTables.ml at line 19)] codetoanalyze/java/eradicate/LibraryCalls.java, codetoanalyze.java.eradicate.LibraryCalls.badSoftReferenceDereference(java.lang.ref.SoftReference):java.lang.String, 1, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [origin,The value of `ref.get()` in the call to `toString()` could be null. (Origin: call to get() modelled in modelTables.ml at line 31)] codetoanalyze/java/eradicate/LibraryCalls.java, codetoanalyze.java.eradicate.LibraryCalls.badWeakReferenceDereference(java.lang.ref.WeakReference):java.lang.String, 1, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [origin,The value of `ref.get()` in the call to `toString()` could be null. (Origin: call to get() modelled in modelTables.ml at line 23)] -codetoanalyze/java/eradicate/NullFieldAccess.java, codetoanalyze.java.eradicate.NullFieldAccess.arrayAccess():java.lang.Object, 1, ERADICATE_NULL_FIELD_ACCESS, no_bucket, WARNING, [origin,Object `NullFieldAccess.objects` could be null when accessing element at index `0`. (Origin: field NullFieldAccess.objects at line 61)] -codetoanalyze/java/eradicate/NullFieldAccess.java, codetoanalyze.java.eradicate.NullFieldAccess.arrayLength():int, 1, ERADICATE_NULL_FIELD_ACCESS, no_bucket, WARNING, [origin,Object `NullFieldAccess.objects` could be null when accessing field `length`. (Origin: field NullFieldAccess.objects at line 57)] -codetoanalyze/java/eradicate/NullFieldAccess.java, codetoanalyze.java.eradicate.NullFieldAccess.useInterface(codetoanalyze.java.eradicate.NullFieldAccess$I):int, 2, ERADICATE_NULL_FIELD_ACCESS, no_bucket, WARNING, [origin,Object `c` could be null when accessing field `NullFieldAccess$C.n`. (Origin: field NullFieldAccess$I.c at line 50)] -codetoanalyze/java/eradicate/NullFieldAccess.java, codetoanalyze.java.eradicate.NullFieldAccess.useX():int, 2, ERADICATE_NULL_FIELD_ACCESS, no_bucket, WARNING, [origin,Object `c` could be null when accessing field `NullFieldAccess$C.n`. (Origin: field NullFieldAccess.x at line 35)] -codetoanalyze/java/eradicate/NullFieldAccess.java, codetoanalyze.java.eradicate.NullFieldAccess.useZ():int, 2, ERADICATE_NULL_FIELD_ACCESS, no_bucket, WARNING, [origin,Object `c` could be null when accessing field `NullFieldAccess$C.n`. (Origin: field NullFieldAccess.z at line 45)] -codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.NullMethodCall$Inner.outerField():int, 2, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [origin,The value of `s` in the call to `length()` could be null. (Origin: field NullMethodCall.fld at line 74)] -codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.NullMethodCall$Inner.outerPrivateField():int, 2, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [origin,The value of `s` in the call to `length()` could be null. (Origin: field NullMethodCall.pfld at line 85)] -codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.NullMethodCall.FP_propagatesNonNullAfterComparisonFieldOkay(java.lang.Object):void, 2, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [origin,The value of `NullMethodCall.nullableField` in the call to `toString()` could be null. (Origin: field NullMethodCall.nullableField at line 286)] +codetoanalyze/java/eradicate/NullFieldAccess.java, codetoanalyze.java.eradicate.NullFieldAccess.arrayAccess():java.lang.Object, 1, ERADICATE_NULL_FIELD_ACCESS, no_bucket, WARNING, [origin,Object `NullFieldAccess.objects` could be null when accessing element at index `0`. (Origin: field NullFieldAccess.objects at line 56)] +codetoanalyze/java/eradicate/NullFieldAccess.java, codetoanalyze.java.eradicate.NullFieldAccess.arrayLength():int, 1, ERADICATE_NULL_FIELD_ACCESS, no_bucket, WARNING, [origin,Object `NullFieldAccess.objects` could be null when accessing field `length`. (Origin: field NullFieldAccess.objects at line 52)] +codetoanalyze/java/eradicate/NullFieldAccess.java, codetoanalyze.java.eradicate.NullFieldAccess.useInterface(codetoanalyze.java.eradicate.NullFieldAccess$I):int, 2, ERADICATE_NULL_FIELD_ACCESS, no_bucket, WARNING, [origin,Object `c` could be null when accessing field `NullFieldAccess$C.n`. (Origin: field NullFieldAccess$I.c at line 45)] +codetoanalyze/java/eradicate/NullFieldAccess.java, codetoanalyze.java.eradicate.NullFieldAccess.useX():int, 2, ERADICATE_NULL_FIELD_ACCESS, no_bucket, WARNING, [origin,Object `c` could be null when accessing field `NullFieldAccess$C.n`. (Origin: field NullFieldAccess.x at line 30)] +codetoanalyze/java/eradicate/NullFieldAccess.java, codetoanalyze.java.eradicate.NullFieldAccess.useZ():int, 2, ERADICATE_NULL_FIELD_ACCESS, no_bucket, WARNING, [origin,Object `c` could be null when accessing field `NullFieldAccess$C.n`. (Origin: field NullFieldAccess.z at line 40)] +codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.NullMethodCall$Inner.outerField():int, 2, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [origin,The value of `s` in the call to `length()` could be null. (Origin: field NullMethodCall.fld at line 66)] +codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.NullMethodCall$Inner.outerPrivateField():int, 2, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [origin,The value of `s` in the call to `length()` could be null. (Origin: field NullMethodCall.pfld at line 77)] +codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.NullMethodCall.FP_propagatesNonNullAfterComparisonFieldOkay(java.lang.Object):void, 2, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [origin,The value of `NullMethodCall.nullableField` in the call to `toString()` could be null. (Origin: field NullMethodCall.nullableField at line 272)] codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.NullMethodCall.FP_propagatesNonNullAfterComparisonParameterOkay(java.lang.Object,java.lang.Object):void, 3, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [The value of `nullableParameter` in the call to `toString()` could be null. (Origin: method parameter nullableParameter)] -codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.NullMethodCall.callOnNull():void, 2, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [origin,The value of `s` in the call to `length()` could be null. (Origin: null constant at line 25)] -codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.NullMethodCall.callingSeverSideNullableGetter(codetoanalyze.java.eradicate.ServerSideDeserializer):java.lang.String, 1, ERADICATE_NULL_METHOD_CALL, no_bucket, ERROR, [origin,The value of `deserializer.nullableGetter()` in the call to `toString()` could be null. (Origin: call to nullableGetter() at line 309)] -codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.NullMethodCall.nullMethodCallWithAlarmManager(android.app.AlarmManager,android.app.PendingIntent):void, 2, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`AlarmManager.cancel(...)` needs a non-null value in parameter 1 but argument `intent` can be null. (Origin: method parameter intent)] -codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.NullMethodCall.testExceptionPerInstruction(int):void, 6, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [origin,The value of `s` in the call to `length()` could be null. (Origin: null constant at line 186)] -codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.NullMethodCall.testFieldAssignmentIfThenElse(java.lang.String):void, 2, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [origin,The value of `s` in the call to `length()` could be null. (Origin: null constant at line 177)] -codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.NullMethodCall.testMapGetBad(java.util.Map,java.util.HashMap,java.util.concurrent.ConcurrentHashMap):void, 4, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [origin,The value of `m.get(...)` in the call to `toString()` could be null. (Origin: call to get(...) modelled in modelTables.ml at line 269)] -codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.NullMethodCall.testMapGetBad(java.util.Map,java.util.HashMap,java.util.concurrent.ConcurrentHashMap):void, 5, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [origin,The value of `hm.get(...)` in the call to `toString()` could be null. (Origin: call to get(...) modelled in modelTables.ml at line 270)] -codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.NullMethodCall.testMapGetBad(java.util.Map,java.util.HashMap,java.util.concurrent.ConcurrentHashMap):void, 6, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [origin,The value of `chm.get(...)` in the call to `toString()` could be null. (Origin: call to get(...) modelled in modelTables.ml at line 271)] -codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.NullMethodCall.testMapRemoveBad(java.util.Map,java.util.HashMap,java.util.concurrent.ConcurrentHashMap):void, 4, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [origin,The value of `m.remove(...)` in the call to `toString()` could be null. (Origin: call to remove(...) modelled in modelTables.ml at line 278)] -codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.NullMethodCall.testMapRemoveBad(java.util.Map,java.util.HashMap,java.util.concurrent.ConcurrentHashMap):void, 5, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [origin,The value of `hm.remove(...)` in the call to `toString()` could be null. (Origin: call to remove(...) modelled in modelTables.ml at line 279)] -codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.NullMethodCall.testMapRemoveBad(java.util.Map,java.util.HashMap,java.util.concurrent.ConcurrentHashMap):void, 6, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [origin,The value of `chm.remove(...)` in the call to `toString()` could be null. (Origin: call to remove(...) modelled in modelTables.ml at line 280)] -codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.NullMethodCall.testSystemGetPropertyReturn():void, 2, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [origin,The value of `s` in the call to `length()` could be null. (Origin: call to getProperty(...) modelled in modelTables.ml at line 241)] -codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.NullMethodCall.testSystemGetenvBad():int, 2, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [origin,The value of `envValue` in the call to `length()` could be null. (Origin: call to getenv(...) modelled in modelTables.ml at line 246)] -codetoanalyze/java/eradicate/ParameterNotNullable.java, codetoanalyze.java.eradicate.ParameterNotNullable$ConstructorCall.(codetoanalyze.java.eradicate.ParameterNotNullable,int), 1, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [origin,`ParameterNotNullable$ConstructorCall(...)` needs a non-null value in parameter 2 but argument `null` can be null. (Origin: null constant at line 100)] -codetoanalyze/java/eradicate/ParameterNotNullable.java, codetoanalyze.java.eradicate.ParameterNotNullable.callNull():void, 2, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [origin,`ParameterNotNullable.test(...)` needs a non-null value in parameter 1 but argument `s` can be null. (Origin: null constant at line 36)] +codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.NullMethodCall.callOnNull():void, 2, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [origin,The value of `s` in the call to `length()` could be null. (Origin: null constant at line 22)] +codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.NullMethodCall.callingSeverSideNullableGetter(codetoanalyze.java.eradicate.ServerSideDeserializer):java.lang.String, 1, ERADICATE_NULL_METHOD_CALL, no_bucket, ERROR, [origin,The value of `deserializer.nullableGetter()` in the call to `toString()` could be null. (Origin: call to nullableGetter() at line 294)] +codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.NullMethodCall.nullMethodCallWithAlarmManager(android.app.AlarmManager,android.app.PendingIntent):void, 1, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`AlarmManager.cancel(...)` needs a non-null value in parameter 1 but argument `intent` can be null. (Origin: method parameter intent)] +codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.NullMethodCall.testExceptionPerInstruction(int):void, 6, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [origin,The value of `s` in the call to `length()` could be null. (Origin: null constant at line 178)] +codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.NullMethodCall.testFieldAssignmentIfThenElse(java.lang.String):void, 2, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [origin,The value of `s` in the call to `length()` could be null. (Origin: null constant at line 169)] +codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.NullMethodCall.testMapGetBad(java.util.Map,java.util.HashMap,java.util.concurrent.ConcurrentHashMap):void, 2, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [origin,The value of `m.get(...)` in the call to `toString()` could be null. (Origin: call to get(...) modelled in modelTables.ml at line 257)] +codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.NullMethodCall.testMapGetBad(java.util.Map,java.util.HashMap,java.util.concurrent.ConcurrentHashMap):void, 3, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [origin,The value of `hm.get(...)` in the call to `toString()` could be null. (Origin: call to get(...) modelled in modelTables.ml at line 258)] +codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.NullMethodCall.testMapGetBad(java.util.Map,java.util.HashMap,java.util.concurrent.ConcurrentHashMap):void, 4, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [origin,The value of `chm.get(...)` in the call to `toString()` could be null. (Origin: call to get(...) modelled in modelTables.ml at line 259)] +codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.NullMethodCall.testMapRemoveBad(java.util.Map,java.util.HashMap,java.util.concurrent.ConcurrentHashMap):void, 2, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [origin,The value of `m.remove(...)` in the call to `toString()` could be null. (Origin: call to remove(...) modelled in modelTables.ml at line 264)] +codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.NullMethodCall.testMapRemoveBad(java.util.Map,java.util.HashMap,java.util.concurrent.ConcurrentHashMap):void, 3, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [origin,The value of `hm.remove(...)` in the call to `toString()` could be null. (Origin: call to remove(...) modelled in modelTables.ml at line 265)] +codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.NullMethodCall.testMapRemoveBad(java.util.Map,java.util.HashMap,java.util.concurrent.ConcurrentHashMap):void, 4, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [origin,The value of `chm.remove(...)` in the call to `toString()` could be null. (Origin: call to remove(...) modelled in modelTables.ml at line 266)] +codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.NullMethodCall.testSystemGetPropertyReturn():void, 2, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [origin,The value of `s` in the call to `length()` could be null. (Origin: call to getProperty(...) modelled in modelTables.ml at line 232)] +codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.NullMethodCall.testSystemGetenvBad():int, 2, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [origin,The value of `envValue` in the call to `length()` could be null. (Origin: call to getenv(...) modelled in modelTables.ml at line 237)] +codetoanalyze/java/eradicate/ParameterNotNullable.java, codetoanalyze.java.eradicate.ParameterNotNullable$ConstructorCall.(codetoanalyze.java.eradicate.ParameterNotNullable,int), 1, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [origin,`ParameterNotNullable$ConstructorCall(...)` needs a non-null value in parameter 2 but argument `null` can be null. (Origin: null constant at line 95)] +codetoanalyze/java/eradicate/ParameterNotNullable.java, codetoanalyze.java.eradicate.ParameterNotNullable.callNull():void, 2, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [origin,`ParameterNotNullable.test(...)` needs a non-null value in parameter 1 but argument `s` can be null. (Origin: null constant at line 33)] codetoanalyze/java/eradicate/ParameterNotNullable.java, codetoanalyze.java.eradicate.ParameterNotNullable.callNullable(java.lang.String):void, 1, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`ParameterNotNullable.test(...)` needs a non-null value in parameter 1 but argument `s` can be null. (Origin: method parameter s)] -codetoanalyze/java/eradicate/ParameterNotNullable.java, codetoanalyze.java.eradicate.ParameterNotNullable.indirectSignatureLookup_FP(codetoanalyze.java.eradicate.SomeClass):void, 1, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [origin,`SomeClass.acceptsNullableParameter(...)` needs a non-null value in parameter 1 but argument `null` can be null. (Origin: null constant at line 105)] -codetoanalyze/java/eradicate/ParameterNotNullable.java, codetoanalyze.java.eradicate.ParameterNotNullable.testClassGetResourceArgument(java.lang.Class):java.net.URL, 1, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [origin,`Class.getResource(...)` needs a non-null value in parameter 1 but argument `null` can be null. (Origin: null constant at line 78)] -codetoanalyze/java/eradicate/ParameterNotNullable.java, codetoanalyze.java.eradicate.ParameterNotNullable.testSystemGetPropertyArgument():java.lang.String, 1, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [origin,`System.getProperty(...)` needs a non-null value in parameter 1 but argument `null` can be null. (Origin: null constant at line 69)] -codetoanalyze/java/eradicate/ParameterNotNullable.java, codetoanalyze.java.eradicate.ParameterNotNullable.testSystemGetenvBad():java.lang.String, 1, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [origin,`System.getenv(...)` needs a non-null value in parameter 1 but argument `null` can be null. (Origin: null constant at line 74)] -codetoanalyze/java/eradicate/ParameterNotNullable.java, codetoanalyze.java.eradicate.ParameterNotNullable.testThreeParameters():void, 2, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [origin,`ParameterNotNullable.threeParameters(...)` needs a non-null value in parameter 1 but argument `null` can be null. (Origin: null constant at line 86)] -codetoanalyze/java/eradicate/ParameterNotNullable.java, codetoanalyze.java.eradicate.ParameterNotNullable.testThreeParameters():void, 3, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [origin,`ParameterNotNullable.threeParameters(...)` needs a non-null value in parameter 2 but argument `null` can be null. (Origin: null constant at line 87)] -codetoanalyze/java/eradicate/ParameterNotNullable.java, codetoanalyze.java.eradicate.ParameterNotNullable.testThreeParameters():void, 4, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [origin,`ParameterNotNullable.threeParameters(...)` needs a non-null value in parameter 3 but argument `null` can be null. (Origin: null constant at line 88)] -codetoanalyze/java/eradicate/PresentTest.java, codetoanalyze.java.eradicate.PresentTest$TestPresentAnnotationBasic.returnPresentBad():com.google.common.base.Optional, 0, ERADICATE_RETURN_VALUE_NOT_PRESENT, no_bucket, WARNING, [origin,Method `returnPresentBad()` may return an absent value but it is annotated with `@Present`. (Origin: field PresentTest$TestPresentAnnotationBasic.absent at line 45)] -codetoanalyze/java/eradicate/PresentTest.java, codetoanalyze.java.eradicate.PresentTest$TestPresentAnnotationBasic.returnPresentBad():com.google.common.base.Optional, 1, ERADICATE_VALUE_NOT_PRESENT, no_bucket, WARNING, [origin,The value of `PresentTest$TestPresentAnnotationBasic.absent` in the call to `get()` is not `@Present`. (Origin: field PresentTest$TestPresentAnnotationBasic.absent at line 45)] -codetoanalyze/java/eradicate/PresentTest.java, codetoanalyze.java.eradicate.PresentTest$TestPresentAnnotationBasic.testOptionalAbsent():void, 1, ERADICATE_PARAMETER_VALUE_ABSENT, no_bucket, WARNING, [origin,`PresentTest$TestPresentAnnotationBasic.expectPresent(...)` needs a present value in parameter 1 but argument `absent()` can be absent. (Origin: call to absent() at line 63)] +codetoanalyze/java/eradicate/ParameterNotNullable.java, codetoanalyze.java.eradicate.ParameterNotNullable.indirectSignatureLookup_FP(codetoanalyze.java.eradicate.SomeClass):void, 1, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [origin,`SomeClass.acceptsNullableParameter(...)` needs a non-null value in parameter 1 but argument `null` can be null. (Origin: null constant at line 100)] +codetoanalyze/java/eradicate/ParameterNotNullable.java, codetoanalyze.java.eradicate.ParameterNotNullable.testClassGetResourceArgument(java.lang.Class):java.net.URL, 1, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [origin,`Class.getResource(...)` needs a non-null value in parameter 1 but argument `null` can be null. (Origin: null constant at line 75)] +codetoanalyze/java/eradicate/ParameterNotNullable.java, codetoanalyze.java.eradicate.ParameterNotNullable.testSystemGetPropertyArgument():java.lang.String, 1, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [origin,`System.getProperty(...)` needs a non-null value in parameter 1 but argument `null` can be null. (Origin: null constant at line 65)] +codetoanalyze/java/eradicate/ParameterNotNullable.java, codetoanalyze.java.eradicate.ParameterNotNullable.testSystemGetenvBad():java.lang.String, 1, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [origin,`System.getenv(...)` needs a non-null value in parameter 1 but argument `null` can be null. (Origin: null constant at line 71)] +codetoanalyze/java/eradicate/ParameterNotNullable.java, codetoanalyze.java.eradicate.ParameterNotNullable.testThreeParameters():void, 2, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [origin,`ParameterNotNullable.threeParameters(...)` needs a non-null value in parameter 1 but argument `null` can be null. (Origin: null constant at line 82)] +codetoanalyze/java/eradicate/ParameterNotNullable.java, codetoanalyze.java.eradicate.ParameterNotNullable.testThreeParameters():void, 3, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [origin,`ParameterNotNullable.threeParameters(...)` needs a non-null value in parameter 2 but argument `null` can be null. (Origin: null constant at line 83)] +codetoanalyze/java/eradicate/ParameterNotNullable.java, codetoanalyze.java.eradicate.ParameterNotNullable.testThreeParameters():void, 4, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [origin,`ParameterNotNullable.threeParameters(...)` needs a non-null value in parameter 3 but argument `null` can be null. (Origin: null constant at line 84)] +codetoanalyze/java/eradicate/PresentTest.java, codetoanalyze.java.eradicate.PresentTest$TestPresentAnnotationBasic.returnPresentBad():com.google.common.base.Optional, 0, ERADICATE_RETURN_VALUE_NOT_PRESENT, no_bucket, WARNING, [origin,Method `returnPresentBad()` may return an absent value but it is annotated with `@Present`. (Origin: field PresentTest$TestPresentAnnotationBasic.absent at line 44)] +codetoanalyze/java/eradicate/PresentTest.java, codetoanalyze.java.eradicate.PresentTest$TestPresentAnnotationBasic.returnPresentBad():com.google.common.base.Optional, 1, ERADICATE_VALUE_NOT_PRESENT, no_bucket, WARNING, [origin,The value of `PresentTest$TestPresentAnnotationBasic.absent` in the call to `get()` is not `@Present`. (Origin: field PresentTest$TestPresentAnnotationBasic.absent at line 44)] +codetoanalyze/java/eradicate/PresentTest.java, codetoanalyze.java.eradicate.PresentTest$TestPresentAnnotationBasic.testOptionalAbsent():void, 1, ERADICATE_PARAMETER_VALUE_ABSENT, no_bucket, WARNING, [origin,`PresentTest$TestPresentAnnotationBasic.expectPresent(...)` needs a present value in parameter 1 but argument `absent()` can be absent. (Origin: call to absent() at line 61)] codetoanalyze/java/eradicate/PresentTest.java, codetoanalyze.java.eradicate.PresentTest.testPresent(com.google.common.base.Optional,com.google.common.base.Optional):void, 4, ERADICATE_PARAMETER_VALUE_ABSENT, no_bucket, WARNING, [`PresentTest.argPresent(...)` needs a present value in parameter 1 but argument `absent` can be absent. (Origin: method parameter absent)] codetoanalyze/java/eradicate/Redundant.java, Redundant.bad():void, 2, ERADICATE_CONDITION_REDUNDANT, no_bucket, WARNING, [The condition s is always true according to the existing annotations.] -codetoanalyze/java/eradicate/ReturnNotNullable.java, codetoanalyze.java.eradicate.ReturnNotNullable$ConditionalAssignment.test(boolean):java.lang.Object, 0, ERADICATE_RETURN_NOT_NULLABLE, no_bucket, WARNING, [origin,Method `test(...)` may return null but it is not annotated with `@Nullable`. (Origin: field ReturnNotNullable$ConditionalAssignment.f1 at line 145)] -codetoanalyze/java/eradicate/ReturnNotNullable.java, codetoanalyze.java.eradicate.ReturnNotNullable.getResourceNullable(java.lang.Class,java.lang.String):java.net.URL, 0, ERADICATE_RETURN_NOT_NULLABLE, no_bucket, WARNING, [origin,Method `getResourceNullable(...)` may return null but it is not annotated with `@Nullable`. (Origin: call to getResource(...) modelled in modelTables.ml at line 126)] +codetoanalyze/java/eradicate/ReturnNotNullable.java, codetoanalyze.java.eradicate.ReturnNotNullable$ConditionalAssignment.test(boolean):java.lang.Object, 0, ERADICATE_RETURN_NOT_NULLABLE, no_bucket, WARNING, [origin,Method `test(...)` may return null but it is not annotated with `@Nullable`. (Origin: field ReturnNotNullable$ConditionalAssignment.f1 at line 143)] +codetoanalyze/java/eradicate/ReturnNotNullable.java, codetoanalyze.java.eradicate.ReturnNotNullable.getResourceNullable(java.lang.Class,java.lang.String):java.net.URL, 0, ERADICATE_RETURN_NOT_NULLABLE, no_bucket, WARNING, [origin,Method `getResourceNullable(...)` may return null but it is not annotated with `@Nullable`. (Origin: call to getResource(...) modelled in modelTables.ml at line 123)] codetoanalyze/java/eradicate/ReturnNotNullable.java, codetoanalyze.java.eradicate.ReturnNotNullable.redundantEq():java.lang.String, 0, ERADICATE_RETURN_OVER_ANNOTATED, no_bucket, WARNING, [Method `redundantEq()` is annotated with `@Nullable` but never returns null.] codetoanalyze/java/eradicate/ReturnNotNullable.java, codetoanalyze.java.eradicate.ReturnNotNullable.redundantEq():java.lang.String, 2, ERADICATE_CONDITION_REDUNDANT_NONNULL, no_bucket, WARNING, [The condition s is always false according to the existing annotations.] codetoanalyze/java/eradicate/ReturnNotNullable.java, codetoanalyze.java.eradicate.ReturnNotNullable.redundantNeq():java.lang.String, 0, ERADICATE_RETURN_OVER_ANNOTATED, no_bucket, WARNING, [Method `redundantNeq()` is annotated with `@Nullable` but never returns null.] codetoanalyze/java/eradicate/ReturnNotNullable.java, codetoanalyze.java.eradicate.ReturnNotNullable.redundantNeq():java.lang.String, 2, ERADICATE_CONDITION_REDUNDANT_NONNULL, no_bucket, WARNING, [The condition s is always true according to the existing annotations.] -codetoanalyze/java/eradicate/ReturnNotNullable.java, codetoanalyze.java.eradicate.ReturnNotNullable.returnNull():java.lang.String, 0, ERADICATE_RETURN_NOT_NULLABLE, no_bucket, WARNING, [origin,Method `returnNull()` may return null but it is not annotated with `@Nullable`. (Origin: null constant at line 33)] +codetoanalyze/java/eradicate/ReturnNotNullable.java, codetoanalyze.java.eradicate.ReturnNotNullable.returnNull():java.lang.String, 0, ERADICATE_RETURN_NOT_NULLABLE, no_bucket, WARNING, [origin,Method `returnNull()` may return null but it is not annotated with `@Nullable`. (Origin: null constant at line 31)] codetoanalyze/java/eradicate/ReturnNotNullable.java, codetoanalyze.java.eradicate.ReturnNotNullable.returnNullable(java.lang.String):java.lang.String, 0, ERADICATE_RETURN_NOT_NULLABLE, no_bucket, WARNING, [Method `returnNullable(...)` may return null but it is not annotated with `@Nullable`. (Origin: method parameter s)] -codetoanalyze/java/eradicate/ReturnNotNullable.java, codetoanalyze.java.eradicate.ReturnNotNullable.return_null_in_catch():java.lang.String, 0, ERADICATE_RETURN_NOT_NULLABLE, no_bucket, WARNING, [origin,Method `return_null_in_catch()` may return null but it is not annotated with `@Nullable`. (Origin: null constant at line 109)] -codetoanalyze/java/eradicate/ReturnNotNullable.java, codetoanalyze.java.eradicate.ReturnNotNullable.return_null_in_catch_after_throw():java.lang.String, 0, ERADICATE_RETURN_NOT_NULLABLE, no_bucket, WARNING, [origin,Method `return_null_in_catch_after_throw()` may return null but it is not annotated with `@Nullable`. (Origin: null constant at line 121)] -codetoanalyze/java/eradicate/ReturnNotNullable.java, codetoanalyze.java.eradicate.ReturnNotNullable.tryWithResourcesReturnNullable(java.lang.String):java.lang.Object, 0, ERADICATE_RETURN_NOT_NULLABLE, no_bucket, WARNING, [origin,Method `tryWithResourcesReturnNullable(...)` may return null but it is not annotated with `@Nullable`. (Origin: call to returnNullOK() at line 90)] +codetoanalyze/java/eradicate/ReturnNotNullable.java, codetoanalyze.java.eradicate.ReturnNotNullable.return_null_in_catch():java.lang.String, 0, ERADICATE_RETURN_NOT_NULLABLE, no_bucket, WARNING, [origin,Method `return_null_in_catch()` may return null but it is not annotated with `@Nullable`. (Origin: null constant at line 106)] +codetoanalyze/java/eradicate/ReturnNotNullable.java, codetoanalyze.java.eradicate.ReturnNotNullable.return_null_in_catch_after_throw():java.lang.String, 0, ERADICATE_RETURN_NOT_NULLABLE, no_bucket, WARNING, [origin,Method `return_null_in_catch_after_throw()` may return null but it is not annotated with `@Nullable`. (Origin: null constant at line 118)] +codetoanalyze/java/eradicate/ReturnNotNullable.java, codetoanalyze.java.eradicate.ReturnNotNullable.tryWithResourcesReturnNullable(java.lang.String):java.lang.Object, 0, ERADICATE_RETURN_NOT_NULLABLE, no_bucket, WARNING, [origin,Method `tryWithResourcesReturnNullable(...)` may return null but it is not annotated with `@Nullable`. (Origin: call to returnNullOK() at line 88)] diff --git a/infer/tests/codetoanalyze/java/hoisting/Hoist.java b/infer/tests/codetoanalyze/java/hoisting/Hoist.java index c5b37a445..c33c28fb6 100644 --- a/infer/tests/codetoanalyze/java/hoisting/Hoist.java +++ b/infer/tests/codetoanalyze/java/hoisting/Hoist.java @@ -165,10 +165,11 @@ class Hoist { class EmptyFoo extends Foo implements Nothing {} boolean instanceof_dont_hoist(EmptyFoo empty) { - boolean k = false;; - for (int i = 0; i < 10; i++) { + boolean k = false; + ; + for (int i = 0; i < 10; i++) { k = empty instanceof Nothing; } - return k; + return k; } } diff --git a/infer/tests/codetoanalyze/java/infer/AnalysisStops.java b/infer/tests/codetoanalyze/java/infer/AnalysisStops.java index 2b0560fd1..22f0bef57 100644 --- a/infer/tests/codetoanalyze/java/infer/AnalysisStops.java +++ b/infer/tests/codetoanalyze/java/infer/AnalysisStops.java @@ -267,5 +267,4 @@ public class AnalysisStops { accessPathInCalleeMayCauseFalsePositive(); int i = 1 / 0; } - } diff --git a/infer/tests/codetoanalyze/java/infer/ArrayOutOfBounds.java b/infer/tests/codetoanalyze/java/infer/ArrayOutOfBounds.java index 8f9b6b84c..6a05623bc 100644 --- a/infer/tests/codetoanalyze/java/infer/ArrayOutOfBounds.java +++ b/infer/tests/codetoanalyze/java/infer/ArrayOutOfBounds.java @@ -7,7 +7,6 @@ package codetoanalyze.java.infer; - public class ArrayOutOfBounds { public int arrayOutOfBounds() { @@ -90,5 +89,4 @@ public class ArrayOutOfBounds { public void nestedInBounds() { safeNestedLoop(new int[11], new int[10]); } - } diff --git a/infer/tests/codetoanalyze/java/infer/Builtins.java b/infer/tests/codetoanalyze/java/infer/Builtins.java index bf39318da..b1c6b5de8 100644 --- a/infer/tests/codetoanalyze/java/infer/Builtins.java +++ b/infer/tests/codetoanalyze/java/infer/Builtins.java @@ -34,5 +34,4 @@ public class Builtins { InferBuiltins.assume(x == null); x.toString(); } - } diff --git a/infer/tests/codetoanalyze/java/infer/ClassCastExceptions.java b/infer/tests/codetoanalyze/java/infer/ClassCastExceptions.java index b1ea29e02..def86786b 100644 --- a/infer/tests/codetoanalyze/java/infer/ClassCastExceptions.java +++ b/infer/tests/codetoanalyze/java/infer/ClassCastExceptions.java @@ -11,14 +11,11 @@ import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL; -class SuperClass { -} +class SuperClass {} -class SubClassA extends SuperClass { -} +class SubClassA extends SuperClass {} -class SubClassB extends SuperClass { -} +class SubClassB extends SuperClass {} interface MyInterface { public int getInt(); @@ -37,7 +34,6 @@ class AnotherImplementationOfInterface implements MyInterface { } } - public class ClassCastExceptions { public void classCastException() { @@ -67,5 +63,4 @@ public class ClassCastExceptions { public void castingArrayOfPrimitiveTypeOK(int[] a) { int[] b = (int[]) a; } - } diff --git a/infer/tests/codetoanalyze/java/infer/CloseableAsResourceExample.java b/infer/tests/codetoanalyze/java/infer/CloseableAsResourceExample.java index f0c95e25c..af797ed5f 100644 --- a/infer/tests/codetoanalyze/java/infer/CloseableAsResourceExample.java +++ b/infer/tests/codetoanalyze/java/infer/CloseableAsResourceExample.java @@ -11,15 +11,14 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.Closeable; import java.io.File; -import java.io.FileWriter; import java.io.FileNotFoundException; +import java.io.FileWriter; import java.io.IOException; import java.io.StringReader; -import java.util.Map; import java.util.HashMap; +import java.util.Map; -class LocalException extends IOException { -} +class LocalException extends IOException {} class SomeResource implements Closeable { @@ -32,21 +31,23 @@ class SomeResource implements Closeable { public void close() {} native void foo(int i); - native static void bar(SomeResource r); + static native void bar(SomeResource r); } class Resource implements Closeable { - public Resource() { - } + public Resource() {} + public void close() {} } class Wrapper implements Closeable { Resource mR; + public Wrapper(Resource r) { mR = r; } + public void close() { mR.close(); } @@ -67,8 +68,7 @@ class ResourceWithException implements Closeable { } } -class ByteArrayOutputStreamWrapper extends ByteArrayOutputStream { -} +class ByteArrayOutputStreamWrapper extends ByteArrayOutputStream {} class ByteArrayInputStreamWrapper extends ByteArrayInputStream { @@ -79,7 +79,7 @@ class ByteArrayInputStreamWrapper extends ByteArrayInputStream { public class CloseableAsResourceExample { - native static boolean star(); + static native boolean star(); void closingCloseable() { SomeResource res = new SomeResource(); @@ -88,7 +88,7 @@ public class CloseableAsResourceExample { void notClosingCloseable() { SomeResource res = new SomeResource(); - } // should report a resource leak + } // should report a resource leak void tryWithResource() { try (SomeResource res = new SomeResource()) { @@ -106,7 +106,6 @@ public class CloseableAsResourceExample { res.close(); } // should report a resource leak - void closingWrapper() { Resource r = new Resource(); Sub s = new Sub(r); @@ -116,7 +115,7 @@ public class CloseableAsResourceExample { void notClosingWrapper() { Sub s = new Sub(new Resource()); s.mR.close(); - } // should report a resource leak + } // should report a resource leak void noNeedToCloseStringReader() { StringReader stringReader = new StringReader("paf!"); @@ -227,7 +226,8 @@ public class CloseableAsResourceExample { if (closeable != null) { closeable.close(); } - } catch (Exception ex) {} + } catch (Exception ex) { + } } public void finallyCloseOk(File file, String fileContent) { @@ -245,5 +245,4 @@ public class CloseableAsResourceExample { } } } - } diff --git a/infer/tests/codetoanalyze/java/infer/CursorLeaks.java b/infer/tests/codetoanalyze/java/infer/CursorLeaks.java index 15b097fe6..e853d2d2d 100644 --- a/infer/tests/codetoanalyze/java/infer/CursorLeaks.java +++ b/infer/tests/codetoanalyze/java/infer/CursorLeaks.java @@ -7,7 +7,6 @@ package codetoanalyze.java.infer; - import android.app.DownloadManager; import android.content.ContentProviderClient; import android.content.ContentResolver; @@ -22,20 +21,16 @@ import android.provider.MediaStore; public class CursorLeaks { public int cursorClosed(SQLiteDatabase sqLiteDatabase) { - Cursor cursor = sqLiteDatabase.query( - "events", null, - null, null, null, null, null); - try { - return cursor.getCount(); - } finally { - cursor.close(); - } + Cursor cursor = sqLiteDatabase.query("events", null, null, null, null, null, null); + try { + return cursor.getCount(); + } finally { + cursor.close(); + } } public Object cursorClosedCheckNull(SQLiteDatabase sqLiteDatabase) { - Cursor cursor = sqLiteDatabase.query( - "events", null, - null, null, null, null, null); + Cursor cursor = sqLiteDatabase.query("events", null, null, null, null, null, null); Object value = null; try { @@ -53,9 +48,7 @@ public class CursorLeaks { } public Object cursorClosedCheckNullCheckClosed_FP(SQLiteDatabase sqLiteDatabase) { - Cursor cursor = sqLiteDatabase.query( - "events", null, - null, null, null, null, null); + Cursor cursor = sqLiteDatabase.query("events", null, null, null, null, null, null); Object value = null; try { @@ -73,10 +66,8 @@ public class CursorLeaks { } public int cursorNotClosed(SQLiteDatabase sqLiteDatabase) { - Cursor cursor = sqLiteDatabase.query( - "events", null, - null, null, null, null, null); - return cursor.getCount(); + Cursor cursor = sqLiteDatabase.query("events", null, null, null, null, null, null); + return cursor.getCount(); } Context mContext; @@ -87,19 +78,15 @@ public class CursorLeaks { String selectionClause = selectionClause = customClause; - Cursor cursor = mContext.getContentResolver().query( - null, - projection, - selectionClause, - null, - null); + Cursor cursor = + mContext.getContentResolver().query(null, projection, selectionClause, null, null); if (cursor != null) { int count = cursor.getInt(0); // cursor.close(); return count; } else { - return 0; + return 0; } } @@ -108,12 +95,8 @@ public class CursorLeaks { String selectionClause = selectionClause = customClause; - Cursor cursor = mContext.getContentResolver().query( - null, - projection, - selectionClause, - null, - null); + Cursor cursor = + mContext.getContentResolver().query(null, projection, selectionClause, null, null); if (cursor != null) { int count = cursor.getInt(0); @@ -125,8 +108,7 @@ public class CursorLeaks { } public int getBucketCountNotClosed() { - Cursor cursor = MediaStore.Images.Media.query( - mContentResolver, null, null, null, null, null); + Cursor cursor = MediaStore.Images.Media.query(mContentResolver, null, null, null, null, null); if (cursor == null) { return 0; } else { @@ -136,12 +118,10 @@ public class CursorLeaks { } return count; } - } public int getBucketCountClosed() { - Cursor cursor = MediaStore.Images.Media.query( - mContentResolver, null, null, null, null, null); + Cursor cursor = MediaStore.Images.Media.query(mContentResolver, null, null, null, null, null); if (cursor == null) { return 0; } else { @@ -197,13 +177,12 @@ public class CursorLeaks { return cursor.getColumnIndex(DownloadManager.COLUMN_STATUS); } } finally { - //cursor.close(); + // cursor.close(); } } private void loadPrefsFromContentProviderClosed() { - ContentProviderClient contentProviderClient = - mContentResolver.acquireContentProviderClient(""); + ContentProviderClient contentProviderClient = mContentResolver.acquireContentProviderClient(""); if (contentProviderClient != null) { Cursor cursor = null; try { @@ -220,8 +199,7 @@ public class CursorLeaks { } private void loadPrefsFromContentProviderNotClosed() { - ContentProviderClient contentProviderClient = - mContentResolver.acquireContentProviderClient(""); + ContentProviderClient contentProviderClient = mContentResolver.acquireContentProviderClient(""); if (contentProviderClient == null) return; Cursor cursor = null; try { @@ -231,7 +209,7 @@ public class CursorLeaks { } } finally { if (cursor != null) { - //cursor.close(); + // cursor.close(); } } } @@ -251,11 +229,11 @@ public class CursorLeaks { } // TODO (#7474990): investigate why is Infer reporting a resource leak here -// public void cursorWrapperClosed(SQLiteDatabase sqLiteDatabase) { -// Cursor cursor = sqLiteDatabase.query("events", null, null, null, null, null, null); -// Cursor c = new NamedCursor(cursor, "abc"); -// c.close(); -// } + // public void cursorWrapperClosed(SQLiteDatabase sqLiteDatabase) { + // Cursor cursor = sqLiteDatabase.query("events", null, null, null, null, null, null); + // Cursor c = new NamedCursor(cursor, "abc"); + // c.close(); + // } native NamedCursor createWrapper(Cursor cursor); @@ -263,5 +241,4 @@ public class CursorLeaks { Cursor cursor = sqLiteDatabase.query("events", null, null, null, null, null, null); return createWrapper(cursor); } - } diff --git a/infer/tests/codetoanalyze/java/infer/CursorNPEs.java b/infer/tests/codetoanalyze/java/infer/CursorNPEs.java index d9ad07656..ad9918b62 100644 --- a/infer/tests/codetoanalyze/java/infer/CursorNPEs.java +++ b/infer/tests/codetoanalyze/java/infer/CursorNPEs.java @@ -7,7 +7,6 @@ package codetoanalyze.java.infer; - import android.app.DownloadManager; import android.content.ContentProviderClient; import android.content.ContentResolver; @@ -21,9 +20,7 @@ import android.provider.MediaStore; public class CursorNPEs { public int cursorNPEfromQuery(SQLiteDatabase sqLiteDatabase) { - Cursor cursor = sqLiteDatabase.query( - "events", null, - null, null, null, null, null); + Cursor cursor = sqLiteDatabase.query("events", null, null, null, null, null, null); try { return cursor.getCount(); } finally { @@ -39,20 +36,14 @@ public class CursorNPEs { String selectionClause = selectionClause = customClause; - Cursor cursor = mContext.getContentResolver().query( - null, - projection, - selectionClause, - null, - null); + Cursor cursor = + mContext.getContentResolver().query(null, projection, selectionClause, null, null); cursor.close(); } - public void cursorFromMediaNPE() { - Cursor cursor = MediaStore.Images.Media.query( - mContentResolver, null, null, null, null, null); + Cursor cursor = MediaStore.Images.Media.query(mContentResolver, null, null, null, null, null); cursor.close(); } @@ -75,8 +66,7 @@ public class CursorNPEs { } private void cursorFromContentProviderClient() { - ContentProviderClient contentProviderClient = - mContentResolver.acquireContentProviderClient(""); + ContentProviderClient contentProviderClient = mContentResolver.acquireContentProviderClient(""); if (contentProviderClient != null) { Cursor cursor = null; try { @@ -92,5 +82,4 @@ public class CursorNPEs { } } } - } diff --git a/infer/tests/codetoanalyze/java/infer/DivideByZero.java b/infer/tests/codetoanalyze/java/infer/DivideByZero.java index 954c3b345..248df0491 100644 --- a/infer/tests/codetoanalyze/java/infer/DivideByZero.java +++ b/infer/tests/codetoanalyze/java/infer/DivideByZero.java @@ -7,7 +7,6 @@ package codetoanalyze.java.infer; - public class DivideByZero { public int divByZeroLocal(String s) { @@ -21,12 +20,12 @@ public class DivideByZero { return 10 / denominator; } - //DO NOT MOVE, test relies on line number + // DO NOT MOVE, test relies on line number public int callDivideByZeroInterProc() { return divideByZeroInterProc(0); } - //divide by zero with static fields + // divide by zero with static fields private static int x; public void setXToZero() { @@ -37,5 +36,4 @@ public class DivideByZero { setXToZero(); return divideByZeroInterProc(x); } - } diff --git a/infer/tests/codetoanalyze/java/infer/DynamicDispatch.java b/infer/tests/codetoanalyze/java/infer/DynamicDispatch.java index 3a50eec53..d75b7b81c 100644 --- a/infer/tests/codetoanalyze/java/infer/DynamicDispatch.java +++ b/infer/tests/codetoanalyze/java/infer/DynamicDispatch.java @@ -9,12 +9,13 @@ package codetoanalyze.java.infer; public class DynamicDispatch { - static interface Interface { + static interface Interface { public Object foo(); } static class Impl implements Interface { - @Override public Object foo() { + @Override + public Object foo() { return null; } } @@ -44,11 +45,13 @@ public class DynamicDispatch { } static class Subtype extends Supertype { - @Override Object foo() { + @Override + Object foo() { return null; } - @Override Object bar() { + @Override + Object bar() { return new Object(); } } @@ -128,7 +131,6 @@ public class DynamicDispatch { WithField object = new WithField(subtype); object.mField.foo().toString(); } - } private Object callFoo(Supertype o) { @@ -152,5 +154,4 @@ public class DynamicDispatch { Supertype subtype = new Subtype(); variadicMethod(subtype, null, null).toString(); } - } diff --git a/infer/tests/codetoanalyze/java/infer/FilterInputStreamLeaks.java b/infer/tests/codetoanalyze/java/infer/FilterInputStreamLeaks.java index a6f3701c0..60f164353 100644 --- a/infer/tests/codetoanalyze/java/infer/FilterInputStreamLeaks.java +++ b/infer/tests/codetoanalyze/java/infer/FilterInputStreamLeaks.java @@ -7,19 +7,17 @@ package codetoanalyze.java.infer; - import java.io.*; import java.security.DigestInputStream; import java.util.zip.CheckedInputStream; import java.util.zip.DeflaterInputStream; import java.util.zip.GZIPInputStream; import java.util.zip.InflaterInputStream; - import javax.crypto.CipherInputStream; public class FilterInputStreamLeaks { - //BufferedInputStream tests + // BufferedInputStream tests public void bufferedInputStreamNotClosedAfterRead() { FileInputStream fis; @@ -45,7 +43,7 @@ public class FilterInputStreamLeaks { } } - //CheckedInputStream tests + // CheckedInputStream tests public void checkedInputStreamNotClosedAfterRead() { FileInputStream fis; @@ -71,7 +69,7 @@ public class FilterInputStreamLeaks { } } - //CipherInputStream tests + // CipherInputStream tests public void cipherInputStreamNotClosedAfterSkip() { FileInputStream fis; @@ -97,7 +95,7 @@ public class FilterInputStreamLeaks { } } - //DataInputStream tests + // DataInputStream tests public void dataInputStreamNotClosedAfterRead() { byte[] arr = new byte[10]; @@ -124,7 +122,7 @@ public class FilterInputStreamLeaks { } } - //DeflaterInputStream tests + // DeflaterInputStream tests public void deflaterInputStreamNotClosedAfterRead() { FileInputStream fis; @@ -150,7 +148,7 @@ public class FilterInputStreamLeaks { } } - //GZipInputStream tests + // GZipInputStream tests public void gzipInputStreamNotClosedAfterRead() { FileInputStream fis; @@ -172,14 +170,12 @@ public class FilterInputStreamLeaks { gzipInputStream.read(); } catch (IOException e) { } finally { - if (gzipInputStream != null) - gzipInputStream.close(); - else if (fis != null) - fis.close(); + if (gzipInputStream != null) gzipInputStream.close(); + else if (fis != null) fis.close(); } } - //DigestInputStream tests + // DigestInputStream tests public void digestInputStreamNotClosedAfterRead() { byte[] arr = new byte[10]; @@ -206,7 +202,7 @@ public class FilterInputStreamLeaks { } } - //InflaterInputStream tests + // InflaterInputStream tests public void inflaterInputStreamNotClosedAfterRead() { FileInputStream fis; @@ -232,7 +228,7 @@ public class FilterInputStreamLeaks { } } - //PushbackInputStream tests + // PushbackInputStream tests public void pushbackInputStreamNotClosedAfterRead() { FileInputStream fis; @@ -262,5 +258,4 @@ public class FilterInputStreamLeaks { DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(file))); in.close(); } - } diff --git a/infer/tests/codetoanalyze/java/infer/FilterOutputStreamLeaks.java b/infer/tests/codetoanalyze/java/infer/FilterOutputStreamLeaks.java index bab291f0d..083af51d0 100644 --- a/infer/tests/codetoanalyze/java/infer/FilterOutputStreamLeaks.java +++ b/infer/tests/codetoanalyze/java/infer/FilterOutputStreamLeaks.java @@ -7,7 +7,6 @@ package codetoanalyze.java.infer; - import java.io.BufferedOutputStream; import java.io.DataOutputStream; import java.io.FileOutputStream; @@ -18,13 +17,11 @@ import java.util.zip.CheckedOutputStream; import java.util.zip.DeflaterOutputStream; import java.util.zip.GZIPOutputStream; import java.util.zip.InflaterOutputStream; - import javax.crypto.CipherOutputStream; public class FilterOutputStreamLeaks { - - //FilterOutputStream tests + // FilterOutputStream tests public void filterOutputStreamNotClosedAfterWrite() { byte[] arr = {1, 2, 3}; @@ -48,12 +45,11 @@ public class FilterOutputStreamLeaks { fos.write(arr); } catch (IOException e) { } finally { - if (fos != null) - fos.close(); + if (fos != null) fos.close(); } } - //DataOutputStream tests + // DataOutputStream tests public void dataOutputStreamNotClosedAfterWrite() { byte[] arr = {1, 2, 3}; @@ -77,12 +73,11 @@ public class FilterOutputStreamLeaks { dos.write(arr); } catch (IOException e) { } finally { - if (dos != null) - dos.close(); + if (dos != null) dos.close(); } } - //BufferedOutputStream tests + // BufferedOutputStream tests public void bufferedOutputStreamNotClosedAfterWrite() { byte[] arr = {1, 2, 3}; @@ -106,13 +101,11 @@ public class FilterOutputStreamLeaks { bos.write(arr); } catch (IOException e) { } finally { - if (bos != null) - bos.close(); + if (bos != null) bos.close(); } } - - //CheckedOutputStream tests + // CheckedOutputStream tests public void checkedOutputStreamNotClosedAfterWrite() { byte[] arr = {1, 2, 3}; @@ -136,12 +129,11 @@ public class FilterOutputStreamLeaks { chos.write(arr); } catch (IOException e) { } finally { - if (chos != null) - chos.close(); + if (chos != null) chos.close(); } } - //CipherOutputStream tests + // CipherOutputStream tests public void cipherOutputStreamNotClosedAfterWrite() { byte[] arr = {1, 2, 3}; @@ -165,12 +157,11 @@ public class FilterOutputStreamLeaks { cos.write(arr); } catch (IOException e) { } finally { - if (cos != null) - cos.close(); + if (cos != null) cos.close(); } } - //DeflaterOutputStream tests + // DeflaterOutputStream tests public void deflaterOutputStreamNotClosedAfterWrite() { byte[] arr = {1, 2, 3}; @@ -194,13 +185,11 @@ public class FilterOutputStreamLeaks { dos.write(arr); } catch (IOException e) { } finally { - if (dos != null) - dos.close(); + if (dos != null) dos.close(); } } - - //DigestOutputStream tests + // DigestOutputStream tests public void digestOutputStreamNotClosedAfterWrite() { byte[] arr = {1, 2, 3}; @@ -224,12 +213,11 @@ public class FilterOutputStreamLeaks { dos.write(arr); } catch (IOException e) { } finally { - if (dos != null) - dos.close(); + if (dos != null) dos.close(); } } - //InflaterOutputStream tests + // InflaterOutputStream tests public void inflaterOutputStreamNotClosedAfterWrite() { byte[] arr = {1, 2, 3}; @@ -253,12 +241,11 @@ public class FilterOutputStreamLeaks { ios.write(arr); } catch (IOException e) { } finally { - if (ios != null) - ios.close(); + if (ios != null) ios.close(); } } - //GZipOutputStream tests + // GZipOutputStream tests public void gzipOutputStreamNotClosedAfterFlush() { FileOutputStream fos; @@ -281,14 +268,12 @@ public class FilterOutputStreamLeaks { gzipOutputStream.write(arr); } catch (IOException e) { } finally { - if (gzipOutputStream != null) - gzipOutputStream.close(); - else if (fos != null) - fos.close(); + if (gzipOutputStream != null) gzipOutputStream.close(); + else if (fos != null) fos.close(); } } - //PrintStream tests + // PrintStream tests public void printStreamNotClosedAfterWrite() { byte[] arr = {1, 2, 3}; @@ -311,9 +296,7 @@ public class FilterOutputStreamLeaks { printer.write(arr); } catch (IOException e) { } finally { - if (printer != null) - printer.close(); + if (printer != null) printer.close(); } } - } diff --git a/infer/tests/codetoanalyze/java/infer/GuardedByExample.java b/infer/tests/codetoanalyze/java/infer/GuardedByExample.java index 9d7520fac..1e7bc1ad2 100644 --- a/infer/tests/codetoanalyze/java/infer/GuardedByExample.java +++ b/infer/tests/codetoanalyze/java/infer/GuardedByExample.java @@ -7,25 +7,20 @@ package codetoanalyze.java.infer; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -import com.google.common.annotations.VisibleForTesting; import android.annotation.SuppressLint; -import javax.annotation.concurrent.GuardedBy; +import com.google.common.annotations.VisibleForTesting; +import java.io.Closeable; import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantReadWriteLock; - -import java.io.Closeable; +import javax.annotation.concurrent.GuardedBy; public class GuardedByExample { static class AutoCloseableReadWriteUpdateLock implements Closeable { - @Override public void close() {} + @Override + public void close() {} } private Object mLock = new Object(); @@ -149,7 +144,7 @@ public class GuardedByExample { void reassignCopyOk() { synchronized (this) { - mCopyOfG = g; // these are ok: access of g guarded by this + mCopyOfG = g; // these are ok: access of g guarded by this } mCopyOfG = new Object(); // ok; this doesn't change the value of g } @@ -195,12 +190,12 @@ public class GuardedByExample { } } - synchronized static void staticSynchronizedOk() { + static synchronized void staticSynchronizedOk() { sGuardedByClass.toString(); } static void synchronizeOnClassOk1() { - synchronized(GuardedByExample.class) { + synchronized (GuardedByExample.class) { sGuardedByClass.toString(); // should not warn here sGuardedByClass = new Object(); // or here } @@ -266,10 +261,10 @@ public class GuardedByExample { // "by reference" GuardedBy semantics void readGFromCopyOk() { synchronized (this) { - mCopyOfG = g; // these are ok: access of g guarded by this + mCopyOfG = g; // these are ok: access of g guarded by this g.toString(); } - mCopyOfG.toString(); // should be an error; unprotected access to pt(g) + mCopyOfG.toString(); // should be an error; unprotected access to pt(g) } // another "by reference" vs "by value" test. buggy in "by value", but safe in "by reference" @@ -280,7 +275,7 @@ public class GuardedByExample { Object byRefTrickyBad() { Object local = null; - synchronized(this) { + synchronized (this) { local = g; // we have a local pointer... to pt(G) } g.toString(); // ...but unsafe access is through g! @@ -289,17 +284,18 @@ public class GuardedByExample { void byRefTrickyOk() { Object local = null; - synchronized(this) { + synchronized (this) { local = g; // we have a local pointer... to pt(G) } local.toString(); // ...but unsafe access is through g! } - @GuardedBy("ui_thread") Object uiThread1; + @GuardedBy("ui-thread") Object uiThread2; + @GuardedBy("uithread") Object uiThread3; @@ -330,18 +326,22 @@ public class GuardedByExample { private class Inner { @GuardedBy("this") Object guardedByInnerThis1; + @GuardedBy("Inner.this") Object guardedByInnerThis2; + @GuardedBy("GuardedByExample$Inner.this") Object guardedByInnerThis3; + @GuardedBy("Inner.class") Object guardedByInnerClass1; + @GuardedBy("GuardedByExample.Inner.class") Object guardedByInnerClass2; + @GuardedBy("GuardedByExample$Inner.class") Object guardedByInnerClass3; - synchronized void okAccess1() { guardedByInnerThis1 = null; } @@ -369,7 +369,6 @@ public class GuardedByExample { guardedByInnerClass3 = new Object(); } } - } // TODO: report on these cases @@ -391,7 +390,7 @@ public class GuardedByExample { public void withloop2() { synchronized (mLock) { - for (int i = 0; i<=n; i++) { + for (int i = 0; i <= n; i++) { f = 42; } } @@ -403,38 +402,37 @@ public class GuardedByExample { } } - @GuardedBy("self_reference") - Object self_reference; + @GuardedBy("self_reference") + Object self_reference; - void guardedBySelfReferenceOK() { - synchronized(self_reference){ - this.self_reference.toString(); + void guardedBySelfReferenceOK() { + synchronized (self_reference) { + this.self_reference.toString(); } } // TODO: report on this case, or at least a version which writes /* - void guardedBySelfReferenceBad() { - this.self_reference.toString(); - } - */ + void guardedBySelfReferenceBad() { + this.self_reference.toString(); + } + */ @GuardedBy("itself") Object itself_fld; - void itselfOK() { - synchronized(itself_fld){ - this.itself_fld.toString(); + void itselfOK() { + synchronized (itself_fld) { + this.itself_fld.toString(); } } // TODO: report on this case, or at least a version which writes /* - void itselfBad() { - this.itself_fld.toString(); - } - */ - + void itselfBad() { + this.itself_fld.toString(); + } + */ ReadWriteLock mRWL; @@ -477,10 +475,10 @@ public class GuardedByExample { @GuardedBy("this") Integer xForSub; - static class Sub extends GuardedByExample{ + static class Sub extends GuardedByExample { void goodSub1() { - synchronized (this){ + synchronized (this) { xForSub = 22; } } @@ -492,7 +490,6 @@ public class GuardedByExample { void badSub() { xForSub = 22; } - } Lock normallock; @@ -505,7 +502,6 @@ public class GuardedByExample { @GuardedBy("reentrantlock") Integer guardedbyrel; - void goodGuardedByNormalLock() { normallock.lock(); guardedbynl = 22; @@ -526,11 +522,11 @@ public class GuardedByExample { } } - void badGuardedByNormalLock(){ + void badGuardedByNormalLock() { guardedbynl = 22; } - void badGuardedByReentrantLock(){ + void badGuardedByReentrantLock() { guardedbyrel = 44; } @@ -577,5 +573,4 @@ public class GuardedByExample { guardedByLock1 = true; guardedByLock2 = true; } - } diff --git a/infer/tests/codetoanalyze/java/infer/HashMapExample.java b/infer/tests/codetoanalyze/java/infer/HashMapExample.java index e1ff40dce..3887081f5 100644 --- a/infer/tests/codetoanalyze/java/infer/HashMapExample.java +++ b/infer/tests/codetoanalyze/java/infer/HashMapExample.java @@ -11,9 +11,7 @@ import java.util.HashMap; public class HashMapExample { - public static void putIntegerTwiceThenGetTwice( - HashMap hashMap - ) { + public static void putIntegerTwiceThenGetTwice(HashMap hashMap) { Integer i32 = new Integer(32); Integer i52 = new Integer(52); @@ -27,9 +25,7 @@ public class HashMapExample { b.intValue(); } - public static void containsIntegerTwiceThenGetTwice( - HashMap hashMap - ) { + public static void containsIntegerTwiceThenGetTwice(HashMap hashMap) { Integer i32 = new Integer(32); Integer i52 = new Integer(52); @@ -50,10 +46,7 @@ public class HashMapExample { return a.intValue(); } - public static void getTwoIntegersWithOneCheck( - Integer i, - Integer j - ) { + public static void getTwoIntegersWithOneCheck(Integer i, Integer j) { HashMap hashMap = new HashMap<>(); if (hashMap.containsKey(i) && !i.equals(j)) { @@ -65,24 +58,21 @@ public class HashMapExample { } } - public static Integer getOrCreateInteger( - final HashMap map, - final int id) { - Integer x = null; - if (map.containsKey(id)) { - x = map.get(id); - } else { - x = new Integer(0); - map.put(id, x); - } - return x; + public static Integer getOrCreateInteger(final HashMap map, final int id) { + Integer x = null; + if (map.containsKey(id)) { + x = map.get(id); + } else { + x = new Integer(0); + map.put(id, x); + } + return x; } - public static void getOrCreateIntegerThenDeref( - final HashMap map) { - Integer x = getOrCreateInteger(map, 42); - // dereference x - x.toString(); + public static void getOrCreateIntegerThenDeref(final HashMap map) { + Integer x = getOrCreateInteger(map, 42); + // dereference x + x.toString(); } void getAfterRemovingTheKeyBad() { @@ -117,5 +107,4 @@ public class HashMapExample { } } } - } diff --git a/infer/tests/codetoanalyze/java/infer/IntegerExample.java b/infer/tests/codetoanalyze/java/infer/IntegerExample.java index e8f1a744a..267b3f65c 100644 --- a/infer/tests/codetoanalyze/java/infer/IntegerExample.java +++ b/infer/tests/codetoanalyze/java/infer/IntegerExample.java @@ -7,23 +7,22 @@ package codetoanalyze.java.infer; -import java.util.HashMap; public class IntegerExample { - private static void testIntegerEqualsGood() { - Integer a = new Integer(42); - Integer b = new Integer(42); - Integer c = null; + private static void testIntegerEqualsGood() { + Integer a = new Integer(42); + Integer b = new Integer(42); + Integer c = null; - if (!a.equals(b)) { - c.intValue(); - } + if (!a.equals(b)) { + c.intValue(); + } - if (a != 42) { - c.intValue(); - } + if (a != 42) { + c.intValue(); } + } private static void testIntegerEqualsBad() { Integer a = new Integer(42); @@ -33,7 +32,6 @@ public class IntegerExample { if (a.equals(b)) { c.intValue(); } - } private static void testIntegerEqualsFN() { @@ -44,7 +42,5 @@ public class IntegerExample { if (a == b) { c.intValue(); } - } - } diff --git a/infer/tests/codetoanalyze/java/infer/InvokeDynamic.java b/infer/tests/codetoanalyze/java/infer/InvokeDynamic.java index 0a6b4eda9..6b8f899df 100644 --- a/infer/tests/codetoanalyze/java/infer/InvokeDynamic.java +++ b/infer/tests/codetoanalyze/java/infer/InvokeDynamic.java @@ -14,26 +14,31 @@ public class InvokeDynamic { void invokeDynamicThenNpeBad(List list) { Object o = null; - Collections.sort(list, (String a, String b) -> { - return b.compareTo(a); - }); + Collections.sort( + list, + (String a, String b) -> { + return b.compareTo(a); + }); o.toString(); } void npeInLambdaBad(List list) { - Collections.sort(list, (String a, String b) -> { - Object o = null; - o.toString(); - return b.compareTo(a); - }); + Collections.sort( + list, + (String a, String b) -> { + Object o = null; + o.toString(); + return b.compareTo(a); + }); } // we won't get this one because we don't actually translate the invocation of the lambda void FN_npeViaCaptureBad(List list) { String s = null; - Collections.sort(list, (String a, String b) -> { - return s.compareTo(a); - }); + Collections.sort( + list, + (String a, String b) -> { + return s.compareTo(a); + }); } - } diff --git a/infer/tests/codetoanalyze/java/infer/JunitAssertion.java b/infer/tests/codetoanalyze/java/infer/JunitAssertion.java index 7eddee2b3..f70f8f972 100644 --- a/infer/tests/codetoanalyze/java/infer/JunitAssertion.java +++ b/infer/tests/codetoanalyze/java/infer/JunitAssertion.java @@ -12,8 +12,7 @@ import static junit.framework.Assert.assertTrue; public class JunitAssertion { class A { - public void f() { - } + public void f() {} } public void consistentAssertion(A a) { diff --git a/infer/tests/codetoanalyze/java/infer/Lists.java b/infer/tests/codetoanalyze/java/infer/Lists.java index 5b5aac12f..dd1c0a3cb 100644 --- a/infer/tests/codetoanalyze/java/infer/Lists.java +++ b/infer/tests/codetoanalyze/java/infer/Lists.java @@ -7,7 +7,6 @@ package codetoanalyze.java.infer; -import java.util.ArrayList; import java.util.List; class Lists { @@ -73,5 +72,4 @@ class Lists { } } } - } diff --git a/infer/tests/codetoanalyze/java/infer/NeverNullSource.java b/infer/tests/codetoanalyze/java/infer/NeverNullSource.java index 19e10a655..b9272902e 100644 --- a/infer/tests/codetoanalyze/java/infer/NeverNullSource.java +++ b/infer/tests/codetoanalyze/java/infer/NeverNullSource.java @@ -13,11 +13,9 @@ import javax.annotation.Nullable; public class NeverNullSource { - @Nullable - T t; + @Nullable T t; T get() { return t == null ? null : t; } - } diff --git a/infer/tests/codetoanalyze/java/infer/NullPointerExceptions.java b/infer/tests/codetoanalyze/java/infer/NullPointerExceptions.java index 5b9c6f487..7e7ab3377 100644 --- a/infer/tests/codetoanalyze/java/infer/NullPointerExceptions.java +++ b/infer/tests/codetoanalyze/java/infer/NullPointerExceptions.java @@ -13,33 +13,27 @@ import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.text.TextUtils; - import com.facebook.infer.annotation.Assertions; - import com.google.common.base.Optional; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.nio.channels.FileChannel; import java.nio.channels.FileLock; -import java.lang.System; -import java.util.concurrent.locks.Lock; import java.util.HashMap; +import java.util.concurrent.locks.Lock; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; public class NullPointerExceptions { class A { int x; - public void method() { - } + public void method() {} } // npe local with field @@ -50,10 +44,8 @@ public class NullPointerExceptions { public A canReturnNullObject(boolean ok) { A a = new A(); - if (ok) - return a; - else - return null; + if (ok) return a; + else return null; } public static void expectNotNullObjectParameter(A a) { @@ -83,13 +75,11 @@ public class NullPointerExceptions { class B { A a; - void test() { - } + void test() {} } - public static int nullPointerExceptionWithArray() { - A[] array = new A[]{null}; + A[] array = new A[] {null}; A t = array[0]; return t.x; } @@ -138,8 +128,7 @@ public class NullPointerExceptions { int x; public void nullPointerExceptionFromNotKnowingThatThisIsNotNull() { - if (this == null) { - } + if (this == null) {} this.x = 4; } @@ -170,8 +159,7 @@ public class NullPointerExceptions { } public void genericMethodSomewhereCheckingForNull(String s) { - if (s == null) { - } + if (s == null) {} } public void FP_noNullPointerExceptionAfterSkipFunction() { @@ -192,11 +180,11 @@ public class NullPointerExceptions { return "aa"; } - int NPEvalueOfFromHashmapBad(HashMap h, int position) { + int NPEvalueOfFromHashmapBad(HashMap h, int position) { return h.get(position); } - Integer NPEvalueOfFromHashmapGood(HashMap h, int position) { + Integer NPEvalueOfFromHashmapGood(HashMap h, int position) { return h.get(position); } @@ -213,23 +201,18 @@ public class NullPointerExceptions { public void cursorFromContentResolverNPE(String customClause) { String[] projection = {"COUNT(*)"}; String selectionClause = selectionClause = customClause; - Cursor cursor = mContext.getContentResolver().query( - null, - projection, - selectionClause, - null, - null); + Cursor cursor = + mContext.getContentResolver().query(null, projection, selectionClause, null, null); cursor.close(); } public int cursorQueryShouldNotReturnNull(SQLiteDatabase sqLiteDatabase) { - Cursor cursor = sqLiteDatabase.query( - "events", null, null, null, null, null, null); - try { - return cursor.getCount(); - } finally { - cursor.close(); - } + Cursor cursor = sqLiteDatabase.query("events", null, null, null, null, null, null); + try { + return cursor.getCount(); + } finally { + cursor.close(); + } } Object[] arr = new Object[1]; @@ -527,7 +510,8 @@ public class NullPointerExceptions { o.toString(); } - @Nullable Object wrapUnknownFuncWithNullable() { + @Nullable + Object wrapUnknownFuncWithNullable() { return unknownFunc(); } @@ -574,7 +558,7 @@ public class NullPointerExceptions { } void dereferenceAfterUnlock2(Lock l) { - synchronized(l){ + synchronized (l) { String b = null; } String s = l.toString(); @@ -590,12 +574,12 @@ public class NullPointerExceptions { final String c1 = "Test string!"; final String c2 = "Test string!"; String s = null; - if(c1.equals(c1)) { + if (c1.equals(c1)) { s = "safe"; } s.toString(); // No NPE s = null; - if(c1.equals(c2)) { + if (c1.equals(c2)) { s = "safe"; } s.toString(); // No NPE @@ -608,7 +592,7 @@ public class NullPointerExceptions { final String c1 = "Test string 1"; final String c2 = "Test string 2"; String s = null; - if(!c1.equals(c2)) { + if (!c1.equals(c2)) { s = "safe"; } s.toString(); // No NPE @@ -622,7 +606,7 @@ public class NullPointerExceptions { final String c1 = "Test string 1"; String c2 = "Test " + getString2(); String s = null; - if(!c1.equals(c2)) { + if (!c1.equals(c2)) { s.toString(); // NPE } } @@ -640,7 +624,6 @@ public class NullPointerExceptions { void dereferenceNullableInterfaceFieldBad() { mObject.toString(); } - } Object getObject() { diff --git a/infer/tests/codetoanalyze/java/infer/ReaderLeaks.java b/infer/tests/codetoanalyze/java/infer/ReaderLeaks.java index f9a8173f5..8146c42a5 100644 --- a/infer/tests/codetoanalyze/java/infer/ReaderLeaks.java +++ b/infer/tests/codetoanalyze/java/infer/ReaderLeaks.java @@ -8,8 +8,8 @@ package codetoanalyze.java.infer; import java.io.BufferedReader; -import java.io.FileInputStream; import java.io.File; +import java.io.FileInputStream; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; @@ -22,7 +22,7 @@ public class ReaderLeaks { private void ignore(Object o) {} - //Reader tests + // Reader tests public void readerNotClosedAfterRead() { Reader r; @@ -46,7 +46,7 @@ public class ReaderLeaks { } } - //BufferedReader tests + // BufferedReader tests public void bufferedReaderNotClosedAfterRead() { BufferedReader reader; @@ -76,8 +76,7 @@ public class ReaderLeaks { } } - - //InputStreamReader tests + // InputStreamReader tests public void inputStreamReaderNotClosedAfterRead() { InputStreamReader reader; @@ -100,7 +99,7 @@ public class ReaderLeaks { } } - //FileReader tests + // FileReader tests public void fileReaderNotClosedAfterRead() { FileReader reader; @@ -123,7 +122,7 @@ public class ReaderLeaks { } } - //PushbackReader tests + // PushbackReader tests public void pushbackReaderNotClosedAfterRead() { PushbackReader reader; @@ -146,7 +145,7 @@ public class ReaderLeaks { } } - //PipedReader tests + // PipedReader tests public void pipedReaderNotClosedAfterConstructedWithWriter() { PipedReader reader; @@ -188,8 +187,7 @@ public class ReaderLeaks { reader.read(); } catch (IOException e) { } finally { - if (reader != null) - reader.close(); + if (reader != null) reader.close(); } } @@ -201,9 +199,7 @@ public class ReaderLeaks { reader.read(); } catch (IOException e) { } finally { - if (writer != null) - writer.close(); + if (writer != null) writer.close(); } } - } diff --git a/infer/tests/codetoanalyze/java/infer/ResourceLeaks.java b/infer/tests/codetoanalyze/java/infer/ResourceLeaks.java index aeadcdef0..c9ca0fe8a 100644 --- a/infer/tests/codetoanalyze/java/infer/ResourceLeaks.java +++ b/infer/tests/codetoanalyze/java/infer/ResourceLeaks.java @@ -7,12 +7,15 @@ package codetoanalyze.java.infer; +import android.app.Activity; +import android.content.Context; +import android.content.res.Resources; +import android.content.res.TypedArray; import com.fasterxml.jackson.core.JsonFactory; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.json.UTF8StreamJsonParser; import com.google.common.base.Preconditions; import com.google.common.io.Closeables; - import java.io.BufferedInputStream; import java.io.Closeable; import java.io.DataOutputStream; @@ -45,17 +48,11 @@ import java.util.zip.GZIPInputStream; import java.util.zip.GZIPOutputStream; import java.util.zip.Inflater; import java.util.zip.ZipFile; - import javax.net.ssl.HttpsURLConnection; -import android.app.Activity; -import android.content.Context; -import android.content.res.Resources; -import android.content.res.TypedArray; - public class ResourceLeaks { - //FileOutputStream tests + // FileOutputStream tests public void fileOutputStreamNotClosed() throws IOException { FileOutputStream fis = new FileOutputStream("file.txt"); @@ -72,7 +69,6 @@ public class ResourceLeaks { } } - public void fileOutputStreamClosed() throws IOException { FileOutputStream fis = new FileOutputStream("file.txt"); fis.close(); @@ -104,7 +100,7 @@ public class ResourceLeaks { fis = new FileOutputStream("x"); } - //TwoResources tests + // TwoResources tests public static void twoResources() throws IOException { FileInputStream fis = null; @@ -135,7 +131,6 @@ public class ResourceLeaks { } } - public static void twoResourcesCommonFix() throws IOException { FileInputStream fis = null; FileOutputStream fos = null; @@ -155,7 +150,6 @@ public class ResourceLeaks { } } - public static void twoResourcesServerSocket() throws IOException { ServerSocket a = null; ServerSocket b = null; @@ -168,7 +162,6 @@ public class ResourceLeaks { } } - public static void twoResourcesRandomAccessFile() throws IOException { RandomAccessFile a = null; RandomAccessFile b = null; @@ -199,8 +192,7 @@ public class ResourceLeaks { } } - - //NestedResource tests + // NestedResource tests // BufferedInputStream does not throw exception, and its close // closes the FileInputStream as well @@ -216,13 +208,11 @@ public class ResourceLeaks { g.close(); } - public void nestedBad2() throws IOException { GZIPOutputStream g = new GZIPOutputStream(new FileOutputStream("file.txt")); g.close(); } - /* Fixed versions of this are below with ObjectInputStream tests */ public void objectInputStreamClosedNestedBad() throws IOException { ObjectInputStream oin = null; @@ -247,8 +237,7 @@ public class ResourceLeaks { } } - - //ZipFile tests (Jarfile Tests also test Zipfiles) + // ZipFile tests (Jarfile Tests also test Zipfiles) public static void zipFileLeakExceptionalBranch() throws IOException { ZipFile j = null; @@ -256,7 +245,7 @@ public class ResourceLeaks { j = new ZipFile(""); } catch (IOException e) { FileOutputStream fis = new FileOutputStream("file.txt"); - //The purpose of this is to cause a leak, from when ZipFile constructor throws + // The purpose of this is to cause a leak, from when ZipFile constructor throws } finally { if (j != null) j.close(); } @@ -271,7 +260,7 @@ public class ResourceLeaks { } } - //JarFile tests + // JarFile tests public boolean jarFileClosed() { JarFile jarFile = null; @@ -298,7 +287,7 @@ public class ResourceLeaks { return false; } - //FileInputStream tests + // FileInputStream tests public void fileInputStreamNotClosedAfterRead() { FileInputStream fis; @@ -310,7 +299,6 @@ public class ResourceLeaks { } } - public void fileInputStreamClosed() throws IOException { FileInputStream fis = null; try { @@ -322,7 +310,7 @@ public class ResourceLeaks { } } - //PipedInputStream tests + // PipedInputStream tests public void pipedInputStreamNotClosedAfterRead(PipedOutputStream pout) { PipedInputStream pin; @@ -334,7 +322,6 @@ public class ResourceLeaks { } } - public void pipedInputStreamClosed(PipedOutputStream pout) throws IOException { PipedInputStream pin = null; try { @@ -346,7 +333,7 @@ public class ResourceLeaks { } } - //PipedOutputStream tests + // PipedOutputStream tests public void pipedOutputStreamNotClosedAfterWrite() { byte[] arr = {1, 2, 3, 4, 5}; @@ -359,7 +346,6 @@ public class ResourceLeaks { } } - public void pipedOutputStreamClosed(PipedInputStream pin) throws IOException { PipedOutputStream pout = null; try { @@ -371,7 +357,7 @@ public class ResourceLeaks { } } - //ObjectOutputStream tests + // ObjectOutputStream tests public void objectOutputStreamNotClosedAfterWrite() { byte[] arr = {1, 2, 3, 4, 5}; @@ -384,7 +370,6 @@ public class ResourceLeaks { } } - public void objectOutputStreamClosed() throws IOException { ObjectOutputStream oout = null; FileOutputStream fis = new FileOutputStream("file.txt"); @@ -397,8 +382,7 @@ public class ResourceLeaks { } } - - //ObjectInputStream tests + // ObjectInputStream tests public void objectInputStreamNotClosedAfterRead() { ObjectInputStream oin; @@ -410,7 +394,6 @@ public class ResourceLeaks { } } - public void objectInputStreamClosed() throws IOException { ObjectInputStream oin = null; FileInputStream fis = new FileInputStream("file.txt"); @@ -439,8 +422,7 @@ public class ResourceLeaks { } } - - //JarInputStream tests + // JarInputStream tests public static void jarInputStreamNoLeak() throws IOException { FileInputStream fos = new FileInputStream(""); @@ -467,8 +449,7 @@ public class ResourceLeaks { g.close(); } - - //JarOutputStream tests + // JarOutputStream tests public static void jarOutputStreamNoLeak() throws IOException { FileOutputStream fos = new FileOutputStream(""); @@ -480,7 +461,6 @@ public class ResourceLeaks { } } - public static void jarOutputStreamLeak() throws IOException { FileOutputStream fos = new FileOutputStream(""); try { @@ -496,8 +476,7 @@ public class ResourceLeaks { g.close(); } - - //Socket tests + // Socket tests public void socketNotClosed() { Socket socket = new Socket(); @@ -508,8 +487,7 @@ public class ResourceLeaks { socket.close(); } - - //Socket InputStream tests + // Socket InputStream tests public int socketInputStreamNotClosed(Socket socket) throws IOException { InputStream stream = socket.getInputStream(); @@ -526,7 +504,7 @@ public class ResourceLeaks { socket.close(); } - //Socket OutputStream tests + // Socket OutputStream tests public void socketOutputStreamNotClosed(Socket socket) throws IOException { OutputStream stream = socket.getOutputStream(); @@ -543,15 +521,14 @@ public class ResourceLeaks { socket.close(); } - //ServerSocket tests + // ServerSocket tests public void serverSocketNotClosed() throws IOException { ServerSocket listener = new ServerSocket(9090); while (true) { Socket socket = listener.accept(); try { - PrintWriter out = - new PrintWriter(socket.getOutputStream(), true); + PrintWriter out = new PrintWriter(socket.getOutputStream(), true); out.println(""); } finally { socket.close(); @@ -571,8 +548,7 @@ public class ResourceLeaks { while (true) { Socket socket = listener.accept(); try { - PrintWriter out = - new PrintWriter(socket.getOutputStream(), true); + PrintWriter out = new PrintWriter(socket.getOutputStream(), true); out.println(""); } finally { socket.close(); @@ -583,7 +559,7 @@ public class ResourceLeaks { } } - //HttpURLConnection + // HttpURLConnection public void openHttpURLConnectionDisconnected() throws IOException { String content = "TEXT"; @@ -677,7 +653,7 @@ public class ResourceLeaks { public void closeWithCloseablesNestedAlloc() throws IOException { BufferedInputStream b = null; try { - b = new BufferedInputStream(new FileInputStream("file.txt")); + b = new BufferedInputStream(new FileInputStream("file.txt")); } finally { myClose(b, false); } @@ -726,17 +702,13 @@ public class ResourceLeaks { // parser does not own a resource which is leaked } - private void ignore(Object o) { - } - + private void ignore(Object o) {} // Installation.java examples. Even the fix was a fp for a while // for several reasons, so this test is just to make sure it remains // banished forever - - private String readInstallationFileGood(File installation) - throws IOException { + private String readInstallationFileGood(File installation) throws IOException { RandomAccessFile f = new RandomAccessFile(installation, "r"); try { byte[] bytes = new byte[(int) f.length()]; @@ -747,8 +719,7 @@ public class ResourceLeaks { } } - private String readInstallationFileBad(File installation) - throws IOException { + private String readInstallationFileBad(File installation) throws IOException { RandomAccessFile f = new RandomAccessFile(installation, "r"); byte[] bytes = new byte[(int) f.length()]; f.readFully(bytes); @@ -794,35 +765,35 @@ public class ResourceLeaks { // TypedArray public void themeObtainTypedArrayAndRecycle(Resources.Theme theme) { - TypedArray array = theme.obtainStyledAttributes(new int[]{}); + TypedArray array = theme.obtainStyledAttributes(new int[] {}); ignore(array); array.recycle(); } public void themeObtainTypedArrayAndLeak(Resources.Theme theme) { - TypedArray array = theme.obtainStyledAttributes(new int[]{}); + TypedArray array = theme.obtainStyledAttributes(new int[] {}); ignore(array); } public void activityObtainTypedArrayAndRecycle(Activity activity) { - TypedArray array = activity.obtainStyledAttributes(new int[]{}); + TypedArray array = activity.obtainStyledAttributes(new int[] {}); ignore(array); array.recycle(); } public void activityObtainTypedArrayAndLeak(Activity activity) { - TypedArray array = activity.obtainStyledAttributes(new int[]{}); + TypedArray array = activity.obtainStyledAttributes(new int[] {}); ignore(array); } public void contextObtainTypedArrayAndRecycle(Context context) { - TypedArray array = context.obtainStyledAttributes(new int[]{}); + TypedArray array = context.obtainStyledAttributes(new int[] {}); ignore(array); array.recycle(); } public void contextObtainTypedArrayAndLeak(Context context) { - TypedArray array = context.obtainStyledAttributes(new int[]{}); + TypedArray array = context.obtainStyledAttributes(new int[] {}); ignore(array); } @@ -834,10 +805,8 @@ public class ResourceLeaks { try { inChannel.transferTo(0, inChannel.size(), outChannel); } finally { - if (inChannel != null) - inChannel.close(); - if (outChannel != null) - outChannel.close(); + if (inChannel != null) inChannel.close(); + if (outChannel != null) outChannel.close(); } } @@ -933,9 +902,7 @@ public class ResourceLeaks { public InputStreamReader withCharset(URLConnection urlConnection) { InputStreamReader reader = null; try { - reader = new InputStreamReader( - urlConnection.getInputStream(), - "iso-8859-1"); + reader = new InputStreamReader(urlConnection.getInputStream(), "iso-8859-1"); } catch (Exception e) { return null; } finally { @@ -980,5 +947,4 @@ public class ResourceLeaks { Preconditions.checkState(x > 0); stream.close(); } - } diff --git a/infer/tests/codetoanalyze/java/infer/ReturnValueIgnored.java b/infer/tests/codetoanalyze/java/infer/ReturnValueIgnored.java index 9d3f16485..44c7122fc 100644 --- a/infer/tests/codetoanalyze/java/infer/ReturnValueIgnored.java +++ b/infer/tests/codetoanalyze/java/infer/ReturnValueIgnored.java @@ -7,7 +7,6 @@ package codetoanalyze.java.infer; - public class ReturnValueIgnored { private int m() { @@ -17,5 +16,4 @@ public class ReturnValueIgnored { public void returnValueIgnored() { m(); } - } diff --git a/infer/tests/codetoanalyze/java/infer/SkippedSourceFile.java b/infer/tests/codetoanalyze/java/infer/SkippedSourceFile.java index a36b47cca..2b10919ab 100644 --- a/infer/tests/codetoanalyze/java/infer/SkippedSourceFile.java +++ b/infer/tests/codetoanalyze/java/infer/SkippedSourceFile.java @@ -9,11 +9,9 @@ package codetoanalyze.java.infer; - public class SkippedSourceFile { static Object createdBySkippedFile() { return null; } - } diff --git a/infer/tests/codetoanalyze/java/infer/SomeLibrary.java b/infer/tests/codetoanalyze/java/infer/SomeLibrary.java index 1417320fe..2b3dda65b 100644 --- a/infer/tests/codetoanalyze/java/infer/SomeLibrary.java +++ b/infer/tests/codetoanalyze/java/infer/SomeLibrary.java @@ -16,5 +16,4 @@ public class SomeLibrary { T get() { return t == null ? null : t; } - } diff --git a/infer/tests/codetoanalyze/java/infer/SuppressLintExample.java b/infer/tests/codetoanalyze/java/infer/SuppressLintExample.java index a42acf789..50af88f79 100644 --- a/infer/tests/codetoanalyze/java/infer/SuppressLintExample.java +++ b/infer/tests/codetoanalyze/java/infer/SuppressLintExample.java @@ -8,11 +8,9 @@ package codetoanalyze.java.infer; import com.facebook.infer.annotation.SuppressLint; - -import java.io.IOException; import java.io.File; import java.io.FileInputStream; - +import java.io.IOException; // @SuppressLint("Suppressing all the warnings in a class is not supported yet") class SuppressAllWarnigsInTheClass { @@ -25,9 +23,9 @@ class SuppressAllWarnigsInTheClass { void shouldNotReportResourceLeak() { try { FileInputStream fis = new FileInputStream(new File("whatever.txt")); - } catch (IOException e) {} + } catch (IOException e) { + } } - } public class SuppressLintExample { @@ -48,5 +46,4 @@ public class SuppressLintExample { Object object = null; object.toString(); } - } diff --git a/infer/tests/codetoanalyze/java/infer/T.java b/infer/tests/codetoanalyze/java/infer/T.java index 257650c4c..46fcc4dcb 100644 --- a/infer/tests/codetoanalyze/java/infer/T.java +++ b/infer/tests/codetoanalyze/java/infer/T.java @@ -10,6 +10,5 @@ package codetoanalyze.java.infer; public class T { int x; - void f() { - } + void f() {} } diff --git a/infer/tests/codetoanalyze/java/infer/Utils.java b/infer/tests/codetoanalyze/java/infer/Utils.java index c35dec797..d8a2c62e2 100644 --- a/infer/tests/codetoanalyze/java/infer/Utils.java +++ b/infer/tests/codetoanalyze/java/infer/Utils.java @@ -11,13 +11,12 @@ import java.io.Closeable; public class Utils { - public static void closeQuietly(Closeable closeable) { - try { - if (closeable != null) { - closeable.close(); - } - } catch (Exception ex) { + public static void closeQuietly(Closeable closeable) { + try { + if (closeable != null) { + closeable.close(); } + } catch (Exception ex) { } - + } } diff --git a/infer/tests/codetoanalyze/java/infer/WriterLeaks.java b/infer/tests/codetoanalyze/java/infer/WriterLeaks.java index 56642fc04..1b56e68fe 100644 --- a/infer/tests/codetoanalyze/java/infer/WriterLeaks.java +++ b/infer/tests/codetoanalyze/java/infer/WriterLeaks.java @@ -5,10 +5,8 @@ * LICENSE file in the root directory of this source tree. */ - package codetoanalyze.java.infer; - import java.io.BufferedWriter; import java.io.FileOutputStream; import java.io.FileWriter; @@ -21,7 +19,7 @@ import java.io.Writer; public class WriterLeaks { - //Writer tests + // Writer tests public void writerNotClosedAfterWrite() { Writer writer; @@ -33,7 +31,6 @@ public class WriterLeaks { } } - public void writerClosed() throws IOException { Writer writer = null; try { @@ -41,12 +38,11 @@ public class WriterLeaks { writer.write(10); } catch (IOException e) { } finally { - if (writer != null) - writer.close(); + if (writer != null) writer.close(); } } - //PrintWriter tests + // PrintWriter tests public void printWriterNotClosedAfterAppend() { PrintWriter writer; @@ -58,7 +54,6 @@ public class WriterLeaks { } } - public void printWriterClosed() throws IOException { PrintWriter writer = null; try { @@ -66,12 +61,11 @@ public class WriterLeaks { writer = writer.append(null); } catch (IOException e) { } finally { - if (writer != null) - writer.close(); + if (writer != null) writer.close(); } } - //BufferedWriter tests + // BufferedWriter tests public void bufferedWriterNotClosedAfterWrite() { BufferedWriter writer; @@ -84,7 +78,6 @@ public class WriterLeaks { } } - public void bufferedWriterClosed() throws IOException { BufferedWriter writer = null; try { @@ -93,12 +86,11 @@ public class WriterLeaks { writer.flush(); } catch (IOException e) { } finally { - if (writer != null) - writer.close(); + if (writer != null) writer.close(); } } - //OutputStreamWriter tests + // OutputStreamWriter tests public void outputStreamWriterNotClosedAfterWrite() { OutputStreamWriter writer; @@ -110,7 +102,6 @@ public class WriterLeaks { } } - public void outputStreamWriterClosed() throws IOException { OutputStreamWriter writer = null; try { @@ -118,12 +109,11 @@ public class WriterLeaks { writer.write(10); } catch (IOException e) { } finally { - if (writer != null) - writer.close(); + if (writer != null) writer.close(); } } - //FileWriter tests + // FileWriter tests public void fileWriterNotClosedAfterWrite() { FileWriter writer; @@ -135,7 +125,6 @@ public class WriterLeaks { } } - public void fileWriterClosed() throws IOException { FileWriter writer = null; try { @@ -143,12 +132,11 @@ public class WriterLeaks { writer.write(10); } catch (IOException e) { } finally { - if (writer != null) - writer.close(); + if (writer != null) writer.close(); } } - //PipedWriter tests + // PipedWriter tests public void pipedWriterNotClosedAfterConstructedWithReader() { PipedWriter writer; @@ -190,9 +178,7 @@ public class WriterLeaks { writer.write(42); } catch (IOException e) { } finally { - if (writer != null) - writer.close(); + if (writer != null) writer.close(); } } - } diff --git a/infer/tests/codetoanalyze/java/infer/issues.exp b/infer/tests/codetoanalyze/java/infer/issues.exp index edf6bd6c1..c9739bfe6 100644 --- a/infer/tests/codetoanalyze/java/infer/issues.exp +++ b/infer/tests/codetoanalyze/java/infer/issues.exp @@ -30,15 +30,15 @@ codetoanalyze/java/infer/CloseableAsResourceExample.java, codetoanalyze.java.inf codetoanalyze/java/infer/CloseableAsResourceExample.java, codetoanalyze.java.infer.CloseableAsResourceExample.sourceOfNullWithResourceLeak():codetoanalyze.java.infer.T, 1, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure sourceOfNullWithResourceLeak(),start of procedure SomeResource(),return from a call to SomeResource.()] codetoanalyze/java/infer/CloseableAsResourceExample.java, codetoanalyze.java.infer.CloseableAsResourceExample.withException():void, 4, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure withException(),start of procedure SomeResource(),return from a call to SomeResource.(),start of procedure doSomething(),Skipping star(): method has no implementation,Definition of star(),Taking true branch,start of procedure LocalException(),return from a call to LocalException.(),exception codetoanalyze.java.infer.LocalException,return from a call to void SomeResource.doSomething()] codetoanalyze/java/infer/CursorLeaks.java, codetoanalyze.java.infer.CursorLeaks.completeDownloadNotClosed(android.app.DownloadManager):int, 8, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure completeDownloadNotClosed(...),Taking false branch,Skipping getColumnIndex(...): unknown method] -codetoanalyze/java/infer/CursorLeaks.java, codetoanalyze.java.infer.CursorLeaks.cursorClosedCheckNullCheckClosed_FP(android.database.sqlite.SQLiteDatabase):java.lang.Object, 13, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure cursorClosedCheckNullCheckClosed_FP(...),Taking false branch,Skipping getString(...): unknown method,Taking true branch,Taking false branch] -codetoanalyze/java/infer/CursorLeaks.java, codetoanalyze.java.infer.CursorLeaks.cursorNotClosed(android.database.sqlite.SQLiteDatabase):int, 4, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure cursorNotClosed(...),Skipping getCount(): unknown method] -codetoanalyze/java/infer/CursorLeaks.java, codetoanalyze.java.infer.CursorLeaks.getBucketCountNotClosed():int, 10, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure getBucketCountNotClosed(),Taking false branch,Taking false branch] -codetoanalyze/java/infer/CursorLeaks.java, codetoanalyze.java.infer.CursorLeaks.getImageCountHelperNotClosed(java.lang.String):int, 13, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure getImageCountHelperNotClosed(...),Taking true branch,Skipping getInt(...): unknown method] -codetoanalyze/java/infer/CursorLeaks.java, codetoanalyze.java.infer.CursorLeaks.loadPrefsFromContentProviderNotClosed():void, 11, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure loadPrefsFromContentProviderNotClosed(),Taking false branch,Taking true branch] +codetoanalyze/java/infer/CursorLeaks.java, codetoanalyze.java.infer.CursorLeaks.cursorClosedCheckNullCheckClosed_FP(android.database.sqlite.SQLiteDatabase):java.lang.Object, 11, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure cursorClosedCheckNullCheckClosed_FP(...),Taking false branch,Skipping getString(...): unknown method,Taking true branch,Taking false branch] +codetoanalyze/java/infer/CursorLeaks.java, codetoanalyze.java.infer.CursorLeaks.cursorNotClosed(android.database.sqlite.SQLiteDatabase):int, 2, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure cursorNotClosed(...),Skipping getCount(): unknown method] +codetoanalyze/java/infer/CursorLeaks.java, codetoanalyze.java.infer.CursorLeaks.getBucketCountNotClosed():int, 9, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure getBucketCountNotClosed(),Taking false branch,Taking false branch] +codetoanalyze/java/infer/CursorLeaks.java, codetoanalyze.java.infer.CursorLeaks.getImageCountHelperNotClosed(java.lang.String):int, 9, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure getImageCountHelperNotClosed(...),Taking true branch,Skipping getInt(...): unknown method] +codetoanalyze/java/infer/CursorLeaks.java, codetoanalyze.java.infer.CursorLeaks.loadPrefsFromContentProviderNotClosed():void, 10, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure loadPrefsFromContentProviderNotClosed(),Taking false branch,Taking true branch] codetoanalyze/java/infer/CursorLeaks.java, codetoanalyze.java.infer.CursorLeaks.queryUVMLegacyDbNotClosed():void, 4, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure queryUVMLegacyDbNotClosed(),Skipping setTables(...): unknown method,Taking true branch] -codetoanalyze/java/infer/CursorNPEs.java, codetoanalyze.java.infer.CursorNPEs.cursorFromContentResolverNPE(java.lang.String):void, 12, NULL_DEREFERENCE, B1, ERROR, [start of procedure cursorFromContentResolverNPE(...)] +codetoanalyze/java/infer/CursorNPEs.java, codetoanalyze.java.infer.CursorNPEs.cursorFromContentResolverNPE(java.lang.String):void, 8, NULL_DEREFERENCE, B1, ERROR, [start of procedure cursorFromContentResolverNPE(...)] codetoanalyze/java/infer/CursorNPEs.java, codetoanalyze.java.infer.CursorNPEs.cursorFromDownloadManagerNPE(android.app.DownloadManager):int, 5, NULL_DEREFERENCE, B2, ERROR, [start of procedure cursorFromDownloadManagerNPE(...)] -codetoanalyze/java/infer/CursorNPEs.java, codetoanalyze.java.infer.CursorNPEs.cursorFromMediaNPE():void, 3, NULL_DEREFERENCE, B1, ERROR, [start of procedure cursorFromMediaNPE()] +codetoanalyze/java/infer/CursorNPEs.java, codetoanalyze.java.infer.CursorNPEs.cursorFromMediaNPE():void, 2, NULL_DEREFERENCE, B1, ERROR, [start of procedure cursorFromMediaNPE()] codetoanalyze/java/infer/DivideByZero.java, codetoanalyze.java.infer.DivideByZero.callDivideByZeroInterProc():int, 1, DIVIDE_BY_ZERO, no_bucket, ERROR, [start of procedure callDivideByZeroInterProc(),start of procedure divideByZeroInterProc(...)] codetoanalyze/java/infer/DivideByZero.java, codetoanalyze.java.infer.DivideByZero.divByZeroLocal(java.lang.String):int, 3, DIVIDE_BY_ZERO, no_bucket, ERROR, [start of procedure divByZeroLocal(...)] codetoanalyze/java/infer/DivideByZero.java, codetoanalyze.java.infer.DivideByZero.divideByZeroWithStaticField():int, 2, DIVIDE_BY_ZERO, no_bucket, ERROR, [start of procedure divideByZeroWithStaticField(),start of procedure setXToZero(),return from a call to void DivideByZero.setXToZero(),start of procedure divideByZeroInterProc(...)] @@ -95,9 +95,9 @@ codetoanalyze/java/infer/HashMapExample.java, codetoanalyze.java.infer.HashMapEx codetoanalyze/java/infer/HashMapExample.java, codetoanalyze.java.infer.HashMapExample.getAfterRemovingTheKeyBad():void, 5, NULL_DEREFERENCE, B1, ERROR, [start of procedure getAfterRemovingTheKeyBad()] codetoanalyze/java/infer/HashMapExample.java, codetoanalyze.java.infer.HashMapExample.getFromKeySetGood_FP(java.util.HashMap):void, 3, NULL_DEREFERENCE, B2, ERROR, [start of procedure getFromKeySetGood_FP(...),Taking true branch] codetoanalyze/java/infer/HashMapExample.java, codetoanalyze.java.infer.HashMapExample.getOneIntegerWithoutCheck():int, 6, NULL_DEREFERENCE, B1, ERROR, [start of procedure getOneIntegerWithoutCheck()] -codetoanalyze/java/infer/HashMapExample.java, codetoanalyze.java.infer.HashMapExample.getTwoIntegersWithOneCheck(java.lang.Integer,java.lang.Integer):void, 11, NULL_DEREFERENCE, B2, ERROR, [start of procedure getTwoIntegersWithOneCheck(...),Taking true branch,Taking true branch] +codetoanalyze/java/infer/HashMapExample.java, codetoanalyze.java.infer.HashMapExample.getTwoIntegersWithOneCheck(java.lang.Integer,java.lang.Integer):void, 8, NULL_DEREFERENCE, B2, ERROR, [start of procedure getTwoIntegersWithOneCheck(...),Taking true branch,Taking true branch] codetoanalyze/java/infer/IntegerExample.java, codetoanalyze.java.infer.IntegerExample.testIntegerEqualsBad():void, 6, NULL_DEREFERENCE, B1, ERROR, [start of procedure testIntegerEqualsBad(),Taking true branch] -codetoanalyze/java/infer/InvokeDynamic.java, codetoanalyze.java.infer.InvokeDynamic.invokeDynamicThenNpeBad(java.util.List):void, 5, NULL_DEREFERENCE, B1, ERROR, [start of procedure invokeDynamicThenNpeBad(...),Skipping sort(...): unknown method] +codetoanalyze/java/infer/InvokeDynamic.java, codetoanalyze.java.infer.InvokeDynamic.invokeDynamicThenNpeBad(java.util.List):void, 7, NULL_DEREFERENCE, B1, ERROR, [start of procedure invokeDynamicThenNpeBad(...),Skipping sort(...): unknown method] codetoanalyze/java/infer/InvokeDynamic.java, codetoanalyze.java.infer.InvokeDynamic.lambda$npeInLambdaBad$1(java.lang.String,java.lang.String):int, 1, NULL_DEREFERENCE, B1, ERROR, [start of procedure lambda$npeInLambdaBad$1(...)] codetoanalyze/java/infer/JunitAssertion.java, codetoanalyze.java.infer.JunitAssertion.consistentAssertion(codetoanalyze.java.infer.JunitAssertion$A):void, 1, PRECONDITION_NOT_MET, no_bucket, WARNING, [start of procedure consistentAssertion(...),Taking false branch] codetoanalyze/java/infer/JunitAssertion.java, codetoanalyze.java.infer.JunitAssertion.inconsistentAssertion(codetoanalyze.java.infer.JunitAssertion$A):void, 2, NULL_DEREFERENCE, B5, ERROR, [start of procedure inconsistentAssertion(...),Taking false branch] @@ -110,7 +110,7 @@ codetoanalyze/java/infer/NullPointerExceptions.java, codetoanalyze.java.infer.Nu codetoanalyze/java/infer/NullPointerExceptions.java, codetoanalyze.java.infer.NullPointerExceptions.NPEvalueOfFromHashmapBad(java.util.HashMap,int):int, 1, NULL_DEREFERENCE, B2, ERROR, [start of procedure NPEvalueOfFromHashmapBad(...)] codetoanalyze/java/infer/NullPointerExceptions.java, codetoanalyze.java.infer.NullPointerExceptions.addNullToImmutableListBuilderBad():void, 2, NULL_DEREFERENCE, B1, ERROR, [start of procedure addNullToImmutableListBuilderBad(),Skipping builder(): unknown method,start of procedure getObject(),return from a call to Object NullPointerExceptions.getObject()] codetoanalyze/java/infer/NullPointerExceptions.java, codetoanalyze.java.infer.NullPointerExceptions.badCheckShouldCauseNPE():void, 1, NULL_DEREFERENCE, B1, ERROR, [start of procedure badCheckShouldCauseNPE(),start of procedure getBool(),Skipping test(): method has no implementation,Definition of test(),Taking true branch,return from a call to Boolean NullPointerExceptions.getBool(),Taking true branch,start of procedure getObj(),Skipping test(): method has no implementation,Definition of test(),Taking false branch,return from a call to Object NullPointerExceptions.getObj()] -codetoanalyze/java/infer/NullPointerExceptions.java, codetoanalyze.java.infer.NullPointerExceptions.cursorFromContentResolverNPE(java.lang.String):void, 9, NULL_DEREFERENCE, B1, ERROR, [start of procedure cursorFromContentResolverNPE(...)] +codetoanalyze/java/infer/NullPointerExceptions.java, codetoanalyze.java.infer.NullPointerExceptions.cursorFromContentResolverNPE(java.lang.String):void, 5, NULL_DEREFERENCE, B1, ERROR, [start of procedure cursorFromContentResolverNPE(...)] codetoanalyze/java/infer/NullPointerExceptions.java, codetoanalyze.java.infer.NullPointerExceptions.deferenceNullableMethodCallingSkippedMethodBad():void, 1, NULL_DEREFERENCE, B1, ERROR, [start of procedure deferenceNullableMethodCallingSkippedMethodBad(),start of procedure wrapUnknownFuncWithNullable(),Skipping unknownFunc(): method has no implementation,Definition of unknownFunc(),return from a call to Object NullPointerExceptions.wrapUnknownFuncWithNullable()] codetoanalyze/java/infer/NullPointerExceptions.java, codetoanalyze.java.infer.NullPointerExceptions.derefNull():void, 2, NULL_DEREFERENCE, B1, ERROR, [start of procedure derefNull(),start of procedure derefUndefinedCallee(),start of procedure retUndefined(),return from a call to Object NullPointerExceptions.retUndefined(),Skipping toString(): unknown method,return from a call to Object NullPointerExceptions.derefUndefinedCallee()] codetoanalyze/java/infer/NullPointerExceptions.java, codetoanalyze.java.infer.NullPointerExceptions.derefNullableGetter():void, 2, NULL_DEREFERENCE, B1, ERROR, [start of procedure derefNullableGetter(),start of procedure nullableGetter(),return from a call to Object NullPointerExceptions.nullableGetter()] @@ -158,8 +158,8 @@ codetoanalyze/java/infer/ReaderLeaks.java, codetoanalyze.java.infer.ReaderLeaks. codetoanalyze/java/infer/ResourceLeaks.java, codetoanalyze.java.infer.ResourceLeaks.NoResourceLeakWarningAfterCheckState(java.io.File,int):void, 2, PRECONDITION_NOT_MET, no_bucket, WARNING, [start of procedure NoResourceLeakWarningAfterCheckState(...),Taking false branch] codetoanalyze/java/infer/ResourceLeaks.java, codetoanalyze.java.infer.ResourceLeaks.activityObtainTypedArrayAndLeak(android.app.Activity):void, 2, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure activityObtainTypedArrayAndLeak(...),start of procedure ignore(...),return from a call to void ResourceLeaks.ignore(TypedArray)] codetoanalyze/java/infer/ResourceLeaks.java, codetoanalyze.java.infer.ResourceLeaks.contextObtainTypedArrayAndLeak(android.content.Context):void, 2, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure contextObtainTypedArrayAndLeak(...),start of procedure ignore(...),return from a call to void ResourceLeaks.ignore(TypedArray)] -codetoanalyze/java/infer/ResourceLeaks.java, codetoanalyze.java.infer.ResourceLeaks.copyFileLeak(java.io.File,java.io.File):void, 11, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure copyFileLeak(...),Skipping transferTo(...): unknown method,Taking true branch,exception java.io.IOException] -codetoanalyze/java/infer/ResourceLeaks.java, codetoanalyze.java.infer.ResourceLeaks.copyFileLeak(java.io.File,java.io.File):void, 11, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure copyFileLeak(...),exception java.io.FileNotFoundException] +codetoanalyze/java/infer/ResourceLeaks.java, codetoanalyze.java.infer.ResourceLeaks.copyFileLeak(java.io.File,java.io.File):void, 9, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure copyFileLeak(...),Skipping transferTo(...): unknown method,Taking true branch,exception java.io.IOException] +codetoanalyze/java/infer/ResourceLeaks.java, codetoanalyze.java.infer.ResourceLeaks.copyFileLeak(java.io.File,java.io.File):void, 9, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure copyFileLeak(...),exception java.io.FileNotFoundException] codetoanalyze/java/infer/ResourceLeaks.java, codetoanalyze.java.infer.ResourceLeaks.deflaterLeak():void, 1, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure deflaterLeak()] codetoanalyze/java/infer/ResourceLeaks.java, codetoanalyze.java.infer.ResourceLeaks.fileInputStreamNotClosedAfterRead():void, 6, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure fileInputStreamNotClosedAfterRead(),exception java.io.IOException] codetoanalyze/java/infer/ResourceLeaks.java, codetoanalyze.java.infer.ResourceLeaks.fileOutputStreamNotClosed():void, 1, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure fileOutputStreamNotClosed()] @@ -190,9 +190,9 @@ codetoanalyze/java/infer/ResourceLeaks.java, codetoanalyze.java.infer.ResourceLe codetoanalyze/java/infer/ResourceLeaks.java, codetoanalyze.java.infer.ResourceLeaks.pipedInputStreamNotClosedAfterRead(java.io.PipedOutputStream):void, 6, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure pipedInputStreamNotClosedAfterRead(...),exception java.io.IOException] codetoanalyze/java/infer/ResourceLeaks.java, codetoanalyze.java.infer.ResourceLeaks.pipedOutputStreamNotClosedAfterWrite():void, 7, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure pipedOutputStreamNotClosedAfterWrite(),exception java.io.IOException] codetoanalyze/java/infer/ResourceLeaks.java, codetoanalyze.java.infer.ResourceLeaks.readConfigNotCloseStream(java.lang.String):int, 5, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure readConfigNotCloseStream(...)] -codetoanalyze/java/infer/ResourceLeaks.java, codetoanalyze.java.infer.ResourceLeaks.readInstallationFileBad(java.io.File):java.lang.String, 6, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure readInstallationFileBad(...),exception java.io.IOException] +codetoanalyze/java/infer/ResourceLeaks.java, codetoanalyze.java.infer.ResourceLeaks.readInstallationFileBad(java.io.File):java.lang.String, 5, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure readInstallationFileBad(...),exception java.io.IOException] codetoanalyze/java/infer/ResourceLeaks.java, codetoanalyze.java.infer.ResourceLeaks.scannerNotClosed():void, 1, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure scannerNotClosed()] -codetoanalyze/java/infer/ResourceLeaks.java, codetoanalyze.java.infer.ResourceLeaks.serverSocketNotClosed():void, 12, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure serverSocketNotClosed(),Skipping ServerSocket(...): unknown method,exception java.io.IOException] +codetoanalyze/java/infer/ResourceLeaks.java, codetoanalyze.java.infer.ResourceLeaks.serverSocketNotClosed():void, 11, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure serverSocketNotClosed(),Skipping ServerSocket(...): unknown method,exception java.io.IOException] codetoanalyze/java/infer/ResourceLeaks.java, codetoanalyze.java.infer.ResourceLeaks.socketNotClosed():void, 1, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure socketNotClosed()] codetoanalyze/java/infer/ResourceLeaks.java, codetoanalyze.java.infer.ResourceLeaks.themeObtainTypedArrayAndLeak(android.content.res.Resources$Theme):void, 2, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure themeObtainTypedArrayAndLeak(...),start of procedure ignore(...),return from a call to void ResourceLeaks.ignore(TypedArray)] codetoanalyze/java/infer/ResourceLeaks.java, codetoanalyze.java.infer.ResourceLeaks.twoResources():void, 11, RESOURCE_LEAK, no_bucket, ERROR, [start of procedure twoResources(),Taking true branch,exception java.io.IOException] diff --git a/infer/tests/codetoanalyze/java/lab/Leaks.java b/infer/tests/codetoanalyze/java/lab/Leaks.java index bc2bcca7c..d1673ad1d 100644 --- a/infer/tests/codetoanalyze/java/lab/Leaks.java +++ b/infer/tests/codetoanalyze/java/lab/Leaks.java @@ -39,5 +39,4 @@ public class Leaks { stream1.close(); stream2.close(); } - } diff --git a/infer/tests/codetoanalyze/java/litho/RequiredProps.java b/infer/tests/codetoanalyze/java/litho/RequiredProps.java index 0d2e9efc1..fd1bb5336 100644 --- a/infer/tests/codetoanalyze/java/litho/RequiredProps.java +++ b/infer/tests/codetoanalyze/java/litho/RequiredProps.java @@ -19,16 +19,16 @@ enum ResType { NONE } -@Target({ ElementType.PARAMETER, ElementType.FIELD }) +@Target({ElementType.PARAMETER, ElementType.FIELD}) @Retention(RetentionPolicy.CLASS) @interface Prop { ResType resType() default ResType.NONE; + boolean optional() default false; } class MyComponent extends Component { - @Prop - Object prop1; // implicitly non-optional + @Prop Object prop1; // implicitly non-optional @Prop(optional = true) Object prop2; // explicitly optional @@ -63,13 +63,12 @@ class MyComponent extends Component { public MyComponent build() { return mMyComponent; } - } - } -/** using @Prop(resType = ..) allows you to set the Prop with any of .propname, - * .propnameRes, or .propnameAttr +/** + * using @Prop(resType = ..) allows you to set the Prop with any of .propname, .propnameRes, or + * .propnameAttr */ class ResPropComponent extends Component { @@ -102,9 +101,7 @@ class ResPropComponent extends Component { public ResPropComponent build() { return mResPropComponent; } - } - } public class RequiredProps { @@ -113,8 +110,7 @@ public class RequiredProps { public ResPropComponent mResPropComponent; public MyComponent buildWithAllOk() { - return - mMyComponent + return mMyComponent .create() .prop1(new Object()) .prop2(new Object()) @@ -124,32 +120,17 @@ public class RequiredProps { // prop 2 is optional public MyComponent buildWithout2Ok() { - return - mMyComponent - .create() - .prop1(new Object()) - .prop3(new Object()) - .build(); + return mMyComponent.create().prop1(new Object()).prop3(new Object()).build(); } // prop 1 is required public MyComponent buildWithout1Bad() { - return - mMyComponent - .create() - .prop2(new Object()) - .prop3(new Object()) - .build(); + return mMyComponent.create().prop2(new Object()).prop3(new Object()).build(); } // prop3 is required public MyComponent buildWithout3Bad() { - return - mMyComponent - .create() - .prop1(new Object()) - .prop2(new Object()) - .build(); + return mMyComponent.create().prop1(new Object()).prop2(new Object()).build(); } private static MyComponent.Builder setProp1(MyComponent.Builder builder) { @@ -161,30 +142,15 @@ public class RequiredProps { } public MyComponent setProp1InCalleeOk() { - return - setProp1( - mMyComponent - .create() - .prop2(new Object())) - .prop3(new Object()) - .build(); + return setProp1(mMyComponent.create().prop2(new Object())).prop3(new Object()).build(); } public MyComponent setProp3InCalleeOk() { - return - setProp3( - mMyComponent - .create() - .prop1(new Object()) - .prop2(new Object())) - .build(); + return setProp3(mMyComponent.create().prop1(new Object()).prop2(new Object())).build(); } public MyComponent setProp3InCalleeButForgetProp1Bad() { - return - setProp3(mMyComponent.create()) - .prop2(new Object()) - .build(); + return setProp3(mMyComponent.create()).prop2(new Object()).build(); } public MyComponent setRequiredOnOneBranchBad(boolean b) { @@ -230,37 +196,24 @@ public class RequiredProps { public void buildWithColumnChildBad() { Column.Builder builder = Column.create(); - MyComponent.Builder childBuilder = - mMyComponent.create().prop1(new Object()); + MyComponent.Builder childBuilder = mMyComponent.create().prop1(new Object()); // forgot prop 3, and builder.child() will invoke build() on childBuilder builder.child(childBuilder); } public void buildPropResWithNormalOk() { - mResPropComponent - .create() - .prop(new Object()) - .build(); + mResPropComponent.create().prop(new Object()).build(); } public void buildPropResWithResOk() { - mResPropComponent - .create() - .propRes(new Object()) - .build(); + mResPropComponent.create().propRes(new Object()).build(); } public void buildPropResWithAttrOk() { - mResPropComponent - .create() - .propAttr(new Object()) - .build(); + mResPropComponent.create().propAttr(new Object()).build(); } public void buildPropResMissingBad() { - mResPropComponent - .create() - .build(); + mResPropComponent.create().build(); } - } diff --git a/infer/tests/codetoanalyze/java/litho/ShouldUpdate.java b/infer/tests/codetoanalyze/java/litho/ShouldUpdate.java index 60b717b0f..10de2e23c 100644 --- a/infer/tests/codetoanalyze/java/litho/ShouldUpdate.java +++ b/infer/tests/codetoanalyze/java/litho/ShouldUpdate.java @@ -11,7 +11,9 @@ import java.util.List; abstract class A { abstract A getA(); + abstract B getB(); + abstract C getC(); } @@ -28,27 +30,25 @@ class D {} abstract class GraphQLStory { public abstract List getActors(); - } class LithoTest { - void /*basic chain*/onCreateLayout(A a) { + void /*basic chain*/ onCreateLayout(A a) { a.getB().getC().getD(); } - void /*sibling chain*/onCreateLayout(A a, int i) { + void /*sibling chain*/ onCreateLayout(A a, int i) { a.getB().getC().getD(); a.getC().getD(); } - void /*split chain*/onCreateLayout(A a, int i1, int i2) { - B b = a.getB(); + void /*split chain*/ onCreateLayout(A a, int i1, int i2) { + B b = a.getB(); C c = b.getC(); c.getD(); } - void chainFromActual1(B b) { b.getC().getD(); } @@ -57,11 +57,11 @@ class LithoTest { c.getD(); } - void /*chain rooted in actual*/onCreateLayout(A a, boolean b) { + void /*chain rooted in actual*/ onCreateLayout(A a, boolean b) { chainFromActual1(a.getB()); } - void /*local chain + interproc chain*/onCreateLayout(A a, char ch) { + void /*local chain + interproc chain*/ onCreateLayout(A a, char ch) { C c = a.getB().getC(); chainFromActual2(c); } @@ -72,18 +72,18 @@ class LithoTest { return actors != null && actors.size() > 0 ? (GraphQLStory) actors.get(0) : null; } - void /*conditional getters on formal*/onCreateLayout(GraphQLStory story) { + void /*conditional getters on formal*/ onCreateLayout(GraphQLStory story) { getPrimaryActor(story).toString(); } - native static GraphQLStory getStory(); + static native GraphQLStory getStory(); - void /*conditional getters on local*/onCreateLayout() { + void /*conditional getters on local*/ onCreateLayout() { GraphQLStory story = getStory(); getPrimaryActor(story).toString(); } - void /*cycle*/onCreateLayout(A a, float f) { + void /*cycle*/ onCreateLayout(A a, float f) { a = a.getA(); } @@ -91,8 +91,7 @@ class LithoTest { a = a.getA(); } - void /*interprocedural cycle*/onCreateLayout(A a, double d) { + void /*interprocedural cycle*/ onCreateLayout(A a, double d) { cycle(a); } - } diff --git a/infer/tests/codetoanalyze/java/performance/Array.java b/infer/tests/codetoanalyze/java/performance/Array.java index a4ee808a9..54ada73cf 100644 --- a/infer/tests/codetoanalyze/java/performance/Array.java +++ b/infer/tests/codetoanalyze/java/performance/Array.java @@ -5,6 +5,7 @@ * LICENSE file in the root directory of this source tree. */ package codetoanalyze.java.performance; + public class Array { public void array_access_good() { diff --git a/infer/tests/codetoanalyze/java/performance/ArrayListTest.java b/infer/tests/codetoanalyze/java/performance/ArrayListTest.java index ae8e6fb49..4cc856b9b 100644 --- a/infer/tests/codetoanalyze/java/performance/ArrayListTest.java +++ b/infer/tests/codetoanalyze/java/performance/ArrayListTest.java @@ -5,7 +5,6 @@ * LICENSE file in the root directory of this source tree. */ -import java.util.List; import java.util.ArrayList; import java.util.Iterator; diff --git a/infer/tests/codetoanalyze/java/performance/Break.java b/infer/tests/codetoanalyze/java/performance/Break.java index fc0cad42b..8d0773b69 100644 --- a/infer/tests/codetoanalyze/java/performance/Break.java +++ b/infer/tests/codetoanalyze/java/performance/Break.java @@ -6,39 +6,34 @@ */ package codetoanalyze.java.performance; -public class Break{ -/* t is also in control variables but once we have invariant analysis, it shouldn't be */ -private static int break_loop(int p, int t){ -for (int i = 0; i < p; i++) { - // do something - if (t < 0) - break; - // do something -} - return 0; -} - - -/* calling break_loop with a negative t should give constant - cost. Currently, this doesn't work because parameters are removed - when computing the env size :( */ -private static int break_constant(int p) -{ - return break_loop(p, -1); -} +public class Break { + /* t is also in control variables but once we have invariant analysis, it shouldn't be */ + private static int break_loop(int p, int t) { + for (int i = 0; i < p; i++) { + // do something + if (t < 0) break; + // do something + } + return 0; + } + /* calling break_loop with a negative t should give constant + cost. Currently, this doesn't work because parameters are removed + when computing the env size :( */ + private static int break_constant(int p) { + return break_loop(p, -1); + } -private static void break_outer_loop_FN (int maxI, int maxJ){ - int i = 0 ; + private static void break_outer_loop_FN(int maxI, int maxJ) { + int i = 0; outerloop: while (i < maxI) { - int j = 0 ; + int j = 0; while (j < maxJ) { - if (i+j > 10) - break outerloop ; - j++ ; + if (i + j > 10) break outerloop; + j++; } - i++ ; - }} - + i++; + } + } } diff --git a/infer/tests/codetoanalyze/java/performance/CollectionTest.java b/infer/tests/codetoanalyze/java/performance/CollectionTest.java index 0a93bff41..c833ab570 100644 --- a/infer/tests/codetoanalyze/java/performance/CollectionTest.java +++ b/infer/tests/codetoanalyze/java/performance/CollectionTest.java @@ -6,7 +6,6 @@ */ import java.util.Collection; -import java.util.Iterator; import java.util.concurrent.ConcurrentLinkedQueue; public class CollectionTest { @@ -19,8 +18,7 @@ public class CollectionTest { void iterate_over_some_java_collection( ConcurrentLinkedQueue> mSubscribers) { - for (MyCollection list : mSubscribers) { - } + for (MyCollection list : mSubscribers) {} } // Expected |mSubscribers| * |list| but we get T diff --git a/infer/tests/codetoanalyze/java/performance/Compound_loop.java b/infer/tests/codetoanalyze/java/performance/Compound_loop.java index 2b0cfe02b..a3aa54713 100644 --- a/infer/tests/codetoanalyze/java/performance/Compound_loop.java +++ b/infer/tests/codetoanalyze/java/performance/Compound_loop.java @@ -6,38 +6,37 @@ */ package codetoanalyze.java.performance; -public class Compound_loop{ +public class Compound_loop { -/* while loop that contains && in the guard. It gives the correct bound */ -private static int compound_while(int m) { - int i = 0; - int j = 3 * i; - while (j == 0 && i < m) { - i++; + /* while loop that contains && in the guard. It gives the correct bound */ + private static int compound_while(int m) { + int i = 0; + int j = 3 * i; + while (j == 0 && i < m) { + i++; + } + return j; } - return j; -} -/* p should be in control vars */ -private static void while_and_or(int p) { - int i = 0; - while (p == 1 || (i < 30 && i >= 0)) { - i++; + /* p should be in control vars */ + private static void while_and_or(int p) { + int i = 0; + while (p == 1 || (i < 30 && i >= 0)) { + i++; + } } -} -// should be constant cost -int nested_while_and_or(int p) { - int i = 0; - int j = 3 * i; - while (p == 1 || (i < 30 && i >= 0)) { - while (p == 1 || (j < 5 && j >= 0)) { + // should be constant cost + int nested_while_and_or(int p) { + int i = 0; + int j = 3 * i; + while (p == 1 || (i < 30 && i >= 0)) { + while (p == 1 || (j < 5 && j >= 0)) { - return j; + return j; + } + i++; } - i++; + return j; } - return j; -} - } diff --git a/infer/tests/codetoanalyze/java/performance/Continue.java b/infer/tests/codetoanalyze/java/performance/Continue.java index 84a866596..c743a00e9 100644 --- a/infer/tests/codetoanalyze/java/performance/Continue.java +++ b/infer/tests/codetoanalyze/java/performance/Continue.java @@ -6,16 +6,14 @@ */ package codetoanalyze.java.performance; -public class Continue{ - int continue_outer_loop_FN () -{ - outer: - for (int i = 2; i < 1000; i++) { +public class Continue { + int continue_outer_loop_FN() { + outer: + for (int i = 2; i < 1000; i++) { for (int j = 2; j < i; j++) { - if (i % j == 0) - continue outer; - } + if (i % j == 0) continue outer; + } + } + return 0; } - return 0; -} } diff --git a/infer/tests/codetoanalyze/java/performance/Cost_test_deps.java b/infer/tests/codetoanalyze/java/performance/Cost_test_deps.java index c463eaea1..67e123b09 100644 --- a/infer/tests/codetoanalyze/java/performance/Cost_test_deps.java +++ b/infer/tests/codetoanalyze/java/performance/Cost_test_deps.java @@ -7,107 +7,103 @@ package codetoanalyze.java.performance; -public class Cost_test_deps{ +public class Cost_test_deps { - -// Loop's execution count doesn't depend on values of p,t,k -private static int loop_no_dep1(int k) { - int p = 0; - int t = 2 + k; - for (int i = 0; i < 100; i++) { - p++; + // Loop's execution count doesn't depend on values of p,t,k + private static int loop_no_dep1(int k) { + int p = 0; + int t = 2 + k; + for (int i = 0; i < 100; i++) { + p++; + } + return p; } - return p; -} - -private static int foo(int i, int j) { return i + j; } - // Loop's execution count doesn't depend on values of p,t,k -private static int loop_no_dep2(int k) { - int p = 0; - int t = foo(p, k); - for (int i = 0; i < 100; i++) { - p++; + private static int foo(int i, int j) { + return i + j; } - return p; -} -private static void if_bad(int j) { - int p = 10; - if (p < 10 + j) { - p++; - } else { - p = j + 3; - for (int k = 0; k < 100; k++) { - j += 3; + // Loop's execution count doesn't depend on values of p,t,k + private static int loop_no_dep2(int k) { + int p = 0; + int t = foo(p, k); + for (int i = 0; i < 100; i++) { + p++; } + return p; } -} -private static int if_bad_loop() { - int p = 10; - for (int j = 0; j < 5; j++) { - if (j < 2) { + private static void if_bad(int j) { + int p = 10; + if (p < 10 + j) { p++; } else { - p = 3; - for (int k = 0; k < 10; k++) { - int m = 0; + p = j + 3; + for (int k = 0; k < 100; k++) { + j += 3; } } } - return p; -} - - private static int two_loops() { - int p = 10; - int k = 3; - int t = 2 + k; - for (int j = 0; j < 6; j++) { - k++; - } - for (int i = 0; i < 100; i++) { - p = 3; + private static int if_bad_loop() { + int p = 10; + for (int j = 0; j < 5; j++) { + if (j < 2) { + p++; + } else { + p = 3; + for (int k = 0; k < 10; k++) { + int m = 0; + } + } + } + return p; } - return p; -} -private static int loop_despite_inferbo(int p) { - - int k = 100; - for (int i = 0; i < k; i++) { - int m = p + 3; - if (m < 14) { - p += 9; + private static int two_loops() { + int p = 10; + int k = 3; + int t = 2 + k; + for (int j = 0; j < 6; j++) { + k++; + } + for (int i = 0; i < 100; i++) { + p = 3; } + return p; } - return p; -} + private static int loop_despite_inferbo(int p) { -private static int nested_loop() { - int k = 0; - for (int i = 0; i < 5; i++) { - A: - k = 0; - for (int j = 0; j < 100; j++) { - k = 3; + int k = 100; + for (int i = 0; i < k; i++) { + int m = p + 3; + if (m < 14) { + p += 9; + } } + return p; } - return k; -} + private static int nested_loop() { + int k = 0; + for (int i = 0; i < 5; i++) { + A: + k = 0; + for (int j = 0; j < 100; j++) { + k = 3; + } + } + return k; + } -private static int real_while() -{ - int i = 0; - int j = 3 * i; - while (i < 30){ - j=j+i; - i++; - } - return j; -} - + private static int real_while() { + int i = 0; + int j = 3 * i; + while (i < 30) { + j = j + i; + i++; + } + return j; + } } diff --git a/infer/tests/codetoanalyze/java/performance/FieldAccess.java b/infer/tests/codetoanalyze/java/performance/FieldAccess.java index de7c608db..08614895f 100644 --- a/infer/tests/codetoanalyze/java/performance/FieldAccess.java +++ b/infer/tests/codetoanalyze/java/performance/FieldAccess.java @@ -6,18 +6,13 @@ */ package codetoanalyze.java.performance; +public class FieldAccess { - -public class FieldAccess{ - - public class Test{ - int a; -} - - void iterate_upto_field_size(Test test){ - for (int ci = 0; ci < test.a; ++ci) { - } + public class Test { + int a; } - + void iterate_upto_field_size(Test test) { + for (int ci = 0; ci < test.a; ++ci) {} + } } diff --git a/infer/tests/codetoanalyze/java/performance/IteratorTest.java b/infer/tests/codetoanalyze/java/performance/IteratorTest.java index 86834e256..3dc9654b1 100644 --- a/infer/tests/codetoanalyze/java/performance/IteratorTest.java +++ b/infer/tests/codetoanalyze/java/performance/IteratorTest.java @@ -5,6 +5,7 @@ * LICENSE file in the root directory of this source tree. */ import java.util.Iterator; + public class IteratorTest { public void appendTo(Iterator parts) { diff --git a/infer/tests/codetoanalyze/java/performance/JsonArray.java b/infer/tests/codetoanalyze/java/performance/JsonArray.java index 8852f6eca..a8a68a4d7 100644 --- a/infer/tests/codetoanalyze/java/performance/JsonArray.java +++ b/infer/tests/codetoanalyze/java/performance/JsonArray.java @@ -11,12 +11,10 @@ public class JsonArray implements JsonType { public StringBuilder array = new StringBuilder("["); - public void addStringEntry(String value) { if (array.length() != 1) { array.append(","); } JsonUtils.serialize(array, value); } - } diff --git a/infer/tests/codetoanalyze/java/performance/JsonMap.java b/infer/tests/codetoanalyze/java/performance/JsonMap.java index 4d74a2fe2..29c3ea07b 100644 --- a/infer/tests/codetoanalyze/java/performance/JsonMap.java +++ b/infer/tests/codetoanalyze/java/performance/JsonMap.java @@ -13,7 +13,7 @@ public class JsonMap implements JsonType { public void addEntry(String key, JsonType value) { if (!JsonUtils.isValidInputType(value)) { - //throw new IllegalStateException("illegal input type " + value); + // throw new IllegalStateException("illegal input type " + value); } addKeyToMap(key); @@ -45,7 +45,6 @@ public class JsonMap implements JsonType { JsonUtils.serialize(map, value); } - private void addKeyToMap(String key) { if (map.length() != 1) { map.append(","); diff --git a/infer/tests/codetoanalyze/java/performance/JsonString.java b/infer/tests/codetoanalyze/java/performance/JsonString.java index 345f7dfa5..ee71bb229 100644 --- a/infer/tests/codetoanalyze/java/performance/JsonString.java +++ b/infer/tests/codetoanalyze/java/performance/JsonString.java @@ -30,5 +30,4 @@ public class JsonString implements JsonType { public String toString() { return array; } - } diff --git a/infer/tests/codetoanalyze/java/performance/JsonType.java b/infer/tests/codetoanalyze/java/performance/JsonType.java index ce88d0b5f..6a3c2d8c0 100644 --- a/infer/tests/codetoanalyze/java/performance/JsonType.java +++ b/infer/tests/codetoanalyze/java/performance/JsonType.java @@ -7,6 +7,4 @@ package libraries.marauder.analytics.utils.json; -public interface JsonType { - -} +public interface JsonType {} diff --git a/infer/tests/codetoanalyze/java/performance/JsonUtils.java b/infer/tests/codetoanalyze/java/performance/JsonUtils.java index cd3201f23..0391a90ac 100644 --- a/infer/tests/codetoanalyze/java/performance/JsonUtils.java +++ b/infer/tests/codetoanalyze/java/performance/JsonUtils.java @@ -12,8 +12,8 @@ public class JsonUtils { private static void escape(StringBuilder builder, String input) { for (Character c : input.toCharArray()) { if (Character.getType(c) == Character.CONTROL) { - builder.append(String.format("\\u%04x", (int)c)); - } else if (c == '\\' || c== '\"') { + builder.append(String.format("\\u%04x", (int) c)); + } else if (c == '\\' || c == '\"') { builder.append('\\').append(c); } else { builder.append(c); @@ -47,9 +47,9 @@ public class JsonUtils { || input instanceof Boolean || input instanceof Byte || input instanceof Short) { - return "";//String.valueOf(input); + return ""; // String.valueOf(input); } else { - return "";// serialize(String.valueOf(input)).toString(); + return ""; // serialize(String.valueOf(input)).toString(); } } @@ -80,9 +80,7 @@ public class JsonUtils { } public static boolean isValidInputType(Object value) { - if (value instanceof JsonString || - value instanceof JsonArray || - value instanceof JsonMap) { + if (value instanceof JsonString || value instanceof JsonArray || value instanceof JsonMap) { return true; } return false; diff --git a/infer/tests/codetoanalyze/java/performance/Loops.java b/infer/tests/codetoanalyze/java/performance/Loops.java index 004198547..f491064cb 100644 --- a/infer/tests/codetoanalyze/java/performance/Loops.java +++ b/infer/tests/codetoanalyze/java/performance/Loops.java @@ -6,33 +6,33 @@ */ package codetoanalyze.java.performance; -public class Loops{ +public class Loops { - static int do_while_independent_of_p (int p) { - int a = 0; - do { - if( p == 15) { - p = p + 1; - } - a++; - } while( a < 25 ); + static int do_while_independent_of_p(int p) { + int a = 0; + do { + if (p == 15) { + p = p + 1; + } + a++; + } while (a < 25); - return 0; + return 0; } /* can't handle nested loops yet, but control vars of both loops must - be {a, b} */ - static void nested_do_while_FP (int p) { + be {a, b} */ + static void nested_do_while_FP(int p) { int a = 10; int b = 0; do { - do{ - if( p == 15) { - p = p + 1; - } + do { + if (p == 15) { + p = p + 1; + } b++; - }while ( b < 10); + } while (b < 10); a++; - } while( a < 20 ); + } while (a < 20); } } diff --git a/infer/tests/codetoanalyze/java/performance/Switch.java b/infer/tests/codetoanalyze/java/performance/Switch.java index 4ef1e84c6..95c247e9c 100644 --- a/infer/tests/codetoanalyze/java/performance/Switch.java +++ b/infer/tests/codetoanalyze/java/performance/Switch.java @@ -6,39 +6,40 @@ */ package codetoanalyze.java.performance; -public class Switch{ - // Cost 51 - private static void vanilla_switch(int i){ +public class Switch { + // Cost 51 + private static void vanilla_switch(int i) { - for (int p = 0; p < 100; p++) - { - switch (p) { + for (int p = 0; p < 100; p++) { + switch (p) { case 0: i++; break; - case 1: case 2: case 3: + case 1: + case 2: + case 3: break; default: return; - } } + } } - //797 + // 797 private static int test_switch() { - int value = 0; - // infinite loop - while (value < 100) { - switch (value) { - case 0: - break; - case 1: - continue; - case 2: - default: - continue; + int value = 0; + // infinite loop + while (value < 100) { + switch (value) { + case 0: + break; + case 1: + continue; + case 2: + default: + continue; + } + value++; } - value++; + return 0; } - return 0; -} } diff --git a/infer/tests/codetoanalyze/java/performance/issues.exp b/infer/tests/codetoanalyze/java/performance/issues.exp index 8a4b59641..6a71deda9 100644 --- a/infer/tests/codetoanalyze/java/performance/issues.exp +++ b/infer/tests/codetoanalyze/java/performance/issues.exp @@ -34,7 +34,7 @@ codetoanalyze/java/performance/ArrayListTest.java, ArrayListTest.iterate_while_h codetoanalyze/java/performance/ArrayListTest.java, ArrayListTest.iterate_while_has_next(java.util.ArrayList):void, 3, EXPENSIVE_EXECUTION_TIME_CALL, no_bucket, ERROR, [with estimated cost 5 + 2 * (list.length.ub + -1) + 4 * list.length.ub, degree = 1] codetoanalyze/java/performance/ArrayListTest.java, ArrayListTest.iterate_with_iterator(java.util.ArrayList):void, 1, EXPENSIVE_EXECUTION_TIME_CALL, no_bucket, ERROR, [with estimated cost 4 + 9 * (list.length.ub + -1) + 4 * list.length.ub, degree = 1] codetoanalyze/java/performance/ArrayListTest.java, ArrayListTest.iterate_with_iterator(java.util.ArrayList):void, 1, EXPENSIVE_EXECUTION_TIME_CALL, no_bucket, ERROR, [with estimated cost 5 + 9 * (list.length.ub + -1) + 4 * list.length.ub, degree = 1] -codetoanalyze/java/performance/Break.java, codetoanalyze.java.performance.Break.break_constant(int):int, 2, EXPENSIVE_EXECUTION_TIME_CALL, no_bucket, ERROR, [with estimated cost 8 + 7 * p.ub, degree = 1] +codetoanalyze/java/performance/Break.java, codetoanalyze.java.performance.Break.break_constant(int):int, 1, EXPENSIVE_EXECUTION_TIME_CALL, no_bucket, ERROR, [with estimated cost 8 + 7 * p.ub, degree = 1] codetoanalyze/java/performance/Break.java, codetoanalyze.java.performance.Break.break_loop(int,int):int, 1, EXPENSIVE_EXECUTION_TIME_CALL, no_bucket, ERROR, [with estimated cost 1 + 7 * p.ub, degree = 1] codetoanalyze/java/performance/Break.java, codetoanalyze.java.performance.Break.break_loop(int,int):int, 1, EXPENSIVE_EXECUTION_TIME_CALL, no_bucket, ERROR, [with estimated cost 2 + 7 * p.ub, degree = 1] codetoanalyze/java/performance/Break.java, codetoanalyze.java.performance.Break.break_outer_loop_FN(int,int):void, 0, INFINITE_EXECUTION_TIME_CALL, no_bucket, ERROR, [] @@ -76,9 +76,9 @@ codetoanalyze/java/performance/Cost_test_deps.java, codetoanalyze.java.performan codetoanalyze/java/performance/Cost_test_deps.java, codetoanalyze.java.performance.Cost_test_deps.loop_no_dep2(int):int, 3, EXPENSIVE_EXECUTION_TIME_CALL, no_bucket, ERROR, [with estimated cost 608, degree = 0] codetoanalyze/java/performance/Cost_test_deps.java, codetoanalyze.java.performance.Cost_test_deps.loop_no_dep2(int):int, 3, EXPENSIVE_EXECUTION_TIME_CALL, no_bucket, ERROR, [with estimated cost 609, degree = 0] codetoanalyze/java/performance/Cost_test_deps.java, codetoanalyze.java.performance.Cost_test_deps.nested_loop():int, 0, INFINITE_EXECUTION_TIME_CALL, no_bucket, ERROR, [] -codetoanalyze/java/performance/Cost_test_deps.java, codetoanalyze.java.performance.Cost_test_deps.real_while():int, 4, EXPENSIVE_EXECUTION_TIME_CALL, no_bucket, ERROR, [with estimated cost 213, degree = 0] -codetoanalyze/java/performance/Cost_test_deps.java, codetoanalyze.java.performance.Cost_test_deps.real_while():int, 4, EXPENSIVE_EXECUTION_TIME_CALL, no_bucket, ERROR, [with estimated cost 214, degree = 0] -codetoanalyze/java/performance/Cost_test_deps.java, codetoanalyze.java.performance.Cost_test_deps.real_while():int, 6, EXPENSIVE_EXECUTION_TIME_CALL, no_bucket, ERROR, [with estimated cost 213, degree = 0] +codetoanalyze/java/performance/Cost_test_deps.java, codetoanalyze.java.performance.Cost_test_deps.real_while():int, 3, EXPENSIVE_EXECUTION_TIME_CALL, no_bucket, ERROR, [with estimated cost 213, degree = 0] +codetoanalyze/java/performance/Cost_test_deps.java, codetoanalyze.java.performance.Cost_test_deps.real_while():int, 3, EXPENSIVE_EXECUTION_TIME_CALL, no_bucket, ERROR, [with estimated cost 214, degree = 0] +codetoanalyze/java/performance/Cost_test_deps.java, codetoanalyze.java.performance.Cost_test_deps.real_while():int, 5, EXPENSIVE_EXECUTION_TIME_CALL, no_bucket, ERROR, [with estimated cost 213, degree = 0] codetoanalyze/java/performance/Cost_test_deps.java, codetoanalyze.java.performance.Cost_test_deps.two_loops():int, 7, EXPENSIVE_EXECUTION_TIME_CALL, no_bucket, ERROR, [with estimated cost 545, degree = 0] codetoanalyze/java/performance/Cost_test_deps.java, codetoanalyze.java.performance.Cost_test_deps.two_loops():int, 7, EXPENSIVE_EXECUTION_TIME_CALL, no_bucket, ERROR, [with estimated cost 544, degree = 0] codetoanalyze/java/performance/EvilCfg.java, EvilCfg.foo(int,int,boolean):void, 0, INFINITE_EXECUTION_TIME_CALL, no_bucket, ERROR, [] diff --git a/infer/tests/codetoanalyze/java/purity/Test.java b/infer/tests/codetoanalyze/java/purity/Test.java index 34133935b..168606926 100644 --- a/infer/tests/codetoanalyze/java/purity/Test.java +++ b/infer/tests/codetoanalyze/java/purity/Test.java @@ -51,13 +51,11 @@ class Test { return list.size(); } - void parameter_field_write_bad(Test test, boolean b) { int c = b ? 0 : 1; test.a = c; } - int parameter_field_access_ok(Test test) { return test.a; } @@ -72,7 +70,5 @@ class Test { int tmp = array[i]; array[i] = array[j]; array[j] = tmp; - } - - + } } diff --git a/infer/tests/codetoanalyze/java/quandary/Arrays.java b/infer/tests/codetoanalyze/java/quandary/Arrays.java index 59f5045f6..cbbd828da 100644 --- a/infer/tests/codetoanalyze/java/quandary/Arrays.java +++ b/infer/tests/codetoanalyze/java/quandary/Arrays.java @@ -17,7 +17,6 @@ public class Arrays { } /** should report on these tests */ - void viaArrayBad() { Object[] arr = new Object[1]; arr[0] = InferTaint.inferSecretSource(); @@ -43,7 +42,6 @@ public class Arrays { } /** should not report on these tests */ - void viaArrayOk() { Object[] arr = new Object[1]; arr[0] = new Object(); @@ -66,5 +64,4 @@ public class Arrays { arr[0] = null; InferTaint.inferSensitiveSink(arr[0]); } - } diff --git a/infer/tests/codetoanalyze/java/quandary/Basics.java b/infer/tests/codetoanalyze/java/quandary/Basics.java index 06c31580f..18b7c7411 100644 --- a/infer/tests/codetoanalyze/java/quandary/Basics.java +++ b/infer/tests/codetoanalyze/java/quandary/Basics.java @@ -10,14 +10,13 @@ package codetoanalyze.java.quandary; import com.facebook.infer.builtins.InferTaint; /** testing basic intraprocedural functionality: assignment, ifs, loops, casts */ - public class Basics { native Object notASource(); + native void notASink(Object o); /** should report on these tests */ - void directBad() { InferTaint.inferSensitiveSink(InferTaint.inferSecretSource()); } @@ -97,40 +96,40 @@ public class Basics { void switchBad1(int i) { Object src = InferTaint.inferSecretSource(); switch (i) { - case 1: - InferTaint.inferSensitiveSink(src); - break; - case 2: - break; - default: - break; + case 1: + InferTaint.inferSensitiveSink(src); + break; + case 2: + break; + default: + break; } } void switchBad2(int i) { Object src = InferTaint.inferSecretSource(); switch (i) { - case 1: - break; - case 2: - InferTaint.inferSensitiveSink(src); - break; - default: - break; + case 1: + break; + case 2: + InferTaint.inferSensitiveSink(src); + break; + default: + break; } } void switchBad3(int i) { Object src = null; switch (i) { - case 1: - src = InferTaint.inferSecretSource(); - // fallthrough - case 2: - InferTaint.inferSensitiveSink(src); - break; - default: - break; + case 1: + src = InferTaint.inferSecretSource(); + // fallthrough + case 2: + InferTaint.inferSensitiveSink(src); + break; + default: + break; } } @@ -160,7 +159,7 @@ public class Basics { void arrayWithTaintedContentsBad() { Object src = InferTaint.inferSecretSource(); - Object[] arr = new Object[] { src }; + Object[] arr = new Object[] {src}; InferTaint.inferSensitiveSink(arr); } @@ -174,7 +173,6 @@ public class Basics { } /** should not report on these tests */ - void directOk1() { notASink(notASource()); } @@ -207,7 +205,7 @@ public class Basics { } void synchronizedOk(Object o) { - synchronized(o) { + synchronized (o) { } } @@ -216,9 +214,10 @@ public class Basics { synchronizedOk(o); } - /** "known false positive" tests demonstrating limitations. an ideal analysis would not report on - these tests, but we do. */ - + /** + * "known false positive" tests demonstrating limitations. an ideal analysis would not report on + * these tests, but we do. + */ void FP_deadCodeOk() { Object src = InferTaint.inferSecretSource(); boolean b = false; @@ -234,5 +233,4 @@ public class Basics { } InferTaint.inferSensitiveSink(src); } - } diff --git a/infer/tests/codetoanalyze/java/quandary/ContentProviders.java b/infer/tests/codetoanalyze/java/quandary/ContentProviders.java index 2e6b63f7e..4b89c6628 100644 --- a/infer/tests/codetoanalyze/java/quandary/ContentProviders.java +++ b/infer/tests/codetoanalyze/java/quandary/ContentProviders.java @@ -7,8 +7,6 @@ package codetoanalyze.java.quandary; -import java.io.File; - import android.content.ContentProvider; import android.content.ContentValues; import android.content.res.AssetFileDescriptor; @@ -17,6 +15,7 @@ import android.net.Uri; import android.os.Bundle; import android.os.CancellationSignal; import android.os.ParcelFileDescriptor; +import java.io.File; public abstract class ContentProviders extends ContentProvider { @@ -60,15 +59,15 @@ public abstract class ContentProviders extends ContentProvider { @Override public ParcelFileDescriptor openFile(Uri uri, String mode, CancellationSignal signal) { - mFile = new File(uri.toString()); - return null; + mFile = new File(uri.toString()); + return null; } - @Override - public AssetFileDescriptor openTypedAssetFile( - Uri uri, String mimeTypeFilter, Bundle opts, CancellationSignal signal) { - mFile = new File(uri.toString()); - return null; + @Override + public AssetFileDescriptor openTypedAssetFile( + Uri uri, String mimeTypeFilter, Bundle opts, CancellationSignal signal) { + mFile = new File(uri.toString()); + return null; } @Override @@ -83,5 +82,4 @@ public abstract class ContentProviders extends ContentProvider { mFile = new File(uri.toString()); return 0; } - } diff --git a/infer/tests/codetoanalyze/java/quandary/DynamicDispatch.java b/infer/tests/codetoanalyze/java/quandary/DynamicDispatch.java index ebfa3573d..c4fd841f6 100644 --- a/infer/tests/codetoanalyze/java/quandary/DynamicDispatch.java +++ b/infer/tests/codetoanalyze/java/quandary/DynamicDispatch.java @@ -13,7 +13,9 @@ public class DynamicDispatch { static interface Interface { public Object returnSource(); + public void callSink(Object o); + public Object propagate(Object o); } @@ -58,8 +60,7 @@ public class DynamicDispatch { } @Override - public void callSink(Object o) { - } + public void callSink(Object o) {} @Override public Object propagate(Object o) { @@ -67,9 +68,10 @@ public class DynamicDispatch { } } - /** interface tests. for all of these, we should see a warning for both BadInterfaceImpl1 and - BadInterfaceImpl2, but not OkInterfaceImpl */ - + /** + * interface tests. for all of these, we should see a warning for both BadInterfaceImpl1 and + * BadInterfaceImpl2, but not OkInterfaceImpl + */ static void FN_returnSourceViaInterfaceBad(Interface i) { Object source = i.returnSource(); InferTaint.inferSensitiveSink(source); @@ -103,8 +105,7 @@ public class DynamicDispatch { return null; } - public void callSink(Object o) { - } + public void callSink(Object o) {} public Object propagate(Object o) { return null; @@ -157,5 +158,4 @@ public class DynamicDispatch { Object launderedSource = s.propagate(source2); InferTaint.inferSensitiveSink(launderedSource); } - } diff --git a/infer/tests/codetoanalyze/java/quandary/Exceptions.java b/infer/tests/codetoanalyze/java/quandary/Exceptions.java index ba3d996fd..576c4c7ba 100644 --- a/infer/tests/codetoanalyze/java/quandary/Exceptions.java +++ b/infer/tests/codetoanalyze/java/quandary/Exceptions.java @@ -11,7 +11,7 @@ import com.facebook.infer.builtins.InferTaint; class Exceptions { - native static void mayExcept() throws Exception; + static native void mayExcept() throws Exception; public static void sinkInCatchBad1() { Object source = InferTaint.inferSecretSource(); @@ -53,7 +53,7 @@ class Exceptions { InferTaint.inferSensitiveSink(source); } - public static void sinkInFinallyBad1() throws Exception{ + public static void sinkInFinallyBad1() throws Exception { Object source = InferTaint.inferSecretSource(); try { mayExcept(); @@ -127,5 +127,4 @@ class Exceptions { InferTaint.inferSensitiveSink(e); } } - } diff --git a/infer/tests/codetoanalyze/java/quandary/ExternalSpecs.java b/infer/tests/codetoanalyze/java/quandary/ExternalSpecs.java index 565abbd78..93804267b 100644 --- a/infer/tests/codetoanalyze/java/quandary/ExternalSpecs.java +++ b/infer/tests/codetoanalyze/java/quandary/ExternalSpecs.java @@ -10,11 +10,9 @@ package codetoanalyze.java.quandary; import android.app.Activity; import android.content.Intent; import android.util.Log; - import com.facebook.infer.builtins.InferTaint; /** Testing that sources and sinks specified in external JSON work correctly */ - public class ExternalSpecs { // we specify this as a source with kind PrivateData in .inferconfig @@ -130,7 +128,7 @@ public class ExternalSpecs { public static void loggingSink1() {} // we shouldn't fail when calling this either - public static void loggingSink1(Object notASink) { } + public static void loggingSink1(Object notASink) {} void callLoggingSink1sOk(Object o) { loggingSink1(); @@ -146,7 +144,6 @@ public class ExternalSpecs { Object sourceAgain = sinkThatPropagates(source); // should report loggingSink1(null, sourceAgain); // should report here too } - } interface InterfaceSpec { @@ -171,14 +168,12 @@ class InterfaceSpecImpl implements InterfaceSpec { public void externalSpecBad() { sink(source()); } - } class ConstructorSink { // specified as a source in .inferconfig - public ConstructorSink(Object o) { - } + public ConstructorSink(Object o) {} public static ConstructorSink constructorSinkBad() { Object source = InferTaint.inferSecretSource(); diff --git a/infer/tests/codetoanalyze/java/quandary/Fields.java b/infer/tests/codetoanalyze/java/quandary/Fields.java index f3f7115d4..fc92d23dd 100644 --- a/infer/tests/codetoanalyze/java/quandary/Fields.java +++ b/infer/tests/codetoanalyze/java/quandary/Fields.java @@ -20,7 +20,6 @@ public class Fields { static Object sFld; /** should report on these tests */ - void instanceFieldBad() { this.mFld = InferTaint.inferSecretSource(); InferTaint.inferSensitiveSink(this.mFld); @@ -62,7 +61,6 @@ public class Fields { } /** should not report on these tests */ - void viaFieldOk() { Obj obj = new Obj(); obj.f = InferTaint.inferSecretSource(); @@ -119,5 +117,4 @@ public class Fields { } InferTaint.inferSensitiveSink(obj.g.g.f); } - } diff --git a/infer/tests/codetoanalyze/java/quandary/Files.java b/infer/tests/codetoanalyze/java/quandary/Files.java index fd539ae01..242a3d7be 100644 --- a/infer/tests/codetoanalyze/java/quandary/Files.java +++ b/infer/tests/codetoanalyze/java/quandary/Files.java @@ -41,5 +41,4 @@ public class Files { String taintedString = (String) InferTaint.inferSecretSource(); return Paths.get("", taintedString); } - } diff --git a/infer/tests/codetoanalyze/java/quandary/FlowSensitivity.java b/infer/tests/codetoanalyze/java/quandary/FlowSensitivity.java index 7a56e2cc1..615122388 100644 --- a/infer/tests/codetoanalyze/java/quandary/FlowSensitivity.java +++ b/infer/tests/codetoanalyze/java/quandary/FlowSensitivity.java @@ -10,7 +10,6 @@ package codetoanalyze.java.quandary; import com.facebook.infer.builtins.InferTaint; /** making sure the traces we report respect control-flow */ - class FlowSensitivity { static class Obj { @@ -63,5 +62,4 @@ class FlowSensitivity { o.f = InferTaint.inferSecretSource(); sourceAndSink(o); } - } diff --git a/infer/tests/codetoanalyze/java/quandary/Intents.java b/infer/tests/codetoanalyze/java/quandary/Intents.java index d19b7e182..dcf79e66f 100644 --- a/infer/tests/codetoanalyze/java/quandary/Intents.java +++ b/infer/tests/codetoanalyze/java/quandary/Intents.java @@ -7,30 +7,24 @@ package codetoanalyze.java.quandary; -import java.io.IOException; -import java.net.URISyntaxException; -import java.util.List; - import android.app.Activity; import android.app.Service; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentSender.SendIntentException; -import android.content.res.Resources; import android.net.Uri; import android.os.Bundle; import android.os.IBinder; - import com.facebook.infer.builtins.InferTaint; - +import java.io.IOException; +import java.net.URISyntaxException; +import java.util.List; import org.xmlpull.v1.XmlPullParserException; -class IntentSubclass extends Intent { -} +class IntentSubclass extends Intent {} -abstract class ContextSubclass extends Context { -} +abstract class ContextSubclass extends Context {} class MyActivity extends Activity { @@ -51,17 +45,17 @@ class MyActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { - mReceiver = new BroadcastReceiver() { - @Override - // intent is modeled as tainted - public void onReceive(Context context, Intent intent) { - mUri = intent.getData(); - } - }; + mReceiver = + new BroadcastReceiver() { + @Override + // intent is modeled as tainted + public void onReceive(Context context, Intent intent) { + mUri = intent.getData(); + } + }; registerReceiver(mReceiver, null); } - @Override public void onResume() { startServiceWithTaintedIntent(); @@ -82,7 +76,6 @@ class MyBroadcastReceiver extends BroadcastReceiver { public void onReceive(Context context, Intent intent) { mActivity.startService(intent); } - } class MyService extends Service { @@ -127,15 +120,14 @@ class MyService extends Service { mActivity.startService(intent); return false; } - } public class Intents { private native int rand(); - public void callAllActivitySinksBad(Activity activity, String uri) throws - SendIntentException, IOException, URISyntaxException, XmlPullParserException { + public void callAllActivitySinksBad(Activity activity, String uri) + throws SendIntentException, IOException, URISyntaxException, XmlPullParserException { Intent intent = (Intent) InferTaint.inferSecretSource(); activity.bindService(intent, null, 0); @@ -147,7 +139,7 @@ public class Intents { activity.sendStickyBroadcastAsUser(intent, null); activity.sendStickyOrderedBroadcast(intent, null, null, 0, null, null); activity.sendStickyOrderedBroadcastAsUser(intent, null, null, null, 0, null, null); - activity.startActivities(new Intent[] { intent }); + activity.startActivities(new Intent[] {intent}); activity.startActivity(intent); activity.startActivityForResult(intent, 0); activity.startActivityIfNeeded(intent, 0); @@ -236,5 +228,4 @@ public class Intents { void startWithUri2Bad(Uri uri) { mActivity.startActivity(new Intent("action", uri, mActivity, MyActivity.class)); } - } diff --git a/infer/tests/codetoanalyze/java/quandary/Interprocedural.java b/infer/tests/codetoanalyze/java/quandary/Interprocedural.java index e181c1713..cf4fe70e2 100644 --- a/infer/tests/codetoanalyze/java/quandary/Interprocedural.java +++ b/infer/tests/codetoanalyze/java/quandary/Interprocedural.java @@ -24,7 +24,6 @@ class Interprocedural { } /** source tests */ - public static Object returnSourceDirect() { return InferTaint.inferSecretSource(); } @@ -97,7 +96,6 @@ class Interprocedural { } /** sink tests */ - public static void callSinkParam1(Object param1, Object param2) { InferTaint.inferSensitiveSink(param1); } @@ -201,7 +199,6 @@ class Interprocedural { } /** passthrough tests */ - public static void singlePassthroughBad() { Object source = InferTaint.inferSecretSource(); Object launderedSource = id(source); @@ -216,7 +213,6 @@ class Interprocedural { } /** false positives: an ideal analysis would not report these, but we will */ - public static Object returnSourceConditional(boolean b) { if (b) return InferTaint.inferSecretSource(); return null; @@ -226,8 +222,8 @@ class Interprocedural { InferTaint.inferSensitiveSink(returnSourceConditional(false)); } - public static void reassignInCallee(Obj o) { - o.f = null; + public static void reassignInCallee(Obj o) { + o.f = null; } public static void FP_reassignInCallee() { @@ -303,7 +299,7 @@ class Interprocedural { } void diverge() { - for (;;); + for (; ; ) ; } // we don't propagate divergence in callees to callers @@ -315,7 +311,7 @@ class Interprocedural { public static void callSinkThenDiverge(Object param) { InferTaint.inferSensitiveSink(param); - for (;;); + for (; ; ) ; } public void callSinkThenDivergeBad() { @@ -423,5 +419,4 @@ class Interprocedural { assignSourceToParam(o); InferTaint.inferSensitiveSink(o); } - } diff --git a/infer/tests/codetoanalyze/java/quandary/LoggingPrivateData.java b/infer/tests/codetoanalyze/java/quandary/LoggingPrivateData.java index 85d7a779e..46756c635 100644 --- a/infer/tests/codetoanalyze/java/quandary/LoggingPrivateData.java +++ b/infer/tests/codetoanalyze/java/quandary/LoggingPrivateData.java @@ -7,7 +7,6 @@ package codetoanalyze.java.quandary; -import android.content.SharedPreferences; import android.location.Location; import android.telephony.TelephonyManager; import android.util.Log; @@ -19,36 +18,36 @@ public class LoggingPrivateData { public void logAllSourcesBad(Location l, TelephonyManager t) { String source = null; switch (rand()) { - case 1: - source = String.valueOf(l.getAltitude()); - break; - case 2: - source = String.valueOf(l.getBearing()); - break; - case 3: - source = String.valueOf(l.getLatitude()); - break; - case 4: - source = String.valueOf(l.getLongitude()); - break; - case 5: - source = String.valueOf(l.getSpeed()); - break; - case 6: - source = t.getDeviceId(); - break; - case 7: - source = t.getLine1Number(); - break; - case 8: - source = t.getSimSerialNumber(); - break; - case 9: - source = t.getSubscriberId(); - break; - case 10: - source = t.getVoiceMailNumber(); - break; + case 1: + source = String.valueOf(l.getAltitude()); + break; + case 2: + source = String.valueOf(l.getBearing()); + break; + case 3: + source = String.valueOf(l.getLatitude()); + break; + case 4: + source = String.valueOf(l.getLongitude()); + break; + case 5: + source = String.valueOf(l.getSpeed()); + break; + case 6: + source = t.getDeviceId(); + break; + case 7: + source = t.getLine1Number(); + break; + case 8: + source = t.getSimSerialNumber(); + break; + case 9: + source = t.getSubscriberId(); + break; + case 10: + source = t.getVoiceMailNumber(); + break; } String TAG = "tag"; @@ -57,5 +56,4 @@ public class LoggingPrivateData { Log.w(TAG, source); Log.wtf(TAG, source); // 10 sources * 4 sinks = 40 expected reports } - } diff --git a/infer/tests/codetoanalyze/java/quandary/Recursion.java b/infer/tests/codetoanalyze/java/quandary/Recursion.java index 071bb4dbd..89a9c1831 100644 --- a/infer/tests/codetoanalyze/java/quandary/Recursion.java +++ b/infer/tests/codetoanalyze/java/quandary/Recursion.java @@ -40,5 +40,4 @@ public class Recursion { InferTaint.inferSensitiveSink(param); FN_recursionBad(i - 1, InferTaint.inferSecretSource()); } - } diff --git a/infer/tests/codetoanalyze/java/quandary/Serialization.java b/infer/tests/codetoanalyze/java/quandary/Serialization.java index 745f1fe88..e2175632b 100644 --- a/infer/tests/codetoanalyze/java/quandary/Serialization.java +++ b/infer/tests/codetoanalyze/java/quandary/Serialization.java @@ -7,15 +7,13 @@ package codetoanalyze.java.quandary; +import com.facebook.infer.builtins.InferTaint; import java.io.IOException; import java.io.InputStream; import java.io.ObjectInputStream; -import com.facebook.infer.builtins.InferTaint; - public class Serialization { - // we could warn on only particular calls to the tainted ObjectInputStream (e.g., readObject, // readUnshared, but nothing good can come from creating a tainted ObjectInputStream Object taintedObjectInputStreamBad() throws IOException, ClassNotFoundException { diff --git a/infer/tests/codetoanalyze/java/quandary/Services.java b/infer/tests/codetoanalyze/java/quandary/Services.java index 9cf4d0dda..34c4e82c7 100644 --- a/infer/tests/codetoanalyze/java/quandary/Services.java +++ b/infer/tests/codetoanalyze/java/quandary/Services.java @@ -10,26 +10,28 @@ package codetoanalyze.java.quandary; import java.io.IOException; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; -import java.lang.Runtime; -import java.sql.Statement; import java.sql.SQLException; +import java.sql.Statement; -class Services { - -} +class Services {} @Retention(RetentionPolicy.CLASS) -@interface ThriftService { -} +@interface ThriftService {} @ThriftService interface GeneratedServiceInterface { public void serviceMethodBad(String s) throws IOException; + public void paramToSql1Bad(String s) throws SQLException; + public void paramToSql2Bad(String s) throws SQLException; + public void paramToSql3Bad(String s) throws SQLException; + public void paramToSql4Bad(String s) throws SQLException; + public void paramToSql5Bad(String s) throws SQLException; + void packageProtectedServiceMethodBad(String s) throws IOException; } @@ -91,5 +93,4 @@ class Service1 implements GeneratedServiceInterface { private void privateMethodNotEndpointOk(String s) throws IOException { Runtime.getRuntime().exec(s); } - } diff --git a/infer/tests/codetoanalyze/java/quandary/Strings.java b/infer/tests/codetoanalyze/java/quandary/Strings.java index 5589d7563..4706bcebc 100644 --- a/infer/tests/codetoanalyze/java/quandary/Strings.java +++ b/infer/tests/codetoanalyze/java/quandary/Strings.java @@ -5,15 +5,15 @@ * LICENSE file in the root directory of this source tree. */ -//package codetoanalyze.java.quandary; - -import java.util.Formatter; +// package codetoanalyze.java.quandary; import com.facebook.infer.builtins.InferTaint; +import java.util.Formatter; -/** a lot of tainted values are strings, so propagation through StringBuilder's and the like is very - * important. */ - +/** + * a lot of tainted values are strings, so propagation through StringBuilder's and the like is very + * important. + */ public class Strings { void viaStringBuilderSugarBad() { @@ -75,5 +75,4 @@ public class Strings { void viaStringFormatVarArgsIndirectBad() { viaStringFormatVarArgsIndirect(InferTaint.inferSecretSource()); } - } diff --git a/infer/tests/codetoanalyze/java/quandary/TaintExample.java b/infer/tests/codetoanalyze/java/quandary/TaintExample.java index bb03c177e..f3973d132 100644 --- a/infer/tests/codetoanalyze/java/quandary/TaintExample.java +++ b/infer/tests/codetoanalyze/java/quandary/TaintExample.java @@ -7,50 +7,39 @@ package codetoanalyze.java.quandary; -import java.io.InputStream; +import android.content.ContentValues; +import android.content.SharedPreferences; +import com.facebook.infer.annotation.IntegritySink; +import com.facebook.infer.annotation.IntegritySource; +import com.facebook.infer.annotation.PrivacySink; +import com.facebook.infer.annotation.PrivacySource; +import com.facebook.infer.builtins.InferTaint; import java.io.IOException; -import java.net.MalformedURLException; +import java.io.InputStream; import java.net.Socket; -import java.net.URL; - import javax.net.ssl.HostnameVerifier; import javax.net.ssl.SSLException; import javax.net.ssl.SSLSession; import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocketFactory; -import android.content.ContentValues; -import android.content.SharedPreferences; - -import com.facebook.infer.builtins.InferTaint; -import com.facebook.infer.annotation.IntegritySource; -import com.facebook.infer.annotation.IntegritySink; -import com.facebook.infer.annotation.PrivacySource; -import com.facebook.infer.annotation.PrivacySink; - public class TaintExample { - public InputStream socketNotVerifiedSimple_FN(SSLSocketFactory f) - throws IOException { + public InputStream socketNotVerifiedSimple_FN(SSLSocketFactory f) throws IOException { Socket socket = f.createSocket(); return socket.getInputStream(); } public InputStream socketVerifiedForgotToCheckRetval_FN( - SSLSocketFactory f, - HostnameVerifier v, - SSLSession session) - throws IOException { + SSLSocketFactory f, HostnameVerifier v, SSLSession session) throws IOException { Socket socket = f.createSocket(); v.verify("hostname", session); return socket.getInputStream(); } - public InputStream socketVerifiedOk1(SSLSocketFactory f, - HostnameVerifier v, - SSLSession session) - throws IOException { + public InputStream socketVerifiedOk1(SSLSocketFactory f, HostnameVerifier v, SSLSession session) + throws IOException { Socket socket = f.createSocket(); if (v.verify("hostname", session)) { @@ -62,8 +51,7 @@ public class TaintExample { HostnameVerifier mHostnameVerifier; - public void throwExceptionIfNoVerify(SSLSocket sslSocket, String host) - throws IOException { + public void throwExceptionIfNoVerify(SSLSocket sslSocket, String host) throws IOException { if (!mHostnameVerifier.verify(host, sslSocket.getSession())) { throw new SSLException("Couldn't verify!"); @@ -76,8 +64,7 @@ public class TaintExample { return s.getInputStream(); } - public InputStream socketIgnoreExceptionNoVerify_FN(SSLSocketFactory f) - throws IOException { + public InputStream socketIgnoreExceptionNoVerify_FN(SSLSocketFactory f) throws IOException { SSLSocket s = (SSLSocket) f.createSocket(); try { @@ -100,8 +87,7 @@ public class TaintExample { } // if we're not careful, postcondition inference will fail for this function - Socket callReadInputStreamCauseTaintError_FN(SSLSocketFactory f) - throws IOException { + Socket callReadInputStreamCauseTaintError_FN(SSLSocketFactory f) throws IOException { Socket socket = f.createSocket(); InputStream s = readInputStream(socket); s.toString(); // to avoid RETURN_VALUE_IGNORED warning @@ -182,11 +168,9 @@ public class TaintExample { InferTaint.inferSensitiveSinkUndefined(privacySource()); // should report } - public void instancePrivacySink(@PrivacySink String s1, String s2) { - } + public void instancePrivacySink(@PrivacySink String s1, String s2) {} - public static void staticPrivacySink(@PrivacySink String s1, String s2) { - } + public static void staticPrivacySink(@PrivacySink String s1, String s2) {} public void testPrivacySinkAnnot1_FN() { String source = privacySource(); @@ -252,8 +236,7 @@ public class TaintExample { InferTaint.inferSensitiveSinkUndefined(source); // should report } - public void integritySink(@IntegritySink String s1, String s2) { - } + public void integritySink(@IntegritySink String s1, String s2) {} void testIntegritySinkAnnotReport_FN(String s) { integritySink(integritySource(), s); // should report @@ -262,5 +245,4 @@ public class TaintExample { void testIntegritySinkAnnotNoReport(String s) { integritySink(s, integritySource()); // should not report } - } diff --git a/infer/tests/codetoanalyze/java/quandary/TaintedFormals.java b/infer/tests/codetoanalyze/java/quandary/TaintedFormals.java index c96dabb78..a8025aedd 100644 --- a/infer/tests/codetoanalyze/java/quandary/TaintedFormals.java +++ b/infer/tests/codetoanalyze/java/quandary/TaintedFormals.java @@ -9,7 +9,6 @@ package codetoanalyze.java.quandary; import android.app.Activity; import android.content.Intent; - import com.facebook.infer.builtins.InferTaint; class Obj { @@ -25,9 +24,8 @@ public class TaintedFormals { } // taintedFormal1 and taintedFormal2 were are modeled as tainted - public void taintedContextBad(String taintedFormal1, - Intent untaintedFormal, - Integer taintedFormal2) { + public void taintedContextBad( + String taintedFormal1, Intent untaintedFormal, Integer taintedFormal2) { InferTaint.inferSensitiveSink(taintedFormal1); // should report here InferTaint.inferSensitiveSink(taintedFormal2); // should report here callSink(taintedFormal1); // should report here @@ -58,5 +56,4 @@ public class TaintedFormals { public void callTaintedContextOk2() { taintedContextBad(null, null, new Integer(1)); } - } diff --git a/infer/tests/codetoanalyze/java/quandary/Traces.java b/infer/tests/codetoanalyze/java/quandary/Traces.java index d6547305a..307be7ac2 100644 --- a/infer/tests/codetoanalyze/java/quandary/Traces.java +++ b/infer/tests/codetoanalyze/java/quandary/Traces.java @@ -29,5 +29,4 @@ class Traces { void callMySink(Obj o) { InferTaint.inferSensitiveSink(o); } - } diff --git a/infer/tests/codetoanalyze/java/quandary/UnknownCode.java b/infer/tests/codetoanalyze/java/quandary/UnknownCode.java index b08a1603b..e3e28ee1f 100644 --- a/infer/tests/codetoanalyze/java/quandary/UnknownCode.java +++ b/infer/tests/codetoanalyze/java/quandary/UnknownCode.java @@ -7,16 +7,14 @@ package codetoanalyze.java.quandary; -import com.facebook.infer.builtins.InferTaint; - import android.content.Intent; import android.os.Parcel; +import com.facebook.infer.builtins.InferTaint; /** testing how the analysis handles missing/unknown code */ - public abstract class UnknownCode { - native static Object nativeMethod(Object o); + static native Object nativeMethod(Object o); abstract Object abstractMethod(Object o); @@ -88,5 +86,4 @@ public abstract class UnknownCode { Object launderedSource = nativeMethod(source); InferTaint.inferSensitiveSink(launderedSource); } - } diff --git a/infer/tests/codetoanalyze/java/quandary/UserControlledStrings.java b/infer/tests/codetoanalyze/java/quandary/UserControlledStrings.java index 48db8fc18..b2b79737f 100644 --- a/infer/tests/codetoanalyze/java/quandary/UserControlledStrings.java +++ b/infer/tests/codetoanalyze/java/quandary/UserControlledStrings.java @@ -7,19 +7,15 @@ package codetoanalyze.java.quandary; -import android.app.Activity; import android.content.ClipboardManager; import android.text.Html; import android.text.Spanned; import android.widget.EditText; +import com.facebook.infer.builtins.InferTaint; import java.io.IOException; -import java.lang.ProcessBuilder; -import java.lang.Runtime; import java.util.ArrayList; import java.util.List; -import com.facebook.infer.builtins.InferTaint; - public class UserControlledStrings { ClipboardManager clipboard; @@ -37,6 +33,7 @@ public class UserControlledStrings { } EditText mEditText; + Spanned editTextToHtmlBad() { return Html.fromHtml(mEditText.getText().toString()); } @@ -46,7 +43,7 @@ public class UserControlledStrings { } void clipboardToShellArrayBad() throws IOException { - String[] cmds = new String[] { "ls", clipboard.getText().toString() }; + String[] cmds = new String[] {"ls", clipboard.getText().toString()}; Runtime.getRuntime().exec(cmds); } @@ -67,5 +64,4 @@ public class UserControlledStrings { cmds.add(clipboard.getText().toString()); return builder.command(cmds); } - } diff --git a/infer/tests/codetoanalyze/java/quandary/WebViews.java b/infer/tests/codetoanalyze/java/quandary/WebViews.java index b188683d2..7839bd11e 100644 --- a/infer/tests/codetoanalyze/java/quandary/WebViews.java +++ b/infer/tests/codetoanalyze/java/quandary/WebViews.java @@ -7,9 +7,6 @@ package codetoanalyze.java.quandary; -import java.io.File; -import java.net.URISyntaxException; - import android.app.Activity; import android.content.Context; import android.content.Intent; @@ -17,15 +14,14 @@ import android.net.Uri; import android.webkit.JavascriptInterface; import android.webkit.JsPromptResult; import android.webkit.JsResult; -import android.webkit.ValueCallback; import android.webkit.WebChromeClient; -import android.webkit.WebMessage; import android.webkit.WebResourceRequest; import android.webkit.WebResourceResponse; import android.webkit.WebView; import android.webkit.WebViewClient; - import com.facebook.infer.builtins.InferTaint; +import java.io.File; +import java.net.URISyntaxException; public class WebViews { @@ -142,5 +138,4 @@ public class WebViews { // should warn here webview.addJavascriptInterface(new JsObject(), "injectedObject"); } - } diff --git a/infer/tests/codetoanalyze/java/quandary/issues.exp b/infer/tests/codetoanalyze/java/quandary/issues.exp index e5374a889..287176957 100644 --- a/infer/tests/codetoanalyze/java/quandary/issues.exp +++ b/infer/tests/codetoanalyze/java/quandary/issues.exp @@ -200,10 +200,10 @@ codetoanalyze/java/quandary/TaintExample.java, codetoanalyze.java.quandary.Taint codetoanalyze/java/quandary/TaintExample.java, codetoanalyze.java.quandary.TaintExample.simpleTaintErrorWithModelMethods():void, 2, QUANDARY_TAINT_ERROR, no_bucket, ERROR, [Return from Object InferTaint.inferSecretSource(),Call to void InferTaint.inferSensitiveSink(Object) with tainted index 0] codetoanalyze/java/quandary/TaintedFormals.java, codetoanalyze.java.quandary.TaintedFormals.callTaintedContextBad1(java.lang.String):void, 2, QUANDARY_TAINT_ERROR, no_bucket, ERROR, [Return from Object TaintedFormals.taintedContextBad(String) with tainted data return*,Return from Object TaintedFormals.taintedContextBad(String),Call to void InferTaint.inferSensitiveSink(Object) with tainted index 0] codetoanalyze/java/quandary/TaintedFormals.java, codetoanalyze.java.quandary.TaintedFormals.callTaintedContextBad2():void, 1, QUANDARY_TAINT_ERROR, no_bucket, ERROR, [Return from Object InferTaint.inferSecretSource(),Call to void TaintedFormals.taintedContextBad(String,Intent,Integer) with tainted index 2,Call to ComponentName ContextWrapper.startService(Intent) with tainted index 1] +codetoanalyze/java/quandary/TaintedFormals.java, codetoanalyze.java.quandary.TaintedFormals.taintedContextBad(java.lang.String,android.content.Intent,java.lang.Integer):void, 2, QUANDARY_TAINT_ERROR, no_bucket, ERROR, [Return from void TaintedFormals.taintedContextBad(String,Intent,Integer),Call to void InferTaint.inferSensitiveSink(Object) with tainted index 0] codetoanalyze/java/quandary/TaintedFormals.java, codetoanalyze.java.quandary.TaintedFormals.taintedContextBad(java.lang.String,android.content.Intent,java.lang.Integer):void, 3, QUANDARY_TAINT_ERROR, no_bucket, ERROR, [Return from void TaintedFormals.taintedContextBad(String,Intent,Integer),Call to void InferTaint.inferSensitiveSink(Object) with tainted index 0] -codetoanalyze/java/quandary/TaintedFormals.java, codetoanalyze.java.quandary.TaintedFormals.taintedContextBad(java.lang.String,android.content.Intent,java.lang.Integer):void, 4, QUANDARY_TAINT_ERROR, no_bucket, ERROR, [Return from void TaintedFormals.taintedContextBad(String,Intent,Integer),Call to void InferTaint.inferSensitiveSink(Object) with tainted index 0] +codetoanalyze/java/quandary/TaintedFormals.java, codetoanalyze.java.quandary.TaintedFormals.taintedContextBad(java.lang.String,android.content.Intent,java.lang.Integer):void, 4, QUANDARY_TAINT_ERROR, no_bucket, ERROR, [Return from void TaintedFormals.taintedContextBad(String,Intent,Integer),Call to void TaintedFormals.callSink(Object) with tainted index 1,Call to void InferTaint.inferSensitiveSink(Object) with tainted index 0] codetoanalyze/java/quandary/TaintedFormals.java, codetoanalyze.java.quandary.TaintedFormals.taintedContextBad(java.lang.String,android.content.Intent,java.lang.Integer):void, 5, QUANDARY_TAINT_ERROR, no_bucket, ERROR, [Return from void TaintedFormals.taintedContextBad(String,Intent,Integer),Call to void TaintedFormals.callSink(Object) with tainted index 1,Call to void InferTaint.inferSensitiveSink(Object) with tainted index 0] -codetoanalyze/java/quandary/TaintedFormals.java, codetoanalyze.java.quandary.TaintedFormals.taintedContextBad(java.lang.String,android.content.Intent,java.lang.Integer):void, 6, QUANDARY_TAINT_ERROR, no_bucket, ERROR, [Return from void TaintedFormals.taintedContextBad(String,Intent,Integer),Call to void TaintedFormals.callSink(Object) with tainted index 1,Call to void InferTaint.inferSensitiveSink(Object) with tainted index 0] codetoanalyze/java/quandary/Traces.java, codetoanalyze.java.quandary.Traces.sourceMethod():void, 2, QUANDARY_TAINT_ERROR, no_bucket, ERROR, [Return from Object InferTaint.inferSecretSource(),Call to void Traces.callSameSink(Obj,Obj,Obj,Obj) with tainted index 2,Call to void Traces.callMySinkIndirect(Obj) with tainted index 1,Call to void Traces.callMySink(Obj) with tainted index 1,Call to void InferTaint.inferSensitiveSink(Object) with tainted index 0] codetoanalyze/java/quandary/UnknownCode.java, codetoanalyze.java.quandary.UnknownCode.callPropagateFootprintBad():void, 1, QUANDARY_TAINT_ERROR, no_bucket, ERROR, [Return from Object InferTaint.inferSecretSource(),Call to void UnknownCode.propagateFootprint(String) with tainted index 1,Call to void InferTaint.inferSensitiveSink(Object) with tainted index 0] codetoanalyze/java/quandary/UnknownCode.java, codetoanalyze.java.quandary.UnknownCode.callUnknownSetterBad(android.content.Intent):void, 4, QUANDARY_TAINT_ERROR, no_bucket, ERROR, [Return from Object InferTaint.inferSecretSource(),Call to void InferTaint.inferSensitiveSink(Object) with tainted index 0] diff --git a/infer/tests/codetoanalyze/java/racerd/Alias.java b/infer/tests/codetoanalyze/java/racerd/Alias.java index 386894e27..36515a676 100644 --- a/infer/tests/codetoanalyze/java/racerd/Alias.java +++ b/infer/tests/codetoanalyze/java/racerd/Alias.java @@ -7,25 +7,27 @@ import javax.annotation.concurrent.ThreadSafe; @ThreadSafe -class Alias{ - A a,b; +class Alias { + A a, b; public void foo() { int x; - synchronized(this){ + synchronized (this) { a = b; a.f = 101; } - x = b.f; // may_alias + x = b.f; // may_alias } - public void bar(A a,A b) { - int x; - synchronized(this){ - a.f = 101; - } - x = b.f; // no may_alias needed, argument treatment suffices + public void bar(A a, A b) { + int x; + synchronized (this) { + a.f = 101; + } + x = b.f; // no may_alias needed, argument treatment suffices } } -class A { int f = 0; } +class A { + int f = 0; +} diff --git a/infer/tests/codetoanalyze/java/racerd/AndroidModels.java b/infer/tests/codetoanalyze/java/racerd/AndroidModels.java index 8c52cb408..6f4f6b603 100644 --- a/infer/tests/codetoanalyze/java/racerd/AndroidModels.java +++ b/infer/tests/codetoanalyze/java/racerd/AndroidModels.java @@ -7,26 +7,22 @@ package codetoanalyze.java.checkers; -import javax.annotation.concurrent.ThreadSafe; - import android.app.Activity; import android.content.Context; import android.content.res.AssetManager; import android.content.res.Configuration; import android.content.res.Resources; -import android.view.View; import android.util.DisplayMetrics; +import android.view.View; +import javax.annotation.concurrent.ThreadSafe; -class MyActivity extends Activity { - -} +class MyActivity extends Activity {} class MyResources extends Resources { public MyResources(AssetManager assets, DisplayMetrics metrics, Configuration config) { super(assets, metrics, config); } - } class MyView extends View { @@ -36,7 +32,6 @@ class MyView extends View { public MyView(Context c) { super(c); } - } @ThreadSafe @@ -72,5 +67,4 @@ public class AndroidModels { MyView view = (MyView) activity.findViewById(-1); view.mField = true; // ok; } - } diff --git a/infer/tests/codetoanalyze/java/racerd/Annotations.java b/infer/tests/codetoanalyze/java/racerd/Annotations.java index 9219909a7..7a8e9449f 100644 --- a/infer/tests/codetoanalyze/java/racerd/Annotations.java +++ b/infer/tests/codetoanalyze/java/racerd/Annotations.java @@ -7,6 +7,12 @@ package codetoanalyze.java.checkers; +import android.support.annotation.UiThread; +import com.facebook.infer.annotation.Functional; +import com.facebook.infer.annotation.ReturnsOwnership; +import com.facebook.infer.annotation.SynchronizedCollection; +import com.facebook.infer.annotation.ThreadConfined; +import com.facebook.infer.annotation.ThreadSafe; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -15,60 +21,46 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; -import android.support.annotation.UiThread; - -import com.facebook.infer.annotation.Functional; -import com.facebook.infer.annotation.ReturnsOwnership; -import com.facebook.infer.annotation.SynchronizedCollection; -import com.facebook.infer.annotation.ThreadConfined; -import com.facebook.infer.annotation.ThreadSafe; - /** tests for classes and method annotations that are meaningful w.r.t thread-safety */ - @Target(ElementType.METHOD) @Retention(RetentionPolicy.CLASS) -@interface OnBind { -} +@interface OnBind {} @Target(ElementType.METHOD) @Retention(RetentionPolicy.CLASS) -@interface OnEvent { -} +@interface OnEvent {} @Target(ElementType.METHOD) @Retention(RetentionPolicy.CLASS) -@interface OnMount { -} +@interface OnMount {} @Target(ElementType.METHOD) @Retention(RetentionPolicy.CLASS) -@interface OnUnbind { -} +@interface OnUnbind {} @Target(ElementType.METHOD) @Retention(RetentionPolicy.CLASS) -@interface OnUnmount { -} +@interface OnUnmount {} @Target(ElementType.METHOD) @Retention(RetentionPolicy.CLASS) -@interface MyThreadSafeAlias1 { -} +@interface MyThreadSafeAlias1 {} @Target(ElementType.METHOD) @Retention(RetentionPolicy.CLASS) -@interface MyThreadSafeAlias2 { -} +@interface MyThreadSafeAlias2 {} @Target(ElementType.PARAMETER) @Retention(RetentionPolicy.CLASS) -@interface InjectProp { -} +@interface InjectProp {} interface Interface { - @Functional Object functionalMethod(); - @ReturnsOwnership Obj returnsOwnershipMethod(); + @Functional + Object functionalMethod(); + + @ReturnsOwnership + Obj returnsOwnershipMethod(); } @ThreadSafe(enableChecks = false) @@ -122,7 +114,7 @@ class Annotations implements Interface { Confined con; - public void confinedCallerOk(){ + public void confinedCallerOk() { con.foo(); } @@ -134,12 +126,13 @@ class Annotations implements Interface { class Confined { Integer x; - void foo(){ + void foo() { x = 22; } } - @ThreadConfined(ThreadConfined.ANY) Obj encapsulatedField; + @ThreadConfined(ThreadConfined.ANY) + Obj encapsulatedField; public void mutateConfinedFieldDirectlyOk() { this.encapsulatedField = new Obj(); @@ -161,41 +154,39 @@ class Annotations implements Interface { zz = 22; } - public void read_from_non_confined_method_Bad(){ + public void read_from_non_confined_method_Bad() { Integer i; i = zz; } /* Like in RaceWithMainThread.java with assertMainThread() */ - void conditional1_ok(boolean b){ - if (b) { - write_on_main_thread_ok(); - } + void conditional1_ok(boolean b) { + if (b) { + write_on_main_thread_ok(); + } } Integer ii; @ThreadConfined(ThreadConfined.UI) - void write_on_main_thread_ok(){ - ii = 22; + void write_on_main_thread_ok() { + ii = 22; } - void conditional2_bad(boolean b){ - if (b) - { - write_on_main_thread_ok(); - } else { - ii = 99; // this might or might not run on the main thread; warn - } - } - + void conditional2_bad(boolean b) { + if (b) { + write_on_main_thread_ok(); + } else { + ii = 99; // this might or might not run on the main thread; warn + } + } @OnBind public void onBindMethodOk() { this.f = new Object(); } - public void read_off_UI_thread_Bad(){ + public void read_off_UI_thread_Bad() { Object o = f; } @@ -219,10 +210,18 @@ class Annotations implements Interface { this.f = new Object(); } - @Functional native Object returnFunctional1(); - @Functional Object returnFunctional2() { return null; } + @Functional + native Object returnFunctional1(); + + @Functional + Object returnFunctional2() { + return null; + } // marked @Functional in interface - @Override public Object functionalMethod() { return null; } + @Override + public Object functionalMethod() { + return null; + } Object mAssignToFunctional; @@ -247,8 +246,11 @@ class Annotations implements Interface { return mAssignToFunctional; } - @Functional native double returnDouble(); - @Functional native long returnLong(); + @Functional + native double returnDouble(); + + @Functional + native long returnLong(); double mDouble; long mLong; @@ -288,7 +290,8 @@ class Annotations implements Interface { Boolean mBoxedBool; - @Functional native boolean returnBool(); + @Functional + native boolean returnBool(); public boolean functionalAcrossBoxingOk() { if (b) { @@ -299,7 +302,8 @@ class Annotations implements Interface { boolean mBool; - @Functional native Boolean returnBoxedBool(); + @Functional + native Boolean returnBoxedBool(); boolean mBool2; @@ -312,7 +316,8 @@ class Annotations implements Interface { Long mBoxedLong; - @Functional native Long returnBoxedLong(); + @Functional + native Long returnBoxedLong(); public int functionalBoxedLongOk() { if (b) { @@ -349,7 +354,9 @@ class Annotations implements Interface { mBool = returnedFunctional; } - @Functional native int returnInt(); + @Functional + native int returnInt(); + int mInt; public void functionalAcrossLogicalOpsOk() { @@ -371,7 +378,8 @@ class Annotations implements Interface { mInt = returnNonFunctionalInt() + returnInt(); } - @ReturnsOwnership native Obj returnsOwned(); + @ReturnsOwnership + native Obj returnsOwned(); @Override public native Obj returnsOwnershipMethod(); // marked @ReturnsOwnership in interface @@ -391,7 +399,7 @@ class Annotations implements Interface { } @SynchronizedCollection - private final Map mSynchronizedMap = Collections.synchronizedMap(new HashMap()); + private final Map mSynchronizedMap = Collections.synchronizedMap(new HashMap()); public void synchronizedMapOk1() { mSynchronizedMap.put(new Object(), new Object()); @@ -404,10 +412,8 @@ class Annotations implements Interface { public void injectPropOk(@InjectProp Obj o) { o.f = 7; } - } - @UiThread @ThreadSafe class AllMethodsOnUiThread { diff --git a/infer/tests/codetoanalyze/java/racerd/Arrays.java b/infer/tests/codetoanalyze/java/racerd/Arrays.java index 81e0ae2c2..1aa5a7e7b 100644 --- a/infer/tests/codetoanalyze/java/racerd/Arrays.java +++ b/infer/tests/codetoanalyze/java/racerd/Arrays.java @@ -32,7 +32,7 @@ class Arrays { } int arrayParameterLiteralReadOk() { - return (new int[] { 2, 3})[1]; + return (new int[] {2, 3})[1]; } public void writeWriteRaceBad(String s) { @@ -57,7 +57,7 @@ class Arrays { // arrays are compatible types and can alias public Child FN_readWriteAliasRaceBad() { - synchronized(this) { + synchronized (this) { parentArr[3] = null; } return childArr[3]; @@ -68,11 +68,10 @@ class Arrays { // arrays are different types and thus cannot alias public Parent noRaceOk() { - synchronized(this) { + synchronized (this) { type1Arr[3] = null; } return type2Arr[3]; } - } diff --git a/infer/tests/codetoanalyze/java/racerd/Builders.java b/infer/tests/codetoanalyze/java/racerd/Builders.java index 7bc8a5bbb..9d6a3e162 100644 --- a/infer/tests/codetoanalyze/java/racerd/Builders.java +++ b/infer/tests/codetoanalyze/java/racerd/Builders.java @@ -8,7 +8,6 @@ package codetoanalyze.java.checkers; import com.facebook.infer.annotation.ThreadSafe; - import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList.Builder; @@ -90,7 +89,6 @@ public class Builders { input.g = ""; return output; } - } @ThreadSafe @@ -100,7 +98,6 @@ class TopLevelBuilder { public void setG(String g) { this.g = g; // still want to warn if the builder is annotated ThreadSafe } - } class MyBuilder { @@ -119,5 +116,4 @@ class MyBuilder { static void setNestedPathOk(int i) { MyBuilder.create().setNestedPath(1); } - } diff --git a/infer/tests/codetoanalyze/java/racerd/Constructors.java b/infer/tests/codetoanalyze/java/racerd/Constructors.java index 7f3eef40a..7dcf2d881 100644 --- a/infer/tests/codetoanalyze/java/racerd/Constructors.java +++ b/infer/tests/codetoanalyze/java/racerd/Constructors.java @@ -65,5 +65,4 @@ public class Constructors { } return sSingleton2; } - } diff --git a/infer/tests/codetoanalyze/java/racerd/Containers.java b/infer/tests/codetoanalyze/java/racerd/Containers.java index 0228b0559..a66274087 100644 --- a/infer/tests/codetoanalyze/java/racerd/Containers.java +++ b/infer/tests/codetoanalyze/java/racerd/Containers.java @@ -7,24 +7,22 @@ package codetoanalyze.java.checkers; +import android.support.v4.util.Pools; +import android.support.v4.util.Pools.SimplePool; +import android.support.v4.util.Pools.SynchronizedPool; +import android.support.v4.util.SimpleArrayMap; +import android.support.v4.util.SparseArrayCompat; +import android.util.SparseArray; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; import java.util.concurrent.CopyOnWriteArrayList; - import javax.annotation.concurrent.ThreadSafe; -import android.support.v4.util.Pools.SynchronizedPool; -import android.support.v4.util.SparseArrayCompat; -import android.util.SparseArray; -import android.support.v4.util.SimpleArrayMap; -import android.support.v4.util.Pools; -import android.support.v4.util.Pools.SimplePool; - class ContainerWrapper { private final List children = new ArrayList(); @@ -32,19 +30,17 @@ class ContainerWrapper { return _write(v); } - private Object _write(Object node) - { + private Object _write(Object node) { children.add(node); return this; } - } @ThreadSafe class Containers { List mList; - Map mMap; + Map mMap; // lists void listAddBad1(String s) { @@ -113,11 +109,11 @@ class Containers { mMap.clear(); } - void mapPutAllBad(Map otherMap) { + void mapPutAllBad(Map otherMap) { mMap.putAll(otherMap); } - Map mMapNobodyWrites; + Map mMapNobodyWrites; void mapReadsOk(String s) { mMapNobodyWrites.containsKey(s); @@ -131,7 +127,7 @@ class Containers { } // make sure we still warn on subtypes of Map - void mapSubclassWriteBad(HashMap m, String key) { + void mapSubclassWriteBad(HashMap m, String key) { m.remove(key); } @@ -146,9 +142,9 @@ class Containers { } void accessToSychronizedMapsOk( - String key, - ConcurrentMap concurrentMap, - ConcurrentHashMap concurrentHashMap) { + String key, + ConcurrentMap concurrentMap, + ConcurrentHashMap concurrentHashMap) { concurrentMap.remove(key); concurrentHashMap.remove(key); @@ -269,12 +265,12 @@ class Containers { SimpleArrayMap si_map = new SimpleArrayMap(); - synchronized public void addToSimpleArrayMapOk() { - si_map.put(1,1); + public synchronized void addToSimpleArrayMapOk() { + si_map.put(1, 1); } public void addToSimpleArrayMapBad(SimpleArrayMap map) { - map.put(1,1); + map.put(1, 1); } // this should be a read/write race with addToSimpleArrayMapOk @@ -283,27 +279,27 @@ class Containers { } SimplePool simplePool = new SimplePool(10); - synchronized public Integer getFromPoolOK() { + + public synchronized Integer getFromPoolOK() { return simplePool.acquire(); } public void poolBad() { Integer a; - synchronized(this) { + synchronized (this) { a = simplePool.acquire(); } simplePool.release(a); } - Map mAliasedMap; + Map mAliasedMap; // won't report here because the read happens through an alias public String FN_AliasedMapBad() { synchronized (this) { mAliasedMap.put("a", "b"); } - Map alias = mAliasedMap; + Map alias = mAliasedMap; return alias.get("a"); } - } diff --git a/infer/tests/codetoanalyze/java/racerd/DeepOwnership.java b/infer/tests/codetoanalyze/java/racerd/DeepOwnership.java index a2d09819d..d96fba78d 100644 --- a/infer/tests/codetoanalyze/java/racerd/DeepOwnership.java +++ b/infer/tests/codetoanalyze/java/racerd/DeepOwnership.java @@ -5,7 +5,6 @@ * LICENSE file in the root directory of this source tree. */ - import com.facebook.infer.annotation.ThreadSafe; @ThreadSafe @@ -17,7 +16,7 @@ class DeepOwnership { global.next = null; } - void reassignBaseToGlobalBad(){ + void reassignBaseToGlobalBad() { DeepOwnership x = new DeepOwnership(); x = global; x.next = null; @@ -29,31 +28,29 @@ class DeepOwnership { x.next.next = null; } - - - void deepIntraOk(){ + void deepIntraOk() { DeepOwnership x = new DeepOwnership(); x.next.next = null; // doesn't warn here } - void deepInterOk(){ + void deepInterOk() { DeepOwnership x = new DeepOwnership(); deepPrivate(x.next); } - private void deepPrivate(DeepOwnership y){ + private void deepPrivate(DeepOwnership y) { y.next = null; } - DeepOwnership deepFromOwnedThisOk(){ + DeepOwnership deepFromOwnedThisOk() { return new DeepOwnership(); } DeepOwnership arr[]; - DeepOwnership(){ - next.next = null; - arr[0] = null; + DeepOwnership() { + next.next = null; + arr[0] = null; } private void loseOwnershipOfNext() { @@ -68,5 +65,4 @@ class DeepOwnership { loseOwnershipOfNext(); x.next.next = null; // doesn't warn here } - } diff --git a/infer/tests/codetoanalyze/java/racerd/Dispatch.java b/infer/tests/codetoanalyze/java/racerd/Dispatch.java index f58252cbd..bf76733c1 100644 --- a/infer/tests/codetoanalyze/java/racerd/Dispatch.java +++ b/infer/tests/codetoanalyze/java/racerd/Dispatch.java @@ -21,7 +21,8 @@ interface AnnotatedInterface { interface AnnotatedInterfaceMethod { - @ThreadSafe public void foo(); + @ThreadSafe + public void foo(); } class NotThreadSafe { @@ -35,7 +36,6 @@ interface ThreadConfinedInterface { void foo(); } - interface ThreadConfinedMethod { @ThreadConfined(ThreadConfined.ANY) @@ -74,11 +74,10 @@ public class Dispatch { } public void callUnderLock(AnnotatedInterface i) { - synchronized(this) { + synchronized (this) { i.foo(); } } - } class Some { @@ -90,14 +89,16 @@ class Some { @ThreadSafe class ThreadConfinedField { - @ThreadConfined(ThreadConfined.ANY) UnannotatedInterface mThreadConfined; - UnannotatedInterface mNormal; + @ThreadConfined(ThreadConfined.ANY) + UnannotatedInterface mThreadConfined; - void interfaceCallOnThreadConfinedFieldOk() { - mThreadConfined.foo(); - } + UnannotatedInterface mNormal; - void interfaceCallOnNormalFieldBad() { - mNormal.foo(); - } + void interfaceCallOnThreadConfinedFieldOk() { + mThreadConfined.foo(); + } + + void interfaceCallOnNormalFieldBad() { + mNormal.foo(); + } } diff --git a/infer/tests/codetoanalyze/java/racerd/Escape.java b/infer/tests/codetoanalyze/java/racerd/Escape.java index 7269fe9dd..6ace9032c 100644 --- a/infer/tests/codetoanalyze/java/racerd/Escape.java +++ b/infer/tests/codetoanalyze/java/racerd/Escape.java @@ -27,7 +27,7 @@ public class Escape { public void FN_fieldEscapeBad() { Obj o = new Obj(); - synchronized(this) { + synchronized (this) { mField = o; } o.f = new Object(); // not safe @@ -119,7 +119,6 @@ public class Escape { twoParamsOneEscapes(o1, o2); o2.f = null; // ok } - } @ThreadSafe @@ -140,5 +139,4 @@ class Leaky { } l.mField = 1; // bad } - } diff --git a/infer/tests/codetoanalyze/java/racerd/Inference.java b/infer/tests/codetoanalyze/java/racerd/Inference.java index dbcf63482..8148111cc 100644 --- a/infer/tests/codetoanalyze/java/racerd/Inference.java +++ b/infer/tests/codetoanalyze/java/racerd/Inference.java @@ -40,8 +40,7 @@ public class Inference { int mField3; // empty call that uses a lock - synchronized private void useLock() { - } + private synchronized void useLock() {} int useLockInCalleeThenReadBad() { useLock(); @@ -69,5 +68,4 @@ public class Inference { void write5OutsideSyncOk() { mField5 = 5; // don't report } - } diff --git a/infer/tests/codetoanalyze/java/racerd/Locks.java b/infer/tests/codetoanalyze/java/racerd/Locks.java index f38079b4e..f6062183d 100644 --- a/infer/tests/codetoanalyze/java/racerd/Locks.java +++ b/infer/tests/codetoanalyze/java/racerd/Locks.java @@ -7,12 +7,11 @@ package codetoanalyze.java.checkers; -import javax.annotation.concurrent.ThreadSafe; - import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantReadWriteLock; +import javax.annotation.concurrent.ThreadSafe; @ThreadSafe public class Locks { @@ -212,7 +211,6 @@ public class Locks { f = 32; } - void useLock() { synchronized (this) { } @@ -243,7 +241,7 @@ public class Locks { void lockInLoopLexicalBad(int i) { while (i > 0) { i++; - synchronized(this) { + synchronized (this) { } } f = 32; @@ -252,14 +250,14 @@ public class Locks { void lockInLoopLexicalOk(int i) { while (i > 0) { i++; - synchronized(this) { + synchronized (this) { f = 32; } } } void loopInLockLexicalBad(int i) { - synchronized(this) { + synchronized (this) { while (i > 0) { i++; } @@ -363,6 +361,4 @@ public class Locks { public Object unownedReadBad() { return this.mField3; } - - } diff --git a/infer/tests/codetoanalyze/java/racerd/NotThreadSafeExample.java b/infer/tests/codetoanalyze/java/racerd/NotThreadSafeExample.java index 77b629f40..d30038731 100644 --- a/infer/tests/codetoanalyze/java/racerd/NotThreadSafeExample.java +++ b/infer/tests/codetoanalyze/java/racerd/NotThreadSafeExample.java @@ -10,12 +10,12 @@ package codetoanalyze.java.checkers; import javax.annotation.concurrent.NotThreadSafe; @NotThreadSafe -public class NotThreadSafeExample{ +public class NotThreadSafeExample { Integer f; - public void tsBad() { /*Shouldn't report*/ + public void tsBad() { + /*Shouldn't report*/ f = 24; } - } diff --git a/infer/tests/codetoanalyze/java/racerd/Ownership.java b/infer/tests/codetoanalyze/java/racerd/Ownership.java index f169aa80d..adfb8e0d1 100644 --- a/infer/tests/codetoanalyze/java/racerd/Ownership.java +++ b/infer/tests/codetoanalyze/java/racerd/Ownership.java @@ -9,8 +9,6 @@ package codetoanalyze.java.checkers; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; - - import javax.annotation.concurrent.ThreadSafe; import javax.inject.Inject; import javax.inject.Provider; @@ -31,20 +29,21 @@ public class Ownership { Obj field; - public Ownership() { - } + public Ownership() {} public Ownership(Obj o) { field = o; } // understand that ownership can be acquired via DI - @Inject Ownership(Provider objProvider) { + @Inject + Ownership(Provider objProvider) { Obj owned = objProvider.get(); owned.f = new Object(); // should not report } - @Inject Ownership(CustomProvider objProvider) { + @Inject + Ownership(CustomProvider objProvider) { Obj owned = objProvider.get(); owned.f = new Object(); // should not report } @@ -54,7 +53,8 @@ public class Ownership { // because this constructor is meant to be called via DI, we assume that injectedField and other // parameters passed to the constructor will always be freshly allocated - @Inject Ownership(Obj injectedField1, Obj injectedField2) { + @Inject + Ownership(Obj injectedField1, Obj injectedField2) { mInjectedField1 = injectedField1; mInjectedField2 = injectedField2; mInjectedField1.f = new Object(); // should not warn @@ -365,7 +365,8 @@ public class Ownership { } void ownViaReflectionOk2() - throws IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException { + throws IllegalAccessException, InstantiationException, InvocationTargetException, + NoSuchMethodException { Class oClass = Obj.class; Constructor oConstructor = oClass.getConstructor(); Obj o = oConstructor.newInstance(); @@ -377,13 +378,13 @@ public class Ownership { c.f = new Object(); } - void cloningAquiresOwnershipOk(){ - Ownership ow; - try { - ow = (Ownership) this.clone(); - ow.field = null; - } - catch (CloneNotSupportedException e) {} + void cloningAquiresOwnershipOk() { + Ownership ow; + try { + ow = (Ownership) this.clone(); + ow.field = null; + } catch (CloneNotSupportedException e) { + } } static MyObj global; @@ -408,7 +409,7 @@ public class Ownership { private Obj returnOwnedWithException() { Obj options = new Obj(); - if (options.f==null) { + if (options.f == null) { throw new IllegalArgumentException(); } return options; @@ -422,7 +423,9 @@ public class Ownership { // not propagating ownership to unowned local access path public void notPropagatingOwnershipToUnownedLocalAccessPathBad() { Obj m; - synchronized(this) { m = field; } + synchronized (this) { + m = field; + } m.g = new Obj(); } @@ -440,11 +443,13 @@ public class Ownership { } Obj unownedField1; + void reassignParamToOwnedOk() { reassignParamToOwned(this.unownedField1); // ok even though this.unownedField1 isn't owned } Obj unownedField2; + private void reassignParamToUnowned(Obj o) { o = this.unownedField2; o.f = null; // don't know that this.unownedField2 is owned @@ -473,6 +478,7 @@ public class Ownership { } Obj unownedField3; + private void ownedViaThisAlias() { Ownership alias = this; alias.unownedField3 = null; // ok if this owned in caller @@ -503,17 +509,17 @@ public class Ownership { void conditionalAliasBad(Obj unowned) { conditionalAlias(new Obj(), unowned); } - } -class MyObj { int data; } +class MyObj { + int data; +} class Subclass extends Obj { public void doWrite() { f = new Object(); } - } @ThreadSafe diff --git a/infer/tests/codetoanalyze/java/racerd/RaceWithMainThread.java b/infer/tests/codetoanalyze/java/racerd/RaceWithMainThread.java index aa3619134..74ce1c6c9 100644 --- a/infer/tests/codetoanalyze/java/racerd/RaceWithMainThread.java +++ b/infer/tests/codetoanalyze/java/racerd/RaceWithMainThread.java @@ -9,54 +9,57 @@ package codetoanalyze.java.checkers; import javax.annotation.concurrent.ThreadSafe; -class OurThreadUtils{ - native static boolean isMainThread(); - static void assertMainThread(){} - static void assertHoldsLock(Object lock){} -} +class OurThreadUtils { + static native boolean isMainThread(); + + static void assertMainThread() {} -class OurThreadUtil{ /*This is like AndroidThreadUtil*/ - native static boolean isUiThread(); - static void assertOnUiThread(){} - static void assertOnBackgroundThread(){} + static void assertHoldsLock(Object lock) {} } +class OurThreadUtil { + /*This is like AndroidThreadUtil*/ + static native boolean isUiThread(); + + static void assertOnUiThread() {} + + static void assertOnBackgroundThread() {} +} @ThreadSafe -class RaceWithMainThread{ +class RaceWithMainThread { Integer f; - void main_thread_OK(){ - OurThreadUtils.assertMainThread(); - f = 88; - } + void main_thread_OK() { + OurThreadUtils.assertMainThread(); + f = 88; + } Integer f1; - void main_thread1_OK(){ - OurThreadUtil.assertOnUiThread(); - f1 = 88; - } - + void main_thread1_OK() { + OurThreadUtil.assertOnUiThread(); + f1 = 88; + } - void main_thread_indirect_OK() { - main_thread_OK(); - f = 77; - } + void main_thread_indirect_OK() { + main_thread_OK(); + f = 77; + } - void read_from_main_thread_OK(){ + void read_from_main_thread_OK() { Integer x; OurThreadUtils.assertMainThread(); x = f; } - void read_unprotected_unthreaded_Bad(){ + void read_unprotected_unthreaded_Bad() { Integer x; x = f; } - void read_unprotected_unthreaded1_Bad(){ + void read_unprotected_unthreaded1_Bad() { Integer x; x = f1; } @@ -89,101 +92,92 @@ class RaceWithMainThread{ } } - void readProtectedUnthreadedBad(){ + void readProtectedUnthreadedBad() { Integer x; - synchronized (this){ + synchronized (this) { x = f; } } Integer g; - void holds_lock_OK(){ - OurThreadUtils.assertHoldsLock(this); - g = 88; - } + void holds_lock_OK() { + OurThreadUtils.assertHoldsLock(this); + g = 88; + } - void holds_lock_indirect_OK() { - holds_lock_OK(); - g = 77; - } + void holds_lock_indirect_OK() { + holds_lock_OK(); + g = 77; + } Integer ff; - void conditional1_Ok(boolean b){ - if (b) - { /*People not literally putting this assert inside if's, - but implicitly by method calls */ - OurThreadUtils.assertMainThread(); - ff = 88; - } - } - - void conditional2_bad(boolean b){ - if (b) - { - OurThreadUtils.assertMainThread(); - ff = 88; - } else { - ff = 99; // this might or might now run on the main thread; warn - } - } - - void conditional_isMainThread_Ok(){ - if (OurThreadUtils.isMainThread()) - { - ff = 88; - } - } - - void conditional_isUiThread_Ok(){ - if (OurThreadUtil.isUiThread()) - { - ff = 88; - } - } - - - void conditional_isMainThread_ElseBranch_Bad(){ - if (OurThreadUtils.isMainThread()) - { - synchronized(this){ - ff = 88; - } - } else { - ff = 99; - } - } - - void conditional_isUiThread_ElseBranch_Bad(){ - if (OurThreadUtil.isUiThread()) - { - synchronized(this){ - ff = 88; - } - } else { - ff = 99; - } - } - - - void conditional_isMainThread_Negation_Bad(){ - if (!OurThreadUtils.isMainThread()) - { - ff = 88; - } - } - - void conditional_isMainThread_ElseBranch_Ok(){ - if (!OurThreadUtils.isMainThread()) - { - synchronized(this){ - ff = 88; - } - } else { - ff = 99; - } - } + void conditional1_Ok(boolean b) { + if (b) { + /*People not literally putting this assert inside if's, + but implicitly by method calls */ + OurThreadUtils.assertMainThread(); + ff = 88; + } + } + + void conditional2_bad(boolean b) { + if (b) { + OurThreadUtils.assertMainThread(); + ff = 88; + } else { + ff = 99; // this might or might now run on the main thread; warn + } + } + + void conditional_isMainThread_Ok() { + if (OurThreadUtils.isMainThread()) { + ff = 88; + } + } + + void conditional_isUiThread_Ok() { + if (OurThreadUtil.isUiThread()) { + ff = 88; + } + } + + void conditional_isMainThread_ElseBranch_Bad() { + if (OurThreadUtils.isMainThread()) { + synchronized (this) { + ff = 88; + } + } else { + ff = 99; + } + } + + void conditional_isUiThread_ElseBranch_Bad() { + if (OurThreadUtil.isUiThread()) { + synchronized (this) { + ff = 88; + } + } else { + ff = 99; + } + } + + void conditional_isMainThread_Negation_Bad() { + if (!OurThreadUtils.isMainThread()) { + ff = 88; + } + } + + void conditional_isMainThread_ElseBranch_Ok() { + if (!OurThreadUtils.isMainThread()) { + synchronized (this) { + ff = 88; + } + } else { + ff = 99; + } + } Object mFld; @@ -233,7 +227,6 @@ class RaceWithMainThread{ // the caller does too mSharedField = 7; } - } // not marked thread-safe @@ -256,5 +249,4 @@ class Unmarked { // on a background thread return mField; } - } diff --git a/infer/tests/codetoanalyze/java/racerd/ReadWriteRaces.java b/infer/tests/codetoanalyze/java/racerd/ReadWriteRaces.java index da35dc51a..a1ecc2bd0 100644 --- a/infer/tests/codetoanalyze/java/racerd/ReadWriteRaces.java +++ b/infer/tests/codetoanalyze/java/racerd/ReadWriteRaces.java @@ -29,27 +29,27 @@ class ReadWriteRaces { Integer safe_read; Integer racy; - void m0_OK(){ - Integer local; - local = safe_read; - } + void m0_OK() { + Integer local; + local = safe_read; + } - void m0_OK2(){ //parallel reads are OK - Integer local; - local = safe_read; + void m0_OK2() { // parallel reads are OK + Integer local; + local = safe_read; } - void m1(){ // A read where there are other writes - Integer local; - local = racy; + void m1() { // A read where there are other writes + Integer local; + local = racy; } - public void m2(){ - racy = 88; + public void m2() { + racy = 88; } - public void m3(){ - racy = 99; + public void m3() { + racy = 99; } // write inside sync, read outside of sync races @@ -75,7 +75,7 @@ class ReadWriteRaces { } public void syncWrite2() { - synchronized(this) { + synchronized (this) { field2 = new Object(); } } @@ -106,5 +106,4 @@ class ReadWriteRaces { lock.unlock(); } } - } diff --git a/infer/tests/codetoanalyze/java/racerd/SkippedClass.java b/infer/tests/codetoanalyze/java/racerd/SkippedClass.java index 335eac630..cee995ec9 100644 --- a/infer/tests/codetoanalyze/java/racerd/SkippedClass.java +++ b/infer/tests/codetoanalyze/java/racerd/SkippedClass.java @@ -16,5 +16,4 @@ public class SkippedClass { public static SkippedClass returnOwned() { return new SkippedClass(); } - } diff --git a/infer/tests/codetoanalyze/java/racerd/SubFld.java b/infer/tests/codetoanalyze/java/racerd/SubFld.java index d99a510a2..0754d9d40 100644 --- a/infer/tests/codetoanalyze/java/racerd/SubFld.java +++ b/infer/tests/codetoanalyze/java/racerd/SubFld.java @@ -13,26 +13,28 @@ import javax.annotation.concurrent.ThreadSafe; class SuperFld { private int f = 0; + public int getF() { return f; // should *not* report read/write race with SubFld.setF() } protected int g = 0; + public int getG() { return g; // must report read/write race with SubFld.setG() } - } @ThreadSafe public class SubFld extends SuperFld { private int f = 0; - synchronized public void setF() { + + public synchronized void setF() { f = 5; // should *not* report } - synchronized public void setG() { + public synchronized void setG() { g = 5; // must report } } diff --git a/infer/tests/codetoanalyze/java/racerd/SwitchEnum.java b/infer/tests/codetoanalyze/java/racerd/SwitchEnum.java index af1b43396..48d80824f 100644 --- a/infer/tests/codetoanalyze/java/racerd/SwitchEnum.java +++ b/infer/tests/codetoanalyze/java/racerd/SwitchEnum.java @@ -13,15 +13,22 @@ public class SwitchEnum { // Java generates a class for the switch, which contains an int array // This leads to races where there are int arrays, here a[] public String getName(EnumClass value) { - synchronized(this) { + synchronized (this) { a[0] = 0; // should not report here } switch (value) { - case VALUE1: return "value 1"; - case VALUE3: return "value 3"; - default: return "other"; + case VALUE1: + return "value 1"; + case VALUE3: + return "value 3"; + default: + return "other"; } } } -enum EnumClass { VALUE1, VALUE2, VALUE3 } +enum EnumClass { + VALUE1, + VALUE2, + VALUE3 +} diff --git a/infer/tests/codetoanalyze/java/racerd/ThreadSafeExample.java b/infer/tests/codetoanalyze/java/racerd/ThreadSafeExample.java index 50f9be778..926b72a4b 100644 --- a/infer/tests/codetoanalyze/java/racerd/ThreadSafeExample.java +++ b/infer/tests/codetoanalyze/java/racerd/ThreadSafeExample.java @@ -7,14 +7,12 @@ package codetoanalyze.java.checkers; -import javax.annotation.concurrent.NotThreadSafe; - import com.facebook.infer.annotation.ThreadSafe; - import com.google.common.annotations.VisibleForTesting; +import javax.annotation.concurrent.NotThreadSafe; @ThreadSafe -public class ThreadSafeExample{ +public class ThreadSafeExample { /*Included to make sure infer does not report on class initializers*/ static Class A = ThreadSafeExample.class; @@ -131,48 +129,44 @@ public class ThreadSafeExample{ } return sStaticField; // we'll warn here, although this is fine } - } -class ExtendsThreadSafeExample extends ThreadSafeExample{ +class ExtendsThreadSafeExample extends ThreadSafeExample { Integer field; /* Presently,we will warn not just on overwridden methods from @ThreadSafe class, but potentially on other methods in subclass */ public void newmethodBad() { - field = 22; + field = 22; } /* Bad now that it's overridden */ public void tsOK() { - field = 44; + field = 44; } - } @NotThreadSafe -class NotThreadSafeExtendsThreadSafeExample extends ThreadSafeExample{ +class NotThreadSafeExtendsThreadSafeExample extends ThreadSafeExample { Integer field; -/* We don't want to warn on this */ + /* We don't want to warn on this */ public void newmethodBad() { - field = 22; + field = 22; } - } @ThreadSafe -class YesThreadSafeExtendsNotThreadSafeExample extends NotThreadSafeExtendsThreadSafeExample{ +class YesThreadSafeExtendsNotThreadSafeExample extends NotThreadSafeExtendsThreadSafeExample { Integer subsubfield; -/* We do want to warn on this */ + /* We do want to warn on this */ public void subsubmethodBad() { - subsubfield = 22; + subsubfield = 22; } - } class Unannotated { diff --git a/infer/tests/codetoanalyze/java/racerd/ThreadSafeMethods.java b/infer/tests/codetoanalyze/java/racerd/ThreadSafeMethods.java index 6662caa3c..008975a7c 100644 --- a/infer/tests/codetoanalyze/java/racerd/ThreadSafeMethods.java +++ b/infer/tests/codetoanalyze/java/racerd/ThreadSafeMethods.java @@ -7,7 +7,6 @@ package codetoanalyze.java.checkers; - import com.facebook.infer.annotation.ThreadSafe; import com.google.common.annotations.VisibleForTesting; @@ -41,8 +40,7 @@ class ThreadSafeMethods { } @ThreadSafe - public void safeMethodOverride() { - } + public void safeMethodOverride() {} // if a method annotated with @ThreadSafe in class C writes field f, then all other accesses to f // in C must also be thread-safe @@ -98,7 +96,6 @@ class ThreadSafeMethods { public Object readSameFieldAsThreadSafeMethodOk() { return this.field5; } - } class ThreadSafeMethodsSubclass extends ThreadSafeMethods { @@ -125,5 +122,4 @@ class ThreadSafeMethodsSubclass extends ThreadSafeMethods { public Object readThreadSafeFieldOfOverrideBad() { return this.subclassField; } - } diff --git a/infer/tests/codetoanalyze/java/racerd/issues.exp b/infer/tests/codetoanalyze/java/racerd/issues.exp index a605eadde..b0d870bca 100644 --- a/infer/tests/codetoanalyze/java/racerd/issues.exp +++ b/infer/tests/codetoanalyze/java/racerd/issues.exp @@ -1,24 +1,24 @@ -codetoanalyze/java/racerd/AndroidModels.java, codetoanalyze.java.checkers.AndroidModels.someResourceMethodsNotFunctionalBad():void, 63, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.AndroidModels.mField`] -codetoanalyze/java/racerd/Annotations.java, codetoanalyze.java.checkers.Annotations.FP_functionalAcrossBoxingLongOk():int, 337, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.Annotations.mBoxedLong2`] -codetoanalyze/java/racerd/Annotations.java, codetoanalyze.java.checkers.Annotations.FP_functionalAcrossUnboxingOk():boolean, 308, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.Annotations.mBool2`] -codetoanalyze/java/racerd/Annotations.java, codetoanalyze.java.checkers.Annotations.conditional2_bad(boolean):void, 188, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.Annotations.ii`] -codetoanalyze/java/racerd/Annotations.java, codetoanalyze.java.checkers.Annotations.functionaLongBad():long, 284, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.Annotations.mLong`] -codetoanalyze/java/racerd/Annotations.java, codetoanalyze.java.checkers.Annotations.functionalAcrossUnboxingLongBad():int, 328, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.Annotations.mLong2`] -codetoanalyze/java/racerd/Annotations.java, codetoanalyze.java.checkers.Annotations.functionalAndNonfunctionalBad():void, 371, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.Annotations.mInt`] -codetoanalyze/java/racerd/Annotations.java, codetoanalyze.java.checkers.Annotations.functionalDoubleBad():double, 276, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.Annotations.mDouble`] -codetoanalyze/java/racerd/Annotations.java, codetoanalyze.java.checkers.Annotations.mutateOffUiThreadBad():void, 114, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.Annotations.f`] -codetoanalyze/java/racerd/Annotations.java, codetoanalyze.java.checkers.Annotations.mutateSubfieldOfConfinedBad():void, 153, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.Annotations.encapsulatedField.codetoanalyze.java.checkers.Obj.f`] -codetoanalyze/java/racerd/Annotations.java, codetoanalyze.java.checkers.Annotations.read_from_non_confined_method_Bad():void, 166, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.checkers.Annotations.zz`,,access to `this.codetoanalyze.java.checkers.Annotations.zz`] -codetoanalyze/java/racerd/Annotations.java, codetoanalyze.java.checkers.Annotations.read_off_UI_thread_Bad():void, 199, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.checkers.Annotations.f`,,access to `this.codetoanalyze.java.checkers.Annotations.f`] -codetoanalyze/java/racerd/Annotations.java, codetoanalyze.java.checkers.ThreadSafeAlias.threadSafeAliasBad1():void, 90, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.ThreadSafeAlias.field`] -codetoanalyze/java/racerd/Annotations.java, codetoanalyze.java.checkers.ThreadSafeAlias.threadSafeAliasBad2():void, 95, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.ThreadSafeAlias.field`] +codetoanalyze/java/racerd/AndroidModels.java, codetoanalyze.java.checkers.AndroidModels.someResourceMethodsNotFunctionalBad():void, 58, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.AndroidModels.mField`] +codetoanalyze/java/racerd/Annotations.java, codetoanalyze.java.checkers.Annotations.FP_functionalAcrossBoxingLongOk():int, 342, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.Annotations.mBoxedLong2`] +codetoanalyze/java/racerd/Annotations.java, codetoanalyze.java.checkers.Annotations.FP_functionalAcrossUnboxingOk():boolean, 312, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.Annotations.mBool2`] +codetoanalyze/java/racerd/Annotations.java, codetoanalyze.java.checkers.Annotations.conditional2_bad(boolean):void, 180, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.Annotations.ii`] +codetoanalyze/java/racerd/Annotations.java, codetoanalyze.java.checkers.Annotations.functionaLongBad():long, 286, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.Annotations.mLong`] +codetoanalyze/java/racerd/Annotations.java, codetoanalyze.java.checkers.Annotations.functionalAcrossUnboxingLongBad():int, 333, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.Annotations.mLong2`] +codetoanalyze/java/racerd/Annotations.java, codetoanalyze.java.checkers.Annotations.functionalAndNonfunctionalBad():void, 378, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.Annotations.mInt`] +codetoanalyze/java/racerd/Annotations.java, codetoanalyze.java.checkers.Annotations.functionalDoubleBad():double, 278, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.Annotations.mDouble`] +codetoanalyze/java/racerd/Annotations.java, codetoanalyze.java.checkers.Annotations.mutateOffUiThreadBad():void, 106, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.Annotations.f`] +codetoanalyze/java/racerd/Annotations.java, codetoanalyze.java.checkers.Annotations.mutateSubfieldOfConfinedBad():void, 146, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.Annotations.encapsulatedField.codetoanalyze.java.checkers.Obj.f`] +codetoanalyze/java/racerd/Annotations.java, codetoanalyze.java.checkers.Annotations.read_from_non_confined_method_Bad():void, 159, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.checkers.Annotations.zz`,,access to `this.codetoanalyze.java.checkers.Annotations.zz`] +codetoanalyze/java/racerd/Annotations.java, codetoanalyze.java.checkers.Annotations.read_off_UI_thread_Bad():void, 190, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.checkers.Annotations.f`,,access to `this.codetoanalyze.java.checkers.Annotations.f`] +codetoanalyze/java/racerd/Annotations.java, codetoanalyze.java.checkers.ThreadSafeAlias.threadSafeAliasBad1():void, 82, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.ThreadSafeAlias.field`] +codetoanalyze/java/racerd/Annotations.java, codetoanalyze.java.checkers.ThreadSafeAlias.threadSafeAliasBad2():void, 87, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.ThreadSafeAlias.field`] codetoanalyze/java/racerd/Arrays.java, Arrays.arrayParameterWriteBad(int[]):void, 26, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `name1.[_]`] codetoanalyze/java/racerd/Arrays.java, Arrays.readWriteRaceBad(java.lang.String):java.lang.String, 47, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.Arrays.strArr1.[_]`,,access to `this.Arrays.strArr1.[_]`] codetoanalyze/java/racerd/Arrays.java, Arrays.writeWriteRaceBad(java.lang.String):void, 39, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.Arrays.strArr1.[_]`] -codetoanalyze/java/racerd/Builders.java, codetoanalyze.java.checkers.Builders.buildThenMutateBad(codetoanalyze.java.checkers.Builders$Obj):codetoanalyze.java.checkers.Builders$Obj, 89, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,call to Builders$Obj$Builder Builders$Obj$Builder.setFromObj(Builders$Obj),access to `input.codetoanalyze.java.checkers.Builders$Obj.g`,,access to `input.codetoanalyze.java.checkers.Builders$Obj.g`] -codetoanalyze/java/racerd/Builders.java, codetoanalyze.java.checkers.Builders.buildThenMutateBad(codetoanalyze.java.checkers.Builders$Obj):codetoanalyze.java.checkers.Builders$Obj, 90, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `input.codetoanalyze.java.checkers.Builders$Obj.g`] -codetoanalyze/java/racerd/Builders.java, codetoanalyze.java.checkers.Builders.mutateBad(codetoanalyze.java.checkers.Builders$Obj):codetoanalyze.java.checkers.Builders$Obj, 82, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `o.codetoanalyze.java.checkers.Builders$Obj.g`] -codetoanalyze/java/racerd/Builders.java, codetoanalyze.java.checkers.TopLevelBuilder.setG(java.lang.String):void, 101, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.TopLevelBuilder.g`] +codetoanalyze/java/racerd/Builders.java, codetoanalyze.java.checkers.Builders.buildThenMutateBad(codetoanalyze.java.checkers.Builders$Obj):codetoanalyze.java.checkers.Builders$Obj, 88, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,call to Builders$Obj$Builder Builders$Obj$Builder.setFromObj(Builders$Obj),access to `input.codetoanalyze.java.checkers.Builders$Obj.g`,,access to `input.codetoanalyze.java.checkers.Builders$Obj.g`] +codetoanalyze/java/racerd/Builders.java, codetoanalyze.java.checkers.Builders.buildThenMutateBad(codetoanalyze.java.checkers.Builders$Obj):codetoanalyze.java.checkers.Builders$Obj, 89, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `input.codetoanalyze.java.checkers.Builders$Obj.g`] +codetoanalyze/java/racerd/Builders.java, codetoanalyze.java.checkers.Builders.mutateBad(codetoanalyze.java.checkers.Builders$Obj):codetoanalyze.java.checkers.Builders$Obj, 81, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `o.codetoanalyze.java.checkers.Builders$Obj.g`] +codetoanalyze/java/racerd/Builders.java, codetoanalyze.java.checkers.TopLevelBuilder.setG(java.lang.String):void, 99, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.TopLevelBuilder.g`] codetoanalyze/java/racerd/Constructors.java, Constructors.(), 20, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `Constructors.Constructors.staticField`] codetoanalyze/java/racerd/Constructors.java, Constructors.(Constructors), 28, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `o.Constructors.field`] codetoanalyze/java/racerd/Constructors.java, Constructors.FP_singleton2Ok():Constructors, 52, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `Constructors.Constructors.sSingleton1`,,access to `Constructors.Constructors.sSingleton1`] @@ -26,58 +26,58 @@ codetoanalyze/java/racerd/Constructors.java, Constructors.singleton1Bad():Constr codetoanalyze/java/racerd/Constructors.java, Constructors.singleton2Bad():Constructors, 63, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `Constructors.Constructors.sSingleton2`,,access to `Constructors.Constructors.sSingleton2`] codetoanalyze/java/racerd/Constructors.java, Constructors.singleton2Bad():Constructors, 64, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `Constructors.Constructors.sSingleton2`] codetoanalyze/java/racerd/Constructors.java, Constructors.singleton2Bad():Constructors, 66, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `Constructors.Constructors.sSingleton2`,,access to `Constructors.Constructors.sSingleton2`] -codetoanalyze/java/racerd/Containers.java, codetoanalyze.java.checkers.Containers.addToSimpleArrayMapBad(android.support.v4.util.SimpleArrayMap):void, 277, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [Write to container `map` via call to `put`] -codetoanalyze/java/racerd/Containers.java, codetoanalyze.java.checkers.Containers.addToSparseArrayBad(android.util.SparseArray):void, 267, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [Write to container `sparseArray` via call to `put`] -codetoanalyze/java/racerd/Containers.java, codetoanalyze.java.checkers.Containers.addToSparseArrayCompatBad(android.support.v4.util.SparseArrayCompat):void, 258, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [Write to container `sparseArray` via call to `put`] -codetoanalyze/java/racerd/Containers.java, codetoanalyze.java.checkers.Containers.containerWrapperUnownedWriteBad(java.lang.Object):void, 165, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [call to Object ContainerWrapper.write(Object),call to Object ContainerWrapper._write(Object),Write to container `this.codetoanalyze.java.checkers.ContainerWrapper.children` via call to `add`] -codetoanalyze/java/racerd/Containers.java, codetoanalyze.java.checkers.Containers.listAddAllBad(java.util.Collection):void, 59, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [Write to container `this.codetoanalyze.java.checkers.Containers.mList` via call to `addAll`] -codetoanalyze/java/racerd/Containers.java, codetoanalyze.java.checkers.Containers.listAddBad1(java.lang.String):void, 51, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [Write to container `this.codetoanalyze.java.checkers.Containers.mList` via call to `add`] -codetoanalyze/java/racerd/Containers.java, codetoanalyze.java.checkers.Containers.listAddBad2(int,java.lang.String):void, 55, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [Write to container `this.codetoanalyze.java.checkers.Containers.mList` via call to `add`] -codetoanalyze/java/racerd/Containers.java, codetoanalyze.java.checkers.Containers.listClearBad():void, 63, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [Write to container `this.codetoanalyze.java.checkers.Containers.mList` via call to `clear`] -codetoanalyze/java/racerd/Containers.java, codetoanalyze.java.checkers.Containers.listReadBad(java.lang.String):boolean, 96, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,Read of container `this.codetoanalyze.java.checkers.Containers.mList` via call to `contains`,,Write to container `this.codetoanalyze.java.checkers.Containers.mList` via call to `set`] -codetoanalyze/java/racerd/Containers.java, codetoanalyze.java.checkers.Containers.listRemoveBad1(int):void, 67, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [Write to container `this.codetoanalyze.java.checkers.Containers.mList` via call to `remove`] -codetoanalyze/java/racerd/Containers.java, codetoanalyze.java.checkers.Containers.listRemoveBad2(java.lang.String):void, 71, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [Write to container `this.codetoanalyze.java.checkers.Containers.mList` via call to `remove`] -codetoanalyze/java/racerd/Containers.java, codetoanalyze.java.checkers.Containers.listSetBad(int,java.lang.String):void, 79, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [Write to container `this.codetoanalyze.java.checkers.Containers.mList` via call to `set`] -codetoanalyze/java/racerd/Containers.java, codetoanalyze.java.checkers.Containers.listSubclassWriteBad(java.util.ArrayList,int):void, 83, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [Write to container `list` via call to `remove`] -codetoanalyze/java/racerd/Containers.java, codetoanalyze.java.checkers.Containers.mapClearBad():void, 113, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [Write to container `this.codetoanalyze.java.checkers.Containers.mMap` via call to `clear`] -codetoanalyze/java/racerd/Containers.java, codetoanalyze.java.checkers.Containers.mapPutAllBad(java.util.Map):void, 117, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [Write to container `this.codetoanalyze.java.checkers.Containers.mMap` via call to `putAll`] -codetoanalyze/java/racerd/Containers.java, codetoanalyze.java.checkers.Containers.mapPutBad(java.lang.String,java.lang.String):void, 105, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [Write to container `this.codetoanalyze.java.checkers.Containers.mMap` via call to `put`] -codetoanalyze/java/racerd/Containers.java, codetoanalyze.java.checkers.Containers.mapRemoveBad(java.lang.String):void, 109, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [Write to container `this.codetoanalyze.java.checkers.Containers.mMap` via call to `remove`] -codetoanalyze/java/racerd/Containers.java, codetoanalyze.java.checkers.Containers.mapSubclassWriteBad(java.util.HashMap,java.lang.String):void, 135, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [Write to container `m` via call to `remove`] -codetoanalyze/java/racerd/Containers.java, codetoanalyze.java.checkers.Containers.poolBad():void, 295, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [Write to container `this.codetoanalyze.java.checkers.Containers.simplePool` via call to `release`] -codetoanalyze/java/racerd/Containers.java, codetoanalyze.java.checkers.Containers.readSimpleArrayMap():int, 282, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,Read of container `this.codetoanalyze.java.checkers.Containers.si_map` via call to `get`,,Write to container `this.codetoanalyze.java.checkers.Containers.si_map` via call to `put`] -codetoanalyze/java/racerd/DeepOwnership.java, DeepOwnership.globalNotOwnedBad():void, 17, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `DeepOwnership.DeepOwnership.global.DeepOwnership.next`] -codetoanalyze/java/racerd/DeepOwnership.java, DeepOwnership.reassignBaseToGlobalBad():void, 23, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `x.DeepOwnership.next`] +codetoanalyze/java/racerd/Containers.java, codetoanalyze.java.checkers.Containers.addToSimpleArrayMapBad(android.support.v4.util.SimpleArrayMap):void, 273, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [Write to container `map` via call to `put`] +codetoanalyze/java/racerd/Containers.java, codetoanalyze.java.checkers.Containers.addToSparseArrayBad(android.util.SparseArray):void, 263, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [Write to container `sparseArray` via call to `put`] +codetoanalyze/java/racerd/Containers.java, codetoanalyze.java.checkers.Containers.addToSparseArrayCompatBad(android.support.v4.util.SparseArrayCompat):void, 254, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [Write to container `sparseArray` via call to `put`] +codetoanalyze/java/racerd/Containers.java, codetoanalyze.java.checkers.Containers.containerWrapperUnownedWriteBad(java.lang.Object):void, 161, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [call to Object ContainerWrapper.write(Object),call to Object ContainerWrapper._write(Object),Write to container `this.codetoanalyze.java.checkers.ContainerWrapper.children` via call to `add`] +codetoanalyze/java/racerd/Containers.java, codetoanalyze.java.checkers.Containers.listAddAllBad(java.util.Collection):void, 55, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [Write to container `this.codetoanalyze.java.checkers.Containers.mList` via call to `addAll`] +codetoanalyze/java/racerd/Containers.java, codetoanalyze.java.checkers.Containers.listAddBad1(java.lang.String):void, 47, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [Write to container `this.codetoanalyze.java.checkers.Containers.mList` via call to `add`] +codetoanalyze/java/racerd/Containers.java, codetoanalyze.java.checkers.Containers.listAddBad2(int,java.lang.String):void, 51, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [Write to container `this.codetoanalyze.java.checkers.Containers.mList` via call to `add`] +codetoanalyze/java/racerd/Containers.java, codetoanalyze.java.checkers.Containers.listClearBad():void, 59, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [Write to container `this.codetoanalyze.java.checkers.Containers.mList` via call to `clear`] +codetoanalyze/java/racerd/Containers.java, codetoanalyze.java.checkers.Containers.listReadBad(java.lang.String):boolean, 92, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,Read of container `this.codetoanalyze.java.checkers.Containers.mList` via call to `contains`,,Write to container `this.codetoanalyze.java.checkers.Containers.mList` via call to `set`] +codetoanalyze/java/racerd/Containers.java, codetoanalyze.java.checkers.Containers.listRemoveBad1(int):void, 63, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [Write to container `this.codetoanalyze.java.checkers.Containers.mList` via call to `remove`] +codetoanalyze/java/racerd/Containers.java, codetoanalyze.java.checkers.Containers.listRemoveBad2(java.lang.String):void, 67, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [Write to container `this.codetoanalyze.java.checkers.Containers.mList` via call to `remove`] +codetoanalyze/java/racerd/Containers.java, codetoanalyze.java.checkers.Containers.listSetBad(int,java.lang.String):void, 75, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [Write to container `this.codetoanalyze.java.checkers.Containers.mList` via call to `set`] +codetoanalyze/java/racerd/Containers.java, codetoanalyze.java.checkers.Containers.listSubclassWriteBad(java.util.ArrayList,int):void, 79, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [Write to container `list` via call to `remove`] +codetoanalyze/java/racerd/Containers.java, codetoanalyze.java.checkers.Containers.mapClearBad():void, 109, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [Write to container `this.codetoanalyze.java.checkers.Containers.mMap` via call to `clear`] +codetoanalyze/java/racerd/Containers.java, codetoanalyze.java.checkers.Containers.mapPutAllBad(java.util.Map):void, 113, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [Write to container `this.codetoanalyze.java.checkers.Containers.mMap` via call to `putAll`] +codetoanalyze/java/racerd/Containers.java, codetoanalyze.java.checkers.Containers.mapPutBad(java.lang.String,java.lang.String):void, 101, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [Write to container `this.codetoanalyze.java.checkers.Containers.mMap` via call to `put`] +codetoanalyze/java/racerd/Containers.java, codetoanalyze.java.checkers.Containers.mapRemoveBad(java.lang.String):void, 105, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [Write to container `this.codetoanalyze.java.checkers.Containers.mMap` via call to `remove`] +codetoanalyze/java/racerd/Containers.java, codetoanalyze.java.checkers.Containers.mapSubclassWriteBad(java.util.HashMap,java.lang.String):void, 131, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [Write to container `m` via call to `remove`] +codetoanalyze/java/racerd/Containers.java, codetoanalyze.java.checkers.Containers.poolBad():void, 292, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [Write to container `this.codetoanalyze.java.checkers.Containers.simplePool` via call to `release`] +codetoanalyze/java/racerd/Containers.java, codetoanalyze.java.checkers.Containers.readSimpleArrayMap():int, 278, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,Read of container `this.codetoanalyze.java.checkers.Containers.si_map` via call to `get`,,Write to container `this.codetoanalyze.java.checkers.Containers.si_map` via call to `put`] +codetoanalyze/java/racerd/DeepOwnership.java, DeepOwnership.globalNotOwnedBad():void, 16, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `DeepOwnership.DeepOwnership.global.DeepOwnership.next`] +codetoanalyze/java/racerd/DeepOwnership.java, DeepOwnership.reassignBaseToGlobalBad():void, 22, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `x.DeepOwnership.next`] codetoanalyze/java/racerd/Dispatch.java, codetoanalyze.java.checkers.Dispatch.callUnannotatedInterfaceBad(codetoanalyze.java.checkers.UnannotatedInterface):void, 49, INTERFACE_NOT_THREAD_SAFE, no_bucket, ERROR, [Call to un-annotated interface method void UnannotatedInterface.foo()] codetoanalyze/java/racerd/Dispatch.java, codetoanalyze.java.checkers.Dispatch.callUnannotatedInterfaceIndirectBad(codetoanalyze.java.checkers.NotThreadSafe,codetoanalyze.java.checkers.UnannotatedInterface):void, 53, INTERFACE_NOT_THREAD_SAFE, no_bucket, ERROR, [call to void NotThreadSafe.notThreadSafeOk(UnannotatedInterface),Call to un-annotated interface method void UnannotatedInterface.foo()] -codetoanalyze/java/racerd/Dispatch.java, codetoanalyze.java.checkers.ThreadConfinedField.interfaceCallOnNormalFieldBad():void, 101, INTERFACE_NOT_THREAD_SAFE, no_bucket, ERROR, [Call to un-annotated interface method void UnannotatedInterface.foo()] -codetoanalyze/java/racerd/Inference.java, codetoanalyze.java.checkers.Inference.read4OutsideSyncBad():int, 65, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.checkers.Inference.mField4`,,access to `this.codetoanalyze.java.checkers.Inference.mField4`] +codetoanalyze/java/racerd/Dispatch.java, codetoanalyze.java.checkers.ThreadConfinedField.interfaceCallOnNormalFieldBad():void, 102, INTERFACE_NOT_THREAD_SAFE, no_bucket, ERROR, [Call to un-annotated interface method void UnannotatedInterface.foo()] +codetoanalyze/java/racerd/Inference.java, codetoanalyze.java.checkers.Inference.read4OutsideSyncBad():int, 64, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.checkers.Inference.mField4`,,access to `this.codetoanalyze.java.checkers.Inference.mField4`] codetoanalyze/java/racerd/Inference.java, codetoanalyze.java.checkers.Inference.unprotectedRead1Bad():int, 21, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.checkers.Inference.mField1`,,access to `this.codetoanalyze.java.checkers.Inference.mField1`] codetoanalyze/java/racerd/Inference.java, codetoanalyze.java.checkers.Inference.unprotectedRead2Bad():int, 34, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.checkers.Inference.mField2`,,access to `this.codetoanalyze.java.checkers.Inference.mField2`] -codetoanalyze/java/racerd/Locks.java, codetoanalyze.java.checkers.Locks.afterReentrantLockUnlockBad():void, 46, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.Locks.f`] -codetoanalyze/java/racerd/Locks.java, codetoanalyze.java.checkers.Locks.afterUnlockBad():void, 40, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.Locks.f`] -codetoanalyze/java/racerd/Locks.java, codetoanalyze.java.checkers.Locks.afterWriteLockUnlockBad():void, 52, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.Locks.f`] -codetoanalyze/java/racerd/Locks.java, codetoanalyze.java.checkers.Locks.lockInLoopLexicalBad(int):void, 249, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.Locks.f`] -codetoanalyze/java/racerd/Locks.java, codetoanalyze.java.checkers.Locks.negatedReentrantLockTryLockBad():void, 113, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.Locks.f`] -codetoanalyze/java/racerd/Locks.java, codetoanalyze.java.checkers.Locks.nested1Bad():void, 196, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.Locks.f`] -codetoanalyze/java/racerd/Locks.java, codetoanalyze.java.checkers.Locks.nested2Bad():void, 202, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.Locks.f`] -codetoanalyze/java/racerd/Locks.java, codetoanalyze.java.checkers.Locks.nested3Bad():void, 212, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.Locks.f`] -codetoanalyze/java/racerd/Locks.java, codetoanalyze.java.checkers.Locks.readOutsideLock1Bad():boolean, 309, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.checkers.Locks.mField`,,access to `this.codetoanalyze.java.checkers.Locks.mField`] -codetoanalyze/java/racerd/Locks.java, codetoanalyze.java.checkers.Locks.readOutsideLock2Bad():boolean, 313, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.checkers.Locks.mField`,,access to `this.codetoanalyze.java.checkers.Locks.mField`] -codetoanalyze/java/racerd/Locks.java, codetoanalyze.java.checkers.Locks.tryLockNoCheckBad():void, 93, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.Locks.f`] -codetoanalyze/java/racerd/Locks.java, codetoanalyze.java.checkers.Locks.tryLockWrongBranchBad():void, 99, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.Locks.f`] -codetoanalyze/java/racerd/Locks.java, codetoanalyze.java.checkers.Locks.unownedReadBad():java.lang.Object, 364, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.checkers.Locks.mField3`,,call to void Locks.lockedWriteInCallee2(),access to `this.codetoanalyze.java.checkers.Locks.mField3`] -codetoanalyze/java/racerd/Locks.java, codetoanalyze.java.checkers.Locks.useLockInCalleeBad():void, 223, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.Locks.f`] +codetoanalyze/java/racerd/Locks.java, codetoanalyze.java.checkers.Locks.afterReentrantLockUnlockBad():void, 45, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.Locks.f`] +codetoanalyze/java/racerd/Locks.java, codetoanalyze.java.checkers.Locks.afterUnlockBad():void, 39, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.Locks.f`] +codetoanalyze/java/racerd/Locks.java, codetoanalyze.java.checkers.Locks.afterWriteLockUnlockBad():void, 51, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.Locks.f`] +codetoanalyze/java/racerd/Locks.java, codetoanalyze.java.checkers.Locks.lockInLoopLexicalBad(int):void, 247, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.Locks.f`] +codetoanalyze/java/racerd/Locks.java, codetoanalyze.java.checkers.Locks.negatedReentrantLockTryLockBad():void, 112, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.Locks.f`] +codetoanalyze/java/racerd/Locks.java, codetoanalyze.java.checkers.Locks.nested1Bad():void, 195, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.Locks.f`] +codetoanalyze/java/racerd/Locks.java, codetoanalyze.java.checkers.Locks.nested2Bad():void, 201, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.Locks.f`] +codetoanalyze/java/racerd/Locks.java, codetoanalyze.java.checkers.Locks.nested3Bad():void, 211, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.Locks.f`] +codetoanalyze/java/racerd/Locks.java, codetoanalyze.java.checkers.Locks.readOutsideLock1Bad():boolean, 307, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.checkers.Locks.mField`,,access to `this.codetoanalyze.java.checkers.Locks.mField`] +codetoanalyze/java/racerd/Locks.java, codetoanalyze.java.checkers.Locks.readOutsideLock2Bad():boolean, 311, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.checkers.Locks.mField`,,access to `this.codetoanalyze.java.checkers.Locks.mField`] +codetoanalyze/java/racerd/Locks.java, codetoanalyze.java.checkers.Locks.tryLockNoCheckBad():void, 92, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.Locks.f`] +codetoanalyze/java/racerd/Locks.java, codetoanalyze.java.checkers.Locks.tryLockWrongBranchBad():void, 98, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.Locks.f`] +codetoanalyze/java/racerd/Locks.java, codetoanalyze.java.checkers.Locks.unownedReadBad():java.lang.Object, 362, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.checkers.Locks.mField3`,,call to void Locks.lockedWriteInCallee2(),access to `this.codetoanalyze.java.checkers.Locks.mField3`] +codetoanalyze/java/racerd/Locks.java, codetoanalyze.java.checkers.Locks.useLockInCalleeBad():void, 221, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.Locks.f`] codetoanalyze/java/racerd/Ownership.java, codetoanalyze.java.checkers.Ownership.(codetoanalyze.java.checkers.Obj,java.lang.Object), 65, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `obj.codetoanalyze.java.checkers.Obj.f`] codetoanalyze/java/racerd/Ownership.java, codetoanalyze.java.checkers.Ownership.cantOwnThisBad():void, 170, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [call to void Ownership.setField(Obj),access to `this.codetoanalyze.java.checkers.Ownership.field`] codetoanalyze/java/racerd/Ownership.java, codetoanalyze.java.checkers.Ownership.castThenCallBad():void, 343, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [call to void Ownership.castThenCall(Obj),call to void Subclass.doWrite(),access to `this.codetoanalyze.java.checkers.Obj.f`] -codetoanalyze/java/racerd/Ownership.java, codetoanalyze.java.checkers.Ownership.conditionalAliasBad(codetoanalyze.java.checkers.Obj):void, 504, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [call to void Ownership.conditionalAlias(Obj,Obj),access to `alias.codetoanalyze.java.checkers.Obj.f`] +codetoanalyze/java/racerd/Ownership.java, codetoanalyze.java.checkers.Ownership.conditionalAliasBad(codetoanalyze.java.checkers.Obj):void, 510, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [call to void Ownership.conditionalAlias(Obj,Obj),access to `alias.codetoanalyze.java.checkers.Obj.f`] codetoanalyze/java/racerd/Ownership.java, codetoanalyze.java.checkers.Ownership.notOwnedInCalleeBad(codetoanalyze.java.checkers.Obj):void, 232, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [call to void Ownership.mutateIfNotNull(Obj),access to `o.codetoanalyze.java.checkers.Obj.f`] -codetoanalyze/java/racerd/Ownership.java, codetoanalyze.java.checkers.Ownership.notPropagatingOwnershipToAccessPathRootedAtFormalBad(codetoanalyze.java.checkers.Obj):void, 419, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `m.codetoanalyze.java.checkers.Obj.g`] -codetoanalyze/java/racerd/Ownership.java, codetoanalyze.java.checkers.Ownership.notPropagatingOwnershipToUnownedLocalAccessPathBad():void, 425, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.checkers.Ownership.field`,,call to void Ownership.setField(Obj),access to `this.codetoanalyze.java.checkers.Ownership.field`] -codetoanalyze/java/racerd/Ownership.java, codetoanalyze.java.checkers.Ownership.notPropagatingOwnershipToUnownedLocalAccessPathBad():void, 426, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `m.codetoanalyze.java.checkers.Obj.g`] +codetoanalyze/java/racerd/Ownership.java, codetoanalyze.java.checkers.Ownership.notPropagatingOwnershipToAccessPathRootedAtFormalBad(codetoanalyze.java.checkers.Obj):void, 420, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `m.codetoanalyze.java.checkers.Obj.g`] +codetoanalyze/java/racerd/Ownership.java, codetoanalyze.java.checkers.Ownership.notPropagatingOwnershipToUnownedLocalAccessPathBad():void, 427, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.checkers.Ownership.field`,,call to void Ownership.setField(Obj),access to `this.codetoanalyze.java.checkers.Ownership.field`] +codetoanalyze/java/racerd/Ownership.java, codetoanalyze.java.checkers.Ownership.notPropagatingOwnershipToUnownedLocalAccessPathBad():void, 429, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `m.codetoanalyze.java.checkers.Obj.g`] codetoanalyze/java/racerd/Ownership.java, codetoanalyze.java.checkers.Ownership.ownInOneBranchBad(codetoanalyze.java.checkers.Obj,boolean):void, 81, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `formal.codetoanalyze.java.checkers.Obj.f`] -codetoanalyze/java/racerd/Ownership.java, codetoanalyze.java.checkers.Ownership.readGlobalBad():int, 401, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `checkers.Ownership.codetoanalyze.java.checkers.Ownership.global`,,access to `checkers.Ownership.codetoanalyze.java.checkers.Ownership.global`] +codetoanalyze/java/racerd/Ownership.java, codetoanalyze.java.checkers.Ownership.readGlobalBad():int, 402, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `checkers.Ownership.codetoanalyze.java.checkers.Ownership.global`,,access to `checkers.Ownership.codetoanalyze.java.checkers.Ownership.global`] codetoanalyze/java/racerd/Ownership.java, codetoanalyze.java.checkers.Ownership.reassignToFormalBad(codetoanalyze.java.checkers.Obj):void, 86, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `formal.codetoanalyze.java.checkers.Obj.g`] codetoanalyze/java/racerd/Ownership.java, codetoanalyze.java.checkers.Ownership.reassignToFormalBad(codetoanalyze.java.checkers.Obj):void, 87, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `formal.codetoanalyze.java.checkers.Obj.g.codetoanalyze.java.checkers.Obj.f`] codetoanalyze/java/racerd/Ownership.java, codetoanalyze.java.checkers.Ownership.reassignToFormalBad(codetoanalyze.java.checkers.Obj):void, 87, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `formal.codetoanalyze.java.checkers.Obj.g`,,access to `formal.codetoanalyze.java.checkers.Obj.g`] @@ -85,16 +85,16 @@ codetoanalyze/java/racerd/Ownership.java, codetoanalyze.java.checkers.Ownership. codetoanalyze/java/racerd/Ownership.java, codetoanalyze.java.checkers.Ownership.writeToNotOwnedInCalleeBad2():void, 161, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [call to void Ownership.writeToFormal(Obj),access to `formal.codetoanalyze.java.checkers.Obj.f`] codetoanalyze/java/racerd/Ownership.java, codetoanalyze.java.checkers.Ownership.writeToNotOwnedInCalleeBad3(codetoanalyze.java.checkers.Obj):void, 165, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [call to void Ownership.callWriteToFormal(Obj),call to void Ownership.writeToFormal(Obj),access to `formal.codetoanalyze.java.checkers.Obj.f`] codetoanalyze/java/racerd/Ownership.java, codetoanalyze.java.checkers.Ownership.writeToOwnedInCalleeOk2():void, 182, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.checkers.Ownership.field`,,access to `this.codetoanalyze.java.checkers.Ownership.field`] -codetoanalyze/java/racerd/RaceWithMainThread.java, codetoanalyze.java.checkers.RaceWithMainThread.conditional2_bad(boolean):void, 128, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.RaceWithMainThread.ff`] -codetoanalyze/java/racerd/RaceWithMainThread.java, codetoanalyze.java.checkers.RaceWithMainThread.conditionalMainThreadWriteBad():void, 225, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [call to void RaceWithMainThread.conditionalMainThreadWrite2(boolean),access to `this.codetoanalyze.java.checkers.RaceWithMainThread.mOnlyWrittenOnMain`] -codetoanalyze/java/racerd/RaceWithMainThread.java, codetoanalyze.java.checkers.RaceWithMainThread.conditional_isMainThread_ElseBranch_Bad():void, 154, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.RaceWithMainThread.ff`] -codetoanalyze/java/racerd/RaceWithMainThread.java, codetoanalyze.java.checkers.RaceWithMainThread.conditional_isMainThread_Negation_Bad():void, 173, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.RaceWithMainThread.ff`] -codetoanalyze/java/racerd/RaceWithMainThread.java, codetoanalyze.java.checkers.RaceWithMainThread.conditional_isUiThread_ElseBranch_Bad():void, 165, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.RaceWithMainThread.ff`] -codetoanalyze/java/racerd/RaceWithMainThread.java, codetoanalyze.java.checkers.RaceWithMainThread.confusedAssertBad(boolean):void, 197, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.RaceWithMainThread.mFld`] -codetoanalyze/java/racerd/RaceWithMainThread.java, codetoanalyze.java.checkers.RaceWithMainThread.readProtectedUnthreadedBad():void, 95, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.checkers.RaceWithMainThread.f`,,access to `this.codetoanalyze.java.checkers.RaceWithMainThread.f`] -codetoanalyze/java/racerd/RaceWithMainThread.java, codetoanalyze.java.checkers.RaceWithMainThread.read_unprotected_unthreaded1_Bad():void, 61, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.checkers.RaceWithMainThread.f1`,,access to `this.codetoanalyze.java.checkers.RaceWithMainThread.f1`] -codetoanalyze/java/racerd/RaceWithMainThread.java, codetoanalyze.java.checkers.RaceWithMainThread.read_unprotected_unthreaded_Bad():void, 56, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.checkers.RaceWithMainThread.f`,,access to `this.codetoanalyze.java.checkers.RaceWithMainThread.f`] -codetoanalyze/java/racerd/RaceWithMainThread.java, codetoanalyze.java.checkers.RaceWithMainThread.writeAfterConditionalMainThreadInCalleeBad():void, 234, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.RaceWithMainThread.mSharedField`] +codetoanalyze/java/racerd/RaceWithMainThread.java, codetoanalyze.java.checkers.RaceWithMainThread.conditional2_bad(boolean):void, 130, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.RaceWithMainThread.ff`] +codetoanalyze/java/racerd/RaceWithMainThread.java, codetoanalyze.java.checkers.RaceWithMainThread.conditionalMainThreadWriteBad():void, 219, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [call to void RaceWithMainThread.conditionalMainThreadWrite2(boolean),access to `this.codetoanalyze.java.checkers.RaceWithMainThread.mOnlyWrittenOnMain`] +codetoanalyze/java/racerd/RaceWithMainThread.java, codetoanalyze.java.checkers.RaceWithMainThread.conditional_isMainThread_ElseBranch_Bad():void, 152, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.RaceWithMainThread.ff`] +codetoanalyze/java/racerd/RaceWithMainThread.java, codetoanalyze.java.checkers.RaceWithMainThread.conditional_isMainThread_Negation_Bad():void, 168, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.RaceWithMainThread.ff`] +codetoanalyze/java/racerd/RaceWithMainThread.java, codetoanalyze.java.checkers.RaceWithMainThread.conditional_isUiThread_ElseBranch_Bad():void, 162, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.RaceWithMainThread.ff`] +codetoanalyze/java/racerd/RaceWithMainThread.java, codetoanalyze.java.checkers.RaceWithMainThread.confusedAssertBad(boolean):void, 191, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.RaceWithMainThread.mFld`] +codetoanalyze/java/racerd/RaceWithMainThread.java, codetoanalyze.java.checkers.RaceWithMainThread.readProtectedUnthreadedBad():void, 98, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.checkers.RaceWithMainThread.f`,,access to `this.codetoanalyze.java.checkers.RaceWithMainThread.f`] +codetoanalyze/java/racerd/RaceWithMainThread.java, codetoanalyze.java.checkers.RaceWithMainThread.read_unprotected_unthreaded1_Bad():void, 64, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.checkers.RaceWithMainThread.f1`,,access to `this.codetoanalyze.java.checkers.RaceWithMainThread.f1`] +codetoanalyze/java/racerd/RaceWithMainThread.java, codetoanalyze.java.checkers.RaceWithMainThread.read_unprotected_unthreaded_Bad():void, 59, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.checkers.RaceWithMainThread.f`,,access to `this.codetoanalyze.java.checkers.RaceWithMainThread.f`] +codetoanalyze/java/racerd/RaceWithMainThread.java, codetoanalyze.java.checkers.RaceWithMainThread.writeAfterConditionalMainThreadInCalleeBad():void, 228, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.RaceWithMainThread.mSharedField`] codetoanalyze/java/racerd/ReadWriteRaces.java, codetoanalyze.java.checkers.ReadWriteRaces.callUnprotecteReadInCallee():java.lang.Object, 74, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,call to Object ReadWriteRaces.unprotectedReadInCallee(),access to `this.codetoanalyze.java.checkers.ReadWriteRaces.field1`,,access to `this.codetoanalyze.java.checkers.ReadWriteRaces.field1`] codetoanalyze/java/racerd/ReadWriteRaces.java, codetoanalyze.java.checkers.ReadWriteRaces.m1():void, 44, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.checkers.ReadWriteRaces.racy`,,access to `this.codetoanalyze.java.checkers.ReadWriteRaces.racy`] codetoanalyze/java/racerd/ReadWriteRaces.java, codetoanalyze.java.checkers.ReadWriteRaces.m2():void, 48, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.ReadWriteRaces.racy`] @@ -103,26 +103,26 @@ codetoanalyze/java/racerd/ReadWriteRaces.java, codetoanalyze.java.checkers.ReadW codetoanalyze/java/racerd/ReadWriteRaces.java, codetoanalyze.java.checkers.ReadWriteRaces.unprotectedRead1():java.lang.Object, 66, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.checkers.ReadWriteRaces.field1`,,access to `this.codetoanalyze.java.checkers.ReadWriteRaces.field1`] codetoanalyze/java/racerd/ReadWriteRaces.java, codetoanalyze.java.checkers.ReadWriteRaces.unprotectedRead2():java.lang.Object, 84, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.checkers.ReadWriteRaces.field2`,,access to `this.codetoanalyze.java.checkers.ReadWriteRaces.field2`] codetoanalyze/java/racerd/ReadWriteRaces.java, codetoanalyze.java.checkers.ReadWriteRaces.unprotectedRead3():java.lang.Object, 96, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.checkers.ReadWriteRaces.field3`,,call to void ReadWriteRaces.syncWrite3(),access to `this.codetoanalyze.java.checkers.ReadWriteRaces.field3`] -codetoanalyze/java/racerd/SubFld.java, SubFld.getG():int, 27, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,call to int SuperFld.getG(),access to `this.SuperFld.g`,,access to `this.SuperFld.g`] -codetoanalyze/java/racerd/ThreadSafeExample.java, codetoanalyze.java.checkers.ExtendsThreadSafeExample.newmethodBad():void, 144, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.ExtendsThreadSafeExample.field`] -codetoanalyze/java/racerd/ThreadSafeExample.java, codetoanalyze.java.checkers.ExtendsThreadSafeExample.tsOK():void, 149, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.ExtendsThreadSafeExample.field`] -codetoanalyze/java/racerd/ThreadSafeExample.java, codetoanalyze.java.checkers.ThreadSafeExample.FP_lazyInitOk():java.lang.Object, 132, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.checkers.ThreadSafeExample.sStaticField`,,access to `this.codetoanalyze.java.checkers.ThreadSafeExample.sStaticField`] -codetoanalyze/java/racerd/ThreadSafeExample.java, codetoanalyze.java.checkers.ThreadSafeExample.callPublicMethodBad():void, 59, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [call to void ThreadSafeExample.assignInPrivateMethodOk(),access to `this.codetoanalyze.java.checkers.ThreadSafeExample.f`] -codetoanalyze/java/racerd/ThreadSafeExample.java, codetoanalyze.java.checkers.ThreadSafeExample.callVisibleForTestingBad():void, 111, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [call to void ThreadSafeExample.visibleForTestingNotPublicOk(),access to `this.codetoanalyze.java.checkers.ThreadSafeExample.f`] -codetoanalyze/java/racerd/ThreadSafeExample.java, codetoanalyze.java.checkers.ThreadSafeExample.deeperTraceBad():void, 68, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [call to void ThreadSafeExample.callAssignInPrivateMethod(),call to void ThreadSafeExample.assignInPrivateMethodOk(),access to `this.codetoanalyze.java.checkers.ThreadSafeExample.f`] -codetoanalyze/java/racerd/ThreadSafeExample.java, codetoanalyze.java.checkers.ThreadSafeExample.oddBad():void, 49, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [call to void ThreadSafeExample.evenOk(),access to `this.codetoanalyze.java.checkers.ThreadSafeExample.f`] -codetoanalyze/java/racerd/ThreadSafeExample.java, codetoanalyze.java.checkers.ThreadSafeExample.recursiveBad():void, 39, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.ThreadSafeExample.f`] -codetoanalyze/java/racerd/ThreadSafeExample.java, codetoanalyze.java.checkers.ThreadSafeExample.tsBad():void, 35, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.ThreadSafeExample.f`] -codetoanalyze/java/racerd/ThreadSafeExample.java, codetoanalyze.java.checkers.YesThreadSafeExtendsNotThreadSafeExample.subsubmethodBad():void, 173, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.YesThreadSafeExtendsNotThreadSafeExample.subsubfield`] -codetoanalyze/java/racerd/ThreadSafeMethods.java, codetoanalyze.java.checkers.ThreadSafeMethods.readSameFieldAsThreadSafeMethod1Bad():java.lang.Object, 56, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.checkers.ThreadSafeMethods.field1`,,access to `this.codetoanalyze.java.checkers.ThreadSafeMethods.field1`] -codetoanalyze/java/racerd/ThreadSafeMethods.java, codetoanalyze.java.checkers.ThreadSafeMethods.readSameFieldAsThreadSafeMethod2Bad():java.lang.Object, 80, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.checkers.ThreadSafeMethods.field4`,,access to `this.codetoanalyze.java.checkers.ThreadSafeMethods.field4`] -codetoanalyze/java/racerd/ThreadSafeMethods.java, codetoanalyze.java.checkers.ThreadSafeMethods.readSameFieldAsThreadSafeMethodWhileSynchronized1Bad():java.lang.Object, 65, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.checkers.ThreadSafeMethods.field1`,,access to `this.codetoanalyze.java.checkers.ThreadSafeMethods.field1`] -codetoanalyze/java/racerd/ThreadSafeMethods.java, codetoanalyze.java.checkers.ThreadSafeMethods.threadSafeMethodReadBad():java.lang.Object, 29, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.checkers.ThreadSafeMethods.field2`,,access to `this.codetoanalyze.java.checkers.ThreadSafeMethods.field2`] -codetoanalyze/java/racerd/ThreadSafeMethods.java, codetoanalyze.java.checkers.ThreadSafeMethods.threadSafeMethodWriteBad():void, 24, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.ThreadSafeMethods.field1`] -codetoanalyze/java/racerd/ThreadSafeMethods.java, codetoanalyze.java.checkers.ThreadSafeMethods.threadSafePrivateMethodBad():void, 34, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.ThreadSafeMethods.field2`] -codetoanalyze/java/racerd/ThreadSafeMethods.java, codetoanalyze.java.checkers.ThreadSafeMethods.threadSafeVisibleForTestingMethodBad():void, 40, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.ThreadSafeMethods.field3`] -codetoanalyze/java/racerd/ThreadSafeMethods.java, codetoanalyze.java.checkers.ThreadSafeMethods.writeSameFieldAsThreadSafeMethod1Bad():void, 51, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.checkers.ThreadSafeMethods.field1`,,access to `this.codetoanalyze.java.checkers.ThreadSafeMethods.field1`] -codetoanalyze/java/racerd/ThreadSafeMethods.java, codetoanalyze.java.checkers.ThreadSafeMethods.writeSameFieldAsThreadSafeMethod2Bad():void, 75, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.checkers.ThreadSafeMethods.field4`,,access to `this.codetoanalyze.java.checkers.ThreadSafeMethods.field4`] -codetoanalyze/java/racerd/ThreadSafeMethods.java, codetoanalyze.java.checkers.ThreadSafeMethodsSubclass.readThreadSafeFieldOfOverrideBad():java.lang.Object, 126, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.checkers.ThreadSafeMethodsSubclass.subclassField`,,access to `this.codetoanalyze.java.checkers.ThreadSafeMethodsSubclass.subclassField`] -codetoanalyze/java/racerd/ThreadSafeMethods.java, codetoanalyze.java.checkers.ThreadSafeMethodsSubclass.safeMethodOverride():void, 110, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.ThreadSafeMethodsSubclass.subclassField`] -codetoanalyze/java/racerd/ThreadSafeMethods.java, codetoanalyze.java.checkers.ThreadSafeMethodsSubclass.writeThreadSafeFieldOfOverrideBad():void, 122, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.checkers.ThreadSafeMethodsSubclass.subclassField`,,access to `this.codetoanalyze.java.checkers.ThreadSafeMethodsSubclass.subclassField`] +codetoanalyze/java/racerd/SubFld.java, SubFld.getG():int, 28, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,call to int SuperFld.getG(),access to `this.SuperFld.g`,,access to `this.SuperFld.g`] +codetoanalyze/java/racerd/ThreadSafeExample.java, codetoanalyze.java.checkers.ExtendsThreadSafeExample.newmethodBad():void, 141, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.ExtendsThreadSafeExample.field`] +codetoanalyze/java/racerd/ThreadSafeExample.java, codetoanalyze.java.checkers.ExtendsThreadSafeExample.tsOK():void, 146, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.ExtendsThreadSafeExample.field`] +codetoanalyze/java/racerd/ThreadSafeExample.java, codetoanalyze.java.checkers.ThreadSafeExample.FP_lazyInitOk():java.lang.Object, 130, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.checkers.ThreadSafeExample.sStaticField`,,access to `this.codetoanalyze.java.checkers.ThreadSafeExample.sStaticField`] +codetoanalyze/java/racerd/ThreadSafeExample.java, codetoanalyze.java.checkers.ThreadSafeExample.callPublicMethodBad():void, 57, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [call to void ThreadSafeExample.assignInPrivateMethodOk(),access to `this.codetoanalyze.java.checkers.ThreadSafeExample.f`] +codetoanalyze/java/racerd/ThreadSafeExample.java, codetoanalyze.java.checkers.ThreadSafeExample.callVisibleForTestingBad():void, 109, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [call to void ThreadSafeExample.visibleForTestingNotPublicOk(),access to `this.codetoanalyze.java.checkers.ThreadSafeExample.f`] +codetoanalyze/java/racerd/ThreadSafeExample.java, codetoanalyze.java.checkers.ThreadSafeExample.deeperTraceBad():void, 66, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [call to void ThreadSafeExample.callAssignInPrivateMethod(),call to void ThreadSafeExample.assignInPrivateMethodOk(),access to `this.codetoanalyze.java.checkers.ThreadSafeExample.f`] +codetoanalyze/java/racerd/ThreadSafeExample.java, codetoanalyze.java.checkers.ThreadSafeExample.oddBad():void, 47, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [call to void ThreadSafeExample.evenOk(),access to `this.codetoanalyze.java.checkers.ThreadSafeExample.f`] +codetoanalyze/java/racerd/ThreadSafeExample.java, codetoanalyze.java.checkers.ThreadSafeExample.recursiveBad():void, 37, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.ThreadSafeExample.f`] +codetoanalyze/java/racerd/ThreadSafeExample.java, codetoanalyze.java.checkers.ThreadSafeExample.tsBad():void, 33, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.ThreadSafeExample.f`] +codetoanalyze/java/racerd/ThreadSafeExample.java, codetoanalyze.java.checkers.YesThreadSafeExtendsNotThreadSafeExample.subsubmethodBad():void, 168, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.YesThreadSafeExtendsNotThreadSafeExample.subsubfield`] +codetoanalyze/java/racerd/ThreadSafeMethods.java, codetoanalyze.java.checkers.ThreadSafeMethods.readSameFieldAsThreadSafeMethod1Bad():java.lang.Object, 54, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.checkers.ThreadSafeMethods.field1`,,access to `this.codetoanalyze.java.checkers.ThreadSafeMethods.field1`] +codetoanalyze/java/racerd/ThreadSafeMethods.java, codetoanalyze.java.checkers.ThreadSafeMethods.readSameFieldAsThreadSafeMethod2Bad():java.lang.Object, 78, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.checkers.ThreadSafeMethods.field4`,,access to `this.codetoanalyze.java.checkers.ThreadSafeMethods.field4`] +codetoanalyze/java/racerd/ThreadSafeMethods.java, codetoanalyze.java.checkers.ThreadSafeMethods.readSameFieldAsThreadSafeMethodWhileSynchronized1Bad():java.lang.Object, 63, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.checkers.ThreadSafeMethods.field1`,,access to `this.codetoanalyze.java.checkers.ThreadSafeMethods.field1`] +codetoanalyze/java/racerd/ThreadSafeMethods.java, codetoanalyze.java.checkers.ThreadSafeMethods.threadSafeMethodReadBad():java.lang.Object, 28, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.checkers.ThreadSafeMethods.field2`,,access to `this.codetoanalyze.java.checkers.ThreadSafeMethods.field2`] +codetoanalyze/java/racerd/ThreadSafeMethods.java, codetoanalyze.java.checkers.ThreadSafeMethods.threadSafeMethodWriteBad():void, 23, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.ThreadSafeMethods.field1`] +codetoanalyze/java/racerd/ThreadSafeMethods.java, codetoanalyze.java.checkers.ThreadSafeMethods.threadSafePrivateMethodBad():void, 33, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.ThreadSafeMethods.field2`] +codetoanalyze/java/racerd/ThreadSafeMethods.java, codetoanalyze.java.checkers.ThreadSafeMethods.threadSafeVisibleForTestingMethodBad():void, 39, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.ThreadSafeMethods.field3`] +codetoanalyze/java/racerd/ThreadSafeMethods.java, codetoanalyze.java.checkers.ThreadSafeMethods.writeSameFieldAsThreadSafeMethod1Bad():void, 49, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.checkers.ThreadSafeMethods.field1`,,access to `this.codetoanalyze.java.checkers.ThreadSafeMethods.field1`] +codetoanalyze/java/racerd/ThreadSafeMethods.java, codetoanalyze.java.checkers.ThreadSafeMethods.writeSameFieldAsThreadSafeMethod2Bad():void, 73, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.checkers.ThreadSafeMethods.field4`,,access to `this.codetoanalyze.java.checkers.ThreadSafeMethods.field4`] +codetoanalyze/java/racerd/ThreadSafeMethods.java, codetoanalyze.java.checkers.ThreadSafeMethodsSubclass.readThreadSafeFieldOfOverrideBad():java.lang.Object, 123, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.checkers.ThreadSafeMethodsSubclass.subclassField`,,access to `this.codetoanalyze.java.checkers.ThreadSafeMethodsSubclass.subclassField`] +codetoanalyze/java/racerd/ThreadSafeMethods.java, codetoanalyze.java.checkers.ThreadSafeMethodsSubclass.safeMethodOverride():void, 107, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [access to `this.codetoanalyze.java.checkers.ThreadSafeMethodsSubclass.subclassField`] +codetoanalyze/java/racerd/ThreadSafeMethods.java, codetoanalyze.java.checkers.ThreadSafeMethodsSubclass.writeThreadSafeFieldOfOverrideBad():void, 119, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `this.codetoanalyze.java.checkers.ThreadSafeMethodsSubclass.subclassField`,,access to `this.codetoanalyze.java.checkers.ThreadSafeMethodsSubclass.subclassField`] diff --git a/infer/tests/codetoanalyze/java/stability/Interprocedural.java b/infer/tests/codetoanalyze/java/stability/Interprocedural.java index d4a397c6b..e964bfb2d 100644 --- a/infer/tests/codetoanalyze/java/stability/Interprocedural.java +++ b/infer/tests/codetoanalyze/java/stability/Interprocedural.java @@ -11,84 +11,81 @@ import com.facebook.infer.annotation.ThreadSafe; class Interprocedural { -static class A { - B f = new B(); - int h = 0; -} + static class A { + B f = new B(); + int h = 0; + } -static class B { - int g = 0; -} + static class B { + int g = 0; + } -@ThreadSafe -static class Field { - private A a = new A(); + @ThreadSafe + static class Field { + private A a = new A(); - private void destabilize() { - B b = a.f; - } + private void destabilize() { + B b = a.f; + } - public void unstable_ok() { - int x = 42; - destabilize(); - synchronized (this){ - a.f.g = 101; + public void unstable_ok() { + int x = 42; + destabilize(); + synchronized (this) { + a.f.g = 101; + } + x = a.f.g; } - x = a.f.g; - } - public void stable_bad() { - int x = 42; - synchronized (this){ - a.f.g = 101; + public void stable_bad() { + int x = 42; + synchronized (this) { + a.f.g = 101; + } + x = a.f.g; } - x = a.f.g; } -} - -@ThreadSafe -static class Param { + @ThreadSafe + static class Param { - private void destabilize(A z) { - B b1 = z.f; - System.out.println(b1); - } + private void destabilize(A z) { + B b1 = z.f; + System.out.println(b1); + } - public void unstable_ok(A a) { - int x = 42; - destabilize(a); - synchronized (this) { - a.f.g = 101; + public void unstable_ok(A a) { + int x = 42; + destabilize(a); + synchronized (this) { + a.f.g = 101; + } + x = a.f.g; } - x = a.f.g; - } - public void stable_bad(A a) { - int x = 42; - synchronized (this) { - a.f.g = 101; + public void stable_bad(A a) { + int x = 42; + synchronized (this) { + a.f.g = 101; + } + x = a.f.g; } - x = a.f.g; } -} - -@ThreadSafe -static class Param2 { + @ThreadSafe + static class Param2 { - private void destabilize(A z) { - // Do nothing - } + private void destabilize(A z) { + // Do nothing + } - public void stable_bad(A a) { - int x = 42; - destabilize(a); // a leaks, but shouldn't be de-stabilized because callee does nothing - synchronized (this) { - a.f.g = 101; + public void stable_bad(A a) { + int x = 42; + destabilize(a); // a leaks, but shouldn't be de-stabilized because callee does nothing + synchronized (this) { + a.f.g = 101; + } + x = a.f.g; } - x = a.f.g; } } - -} diff --git a/infer/tests/codetoanalyze/java/stability/Intraprocedural.java b/infer/tests/codetoanalyze/java/stability/Intraprocedural.java index 24e638b0a..891578234 100644 --- a/infer/tests/codetoanalyze/java/stability/Intraprocedural.java +++ b/infer/tests/codetoanalyze/java/stability/Intraprocedural.java @@ -11,79 +11,76 @@ import com.facebook.infer.annotation.ThreadSafe; class Intraprocedural { -static class B { - int g = 0; -} - -static class A { - B f = new B(); - int h = 0; -} - -@ThreadSafe -static class Field { - private A a = new A(); - - public void unstable_ok() { - int x = 42; - B b = a.f; // destabilizes - synchronized (this) { - a.f.g = 101; - } - x = a.f.g; + static class B { + int g = 0; } - public void FN_stable_bad() { - int x = 42; - synchronized (this) { - a.f.g = 101; - } - x = a.f.g; + static class A { + B f = new B(); + int h = 0; } -} - -static class Param { - public void unstable_ok(A a) { - int x = 42; - B b = a.f; // destabilizes - synchronized (this) { - a.f.g = 101; + @ThreadSafe + static class Field { + private A a = new A(); + + public void unstable_ok() { + int x = 42; + B b = a.f; // destabilizes + synchronized (this) { + a.f.g = 101; + } + x = a.f.g; } - x = a.f.g; - } - public void stable_bad(A a) { - int x = 42; - synchronized (this) { - a.f.g = 101; + public void FN_stable_bad() { + int x = 42; + synchronized (this) { + a.f.g = 101; + } + x = a.f.g; } - x = a.f.g; } -} + static class Param { -@ThreadSafe -static class Global { - private static A a = new A(); + public void unstable_ok(A a) { + int x = 42; + B b = a.f; // destabilizes + synchronized (this) { + a.f.g = 101; + } + x = a.f.g; + } - synchronized public A getA() { - return a; + public void stable_bad(A a) { + int x = 42; + synchronized (this) { + a.f.g = 101; + } + x = a.f.g; + } } - synchronized public void setA(A newA) { - a = newA; - } + @ThreadSafe + static class Global { + private static A a = new A(); - public void unstable_ok() { - int x = 42; - A a = getA(); // destabilizes - synchronized (this) { - a.f.g = 101; - } - x = a.f.g; - } + public synchronized A getA() { + return a; + } -} + public synchronized void setA(A newA) { + a = newA; + } + public void unstable_ok() { + int x = 42; + A a = getA(); // destabilizes + synchronized (this) { + a.f.g = 101; + } + x = a.f.g; + } + } } diff --git a/infer/tests/codetoanalyze/java/stability/issues.exp b/infer/tests/codetoanalyze/java/stability/issues.exp index c8a142d72..c60059961 100644 --- a/infer/tests/codetoanalyze/java/stability/issues.exp +++ b/infer/tests/codetoanalyze/java/stability/issues.exp @@ -1,3 +1,3 @@ -codetoanalyze/java/stability/Interprocedural.java, codetoanalyze.java.checkers.Interprocedural$Param.stable_bad(codetoanalyze.java.checkers.Interprocedural$A):void, 72, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `a.codetoanalyze.java.checkers.Interprocedural$A.f.codetoanalyze.java.checkers.Interprocedural$B.g`,,access to `a.codetoanalyze.java.checkers.Interprocedural$A.f.codetoanalyze.java.checkers.Interprocedural$B.g`] -codetoanalyze/java/stability/Interprocedural.java, codetoanalyze.java.checkers.Interprocedural$Param2.stable_bad(codetoanalyze.java.checkers.Interprocedural$A):void, 90, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `a.codetoanalyze.java.checkers.Interprocedural$A.f.codetoanalyze.java.checkers.Interprocedural$B.g`,,access to `a.codetoanalyze.java.checkers.Interprocedural$A.f.codetoanalyze.java.checkers.Interprocedural$B.g`] +codetoanalyze/java/stability/Interprocedural.java, codetoanalyze.java.checkers.Interprocedural$Param.stable_bad(codetoanalyze.java.checkers.Interprocedural$A):void, 71, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `a.codetoanalyze.java.checkers.Interprocedural$A.f.codetoanalyze.java.checkers.Interprocedural$B.g`,,access to `a.codetoanalyze.java.checkers.Interprocedural$A.f.codetoanalyze.java.checkers.Interprocedural$B.g`] +codetoanalyze/java/stability/Interprocedural.java, codetoanalyze.java.checkers.Interprocedural$Param2.stable_bad(codetoanalyze.java.checkers.Interprocedural$A):void, 88, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `a.codetoanalyze.java.checkers.Interprocedural$A.f.codetoanalyze.java.checkers.Interprocedural$B.g`,,access to `a.codetoanalyze.java.checkers.Interprocedural$A.f.codetoanalyze.java.checkers.Interprocedural$B.g`] codetoanalyze/java/stability/Intraprocedural.java, codetoanalyze.java.checkers.Intraprocedural$Param.stable_bad(codetoanalyze.java.checkers.Intraprocedural$A):void, 61, THREAD_SAFETY_VIOLATION, no_bucket, ERROR, [,access to `a.codetoanalyze.java.checkers.Intraprocedural$A.f.codetoanalyze.java.checkers.Intraprocedural$B.g`,,access to `a.codetoanalyze.java.checkers.Intraprocedural$A.f.codetoanalyze.java.checkers.Intraprocedural$B.g`] diff --git a/infer/tests/codetoanalyze/java/starvation/AccMgr.java b/infer/tests/codetoanalyze/java/starvation/AccMgr.java index d655fbbec..46fb43b96 100644 --- a/infer/tests/codetoanalyze/java/starvation/AccMgr.java +++ b/infer/tests/codetoanalyze/java/starvation/AccMgr.java @@ -22,11 +22,12 @@ class AccMgr { @UiThread void lockOnUiThreadBad() throws InterruptedException { - synchronized(lock) {} + synchronized (lock) { + } } void setUserDataUnderLock() { - synchronized(lock) { + synchronized (lock) { am.setUserData(account, key, data); } } diff --git a/infer/tests/codetoanalyze/java/starvation/AsyncTaskGet.java b/infer/tests/codetoanalyze/java/starvation/AsyncTaskGet.java index 61ff00cff..199903525 100644 --- a/infer/tests/codetoanalyze/java/starvation/AsyncTaskGet.java +++ b/infer/tests/codetoanalyze/java/starvation/AsyncTaskGet.java @@ -5,11 +5,11 @@ * LICENSE file in the root directory of this source tree. */ -import java.util.concurrent.TimeUnit; +import android.os.AsyncTask; +import android.support.annotation.UiThread; import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import android.support.annotation.UiThread; -import android.os.AsyncTask; class AsyncTaskGet { CountTask task; @@ -22,17 +22,18 @@ class AsyncTaskGet { @UiThread void taskGetWithTimeoutOnUiThreadOk() - throws TimeoutException, InterruptedException, ExecutionException { + throws TimeoutException, InterruptedException, ExecutionException { task.get(1000, TimeUnit.NANOSECONDS); } @UiThread void lockOnUiThreadBad() { - synchronized(lock) {} + synchronized (lock) { + } } void taskGetUnderLock() throws InterruptedException, ExecutionException { - synchronized(lock) { + synchronized (lock) { task.get(); } } @@ -43,12 +44,12 @@ class AsyncTaskGet { } class CountTask extends AsyncTask { - protected Long doInBackground(Integer... ints) { - long totalSize = 0; - for (int i = 0; i < ints.length; i++) { - totalSize += ints[i]; - if (isCancelled()) break; - } - return totalSize; - } - } + protected Long doInBackground(Integer... ints) { + long totalSize = 0; + for (int i = 0; i < ints.length; i++) { + totalSize += ints[i]; + if (isCancelled()) break; + } + return totalSize; + } +} diff --git a/infer/tests/codetoanalyze/java/starvation/Countdwn.java b/infer/tests/codetoanalyze/java/starvation/Countdwn.java index bc4209bce..bd9d57c07 100644 --- a/infer/tests/codetoanalyze/java/starvation/Countdwn.java +++ b/infer/tests/codetoanalyze/java/starvation/Countdwn.java @@ -5,8 +5,8 @@ * LICENSE file in the root directory of this source tree. */ -import java.util.concurrent.CountDownLatch; import android.support.annotation.UiThread; +import java.util.concurrent.CountDownLatch; class Countdwn { CountDownLatch latch; diff --git a/infer/tests/codetoanalyze/java/starvation/Dedup.java b/infer/tests/codetoanalyze/java/starvation/Dedup.java index fd0eccb0e..341684fa4 100644 --- a/infer/tests/codetoanalyze/java/starvation/Dedup.java +++ b/infer/tests/codetoanalyze/java/starvation/Dedup.java @@ -5,11 +5,10 @@ * LICENSE file in the root directory of this source tree. */ -import java.util.concurrent.Future; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.CountDownLatch; import android.support.annotation.UiThread; -import java.io.IOException; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; class Dedup { CountDownLatch latch; @@ -33,14 +32,16 @@ class Dedup { // deadlock should be reported between oneWayBad and anotherWayBad only void oneWayBad() { - synchronized(lockA) { - synchronized(lockB) {} + synchronized (lockA) { + synchronized (lockB) { + } } } void anotherWayBad() { - synchronized(lockB) { - synchronized(lockA) {} + synchronized (lockB) { + synchronized (lockA) { + } } } diff --git a/infer/tests/codetoanalyze/java/starvation/FutureGet.java b/infer/tests/codetoanalyze/java/starvation/FutureGet.java index b36823bb0..6c0d2ac6d 100644 --- a/infer/tests/codetoanalyze/java/starvation/FutureGet.java +++ b/infer/tests/codetoanalyze/java/starvation/FutureGet.java @@ -5,12 +5,12 @@ * LICENSE file in the root directory of this source tree. */ -import java.util.concurrent.Future; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeoutException; import android.support.annotation.UiThread; -import java.util.concurrent.TimeUnit; import com.google.common.util.concurrent.Futures; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; class FutureGet { Future future; @@ -23,11 +23,12 @@ class FutureGet { @UiThread void getIndirectBad() { - synchronized(lock) {} + synchronized (lock) { + } } void getUnderLock() throws InterruptedException, ExecutionException { - synchronized(lock) { + synchronized (lock) { future.get(); } } @@ -40,49 +41,56 @@ class FutureGet { void getTimeoutOneDayBad() throws InterruptedException, ExecutionException { try { future.get(1L, TimeUnit.DAYS); - } catch (TimeoutException e) {} + } catch (TimeoutException e) { + } } @UiThread void getTimeoutOneSecondOk() throws InterruptedException, ExecutionException { try { future.get(1L, TimeUnit.SECONDS); - } catch (TimeoutException e) {} + } catch (TimeoutException e) { + } } @UiThread void getTimeoutOneHourBad() throws InterruptedException, ExecutionException { try { future.get(1L, TimeUnit.HOURS); - } catch (TimeoutException e) {} + } catch (TimeoutException e) { + } } @UiThread void getTimeoutFourSecondsOk() throws InterruptedException, ExecutionException { try { future.get(4L, TimeUnit.SECONDS); - } catch (TimeoutException e) {} + } catch (TimeoutException e) { + } } @UiThread void getTimeout4999MilliSecondsOk() throws InterruptedException, ExecutionException { try { future.get(4999L, TimeUnit.MILLISECONDS); - } catch (TimeoutException e) {} + } catch (TimeoutException e) { + } } @UiThread void getTimeout50000001MicroSecondsBad() throws InterruptedException, ExecutionException { try { future.get(5000001L, TimeUnit.MICROSECONDS); - } catch (TimeoutException e) {} + } catch (TimeoutException e) { + } } @UiThread void getTimeout64BitsBad() throws InterruptedException, ExecutionException { try { future.get(9223372036854775807L, TimeUnit.MICROSECONDS); - } catch (TimeoutException e) {} + } catch (TimeoutException e) { + } } @UiThread diff --git a/infer/tests/codetoanalyze/java/starvation/IndirectBlock.java b/infer/tests/codetoanalyze/java/starvation/IndirectBlock.java index 65898e731..7045efbb3 100644 --- a/infer/tests/codetoanalyze/java/starvation/IndirectBlock.java +++ b/infer/tests/codetoanalyze/java/starvation/IndirectBlock.java @@ -5,25 +5,27 @@ * LICENSE file in the root directory of this source tree. */ -import android.support.annotation.UiThread; import android.os.Binder; import android.os.RemoteException; +import android.support.annotation.UiThread; class IndirectBlock { Object expensiveLock; Binder binder; void takeExpensiveLockOk() { - synchronized(expensiveLock) {} + synchronized (expensiveLock) { + } } @UiThread void takeExpensiveLockOnUiThreadBad() { - synchronized(expensiveLock) {} + synchronized (expensiveLock) { + } } void doTransactUnderLock() throws RemoteException { - synchronized(expensiveLock) { + synchronized (expensiveLock) { binder.transact(0, null, null, 0); } } @@ -35,9 +37,9 @@ class IndirectBlock { } class IndirectInterproc { - synchronized public void takeLock() {} + public synchronized void takeLock() {} - synchronized public void doTransactUnderLock(Binder binder) throws RemoteException { + public synchronized void doTransactUnderLock(Binder binder) throws RemoteException { binder.transact(0, null, null, 0); } } diff --git a/infer/tests/codetoanalyze/java/starvation/InnerClass.java b/infer/tests/codetoanalyze/java/starvation/InnerClass.java index b0019e548..b2de9454f 100644 --- a/infer/tests/codetoanalyze/java/starvation/InnerClass.java +++ b/infer/tests/codetoanalyze/java/starvation/InnerClass.java @@ -5,7 +5,6 @@ * LICENSE file in the root directory of this source tree. */ -import java.lang.Object; class InnerClass { synchronized void outerInnerOk(InnerClassA a) { @@ -20,11 +19,12 @@ class InnerClass { class InnerClassA { void foo() { - synchronized(InnerClass.this) {} + synchronized (InnerClass.this) { + } } void outerInnerOk() { - synchronized(InnerClass.this) { + synchronized (InnerClass.this) { InnerClass.this.bar(); } } @@ -38,14 +38,14 @@ class InnerClass { // ctrs generate different access paths so test these too // following should not be flagged InnerClassA() { - synchronized(InnerClass.this) { + synchronized (InnerClass.this) { InnerClass.this.bar(); } } // following should be flagged with outer_inner_bad() InnerClassA(Object o) { - synchronized(this) { + synchronized (this) { InnerClass.this.bar(); } } diff --git a/infer/tests/codetoanalyze/java/starvation/Interclass.java b/infer/tests/codetoanalyze/java/starvation/Interclass.java index e34ebba7b..b0ca76650 100644 --- a/infer/tests/codetoanalyze/java/starvation/Interclass.java +++ b/infer/tests/codetoanalyze/java/starvation/Interclass.java @@ -17,12 +17,13 @@ class Interclass { } void interclass2Ok(InterclassB b) { - synchronized(b) {} + synchronized (b) { + } } void reentrantOk(InterclassB b) { - synchronized(this) { - synchronized(b) { + synchronized (this) { + synchronized (b) { b.interclass1Ok(); } } @@ -41,7 +42,7 @@ class InterclassB { synchronized void interclass1Ok() {} void interclass2_ok(Interclass c) { - synchronized(c) { + synchronized (c) { c.interclass2Ok(this); } } diff --git a/infer/tests/codetoanalyze/java/starvation/Interproc.java b/infer/tests/codetoanalyze/java/starvation/Interproc.java index 234e6a39d..3d27d2914 100644 --- a/infer/tests/codetoanalyze/java/starvation/Interproc.java +++ b/infer/tests/codetoanalyze/java/starvation/Interproc.java @@ -11,7 +11,8 @@ class Interproc { } void interproc2Bad(InterprocA b) { - synchronized(b) {} + synchronized (b) { + } } synchronized void interproc1Ok(InterprocB a) { @@ -19,12 +20,13 @@ class Interproc { } void interproc2Ok(InterprocB b) { - synchronized(b) {} + synchronized (b) { + } } void reentrant1Ok(InterprocB b) { - synchronized(this) { - synchronized(b) { + synchronized (this) { + synchronized (b) { reentrant2Ok(); } } @@ -39,13 +41,14 @@ class InterprocA { } void interproc2Bad(Interproc d) { - synchronized(d) {} + synchronized (d) { + } } } class InterprocB { void interproc1Ok(Interproc c) { - synchronized(c) { + synchronized (c) { interproc2Ok(c); } } diff --git a/infer/tests/codetoanalyze/java/starvation/Intraproc.java b/infer/tests/codetoanalyze/java/starvation/Intraproc.java index 155643f30..56c275cea 100644 --- a/infer/tests/codetoanalyze/java/starvation/Intraproc.java +++ b/infer/tests/codetoanalyze/java/starvation/Intraproc.java @@ -7,21 +7,24 @@ class Intraproc { void intraBad(IntraprocA o) { - synchronized(this) { - synchronized(o) {} + synchronized (this) { + synchronized (o) { + } } } void intraOk(IntraprocB o) { - synchronized(this) { - synchronized(o) {} + synchronized (this) { + synchronized (o) { + } } } void reentrantOk(IntraprocB b) { - synchronized(this) { - synchronized(b) { - synchronized(this) {} + synchronized (this) { + synchronized (b) { + synchronized (this) { + } } } } @@ -29,16 +32,18 @@ class Intraproc { class IntraprocA { void intraBad(Intraproc o) { - synchronized(this) { - synchronized(o) {} + synchronized (this) { + synchronized (o) { + } } } } class IntraprocB { void intraOk(Intraproc o) { - synchronized(o) { - synchronized(this) {} + synchronized (o) { + synchronized (this) { + } } } } diff --git a/infer/tests/codetoanalyze/java/starvation/JavaIO.java b/infer/tests/codetoanalyze/java/starvation/JavaIO.java index 4ba1aeb89..1c2443430 100644 --- a/infer/tests/codetoanalyze/java/starvation/JavaIO.java +++ b/infer/tests/codetoanalyze/java/starvation/JavaIO.java @@ -5,12 +5,12 @@ * LICENSE file in the root directory of this source tree. */ -import java.io.FileReader; +import android.support.annotation.UiThread; import java.io.DataInputStream; -import java.io.FileWriter; import java.io.DataOutputStream; +import java.io.FileReader; +import java.io.FileWriter; import java.io.IOException; -import android.support.annotation.UiThread; class JavaIO { FileReader reader; diff --git a/infer/tests/codetoanalyze/java/starvation/LegacySync.java b/infer/tests/codetoanalyze/java/starvation/LegacySync.java index fdf6a992c..b1a3b6d46 100644 --- a/infer/tests/codetoanalyze/java/starvation/LegacySync.java +++ b/infer/tests/codetoanalyze/java/starvation/LegacySync.java @@ -5,23 +5,23 @@ * LICENSE file in the root directory of this source tree. */ -import java.util.concurrent.Future; -import java.util.concurrent.ExecutionException; import android.support.annotation.UiThread; import java.util.Hashtable; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; class LegacySync { Hashtable table; Future future; void notOnUiThreadSyncedBad() throws InterruptedException, ExecutionException { - synchronized(table) { + synchronized (table) { future.get(); } } @UiThread Object onUiThreadOpBad() { - return table.get("blabla"); + return table.get("blabla"); } } diff --git a/infer/tests/codetoanalyze/java/starvation/LocalLock.java b/infer/tests/codetoanalyze/java/starvation/LocalLock.java index 11eed06cc..93769476b 100644 --- a/infer/tests/codetoanalyze/java/starvation/LocalLock.java +++ b/infer/tests/codetoanalyze/java/starvation/LocalLock.java @@ -13,8 +13,9 @@ class LocalLock { } void localLockOuterOk() { - synchronized(getLock1()) { - synchronized(this) {} + synchronized (getLock1()) { + synchronized (this) { + } } } @@ -23,8 +24,9 @@ class LocalLock { } void localLockInnerOk() { - synchronized(this) { - synchronized(getLock2()) {} + synchronized (this) { + synchronized (getLock2()) { + } } } } diff --git a/infer/tests/codetoanalyze/java/starvation/MainThreadTest.java b/infer/tests/codetoanalyze/java/starvation/MainThreadTest.java index 5ff91df6c..2ce3c198a 100644 --- a/infer/tests/codetoanalyze/java/starvation/MainThreadTest.java +++ b/infer/tests/codetoanalyze/java/starvation/MainThreadTest.java @@ -6,7 +6,6 @@ */ import android.os.Binder; -import android.os.RemoteException; import android.support.annotation.MainThread; class MainThreadTest { @@ -15,7 +14,8 @@ class MainThreadTest { void doTransact() { try { b.transact(0, null, null, 0); - } catch (Exception e) {} + } catch (Exception e) { + } } @MainThread diff --git a/infer/tests/codetoanalyze/java/starvation/MyActivity.java b/infer/tests/codetoanalyze/java/starvation/MyActivity.java index 095381efa..88f7f9af6 100644 --- a/infer/tests/codetoanalyze/java/starvation/MyActivity.java +++ b/infer/tests/codetoanalyze/java/starvation/MyActivity.java @@ -5,13 +5,14 @@ * LICENSE file in the root directory of this source tree. */ -import android.app.Activity; import android.accounts.AccountManager; +import android.app.Activity; import android.os.Bundle; // test is for recognizing Activity lifecycle methods class MyActivity extends Activity { AccountManager am; + private void bad() { am.setUserData(null, null, null); } @@ -19,7 +20,7 @@ class MyActivity extends Activity { // overrides so no Bad suffixes @Override - protected void onCreate (Bundle savedInstanceState) { + protected void onCreate(Bundle savedInstanceState) { bad(); } diff --git a/infer/tests/codetoanalyze/java/starvation/NonBlk.java b/infer/tests/codetoanalyze/java/starvation/NonBlk.java index 04f5e5a73..e6f24ad54 100644 --- a/infer/tests/codetoanalyze/java/starvation/NonBlk.java +++ b/infer/tests/codetoanalyze/java/starvation/NonBlk.java @@ -5,11 +5,10 @@ * LICENSE file in the root directory of this source tree. */ -import java.util.concurrent.Future; -import java.util.concurrent.ExecutionException; -import java.io.IOException; import android.support.annotation.UiThread; import com.facebook.infer.annotation.NonBlocking; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; class NonBlk { Future future; @@ -32,13 +31,15 @@ class NonBlk { @NonBlocking synchronized void deadlockABBad() { - synchronized(future) {} + synchronized (future) { + } } @NonBlocking void deadlockBABad() { - synchronized(future) { - synchronized(this) {} + synchronized (future) { + synchronized (this) { + } } } } diff --git a/infer/tests/codetoanalyze/java/starvation/ObjWait.java b/infer/tests/codetoanalyze/java/starvation/ObjWait.java index 8aa3fd739..3251c41af 100644 --- a/infer/tests/codetoanalyze/java/starvation/ObjWait.java +++ b/infer/tests/codetoanalyze/java/starvation/ObjWait.java @@ -11,7 +11,7 @@ class ObjWait { Object z; void waitOnAnyWithoutTimeoutOk() throws InterruptedException { - synchronized(z) { + synchronized (z) { z.wait(); } } @@ -20,21 +20,21 @@ class ObjWait { @UiThread void waitOnMainWithoutTimeoutBad() throws InterruptedException { - synchronized(o) { + synchronized (o) { o.wait(); } } @UiThread void waitOnMainWithExcessiveTimeout1Bad() throws InterruptedException { - synchronized(o) { + synchronized (o) { o.wait(5001); } } @UiThread void waitOnMainWithExcessiveTimeout2Bad() throws InterruptedException { - synchronized(o) { + synchronized (o) { o.wait(4000, 2000000000); } } @@ -43,12 +43,13 @@ class ObjWait { @UiThread void indirectWaitOnMainWithoutTimeoutBad() throws InterruptedException { - synchronized(lock) {} + synchronized (lock) { + } } void lockAndWaitOnAnyWithoutTimeoutBad() throws InterruptedException { - synchronized(lock) { - synchronized(x) { + synchronized (lock) { + synchronized (x) { x.wait(); } } diff --git a/infer/tests/codetoanalyze/java/starvation/OurThreadUtils.java b/infer/tests/codetoanalyze/java/starvation/OurThreadUtils.java index 6c1a62089..15ff5d339 100644 --- a/infer/tests/codetoanalyze/java/starvation/OurThreadUtils.java +++ b/infer/tests/codetoanalyze/java/starvation/OurThreadUtils.java @@ -5,8 +5,10 @@ * LICENSE file in the root directory of this source tree. */ -class OurThreadUtils{ - native static boolean isMainThread(); - static void assertMainThread(){} - static void assertHoldsLock(Object lock){} +class OurThreadUtils { + static native boolean isMainThread(); + + static void assertMainThread() {} + + static void assertHoldsLock(Object lock) {} } diff --git a/infer/tests/codetoanalyze/java/starvation/PubPriv.java b/infer/tests/codetoanalyze/java/starvation/PubPriv.java index 4b3ebe913..5330d4e8e 100644 --- a/infer/tests/codetoanalyze/java/starvation/PubPriv.java +++ b/infer/tests/codetoanalyze/java/starvation/PubPriv.java @@ -32,14 +32,16 @@ class PubPriv { Object lockA, lockB; private void oneWayOk() { - synchronized(lockA) { - synchronized(lockB) {} + synchronized (lockA) { + synchronized (lockB) { + } } } private void anotherWayOk() { - synchronized(lockB) { - synchronized(lockA) {} + synchronized (lockB) { + synchronized (lockA) { + } } } diff --git a/infer/tests/codetoanalyze/java/starvation/ServiceOnUIThread.java b/infer/tests/codetoanalyze/java/starvation/ServiceOnUIThread.java index 7fdcdeff6..a4a3ab3cb 100644 --- a/infer/tests/codetoanalyze/java/starvation/ServiceOnUIThread.java +++ b/infer/tests/codetoanalyze/java/starvation/ServiceOnUIThread.java @@ -5,10 +5,10 @@ * LICENSE file in the root directory of this source tree. */ -import android.os.IBinder; -import android.content.Intent; -import android.app.Service; import android.app.IntentService; +import android.app.Service; +import android.content.Intent; +import android.os.IBinder; import android.os.RemoteException; class ServiceOnUIThread extends Service { @@ -23,7 +23,8 @@ class ServiceOnUIThread extends Service { void transactBad() { try { mBinder.transact(0, null, null, 0); - } catch (RemoteException e) {} + } catch (RemoteException e) { + } } } @@ -42,6 +43,7 @@ class IntentServiceNotOnUIThread extends IntentService { void transactOk() { try { mBinder.transact(0, null, null, 0); - } catch (RemoteException e) {} + } catch (RemoteException e) { + } } } diff --git a/infer/tests/codetoanalyze/java/starvation/StaticLock.java b/infer/tests/codetoanalyze/java/starvation/StaticLock.java index 7bac3ef66..176c36a02 100644 --- a/infer/tests/codetoanalyze/java/starvation/StaticLock.java +++ b/infer/tests/codetoanalyze/java/starvation/StaticLock.java @@ -9,19 +9,20 @@ class StaticLock { static synchronized void staticSynced() {} void lockSameClassOneWayOk() { - synchronized(StaticLock.class) { + synchronized (StaticLock.class) { staticSynced(); } } static synchronized void lockSameClassAnotherWayOk() { - synchronized(StaticLock.class) { + synchronized (StaticLock.class) { } } void lockOtherClassOneWayBad() { - synchronized(StaticLock.class) { - synchronized(this) {} + synchronized (StaticLock.class) { + synchronized (this) { + } } } diff --git a/infer/tests/codetoanalyze/java/starvation/SuppLint.java b/infer/tests/codetoanalyze/java/starvation/SuppLint.java index a2397b05e..cad9cc442 100644 --- a/infer/tests/codetoanalyze/java/starvation/SuppLint.java +++ b/infer/tests/codetoanalyze/java/starvation/SuppLint.java @@ -5,11 +5,10 @@ * LICENSE file in the root directory of this source tree. */ -import java.util.concurrent.Future; -import java.util.concurrent.ExecutionException; -import java.io.IOException; -import android.support.annotation.UiThread; import android.annotation.SuppressLint; +import android.support.annotation.UiThread; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; class SuppLint { Future future; @@ -30,6 +29,7 @@ class SuppLint { @SuppressLint("STARVATION") class SuppLintClass { Future future; + @UiThread void onUiThreadSuppressed() throws InterruptedException, ExecutionException { future.get(); diff --git a/infer/tests/codetoanalyze/java/starvation/ThreadSleep.java b/infer/tests/codetoanalyze/java/starvation/ThreadSleep.java index 45c0665e8..dd576215f 100644 --- a/infer/tests/codetoanalyze/java/starvation/ThreadSleep.java +++ b/infer/tests/codetoanalyze/java/starvation/ThreadSleep.java @@ -6,7 +6,6 @@ */ import android.support.annotation.UiThread; -import java.lang.Thread; class ThreadSleep { void sleepOnAnyThreadOk() throws InterruptedException { @@ -22,13 +21,13 @@ class ThreadSleep { @UiThread void indirectSleepOnUIThreadBad() { - synchronized(lock) {} + synchronized (lock) { + } } void lockAndSleepOnNonUIThread() throws InterruptedException { - synchronized(lock) { + synchronized (lock) { sleepOnAnyThreadOk(); } } - } diff --git a/infer/tests/codetoanalyze/java/starvation/UIDeadlock.java b/infer/tests/codetoanalyze/java/starvation/UIDeadlock.java index 1590698b6..0252f643c 100644 --- a/infer/tests/codetoanalyze/java/starvation/UIDeadlock.java +++ b/infer/tests/codetoanalyze/java/starvation/UIDeadlock.java @@ -12,24 +12,28 @@ class UIDeadlock { @UiThread public synchronized void onUIThreadAOk() { - synchronized(lockA) {} + synchronized (lockA) { + } } @UiThread public void onUIThreadBOk() { - synchronized(lockA) { - synchronized(this) {} + synchronized (lockA) { + synchronized (this) { + } } } @UiThread public synchronized void onUIThreadBad() { - synchronized(lockB) {} + synchronized (lockB) { + } } public void notOnUIThreadBad() { - synchronized(lockB) { - synchronized(this) {} + synchronized (lockB) { + synchronized (this) { + } } } } diff --git a/infer/tests/codetoanalyze/java/starvation/issues.exp b/infer/tests/codetoanalyze/java/starvation/issues.exp index f96fbe4ed..4dd3e8c94 100644 --- a/infer/tests/codetoanalyze/java/starvation/issues.exp +++ b/infer/tests/codetoanalyze/java/starvation/issues.exp @@ -7,19 +7,19 @@ codetoanalyze/java/starvation/Binders.java, Binders.interBad():void, 24, STARVAT codetoanalyze/java/starvation/Binders.java, Binders.intraBad():void, 30, STARVATION, no_bucket, ERROR, [`void Binders.intraBad()`,Method call: `void Binders.doTransact()`,calls `boolean Binder.transact(int,Parcel,Parcel,int)` from `void Binders.doTransact()`,[Trace on UI thread] `void Binders.intraBad()`,it calls `void OurThreadUtils.assertMainThread()`] codetoanalyze/java/starvation/Countdwn.java, Countdwn.awaitOnMainByAnnotBad():void, 21, STARVATION, no_bucket, ERROR, [`void Countdwn.awaitOnMainByAnnotBad()`,calls `void CountDownLatch.await()` from `void Countdwn.awaitOnMainByAnnotBad()`,[Trace on UI thread] `void Countdwn.awaitOnMainByAnnotBad()`,`void Countdwn.awaitOnMainByAnnotBad()` is annotated `UiThread`] codetoanalyze/java/starvation/Countdwn.java, Countdwn.awaitOnMainByCallBad():void, 16, STARVATION, no_bucket, ERROR, [`void Countdwn.awaitOnMainByCallBad()`,calls `void CountDownLatch.await()` from `void Countdwn.awaitOnMainByCallBad()`,[Trace on UI thread] `void Countdwn.awaitOnMainByCallBad()`,it calls `void OurThreadUtils.assertMainThread()`] -codetoanalyze/java/starvation/Dedup.java, Dedup.callMethodWithMultipleBlocksBad():void, 27, STARVATION, no_bucket, ERROR, [`void Dedup.callMethodWithMultipleBlocksBad()`,calls `Object Future.get()` from `void Dedup.callMethodWithMultipleBlocksBad()`,[Trace on UI thread] `void Dedup.callMethodWithMultipleBlocksBad()`,`void Dedup.callMethodWithMultipleBlocksBad()` is annotated `UiThread`] -codetoanalyze/java/starvation/Dedup.java, Dedup.callMethodWithMultipleBlocksBad():void, 28, STARVATION, no_bucket, ERROR, [`void Dedup.callMethodWithMultipleBlocksBad()`,calls `void CountDownLatch.await()` from `void Dedup.callMethodWithMultipleBlocksBad()`,[Trace on UI thread] `void Dedup.callMethodWithMultipleBlocksBad()`,`void Dedup.callMethodWithMultipleBlocksBad()` is annotated `UiThread`] -codetoanalyze/java/starvation/Dedup.java, Dedup.callMethodWithMultipleBlocksBad():void, 29, STARVATION, no_bucket, ERROR, [`void Dedup.callMethodWithMultipleBlocksBad()`,calls `Object Future.get()` from `void Dedup.callMethodWithMultipleBlocksBad()`,[Trace on UI thread] `void Dedup.callMethodWithMultipleBlocksBad()`,`void Dedup.callMethodWithMultipleBlocksBad()` is annotated `UiThread`] -codetoanalyze/java/starvation/Dedup.java, Dedup.onUiThreadBad():void, 21, STARVATION, no_bucket, ERROR, [`void Dedup.onUiThreadBad()`,Method call: `void Dedup.callMethodWithMultipleBlocksBad()`,calls `void CountDownLatch.await()` from `void Dedup.callMethodWithMultipleBlocksBad()`,[Trace on UI thread] `void Dedup.onUiThreadBad()`,`void Dedup.onUiThreadBad()` is annotated `UiThread`] -codetoanalyze/java/starvation/Dedup.java, Dedup.oneWayBad():void, 36, DEADLOCK, no_bucket, ERROR, [[Trace 1] `void Dedup.oneWayBad()`,locks `this.Dedup.lockA` in class `Dedup*`,locks `this.Dedup.lockB` in class `Dedup*`,[Trace 2] `void Dedup.anotherWayBad()`,locks `this.Dedup.lockB` in class `Dedup*`,locks `this.Dedup.lockA` in class `Dedup*`] +codetoanalyze/java/starvation/Dedup.java, Dedup.callMethodWithMultipleBlocksBad():void, 26, STARVATION, no_bucket, ERROR, [`void Dedup.callMethodWithMultipleBlocksBad()`,calls `Object Future.get()` from `void Dedup.callMethodWithMultipleBlocksBad()`,[Trace on UI thread] `void Dedup.callMethodWithMultipleBlocksBad()`,`void Dedup.callMethodWithMultipleBlocksBad()` is annotated `UiThread`] +codetoanalyze/java/starvation/Dedup.java, Dedup.callMethodWithMultipleBlocksBad():void, 27, STARVATION, no_bucket, ERROR, [`void Dedup.callMethodWithMultipleBlocksBad()`,calls `void CountDownLatch.await()` from `void Dedup.callMethodWithMultipleBlocksBad()`,[Trace on UI thread] `void Dedup.callMethodWithMultipleBlocksBad()`,`void Dedup.callMethodWithMultipleBlocksBad()` is annotated `UiThread`] +codetoanalyze/java/starvation/Dedup.java, Dedup.callMethodWithMultipleBlocksBad():void, 28, STARVATION, no_bucket, ERROR, [`void Dedup.callMethodWithMultipleBlocksBad()`,calls `Object Future.get()` from `void Dedup.callMethodWithMultipleBlocksBad()`,[Trace on UI thread] `void Dedup.callMethodWithMultipleBlocksBad()`,`void Dedup.callMethodWithMultipleBlocksBad()` is annotated `UiThread`] +codetoanalyze/java/starvation/Dedup.java, Dedup.onUiThreadBad():void, 20, STARVATION, no_bucket, ERROR, [`void Dedup.onUiThreadBad()`,Method call: `void Dedup.callMethodWithMultipleBlocksBad()`,calls `void CountDownLatch.await()` from `void Dedup.callMethodWithMultipleBlocksBad()`,[Trace on UI thread] `void Dedup.onUiThreadBad()`,`void Dedup.onUiThreadBad()` is annotated `UiThread`] +codetoanalyze/java/starvation/Dedup.java, Dedup.oneWayBad():void, 35, DEADLOCK, no_bucket, ERROR, [[Trace 1] `void Dedup.oneWayBad()`,locks `this.Dedup.lockA` in class `Dedup*`,locks `this.Dedup.lockB` in class `Dedup*`,[Trace 2] `void Dedup.anotherWayBad()`,locks `this.Dedup.lockB` in class `Dedup*`,locks `this.Dedup.lockA` in class `Dedup*`] codetoanalyze/java/starvation/FutureGet.java, FutureGet.getDirectBad():void, 21, STARVATION, no_bucket, ERROR, [`void FutureGet.getDirectBad()`,calls `Object Future.get()` from `void FutureGet.getDirectBad()`,[Trace on UI thread] `void FutureGet.getDirectBad()`,`void FutureGet.getDirectBad()` is annotated `UiThread`] codetoanalyze/java/starvation/FutureGet.java, FutureGet.getIndirectBad():void, 26, STARVATION, no_bucket, ERROR, [[Trace 1] `void FutureGet.getIndirectBad()`,locks `this.FutureGet.lock` in class `FutureGet*`,[Trace 2] `void FutureGet.getUnderLock()`,locks `this.FutureGet.lock` in class `FutureGet*`,calls `Object Future.get()` from `void FutureGet.getUnderLock()`,[Trace 1 on UI thread] `void FutureGet.getIndirectBad()`,`void FutureGet.getIndirectBad()` is annotated `UiThread`] -codetoanalyze/java/starvation/FutureGet.java, FutureGet.getTimeout50000001MicroSecondsBad():void, 77, STARVATION, no_bucket, ERROR, [`void FutureGet.getTimeout50000001MicroSecondsBad()`,calls `Object Future.get(long,TimeUnit)` from `void FutureGet.getTimeout50000001MicroSecondsBad()`,[Trace on UI thread] `void FutureGet.getTimeout50000001MicroSecondsBad()`,`void FutureGet.getTimeout50000001MicroSecondsBad()` is annotated `UiThread`] -codetoanalyze/java/starvation/FutureGet.java, FutureGet.getTimeout64BitsBad():void, 84, STARVATION, no_bucket, ERROR, [`void FutureGet.getTimeout64BitsBad()`,calls `Object Future.get(long,TimeUnit)` from `void FutureGet.getTimeout64BitsBad()`,[Trace on UI thread] `void FutureGet.getTimeout64BitsBad()`,`void FutureGet.getTimeout64BitsBad()` is annotated `UiThread`] -codetoanalyze/java/starvation/FutureGet.java, FutureGet.getTimeoutOneDayBad():void, 42, STARVATION, no_bucket, ERROR, [`void FutureGet.getTimeoutOneDayBad()`,calls `Object Future.get(long,TimeUnit)` from `void FutureGet.getTimeoutOneDayBad()`,[Trace on UI thread] `void FutureGet.getTimeoutOneDayBad()`,`void FutureGet.getTimeoutOneDayBad()` is annotated `UiThread`] -codetoanalyze/java/starvation/FutureGet.java, FutureGet.getTimeoutOneHourBad():void, 56, STARVATION, no_bucket, ERROR, [`void FutureGet.getTimeoutOneHourBad()`,calls `Object Future.get(long,TimeUnit)` from `void FutureGet.getTimeoutOneHourBad()`,[Trace on UI thread] `void FutureGet.getTimeoutOneHourBad()`,`void FutureGet.getTimeoutOneHourBad()` is annotated `UiThread`] -codetoanalyze/java/starvation/IndirectBlock.java, IndirectBlock.takeExpensiveLockOnUiThreadBad():void, 22, STARVATION, no_bucket, ERROR, [[Trace 1] `void IndirectBlock.takeExpensiveLockOnUiThreadBad()`,locks `this.IndirectBlock.expensiveLock` in class `IndirectBlock*`,[Trace 2] `void IndirectBlock.doTransactUnderLock()`,locks `this.IndirectBlock.expensiveLock` in class `IndirectBlock*`,calls `boolean Binder.transact(int,Parcel,Parcel,int)` from `void IndirectBlock.doTransactUnderLock()`,[Trace 1 on UI thread] `void IndirectBlock.takeExpensiveLockOnUiThreadBad()`,`void IndirectBlock.takeExpensiveLockOnUiThreadBad()` is annotated `UiThread`] -codetoanalyze/java/starvation/IndirectBlock.java, IndirectBlock.takeRemoteExpensiveLockOnUiThreadBad(IndirectInterproc):void, 33, STARVATION, no_bucket, ERROR, [[Trace 1] `void IndirectBlock.takeRemoteExpensiveLockOnUiThreadBad(IndirectInterproc)`,Method call: `void IndirectInterproc.takeLock()`,locks `this` in class `IndirectInterproc*`,[Trace 2] `void IndirectInterproc.doTransactUnderLock(Binder)`,locks `this` in class `IndirectInterproc*`,calls `boolean Binder.transact(int,Parcel,Parcel,int)` from `void IndirectInterproc.doTransactUnderLock(Binder)`,[Trace 1 on UI thread] `void IndirectBlock.takeRemoteExpensiveLockOnUiThreadBad(IndirectInterproc)`,`void IndirectBlock.takeRemoteExpensiveLockOnUiThreadBad(IndirectInterproc)` is annotated `UiThread`] +codetoanalyze/java/starvation/FutureGet.java, FutureGet.getTimeout50000001MicroSecondsBad():void, 83, STARVATION, no_bucket, ERROR, [`void FutureGet.getTimeout50000001MicroSecondsBad()`,calls `Object Future.get(long,TimeUnit)` from `void FutureGet.getTimeout50000001MicroSecondsBad()`,[Trace on UI thread] `void FutureGet.getTimeout50000001MicroSecondsBad()`,`void FutureGet.getTimeout50000001MicroSecondsBad()` is annotated `UiThread`] +codetoanalyze/java/starvation/FutureGet.java, FutureGet.getTimeout64BitsBad():void, 91, STARVATION, no_bucket, ERROR, [`void FutureGet.getTimeout64BitsBad()`,calls `Object Future.get(long,TimeUnit)` from `void FutureGet.getTimeout64BitsBad()`,[Trace on UI thread] `void FutureGet.getTimeout64BitsBad()`,`void FutureGet.getTimeout64BitsBad()` is annotated `UiThread`] +codetoanalyze/java/starvation/FutureGet.java, FutureGet.getTimeoutOneDayBad():void, 43, STARVATION, no_bucket, ERROR, [`void FutureGet.getTimeoutOneDayBad()`,calls `Object Future.get(long,TimeUnit)` from `void FutureGet.getTimeoutOneDayBad()`,[Trace on UI thread] `void FutureGet.getTimeoutOneDayBad()`,`void FutureGet.getTimeoutOneDayBad()` is annotated `UiThread`] +codetoanalyze/java/starvation/FutureGet.java, FutureGet.getTimeoutOneHourBad():void, 59, STARVATION, no_bucket, ERROR, [`void FutureGet.getTimeoutOneHourBad()`,calls `Object Future.get(long,TimeUnit)` from `void FutureGet.getTimeoutOneHourBad()`,[Trace on UI thread] `void FutureGet.getTimeoutOneHourBad()`,`void FutureGet.getTimeoutOneHourBad()` is annotated `UiThread`] +codetoanalyze/java/starvation/IndirectBlock.java, IndirectBlock.takeExpensiveLockOnUiThreadBad():void, 23, STARVATION, no_bucket, ERROR, [[Trace 1] `void IndirectBlock.takeExpensiveLockOnUiThreadBad()`,locks `this.IndirectBlock.expensiveLock` in class `IndirectBlock*`,[Trace 2] `void IndirectBlock.doTransactUnderLock()`,locks `this.IndirectBlock.expensiveLock` in class `IndirectBlock*`,calls `boolean Binder.transact(int,Parcel,Parcel,int)` from `void IndirectBlock.doTransactUnderLock()`,[Trace 1 on UI thread] `void IndirectBlock.takeExpensiveLockOnUiThreadBad()`,`void IndirectBlock.takeExpensiveLockOnUiThreadBad()` is annotated `UiThread`] +codetoanalyze/java/starvation/IndirectBlock.java, IndirectBlock.takeRemoteExpensiveLockOnUiThreadBad(IndirectInterproc):void, 35, STARVATION, no_bucket, ERROR, [[Trace 1] `void IndirectBlock.takeRemoteExpensiveLockOnUiThreadBad(IndirectInterproc)`,Method call: `void IndirectInterproc.takeLock()`,locks `this` in class `IndirectInterproc*`,[Trace 2] `void IndirectInterproc.doTransactUnderLock(Binder)`,locks `this` in class `IndirectInterproc*`,calls `boolean Binder.transact(int,Parcel,Parcel,int)` from `void IndirectInterproc.doTransactUnderLock(Binder)`,[Trace 1 on UI thread] `void IndirectBlock.takeRemoteExpensiveLockOnUiThreadBad(IndirectInterproc)`,`void IndirectBlock.takeRemoteExpensiveLockOnUiThreadBad(IndirectInterproc)` is annotated `UiThread`] codetoanalyze/java/starvation/InnerClass.java, InnerClass$InnerClassA.(InnerClass,java.lang.Object), 48, DEADLOCK, no_bucket, ERROR, [[Trace 1] `InnerClass$InnerClassA.(InnerClass,Object)`,locks `this` in class `InnerClass$InnerClassA*`,Method call: `void InnerClass.bar()`,locks `this` in class `InnerClass*`,[Trace 2] `void InnerClass.outerInnerBad(InnerClass$InnerClassA)`,locks `this` in class `InnerClass*`,Method call: `void InnerClass$InnerClassA.baz()`,locks `this` in class `InnerClass$InnerClassA*`] codetoanalyze/java/starvation/InnerClass.java, InnerClass$InnerClassA.innerOuterBad():void, 34, DEADLOCK, no_bucket, ERROR, [[Trace 1] `void InnerClass$InnerClassA.innerOuterBad()`,locks `this` in class `InnerClass$InnerClassA*`,Method call: `void InnerClass.bar()`,locks `this` in class `InnerClass*`,[Trace 2] `void InnerClass.outerInnerBad(InnerClass$InnerClassA)`,locks `this` in class `InnerClass*`,Method call: `void InnerClass$InnerClassA.baz()`,locks `this` in class `InnerClass$InnerClassA*`] codetoanalyze/java/starvation/Interclass.java, Interclass.interclass1Bad(InterclassA):void, 10, DEADLOCK, no_bucket, ERROR, [[Trace 1] `void Interclass.interclass1Bad(InterclassA)`,locks `this` in class `Interclass*`,Method call: `void InterclassA.interclass1Bad()`,locks `this` in class `InterclassA*`,[Trace 2] `void InterclassA.interclass2Bad(Interclass)`,locks `this` in class `InterclassA*`,Method call: `void Interclass.interclass2Bad()`,locks `this` in class `Interclass*`] @@ -28,25 +28,25 @@ codetoanalyze/java/starvation/Intraproc.java, Intraproc.intraBad(IntraprocA):voi codetoanalyze/java/starvation/LegacySync.java, LegacySync.onUiThreadOpBad():java.lang.Object, 25, STARVATION, no_bucket, ERROR, [[Trace 1] `Object LegacySync.onUiThreadOpBad()`,locks `this.LegacySync.table` in class `LegacySync*`,[Trace 2] `void LegacySync.notOnUiThreadSyncedBad()`,locks `this.LegacySync.table` in class `LegacySync*`,calls `Object Future.get()` from `void LegacySync.notOnUiThreadSyncedBad()`,[Trace 1 on UI thread] `Object LegacySync.onUiThreadOpBad()`,`Object LegacySync.onUiThreadOpBad()` is annotated `UiThread`] codetoanalyze/java/starvation/MainThreadTest.java, AnnotatedClass.callTransactBad(MainThreadTest):void, 30, STARVATION, no_bucket, ERROR, [`void AnnotatedClass.callTransactBad(MainThreadTest)`,Method call: `void MainThreadTest.doTransact()`,calls `boolean Binder.transact(int,Parcel,Parcel,int)` from `void MainThreadTest.doTransact()`,[Trace on UI thread] `void AnnotatedClass.callTransactBad(MainThreadTest)`,class `AnnotatedClass` is annotated `UiThread`] codetoanalyze/java/starvation/MainThreadTest.java, MainThreadTest.callTransactBad():void, 23, STARVATION, no_bucket, ERROR, [`void MainThreadTest.callTransactBad()`,Method call: `void MainThreadTest.doTransact()`,calls `boolean Binder.transact(int,Parcel,Parcel,int)` from `void MainThreadTest.doTransact()`,[Trace on UI thread] `void MainThreadTest.callTransactBad()`,`void MainThreadTest.callTransactBad()` is annotated `UiThread`] -codetoanalyze/java/starvation/MyActivity.java, MyActivity.onCreate(android.os.Bundle):void, 23, STARVATION, no_bucket, ERROR, [`void MyActivity.onCreate(Bundle)`,Method call: `void MyActivity.bad()`,calls `void AccountManager.setUserData(Account,String,String)` from `void MyActivity.bad()`,[Trace on UI thread] `void MyActivity.onCreate(Bundle)`,`void MyActivity.onCreate(Bundle)` is a standard UI-thread method] -codetoanalyze/java/starvation/MyActivity.java, MyActivity.onDestroy():void, 53, STARVATION, no_bucket, ERROR, [`void MyActivity.onDestroy()`,Method call: `void MyActivity.bad()`,calls `void AccountManager.setUserData(Account,String,String)` from `void MyActivity.bad()`,[Trace on UI thread] `void MyActivity.onDestroy()`,`void MyActivity.onDestroy()` is a standard UI-thread method] -codetoanalyze/java/starvation/MyActivity.java, MyActivity.onPause():void, 43, STARVATION, no_bucket, ERROR, [`void MyActivity.onPause()`,Method call: `void MyActivity.bad()`,calls `void AccountManager.setUserData(Account,String,String)` from `void MyActivity.bad()`,[Trace on UI thread] `void MyActivity.onPause()`,`void MyActivity.onPause()` is a standard UI-thread method] -codetoanalyze/java/starvation/MyActivity.java, MyActivity.onRestart():void, 33, STARVATION, no_bucket, ERROR, [`void MyActivity.onRestart()`,Method call: `void MyActivity.bad()`,calls `void AccountManager.setUserData(Account,String,String)` from `void MyActivity.bad()`,[Trace on UI thread] `void MyActivity.onRestart()`,`void MyActivity.onRestart()` is a standard UI-thread method] -codetoanalyze/java/starvation/MyActivity.java, MyActivity.onResume():void, 38, STARVATION, no_bucket, ERROR, [`void MyActivity.onResume()`,Method call: `void MyActivity.bad()`,calls `void AccountManager.setUserData(Account,String,String)` from `void MyActivity.bad()`,[Trace on UI thread] `void MyActivity.onResume()`,`void MyActivity.onResume()` is a standard UI-thread method] -codetoanalyze/java/starvation/MyActivity.java, MyActivity.onStart():void, 28, STARVATION, no_bucket, ERROR, [`void MyActivity.onStart()`,Method call: `void MyActivity.bad()`,calls `void AccountManager.setUserData(Account,String,String)` from `void MyActivity.bad()`,[Trace on UI thread] `void MyActivity.onStart()`,`void MyActivity.onStart()` is a standard UI-thread method] -codetoanalyze/java/starvation/MyActivity.java, MyActivity.onStop():void, 48, STARVATION, no_bucket, ERROR, [`void MyActivity.onStop()`,Method call: `void MyActivity.bad()`,calls `void AccountManager.setUserData(Account,String,String)` from `void MyActivity.bad()`,[Trace on UI thread] `void MyActivity.onStop()`,`void MyActivity.onStop()` is a standard UI-thread method] -codetoanalyze/java/starvation/NonBlk.java, NonBlk.deadlockABBad():void, 34, DEADLOCK, no_bucket, ERROR, [[Trace 1] `void NonBlk.deadlockABBad()`,locks `this` in class `NonBlk*`,locks `this.NonBlk.future` in class `NonBlk*`,[Trace 2] `void NonBlk.deadlockBABad()`,locks `this.NonBlk.future` in class `NonBlk*`,locks `this` in class `NonBlk*`] +codetoanalyze/java/starvation/MyActivity.java, MyActivity.onCreate(android.os.Bundle):void, 24, STARVATION, no_bucket, ERROR, [`void MyActivity.onCreate(Bundle)`,Method call: `void MyActivity.bad()`,calls `void AccountManager.setUserData(Account,String,String)` from `void MyActivity.bad()`,[Trace on UI thread] `void MyActivity.onCreate(Bundle)`,`void MyActivity.onCreate(Bundle)` is a standard UI-thread method] +codetoanalyze/java/starvation/MyActivity.java, MyActivity.onDestroy():void, 54, STARVATION, no_bucket, ERROR, [`void MyActivity.onDestroy()`,Method call: `void MyActivity.bad()`,calls `void AccountManager.setUserData(Account,String,String)` from `void MyActivity.bad()`,[Trace on UI thread] `void MyActivity.onDestroy()`,`void MyActivity.onDestroy()` is a standard UI-thread method] +codetoanalyze/java/starvation/MyActivity.java, MyActivity.onPause():void, 44, STARVATION, no_bucket, ERROR, [`void MyActivity.onPause()`,Method call: `void MyActivity.bad()`,calls `void AccountManager.setUserData(Account,String,String)` from `void MyActivity.bad()`,[Trace on UI thread] `void MyActivity.onPause()`,`void MyActivity.onPause()` is a standard UI-thread method] +codetoanalyze/java/starvation/MyActivity.java, MyActivity.onRestart():void, 34, STARVATION, no_bucket, ERROR, [`void MyActivity.onRestart()`,Method call: `void MyActivity.bad()`,calls `void AccountManager.setUserData(Account,String,String)` from `void MyActivity.bad()`,[Trace on UI thread] `void MyActivity.onRestart()`,`void MyActivity.onRestart()` is a standard UI-thread method] +codetoanalyze/java/starvation/MyActivity.java, MyActivity.onResume():void, 39, STARVATION, no_bucket, ERROR, [`void MyActivity.onResume()`,Method call: `void MyActivity.bad()`,calls `void AccountManager.setUserData(Account,String,String)` from `void MyActivity.bad()`,[Trace on UI thread] `void MyActivity.onResume()`,`void MyActivity.onResume()` is a standard UI-thread method] +codetoanalyze/java/starvation/MyActivity.java, MyActivity.onStart():void, 29, STARVATION, no_bucket, ERROR, [`void MyActivity.onStart()`,Method call: `void MyActivity.bad()`,calls `void AccountManager.setUserData(Account,String,String)` from `void MyActivity.bad()`,[Trace on UI thread] `void MyActivity.onStart()`,`void MyActivity.onStart()` is a standard UI-thread method] +codetoanalyze/java/starvation/MyActivity.java, MyActivity.onStop():void, 49, STARVATION, no_bucket, ERROR, [`void MyActivity.onStop()`,Method call: `void MyActivity.bad()`,calls `void AccountManager.setUserData(Account,String,String)` from `void MyActivity.bad()`,[Trace on UI thread] `void MyActivity.onStop()`,`void MyActivity.onStop()` is a standard UI-thread method] +codetoanalyze/java/starvation/NonBlk.java, NonBlk.deadlockABBad():void, 33, DEADLOCK, no_bucket, ERROR, [[Trace 1] `void NonBlk.deadlockABBad()`,locks `this` in class `NonBlk*`,locks `this.NonBlk.future` in class `NonBlk*`,[Trace 2] `void NonBlk.deadlockBABad()`,locks `this.NonBlk.future` in class `NonBlk*`,locks `this` in class `NonBlk*`] codetoanalyze/java/starvation/ObjWait.java, ObjWait.indirectWaitOnMainWithoutTimeoutBad():void, 46, STARVATION, no_bucket, ERROR, [[Trace 1] `void ObjWait.indirectWaitOnMainWithoutTimeoutBad()`,locks `this.ObjWait.lock` in class `ObjWait*`,[Trace 2] `void ObjWait.lockAndWaitOnAnyWithoutTimeoutBad()`,locks `this.ObjWait.lock` in class `ObjWait*`,calls `void Object.wait()` from `void ObjWait.lockAndWaitOnAnyWithoutTimeoutBad()`,[Trace 1 on UI thread] `void ObjWait.indirectWaitOnMainWithoutTimeoutBad()`,`void ObjWait.indirectWaitOnMainWithoutTimeoutBad()` is annotated `UiThread`] codetoanalyze/java/starvation/ObjWait.java, ObjWait.waitOnMainWithExcessiveTimeout1Bad():void, 31, STARVATION, no_bucket, ERROR, [`void ObjWait.waitOnMainWithExcessiveTimeout1Bad()`,calls `void Object.wait(long)` from `void ObjWait.waitOnMainWithExcessiveTimeout1Bad()`,[Trace on UI thread] `void ObjWait.waitOnMainWithExcessiveTimeout1Bad()`,`void ObjWait.waitOnMainWithExcessiveTimeout1Bad()` is annotated `UiThread`] codetoanalyze/java/starvation/ObjWait.java, ObjWait.waitOnMainWithExcessiveTimeout2Bad():void, 38, STARVATION, no_bucket, ERROR, [`void ObjWait.waitOnMainWithExcessiveTimeout2Bad()`,calls `void Object.wait(long,int)` from `void ObjWait.waitOnMainWithExcessiveTimeout2Bad()`,[Trace on UI thread] `void ObjWait.waitOnMainWithExcessiveTimeout2Bad()`,`void ObjWait.waitOnMainWithExcessiveTimeout2Bad()` is annotated `UiThread`] codetoanalyze/java/starvation/ObjWait.java, ObjWait.waitOnMainWithoutTimeoutBad():void, 24, STARVATION, no_bucket, ERROR, [`void ObjWait.waitOnMainWithoutTimeoutBad()`,calls `void Object.wait()` from `void ObjWait.waitOnMainWithoutTimeoutBad()`,[Trace on UI thread] `void ObjWait.waitOnMainWithoutTimeoutBad()`,`void ObjWait.waitOnMainWithoutTimeoutBad()` is annotated `UiThread`] codetoanalyze/java/starvation/PubPriv.java, PubPriv.alsoBad():void, 25, STARVATION, no_bucket, ERROR, [`void PubPriv.alsoBad()`,Method call: `void PubPriv.transactBad()`,Method call: `void PubPriv.doTransactOk()`,calls `boolean Binder.transact(int,Parcel,Parcel,int)` from `void PubPriv.doTransactOk()`,[Trace on UI thread] `void PubPriv.alsoBad()`,Method call: `void PubPriv.transactBad()`,Method call: `void PubPriv.doTransactOk()`,`void PubPriv.doTransactOk()` is annotated `UiThread`] -codetoanalyze/java/starvation/PubPriv.java, PubPriv.callOneWayBad():void, 47, DEADLOCK, no_bucket, ERROR, [[Trace 1] `void PubPriv.callOneWayBad()`,Method call: `void PubPriv.oneWayOk()`,locks `this.PubPriv.lockA` in class `PubPriv*`,locks `this.PubPriv.lockB` in class `PubPriv*`,[Trace 2] `void PubPriv.callAnotherWayBad()`,Method call: `void PubPriv.anotherWayOk()`,locks `this.PubPriv.lockB` in class `PubPriv*`,locks `this.PubPriv.lockA` in class `PubPriv*`] +codetoanalyze/java/starvation/PubPriv.java, PubPriv.callOneWayBad():void, 49, DEADLOCK, no_bucket, ERROR, [[Trace 1] `void PubPriv.callOneWayBad()`,Method call: `void PubPriv.oneWayOk()`,locks `this.PubPriv.lockA` in class `PubPriv*`,locks `this.PubPriv.lockB` in class `PubPriv*`,[Trace 2] `void PubPriv.callAnotherWayBad()`,Method call: `void PubPriv.anotherWayOk()`,locks `this.PubPriv.lockB` in class `PubPriv*`,locks `this.PubPriv.lockA` in class `PubPriv*`] codetoanalyze/java/starvation/PubPriv.java, PubPriv.transactBad():void, 21, STARVATION, no_bucket, ERROR, [`void PubPriv.transactBad()`,Method call: `void PubPriv.doTransactOk()`,calls `boolean Binder.transact(int,Parcel,Parcel,int)` from `void PubPriv.doTransactOk()`,[Trace on UI thread] `void PubPriv.transactBad()`,Method call: `void PubPriv.doTransactOk()`,`void PubPriv.doTransactOk()` is annotated `UiThread`] codetoanalyze/java/starvation/ServiceOnUIThread.java, ServiceOnUIThread.onBind(android.content.Intent):android.os.IBinder, 19, STARVATION, no_bucket, ERROR, [`IBinder ServiceOnUIThread.onBind(Intent)`,Method call: `void ServiceOnUIThread.transactBad()`,calls `boolean IBinder.transact(int,Parcel,Parcel,int)` from `void ServiceOnUIThread.transactBad()`,[Trace on UI thread] `IBinder ServiceOnUIThread.onBind(Intent)`,`IBinder ServiceOnUIThread.onBind(Intent)` is a standard UI-thread method] codetoanalyze/java/starvation/StaticLock.java, StaticLock.lockOtherClassOneWayBad():void, 23, DEADLOCK, no_bucket, ERROR, [[Trace 1] `void StaticLock.lockOtherClassOneWayBad()`,locks `StaticLock$0` in class `java.lang.Class*`,locks `this` in class `StaticLock*`,[Trace 2] `void StaticLock.lockOtherClassAnotherWayNad()`,locks `this` in class `StaticLock*`,Method call: `void StaticLock.staticSynced()`,locks `StaticLock$0` in class `java.lang.Class*`] -codetoanalyze/java/starvation/SuppLint.java, SuppLint.onUiThreadBad():void, 26, STARVATION, no_bucket, ERROR, [`void SuppLint.onUiThreadBad()`,calls `Object Future.get()` from `void SuppLint.onUiThreadBad()`,[Trace on UI thread] `void SuppLint.onUiThreadBad()`,`void SuppLint.onUiThreadBad()` is annotated `UiThread`] -codetoanalyze/java/starvation/ThreadSleep.java, ThreadSleep.indirectSleepOnUIThreadBad():void, 25, STARVATION, no_bucket, ERROR, [[Trace 1] `void ThreadSleep.indirectSleepOnUIThreadBad()`,locks `this.ThreadSleep.lock` in class `ThreadSleep*`,[Trace 2] `void ThreadSleep.lockAndSleepOnNonUIThread()`,locks `this.ThreadSleep.lock` in class `ThreadSleep*`,Method call: `void ThreadSleep.sleepOnAnyThreadOk()`,calls `void Thread.sleep(long)` from `void ThreadSleep.sleepOnAnyThreadOk()`,[Trace 1 on UI thread] `void ThreadSleep.indirectSleepOnUIThreadBad()`,`void ThreadSleep.indirectSleepOnUIThreadBad()` is annotated `UiThread`] -codetoanalyze/java/starvation/ThreadSleep.java, ThreadSleep.sleepOnUIThreadBad():void, 18, STARVATION, no_bucket, ERROR, [`void ThreadSleep.sleepOnUIThreadBad()`,calls `void Thread.sleep(long)` from `void ThreadSleep.sleepOnUIThreadBad()`,[Trace on UI thread] `void ThreadSleep.sleepOnUIThreadBad()`,`void ThreadSleep.sleepOnUIThreadBad()` is annotated `UiThread`] -codetoanalyze/java/starvation/UIDeadlock.java, UIDeadlock.onUIThreadBad():void, 26, DEADLOCK, no_bucket, ERROR, [[Trace 1] `void UIDeadlock.onUIThreadBad()`,locks `this` in class `UIDeadlock*`,locks `this.UIDeadlock.lockB` in class `UIDeadlock*`,[Trace 2] `void UIDeadlock.notOnUIThreadBad()`,locks `this.UIDeadlock.lockB` in class `UIDeadlock*`,locks `this` in class `UIDeadlock*`] +codetoanalyze/java/starvation/SuppLint.java, SuppLint.onUiThreadBad():void, 25, STARVATION, no_bucket, ERROR, [`void SuppLint.onUiThreadBad()`,calls `Object Future.get()` from `void SuppLint.onUiThreadBad()`,[Trace on UI thread] `void SuppLint.onUiThreadBad()`,`void SuppLint.onUiThreadBad()` is annotated `UiThread`] +codetoanalyze/java/starvation/ThreadSleep.java, ThreadSleep.indirectSleepOnUIThreadBad():void, 24, STARVATION, no_bucket, ERROR, [[Trace 1] `void ThreadSleep.indirectSleepOnUIThreadBad()`,locks `this.ThreadSleep.lock` in class `ThreadSleep*`,[Trace 2] `void ThreadSleep.lockAndSleepOnNonUIThread()`,locks `this.ThreadSleep.lock` in class `ThreadSleep*`,Method call: `void ThreadSleep.sleepOnAnyThreadOk()`,calls `void Thread.sleep(long)` from `void ThreadSleep.sleepOnAnyThreadOk()`,[Trace 1 on UI thread] `void ThreadSleep.indirectSleepOnUIThreadBad()`,`void ThreadSleep.indirectSleepOnUIThreadBad()` is annotated `UiThread`] +codetoanalyze/java/starvation/ThreadSleep.java, ThreadSleep.sleepOnUIThreadBad():void, 17, STARVATION, no_bucket, ERROR, [`void ThreadSleep.sleepOnUIThreadBad()`,calls `void Thread.sleep(long)` from `void ThreadSleep.sleepOnUIThreadBad()`,[Trace on UI thread] `void ThreadSleep.sleepOnUIThreadBad()`,`void ThreadSleep.sleepOnUIThreadBad()` is annotated `UiThread`] +codetoanalyze/java/starvation/UIDeadlock.java, UIDeadlock.onUIThreadBad():void, 28, DEADLOCK, no_bucket, ERROR, [[Trace 1] `void UIDeadlock.onUIThreadBad()`,locks `this` in class `UIDeadlock*`,locks `this.UIDeadlock.lockB` in class `UIDeadlock*`,[Trace 2] `void UIDeadlock.notOnUIThreadBad()`,locks `this.UIDeadlock.lockB` in class `UIDeadlock*`,locks `this` in class `UIDeadlock*`] codetoanalyze/java/starvation/Workers.java, Workers.uiThreadBad():void, 28, STARVATION, no_bucket, ERROR, [`void Workers.uiThreadBad()`,Method call: `void Workers.workerOk()`,Method call: `void Workers.doTransact()`,calls `boolean Binder.transact(int,Parcel,Parcel,int)` from `void Workers.doTransact()`,[Trace on UI thread] `void Workers.uiThreadBad()`,`void Workers.uiThreadBad()` is annotated `UiThread`] diff --git a/infer/tests/codetoanalyze/java/tracing/ArrayIndexOutOfBoundsExceptionExample.java b/infer/tests/codetoanalyze/java/tracing/ArrayIndexOutOfBoundsExceptionExample.java index 62381d671..0b2e1612e 100644 --- a/infer/tests/codetoanalyze/java/tracing/ArrayIndexOutOfBoundsExceptionExample.java +++ b/infer/tests/codetoanalyze/java/tracing/ArrayIndexOutOfBoundsExceptionExample.java @@ -40,5 +40,4 @@ public class ArrayIndexOutOfBoundsExceptionExample { T2[] array = new T2[8]; withFixedIndex(array); } - } diff --git a/infer/tests/codetoanalyze/java/tracing/ClassCastExceptionExample.java b/infer/tests/codetoanalyze/java/tracing/ClassCastExceptionExample.java index 65436726b..e19765e58 100644 --- a/infer/tests/codetoanalyze/java/tracing/ClassCastExceptionExample.java +++ b/infer/tests/codetoanalyze/java/tracing/ClassCastExceptionExample.java @@ -32,5 +32,4 @@ public class ClassCastExceptionExample { } return null; } - } diff --git a/infer/tests/codetoanalyze/java/tracing/LazyDynamicDispatchExample.java b/infer/tests/codetoanalyze/java/tracing/LazyDynamicDispatchExample.java index 3d20fb42e..8a2fd7726 100644 --- a/infer/tests/codetoanalyze/java/tracing/LazyDynamicDispatchExample.java +++ b/infer/tests/codetoanalyze/java/tracing/LazyDynamicDispatchExample.java @@ -16,7 +16,6 @@ class A implements I { public T2 get() { return new T2(); } - } class B extends A { @@ -24,7 +23,6 @@ class B extends A { public T2 get() { return null; } - } public class LazyDynamicDispatchExample { @@ -51,5 +49,4 @@ public class LazyDynamicDispatchExample { B b = new B(); fromInterface(b).f(); } - } diff --git a/infer/tests/codetoanalyze/java/tracing/LocallyDefinedExceptionExample.java b/infer/tests/codetoanalyze/java/tracing/LocallyDefinedExceptionExample.java index 8c9dd355a..beaa91b55 100644 --- a/infer/tests/codetoanalyze/java/tracing/LocallyDefinedExceptionExample.java +++ b/infer/tests/codetoanalyze/java/tracing/LocallyDefinedExceptionExample.java @@ -5,7 +5,6 @@ * LICENSE file in the root directory of this source tree. */ - package codetoanalyze.java.tracing; import com.facebook.infer.annotation.Verify; @@ -15,7 +14,6 @@ class LocallyDefinedException extends RuntimeException { public LocallyDefinedException(String message) { super(message); } - } public class LocallyDefinedExceptionExample { @@ -41,5 +39,4 @@ public class LocallyDefinedExceptionExample { } } } - } diff --git a/infer/tests/codetoanalyze/java/tracing/NullPointerExceptionExample.java b/infer/tests/codetoanalyze/java/tracing/NullPointerExceptionExample.java index e7aa21431..3aebc1916 100644 --- a/infer/tests/codetoanalyze/java/tracing/NullPointerExceptionExample.java +++ b/infer/tests/codetoanalyze/java/tracing/NullPointerExceptionExample.java @@ -37,5 +37,4 @@ public class NullPointerExceptionExample { callDeref(null, true); } } - } diff --git a/infer/tests/codetoanalyze/java/tracing/ReportOnMainExample.java b/infer/tests/codetoanalyze/java/tracing/ReportOnMainExample.java index 58a90635f..cfb9456e2 100644 --- a/infer/tests/codetoanalyze/java/tracing/ReportOnMainExample.java +++ b/infer/tests/codetoanalyze/java/tracing/ReportOnMainExample.java @@ -24,5 +24,4 @@ public class ReportOnMainExample { ReportOnMainExample example = new ReportOnMainExample(); example.foo(); } - } diff --git a/infer/tests/codetoanalyze/java/tracing/T2.java b/infer/tests/codetoanalyze/java/tracing/T2.java index c2acb155a..c05d8536c 100644 --- a/infer/tests/codetoanalyze/java/tracing/T2.java +++ b/infer/tests/codetoanalyze/java/tracing/T2.java @@ -5,11 +5,10 @@ * LICENSE file in the root directory of this source tree. */ - package codetoanalyze.java.tracing; public class T2 { int x; - void f() { - } + + void f() {} } diff --git a/infer/tests/codetoanalyze/java/tracing/UnavoidableExceptionExample.java b/infer/tests/codetoanalyze/java/tracing/UnavoidableExceptionExample.java index cdb3b3b8d..ebbf34550 100644 --- a/infer/tests/codetoanalyze/java/tracing/UnavoidableExceptionExample.java +++ b/infer/tests/codetoanalyze/java/tracing/UnavoidableExceptionExample.java @@ -27,5 +27,4 @@ public class UnavoidableExceptionExample { T2 t = create(); t.f(); } - }