Affects PMD Version:
6.16.0
Rule:
Description:
If method level syncs are allowed, the parent method MUST be synchronized and static. In the case the static member is explicitly synchronized with a block in a non-synchronized method, it will still be counted as a violation.
Code Sample demonstrating the issue:
<test-code>
<description>#xxx</description>
<rule-property name="allowMethodLevelSynchronization">true</rule-property>
<expected-problems>0</expected-problems>
<code><![CDATA[
import java.text.SimpleDateFormat;
public class Foo {
private static final SimpleDateFormat sdf = new SimpleDateFormat();
private void bar() {
synchronized(sdf) {
sdf.format();
}
}
}
]]></code>
</test-code>
Running PMD through: [CLI | Ant | Maven | Gradle | Designer | Other]
Any
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