Ensure #1480 is fixed

Fix #1480
This commit is contained in:
Clément Fournier
2023-04-25 21:49:36 +02:00
parent c4e0586dd4
commit c2b18ce229
2 changed files with 20 additions and 0 deletions

View File

@ -126,4 +126,23 @@ class Foo {
}
]]></code>
</test-code>
<test-code>
<description>[java] IdenticalCatchBranches false positive #1480</description>
<expected-problems>0</expected-problems>
<code><![CDATA[
class Foo {
public boolean classNameExists(String fullyQualifiedClassName) {
try {
Foo.class.getClassLoader().loadClass(fullyQualifiedClassName);
return true; // Class found
} catch (ClassNotFoundException e) {
return false;
} catch (LinkageError e2) {
// Class exists, but may be invalid (see https://github.com/pmd/pmd/issues/1131)
return true;
}
}
}
]]></code>
</test-code>
</test-data>