support ErrorProne Immutable and GuardedBy annotations

GitOrigin-RevId: 10f5298141586860fd180e029905b37566ad2bdf
This commit is contained in:
Bas Leijdekkers
2020-02-21 19:11:25 +00:00
committed by intellij-monorepo-bot
parent 541cc98b39
commit 29f6ad76a4
7 changed files with 63 additions and 30 deletions
@@ -1,13 +1,14 @@
<html>
<body>
Reports any accesses of fields declared as <b>@GuardedBy</b> which are are not guarded by an appropriate synchronization structure.
Supported annotations are:
Reports accesses of fields declared as <b>@GuardedBy</b> which are are not guarded by an appropriate synchronization structure.
Supported <b>@GuardedBy</b> annotations are:
<ul>
<li>net.jcip.annotations.GuardedBy</li>
<li>javax.annotation.concurrent.GuardedBy</li>
<li>org.apache.http.annotation.GuardedBy</li>
<li>com.android.annotations.concurrency.GuardedBy</li>
<li>androidx.annotation.GuardedBy</li>
<li>com.google.errorprone.annotations.concurrent.GuardedBy</li>
</ul>
</body>
</html>
@@ -1,7 +1,16 @@
<html>
<body>
Reports any @GuardedBy annotations (net.jcip.annotations|javax.annotation.concurrent|org.apache.http.annotation) on instance fields or methods,
where the guard is a static field. Guarding a non-static by a static may result in excessive lock contention,
as access to each locked field in any object instance will prevent simultaneous access to that field in every object instance.
Reports <b>@GuardedBy</b> annotations on instance fields or methods,
where the guard is a <b>static</b> field. Guarding a non-static by a <b>static</b> may result in excessive lock contention,
as access to each locked field in any object instance will prevent simultaneous access to that field in every object instance.
Supported <b>@GuardedBy</b> annotations are:
<ul>
<li>net.jcip.annotations.GuardedBy</li>
<li>javax.annotation.concurrent.GuardedBy</li>
<li>org.apache.http.annotation.GuardedBy</li>
<li>com.android.annotations.concurrency.GuardedBy</li>
<li>androidx.annotation.GuardedBy</li>
<li>com.google.errorprone.annotations.concurrent.GuardedBy</li>
</ul>
</body>
</html>
@@ -1,6 +1,15 @@
<html>
<body>
Reports any non-final field in a class with @Immutable annotation
(net.jcip.annotations|javax.annotation.concurrent|org.apache.http.annotation). This violates the contract of the @Immutable annotation.
Reports any non-final field in a class with <b>@Immutable</b> annotation.
This violates the contract of the <b>@Immutable</b> annotation.
Supported <b>@GuardedBy</b> annotations are:
<ul>
<li>net.jcip.annotations.GuardedBy</li>
<li>javax.annotation.concurrent.GuardedBy</li>
<li>org.apache.http.annotation.GuardedBy</li>
<li>com.android.annotations.concurrency.GuardedBy</li>
<li>androidx.annotation.GuardedBy</li>
<li>com.google.errorprone.annotations.concurrent.GuardedBy</li>
</ul>
</body>
</html>
@@ -1,7 +1,16 @@
<html>
<body>
Reports any @GuardedBy annotations (net.jcip.annotations|javax.annotation.concurrent|org.apache.http.annotation) annotations where the guarding field
is not final. Guarding on a non-final field may result in unexpected race conditions, as locks will
be held on the value of the field (which may change), rather than the field itself.
Reports <b>@GuardedBy</b> annotations annotations where the guarding field
is not <b>final</b>. Guarding on a non-final field may result in unexpected race conditions, as locks will
be held on the value of the field (which may change), rather than the field itself.
Supported <b>@GuardedBy</b> annotations are:
<ul>
<li>net.jcip.annotations.GuardedBy</li>
<li>javax.annotation.concurrent.GuardedBy</li>
<li>org.apache.http.annotation.GuardedBy</li>
<li>com.android.annotations.concurrency.GuardedBy</li>
<li>androidx.annotation.GuardedBy</li>
<li>com.google.errorprone.annotations.concurrent.GuardedBy</li>
</ul>
</body>
</html>
@@ -1,7 +1,16 @@
<html>
<body>
Reports any @GuardedBy annotations (net.jcip.annotations|javax.annotation.concurrent|org.apache.http.annotation) on static fields or methods,
where the guard is either a non-static field or 'this'. Guarding a static by a non-static may result in
excessive concurrency, multiple threads may be able to access the guarded field simultaneously, by locking in different object contexts.
Reports <b>@GuardedBy</b> annotations on <b>static</b> fields or methods,
where the guard is either a non-static field or <b>this</b>. Guarding a <b>static</b> by a non-static may result in
excessive concurrency, multiple threads may be able to access the guarded field simultaneously, by locking in different object contexts.
Supported <b>@GuardedBy</b> annotations are:
<ul>
<li>net.jcip.annotations.GuardedBy</li>
<li>javax.annotation.concurrent.GuardedBy</li>
<li>org.apache.http.annotation.GuardedBy</li>
<li>com.android.annotations.concurrency.GuardedBy</li>
<li>androidx.annotation.GuardedBy</li>
<li>com.google.errorprone.annotations.concurrent.GuardedBy</li>
</ul>
</body>
</html>
@@ -1,6 +1,14 @@
<html>
<body>
Reports any @GuardedBy annotations (net.jcip.annotations|javax.annotation.concurrent|org.apache.http.annotation) where the guarding field
is unknown.
Reports <b>@GuardedBy</b> annotations where the specified guarding field is unknown.
Supported <b>@GuardedBy</b> annotations are:
<ul>
<li>net.jcip.annotations.GuardedBy</li>
<li>javax.annotation.concurrent.GuardedBy</li>
<li>org.apache.http.annotation.GuardedBy</li>
<li>com.android.annotations.concurrency.GuardedBy</li>
<li>androidx.annotation.GuardedBy</li>
<li>com.google.errorprone.annotations.concurrent.GuardedBy</li>
</ul>
</body>
</html>
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.codeInsight;
import com.intellij.openapi.components.ServiceManager;
@@ -48,6 +34,8 @@ public class ConcurrencyAnnotationsManager {
fillDefaults(myNotThreadSafeList, NOT_THREAD_SAFE);
myImmutableList.add("com.google.auto.value.AutoValue");
myImmutableList.add("com.google.errorprone.annotations.Immutable");
myGuardedByList.add("com.google.errorprone.annotations.concurrent.GuardedBy");
}
private static void fillDefaults(List<? super String> list, final String annoName) {