From d39d4cfa206a52f652c0076ca32bf7c56b785d2c Mon Sep 17 00:00:00 2001 From: Sam Blackshear Date: Wed, 18 Jan 2017 10:55:02 -0800 Subject: [PATCH] [thread-safety] use jsr-305 versions of ThreadSafe/NotThreadSafe rather than defining custom annotations Summary: Just cleanup; gives us slightly less test code to maintain. Reviewed By: jeremydubreil Differential Revision: D4429265 fbshipit-source-id: d43c308 --- .../java/threadsafety/Annotations.java | 2 ++ .../java/threadsafety/Builders.java | 2 ++ .../java/threadsafety/Containers.java | 2 ++ .../java/threadsafety/Locks.java | 2 ++ .../threadsafety/NotThreadSafeExample.java | 12 +--------- .../java/threadsafety/Ownership.java | 2 ++ .../java/threadsafety/ThreadSafe.java | 22 ------------------- .../java/threadsafety/ThreadSafeExample.java | 3 +++ 8 files changed, 14 insertions(+), 33 deletions(-) delete mode 100644 infer/tests/codetoanalyze/java/threadsafety/ThreadSafe.java diff --git a/infer/tests/codetoanalyze/java/threadsafety/Annotations.java b/infer/tests/codetoanalyze/java/threadsafety/Annotations.java index 0f330d44b..df57957e8 100644 --- a/infer/tests/codetoanalyze/java/threadsafety/Annotations.java +++ b/infer/tests/codetoanalyze/java/threadsafety/Annotations.java @@ -14,6 +14,8 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import javax.annotation.concurrent.ThreadSafe; + import android.support.annotation.UiThread; import com.facebook.infer.annotation.ThreadConfined; diff --git a/infer/tests/codetoanalyze/java/threadsafety/Builders.java b/infer/tests/codetoanalyze/java/threadsafety/Builders.java index d7944b285..eb4e01acb 100644 --- a/infer/tests/codetoanalyze/java/threadsafety/Builders.java +++ b/infer/tests/codetoanalyze/java/threadsafety/Builders.java @@ -9,6 +9,8 @@ package codetoanalyze.java.checkers; +import javax.annotation.concurrent.ThreadSafe; + import com.google.common.collect.ImmutableList; import com.google.common.collect.MyImmutableList; import com.google.common.collect.ImmutableList.Builder; diff --git a/infer/tests/codetoanalyze/java/threadsafety/Containers.java b/infer/tests/codetoanalyze/java/threadsafety/Containers.java index 9a28b9480..6e12cb69d 100644 --- a/infer/tests/codetoanalyze/java/threadsafety/Containers.java +++ b/infer/tests/codetoanalyze/java/threadsafety/Containers.java @@ -9,6 +9,8 @@ package codetoanalyze.java.checkers; +import javax.annotation.concurrent.ThreadSafe; + import java.util.HashMap; import java.util.Map; import java.util.concurrent.ConcurrentMap; diff --git a/infer/tests/codetoanalyze/java/threadsafety/Locks.java b/infer/tests/codetoanalyze/java/threadsafety/Locks.java index c1419bdb7..9d4bddad5 100644 --- a/infer/tests/codetoanalyze/java/threadsafety/Locks.java +++ b/infer/tests/codetoanalyze/java/threadsafety/Locks.java @@ -9,6 +9,8 @@ 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; diff --git a/infer/tests/codetoanalyze/java/threadsafety/NotThreadSafeExample.java b/infer/tests/codetoanalyze/java/threadsafety/NotThreadSafeExample.java index b97ea872e..50078df02 100644 --- a/infer/tests/codetoanalyze/java/threadsafety/NotThreadSafeExample.java +++ b/infer/tests/codetoanalyze/java/threadsafety/NotThreadSafeExample.java @@ -9,17 +9,7 @@ package codetoanalyze.java.checkers; -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Documented -@Target(ElementType.TYPE) -@Retention(RetentionPolicy.CLASS) -@interface NotThreadSafe { -} +import javax.annotation.concurrent.NotThreadSafe; @NotThreadSafe public class NotThreadSafeExample{ diff --git a/infer/tests/codetoanalyze/java/threadsafety/Ownership.java b/infer/tests/codetoanalyze/java/threadsafety/Ownership.java index 7cde6c08f..3230fe6ff 100644 --- a/infer/tests/codetoanalyze/java/threadsafety/Ownership.java +++ b/infer/tests/codetoanalyze/java/threadsafety/Ownership.java @@ -9,6 +9,8 @@ package codetoanalyze.java.checkers; +import javax.annotation.concurrent.ThreadSafe; + class Obj { Object f; Obj g; diff --git a/infer/tests/codetoanalyze/java/threadsafety/ThreadSafe.java b/infer/tests/codetoanalyze/java/threadsafety/ThreadSafe.java deleted file mode 100644 index 88152fe57..000000000 --- a/infer/tests/codetoanalyze/java/threadsafety/ThreadSafe.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2016 - 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 codetoanalyze.java.checkers; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Documented -@Target(ElementType.TYPE) -@Retention(RetentionPolicy.CLASS) -public @interface ThreadSafe { -} diff --git a/infer/tests/codetoanalyze/java/threadsafety/ThreadSafeExample.java b/infer/tests/codetoanalyze/java/threadsafety/ThreadSafeExample.java index c81993184..82698213b 100644 --- a/infer/tests/codetoanalyze/java/threadsafety/ThreadSafeExample.java +++ b/infer/tests/codetoanalyze/java/threadsafety/ThreadSafeExample.java @@ -9,6 +9,9 @@ package codetoanalyze.java.checkers; +import javax.annotation.concurrent.NotThreadSafe; +import javax.annotation.concurrent.ThreadSafe; + import com.facebook.infer.annotation.ThreadSafeMethod; @ThreadSafe