Inspectopedia Help

Assignment to static field from instance context

Reports assignment to, or modification of static fields from within an instance method.

Although legal, such assignments are tricky to do safely and are often a result of marking fields static inadvertently.

Example:

class Counter { private static int count = 0; void increment() { // Warning: updating a static field // from an instance method count++; } }

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3

Plugin:

Java, 233.SNAPSHOT

Last modified: 13 July 2023