Merge branch 'pr-2557'
[java] UseProperClassLoader can not detect the case with method call … #2557
This commit is contained in:
@ -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
|
||||
|
||||
|
@ -3532,7 +3532,7 @@ Thread.currentThread().getContextClassLoader() instead.
|
||||
<properties>
|
||||
<property name="version" value="2.0"/>
|
||||
<property name="xpath">
|
||||
<value>//PrimarySuffix[@Image='getClassLoader']</value>
|
||||
<value>//PrimarySuffix[@Image='getClassLoader'] | //PrimaryPrefix[ends-with(Name/@Image, '.getClassLoader')]</value>
|
||||
</property>
|
||||
</properties>
|
||||
<example>
|
||||
|
@ -20,6 +20,23 @@ public class Foo {
|
||||
<code><![CDATA[
|
||||
public class Foo {
|
||||
void bar() { ClassLoader cl = Thread.currentThread().getContextClassLoader(); }
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>False negatives (#2544)</description>
|
||||
<expected-problems>2</expected-problems>
|
||||
<expected-linenumbers>4,7</expected-linenumbers>
|
||||
<code><![CDATA[
|
||||
public class UseProperClassLoaderFN {
|
||||
{
|
||||
Object o = new Object();
|
||||
ClassLoader cl = o.getClass().getClassLoader();
|
||||
|
||||
Class<?> c = o.getClass();
|
||||
ClassLoader cl2 = c.getClassLoader();
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
Reference in New Issue
Block a user