A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pmd/pmd/issues/4090 below:

[java] FinalFieldCouldBeStatic false positive with non-static synchronized block (regression in 6.48, worked with 6.47) · Issue #4090 · pmd/pmd · GitHub

Affects PMD Version: 6.48

Rule: FinalFieldCouldBeStatic

Please provide the rule name and a link to the rule documentation: https://pmd.github.io/latest/pmd_rules_java_design.html#finalfieldcouldbestatic

Description:

6.48 flags objects that are only used for synchronization incorrectly

Code Sample demonstrating the issue:

class foo {
    private final Object[] lock = new Object[0];

    void init() {
        synchronized (lock) {
            // do init stuff
        }
    }

    public void close() {
        synchronized (lock) {
           // do close stuff
        }
    }
}

Expected outcome: Class passes PMD checks

PMD reports a violation at line 2 ..., but that's wrong. That's a false positive.

Running PMD through: [Maven]

stevenschlansker and kris-scheibe


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4