Unqualified static access
Reports usage of static members that is not qualified with the class name.
This is legal if the static member is in the same class, but may be confusing.
Example:
After the quick-fix is applied:
Use the inspection settings to toggle the reporting for the following items:
static fields access
void bar() { System.out.println(x); }
calls to static methods
void bar() { foo(); }
static void baz() { foo(); }
You can also configure the inspection to only report static member usage from a non-static context. In the above example, static void baz() { foo(); }
will not be reported.
Inspection options
Option | Type | Default |
---|---|---|
Ignore unqualified field accesses | Checkbox | false |
Ignore unqualified method calls | Checkbox | false |
Only report static access from a non-static context | Checkbox | false |
Inspection Details | |
---|---|
Available in: | IntelliJ IDEA 2023.3, Qodana for JVM 2023.3 |
Plugin: | Java, 233.SNAPSHOT |