diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index a2257a6797..2947d9f354 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -72,6 +72,8 @@ The command line version of PMD continues to use **scala 2.13**. * [#2573](https://github.com/pmd/pmd/pull/2573): \[java] DefaultPackage: Allow package default JUnit 5 Test methods * java-design * [#2563](https://github.com/pmd/pmd/pull/2563): \[java] UselessOverridingMethod false negative with already public methods +* java-errorprone + * [#2544](https://github.com/pmd/pmd/issues/2544): \[java] UseProperClassLoader can not detect the case with method call on intermediate variable * scala * [#2547](https://github.com/pmd/pmd/pull/2547): \[scala] Add cross compilation for scala 2.12 and 2.13 diff --git a/pmd-java/src/main/resources/category/java/errorprone.xml b/pmd-java/src/main/resources/category/java/errorprone.xml index ebd938006e..8033820e7f 100644 --- a/pmd-java/src/main/resources/category/java/errorprone.xml +++ b/pmd-java/src/main/resources/category/java/errorprone.xml @@ -3532,7 +3532,7 @@ Thread.currentThread().getContextClassLoader() instead. - //PrimarySuffix[@Image='getClassLoader'] + //PrimarySuffix[@Image='getClassLoader'] | //PrimaryPrefix[ends-with(Name/@Image, '.getClassLoader')] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/UseProperClassLoader.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/UseProperClassLoader.xml index 4fa1d46e23..e6c8238078 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/UseProperClassLoader.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/UseProperClassLoader.xml @@ -20,6 +20,23 @@ public class Foo { + + + + False negatives (#2544) + 2 + 4,7 + c = o.getClass(); + ClassLoader cl2 = c.getClassLoader(); + } } ]]>