Affects PMD Version: 7.22.0
Rule:DoNotUseThreads
Description:
The DoNotUseThreads rule is intended to prevent applications from creating or managing their own threads/ExecutorServices (as required by the J2EE specification).
However, it incorrectly triggers on the static method call java.lang.Thread.onSpinWait(), which is not thread creation or management — it is a performance hint (intrinsic) introduced in Java 9 to help the JIT optimize spin-wait loops. This call appears in official OpenJDK jtreg tests and many legitimate performance-critical codes.
Code Sample demonstrating the issue:
public class a{
public void foo(){
java.lang.Thread.onSpinWait();
}
}
Expected outcome:
PMD reports a violation at line 3 for DoNotUseThreads ("To be compliant to J2EE, a webapp should not use any thread."), but that's wrong. That's a false positive.
Running PMD through: CLI
Affects PMD Version: 7.22.0
Rule:DoNotUseThreads
Description:
The DoNotUseThreads rule is intended to prevent applications from creating or managing their own threads/ExecutorServices (as required by the J2EE specification).
However, it incorrectly triggers on the static method call java.lang.Thread.onSpinWait(), which is not thread creation or management — it is a performance hint (intrinsic) introduced in Java 9 to help the JIT optimize spin-wait loops. This call appears in official OpenJDK jtreg tests and many legitimate performance-critical codes.
Code Sample demonstrating the issue:
Expected outcome:
PMD reports a violation at line 3 for DoNotUseThreads ("To be compliant to J2EE, a webapp should not use any thread."), but that's wrong. That's a false positive.
Running PMD through: CLI