aoqi@0: /* aoqi@0: * @test /nodynamiccopyright/ aoqi@0: * @bug 7039822 aoqi@0: * @summary Verify typing of lub of exception parameter w.r.t getClass aoqi@0: * @author Joseph D. Darcy aoqi@0: * @compile/fail/ref=Neg07.out -XDrawDiagnostics Neg07.java aoqi@0: */ aoqi@0: aoqi@0: public class Neg07 { aoqi@0: private static void test(int i) { aoqi@0: try { aoqi@0: thrower(i); aoqi@0: } catch (SonException | DaughterException e) { aoqi@0: Class clazz2 = e.getClass(); // Rejected! aoqi@0: HasFoo m = e; aoqi@0: e.foo(); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: private static interface HasFoo { aoqi@0: void foo(); aoqi@0: } aoqi@0: aoqi@0: static void thrower(int i) throws SonException, DaughterException { aoqi@0: if (i == 0) aoqi@0: throw new SonException(); aoqi@0: else aoqi@0: throw new DaughterException(); aoqi@0: } aoqi@0: aoqi@0: private static class ParentException extends RuntimeException {} aoqi@0: aoqi@0: private static class SonException aoqi@0: extends ParentException aoqi@0: implements HasFoo { aoqi@0: aoqi@0: public void foo() { aoqi@0: System.out.println("SonException.foo"); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: private static class DaughterException aoqi@0: extends ParentException aoqi@0: implements HasFoo { aoqi@0: aoqi@0: public void foo() { aoqi@0: System.out.println("DaughterException.foo"); aoqi@0: } aoqi@0: } aoqi@0: }