Java


JAVA.CONCURRENCY.LOCK.STATIC : Synchronization on static (Java)

要旨

A synchronized statement on a static guard should lock an instance guard instead.

Concurrency is an important but complex aspect of modern software. As a consequence, it is often used in an incorrect way, also because the subtleties of the Java memory model are not always understood. This checker identifies a large class of common programming errors due to incorrect uses of concurrency primitives, such as incorrect implementations of the singleton pattern and incorrect uses of the volatile field modifier, whose goal is to publish a field update to all executing cores. The latter, however, has a cost in terms of execution time.

プロパティ

クラス名 Synchronization on static (Java)
日本語クラス名 Synchronization on static (Java)
クラス分類 信頼性 (reliability)
ニーモニック JAVA.CONCURRENCY.LOCK.STATIC
カテゴリー
CWE CWE:366 Race Condition within a Thread
  CWE:413 Improper Resource Locking
CERT-Java CERT-Java:VNA00-J Ensure visibility when accessing shared primitive variables
対応言語 Java で利用可能です。
有効/無効設定 このワーニングクラスのチェックはデフォルトで有効になっています。チェックを無効にするにはプロジェクト設定ファイル (configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += discard class="Synchronization on static (Java)"

解決法

Check if the warnings correspond to actual possible errors for a concurrent execution of the program.

関連のある設定ファイルパラメータ

設定ファイルの以下のパラメータがこのワーニングクラスのチェックに影響します。