[infer][java] model the Eradicate assertion utils for the biabduction analysis

Summary: Useful to have Eradicate and Biabduction agree on how to inform that the analysis that some objects are not null.

Reviewed By: sblackshear

Differential Revision: D5075127

fbshipit-source-id: 9e56981
master
Jeremy Dubreil 8 years ago committed by Facebook Github Bot
parent 735e906145
commit 64ab959486

@ -0,0 +1,53 @@
/*
* Copyright (c) 2004 - present Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
package com.facebook.infer.annotation;
import com.facebook.infer.builtins.InferBuiltins;
import javax.annotation.Nullable;
public class Assertions {
public static <T> T assumeNotNull(@Nullable T object) {
InferBuiltins.assume_allocated(object);
return object;
}
public static <T> T assumeNotNull(@Nullable T object, String explanation) {
InferBuiltins.assume_allocated(object);
return object;
}
public static <T> T assertNotNull(@Nullable T object) {
InferBuiltins.assume_allocated(object);
return object;
}
public static <T> T assertNotNull(@Nullable T object, String explanation) {
InferBuiltins.assume_allocated(object);
return object;
}
public static void assumeCondition(boolean condition) {
InferBuiltins.assume(condition);
}
public static void assumeCondition(boolean condition, String explanation) {
InferBuiltins.assume(condition);
}
public static void assertCondition(boolean condition) {
InferBuiltins.assume(condition);
}
public static void assertCondition(boolean condition, String explanation) {
InferBuiltins.assume(condition);
}
}

@ -16,6 +16,8 @@ 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;
@ -605,4 +607,8 @@ public class NullPointerExceptions {
}
}
String assertParameterNotNullableOk(@Nullable Object object) {
return Assertions.assertNotNull(object).toString();
}
}

Loading…
Cancel
Save