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.
- Loading branch information
1 parent
95f1754
commit d51ecda
Showing
4 changed files
with
76 additions
and
0 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
19 changes: 19 additions & 0 deletions
19
spotbugsTestCases/src/java/constructorthrow/ConstructorThrowNegativeTest16.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,19 @@ | ||
package constructorthrow; | ||
|
||
import java.util.function.Supplier; | ||
|
||
/** | ||
* The lambda which throws the exception is created and assigned to a field, but not used. | ||
* @see <a href="https://github.com/spotbugs/spotbugs/issues/2695">GitHub issue #2695</a> | ||
*/ | ||
public class ConstructorThrowNegativeTest16 { | ||
Supplier<String> s; | ||
|
||
public ConstructorThrowNegativeTest16() { | ||
s = ConstructorThrowNegativeTest16::supplier; | ||
} | ||
|
||
private static String supplier() { | ||
throw new IllegalStateException(); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
spotbugsTestCases/src/java/constructorthrow/ConstructorThrowTest18.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,17 @@ | ||
package constructorthrow; | ||
|
||
/** | ||
* The lambda which throws the exception is created and assigned to a field, and used in the Constructor. | ||
* It's similar to {@link ConstructorThrowNegativeTest16}, but it throws an exception. | ||
*/ | ||
public class ConstructorThrowTest18 { | ||
String s; | ||
|
||
public ConstructorThrowTest18() { | ||
s = ConstructorThrowTest18.supplier(); | ||
} | ||
|
||
private static String supplier() { | ||
throw new IllegalStateException(); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
spotbugsTestCases/src/java/constructorthrow/ConstructorThrowTest19.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,20 @@ | ||
package constructorthrow; | ||
|
||
import java.util.function.Supplier; | ||
|
||
/** | ||
* The lambda which throws the exception is created and assigned to a field, and used in the Constructor. | ||
* It's similar to {@link ConstructorThrowNegativeTest16}, but it throws an exception. | ||
*/ | ||
public class ConstructorThrowTest19 { | ||
Supplier<String> s; | ||
|
||
public ConstructorThrowTest19() { | ||
s = ConstructorThrowTest19::supplier; | ||
String str = s.get(); | ||
} | ||
|
||
private static String supplier() { | ||
throw new IllegalStateException(); | ||
} | ||
} |