File: MultipleUnions.java

package info (click to toggle)
checker-framework-java 3.2.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 22,840 kB
  • sloc: java: 145,910; xml: 839; sh: 518; makefile: 401; perl: 26
file content (38 lines) | stat: -rw-r--r-- 1,221 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
public class MultipleUnions {
    public static boolean flag = false;

    void foo1(MyInterface<Throwable> param) throws Throwable {
        try {
            bar();
        } catch (MyExceptionA | MyExceptionB ex1) {
            try {
                bar();
            } catch (SubMyExceptionA | MyExceptionB ex2) {

                Throwable t = flag ? ex1 : ex2;
                typeVar(ex1, ex1);
                typeVar(ex2, ex2);
                // See UnionCrash for version that crashes
                // typeVar(ex1, ex2);
            }
        }
    }

    <T extends Cloneable & MyInterface<String>> void typeVarIntersection(T param) {}

    <T extends Throwable> void typeVar(T param, T param2) {}

    <T extends Throwable> void typeVarWildcard(T param, MyInterface<? extends T> myInterface) {}

    <T extends Throwable> void typeVarWildcard2(T param, MyInterface<? super T> myInterface) {}

    void bar() throws MyExceptionA, MyExceptionB {}

    interface MyInterface<T> {}

    class MyExceptionA extends Throwable implements Cloneable, MyInterface<String> {}

    class MyExceptionB extends Throwable implements Cloneable, MyInterface<String> {}

    class SubMyExceptionA extends MyExceptionA {}
}