1
2
3
4
5
6 package mockit.internal.reflection;
7
8 import edu.umd.cs.findbugs.annotations.NonNull;
9
10 @SuppressWarnings("UtilityClassWithoutPrivateConstructor")
11 final class ThrowOfCheckedException {
12 private static Exception exceptionToThrow;
13
14 ThrowOfCheckedException() throws Exception {
15 throw exceptionToThrow;
16 }
17
18 @SuppressWarnings("deprecation")
19 static synchronized void doThrow(@NonNull Exception checkedException) {
20 exceptionToThrow = checkedException;
21 try {
22 ThrowOfCheckedException.class.newInstance();
23 } catch (InstantiationException | IllegalAccessException ignore) {
24 }
25 }
26 }