Thu, 10 Oct 2013 14:58:04 +0200
8001931: The new build system whitespace cleanup
Reviewed-by: tbell, simonis, erikj
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * @test /nodynamiccopyright/ |
aoqi@0 | 3 | * @bug 7039822 |
aoqi@0 | 4 | * @summary Verify typing of lub of exception parameter w.r.t getClass |
aoqi@0 | 5 | * @author Joseph D. Darcy |
aoqi@0 | 6 | * @compile/fail/ref=Neg07.out -XDrawDiagnostics Neg07.java |
aoqi@0 | 7 | */ |
aoqi@0 | 8 | |
aoqi@0 | 9 | public class Neg07 { |
aoqi@0 | 10 | private static void test(int i) { |
aoqi@0 | 11 | try { |
aoqi@0 | 12 | thrower(i); |
aoqi@0 | 13 | } catch (SonException | DaughterException e) { |
aoqi@0 | 14 | Class<? extends HasFoo> clazz2 = e.getClass(); // Rejected! |
aoqi@0 | 15 | HasFoo m = e; |
aoqi@0 | 16 | e.foo(); |
aoqi@0 | 17 | } |
aoqi@0 | 18 | } |
aoqi@0 | 19 | |
aoqi@0 | 20 | private static interface HasFoo { |
aoqi@0 | 21 | void foo(); |
aoqi@0 | 22 | } |
aoqi@0 | 23 | |
aoqi@0 | 24 | static void thrower(int i) throws SonException, DaughterException { |
aoqi@0 | 25 | if (i == 0) |
aoqi@0 | 26 | throw new SonException(); |
aoqi@0 | 27 | else |
aoqi@0 | 28 | throw new DaughterException(); |
aoqi@0 | 29 | } |
aoqi@0 | 30 | |
aoqi@0 | 31 | private static class ParentException extends RuntimeException {} |
aoqi@0 | 32 | |
aoqi@0 | 33 | private static class SonException |
aoqi@0 | 34 | extends ParentException |
aoqi@0 | 35 | implements HasFoo { |
aoqi@0 | 36 | |
aoqi@0 | 37 | public void foo() { |
aoqi@0 | 38 | System.out.println("SonException.foo"); |
aoqi@0 | 39 | } |
aoqi@0 | 40 | } |
aoqi@0 | 41 | |
aoqi@0 | 42 | private static class DaughterException |
aoqi@0 | 43 | extends ParentException |
aoqi@0 | 44 | implements HasFoo { |
aoqi@0 | 45 | |
aoqi@0 | 46 | public void foo() { |
aoqi@0 | 47 | System.out.println("DaughterException.foo"); |
aoqi@0 | 48 | } |
aoqi@0 | 49 | } |
aoqi@0 | 50 | } |