public class MultipleUnions { public static boolean flag = false; void foo1(MyInterface 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); } } } > void typeVarIntersection(T param) {} void typeVar(T param, T param2) {} void typeVarWildcard(T param, MyInterface myInterface) {} void typeVarWildcard2(T param, MyInterface myInterface) {} void bar() throws MyExceptionA, MyExceptionB {} interface MyInterface {} class MyExceptionA extends Throwable implements Cloneable, MyInterface {} class MyExceptionB extends Throwable implements Cloneable, MyInterface {} class SubMyExceptionA extends MyExceptionA {} }