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
No known key found for this signature in database
GPG Key ID: 4D8D42402E4F47E2
2 changed files with 20 additions and 0 deletions

View File

@ -368,6 +368,7 @@ Language specific fixes:
* java-codestyle
* [#1208](https://github.com/pmd/pmd/issues/1208): \[java] PrematureDeclaration rule false-positive on variable declared to measure time
* [#1429](https://github.com/pmd/pmd/issues/1429): \[java] PrematureDeclaration as result of method call (false positive)
* [#1480](https://github.com/pmd/pmd/issues/1480): \[java] IdenticalCatchBranches false positive
* [#1673](https://github.com/pmd/pmd/issues/1673): \[java] UselessParentheses false positive with conditional operator
* [#1790](https://github.com/pmd/pmd/issues/1790): \[java] UnnecessaryFullyQualifiedName false positive with enum constant
* [#1918](https://github.com/pmd/pmd/issues/1918): \[java] UselessParentheses false positive with boolean operators

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>