forked from spotbugs/spotbugs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix for Issue 2040 This PR fixes issue spotbugs#2040 by limiting the errors reported by the detector `ThrowingExceptions` to cases where `java.lang.Exception` or `lava.lang.Throwable` appears in the exception specification of th method but it is neither inherited from an overridden method nor is is coming from another method that the method invokes. Syntathic methods are also omitted as well as methods which throw generic exceptions. --------- Co-authored-by: Ádám Balogh <adam.balogh@ericsson.com> Co-authored-by: Kengo TODA <skypencil@gmail.com> Co-authored-by: gtoison <guillaume.toison@tobam.fr> Co-authored-by: Judit Knoll <123470644+JuditKnoll@users.noreply.github.com> Co-authored-by: Judit Knoll <judit.knoll@sigmatechnology.com> Co-authored-by: Judit Knoll <knoll.judit94@gmail.com> Co-authored-by: Guillaume Toison <86775455+gtoison@users.noreply.github.com>
- Loading branch information
1 parent
8d986ba
commit bc30b44
Showing
13 changed files
with
384 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
spotbugs-tests/src/test/java/edu/umd/cs/findbugs/detect/Issue2040Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package edu.umd.cs.findbugs.detect; | ||
|
||
import edu.umd.cs.findbugs.AbstractIntegrationTest; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class Issue2040Test extends AbstractIntegrationTest { | ||
@Test | ||
void test() { | ||
performAnalysis("ghIssues/issue2040/Base.class", | ||
"ghIssues/issue2040/Derived.class", | ||
"ghIssues/issue2040/GenericBase.class", | ||
"ghIssues/issue2040/GenericDerived.class", | ||
"ghIssues/issue2040/Interface.class", | ||
"ghIssues/issue2040/Generic.class", | ||
"ghIssues/issue2040/Caller.class"); | ||
|
||
assertBugTypeCount("THROWS_METHOD_THROWS_RUNTIMEEXCEPTION", 3); | ||
assertBugInMethodAtLine("THROWS_METHOD_THROWS_RUNTIMEEXCEPTION", "Derived", "lambda$lambda2$1", 36); | ||
assertBugInMethodAtLine("THROWS_METHOD_THROWS_RUNTIMEEXCEPTION", "Derived", "runtimeExThrownFromCatch", 97); | ||
assertBugInMethodAtLine("THROWS_METHOD_THROWS_RUNTIMEEXCEPTION", "Derived", "runtimeExceptionThrowingMethod", 45); | ||
|
||
assertBugTypeCount("THROWS_METHOD_THROWS_CLAUSE_THROWABLE", 4); | ||
assertBugInMethod("THROWS_METHOD_THROWS_CLAUSE_THROWABLE", "Base", "method"); | ||
assertBugInMethod("THROWS_METHOD_THROWS_CLAUSE_THROWABLE", "Derived", "throwableThrowingMethod"); | ||
assertBugInMethod("THROWS_METHOD_THROWS_CLAUSE_THROWABLE", "GenericBase", "method1"); | ||
assertBugInMethod("THROWS_METHOD_THROWS_CLAUSE_THROWABLE", "GenericBase", "method2"); | ||
|
||
assertBugTypeCount("THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION", 5); | ||
assertBugInMethod("THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION", "Derived", "exceptionThrowingMethod"); | ||
assertBugInMethod("THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION", "Derived", "exThrownFromCatch"); | ||
assertBugInMethod("THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION", "GenericBase", "method"); | ||
assertBugInMethod("THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION", "GenericBase", "method2"); | ||
assertBugInMethod("THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION", "Interface", "iMethod"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package ghIssues.issue2040; | ||
|
||
public class Base { | ||
public void method() throws Throwable { | ||
throw new Throwable(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package ghIssues.issue2040; | ||
|
||
public class Caller { | ||
public void method() throws Throwable { | ||
Base b = new Base(); | ||
b.method(); | ||
} | ||
} |
Oops, something went wrong.