Wed, 08 Oct 2014 12:38:55 -0700
Added tag jdk8u40-b09 for changeset 8bb38a350722
mcimadamore@895 | 1 | /* |
mcimadamore@895 | 2 | * @test /nodynamiccopyright/ |
mcimadamore@895 | 3 | * @bug 7015430 |
mcimadamore@895 | 4 | * |
mcimadamore@895 | 5 | * @summary Incorrect thrown type determined for unchecked invocations |
mcimadamore@895 | 6 | * @author Daniel Smith |
mcimadamore@1896 | 7 | * @compile/fail/ref=T7015430_1.out -source 7 -Xlint:-options,unchecked -XDrawDiagnostics T7015430.java |
mcimadamore@1896 | 8 | * @compile/fail/ref=T7015430_2.out -Xlint:unchecked -XDrawDiagnostics T7015430.java |
mcimadamore@895 | 9 | * |
mcimadamore@895 | 10 | */ |
mcimadamore@895 | 11 | |
mcimadamore@895 | 12 | class T7015430 { |
mcimadamore@895 | 13 | static <E extends Exception> Iterable<E> empty(Iterable<E> arg) throws E { |
mcimadamore@895 | 14 | return null; |
mcimadamore@895 | 15 | } |
mcimadamore@895 | 16 | |
mcimadamore@895 | 17 | <E extends Exception> T7015430(Iterable<E> arg) throws E { } |
mcimadamore@895 | 18 | |
mcimadamore@895 | 19 | static <E extends Exception> Iterable<E> empty2(Iterable x) throws E { |
mcimadamore@895 | 20 | return null; |
mcimadamore@895 | 21 | } |
mcimadamore@895 | 22 | |
mcimadamore@895 | 23 | static class Foo<X extends Exception> { |
mcimadamore@895 | 24 | Foo() throws X {} |
mcimadamore@895 | 25 | } |
mcimadamore@895 | 26 | |
mcimadamore@895 | 27 | /** |
mcimadamore@895 | 28 | * Method invocation, no unchecked |
mcimadamore@895 | 29 | * inferred: RuntimeException - should pass |
mcimadamore@895 | 30 | */ |
mcimadamore@895 | 31 | void m1() { |
mcimadamore@895 | 32 | Iterable<RuntimeException> i = java.util.Collections.emptyList(); |
mcimadamore@895 | 33 | empty(i); |
mcimadamore@895 | 34 | } |
mcimadamore@895 | 35 | |
mcimadamore@895 | 36 | /** |
mcimadamore@895 | 37 | * Method invocation, unchecked, inferred arguments |
mcimadamore@895 | 38 | * inferred: Exception - should fail |
mcimadamore@895 | 39 | */ |
mcimadamore@895 | 40 | void m2() { |
mcimadamore@895 | 41 | Iterable i = java.util.Collections.EMPTY_LIST; |
mcimadamore@895 | 42 | empty(i); |
mcimadamore@895 | 43 | } |
mcimadamore@895 | 44 | |
mcimadamore@895 | 45 | /** |
mcimadamore@895 | 46 | * Method invocation, unchecked, explicit arguments |
mcimadamore@895 | 47 | * inferred: RuntimeException - should pass |
mcimadamore@895 | 48 | */ |
mcimadamore@895 | 49 | void m3() { |
mcimadamore@895 | 50 | Iterable i = java.util.Collections.EMPTY_LIST; |
mcimadamore@895 | 51 | T7015430.<RuntimeException>empty(i); |
mcimadamore@895 | 52 | } |
mcimadamore@895 | 53 | |
mcimadamore@895 | 54 | /** |
mcimadamore@895 | 55 | * Constructor invocation, no unchecked |
mcimadamore@895 | 56 | * inferred: RuntimeException - should pass |
mcimadamore@895 | 57 | */ |
mcimadamore@895 | 58 | void m4() { |
mcimadamore@895 | 59 | Iterable<RuntimeException> i = java.util.Collections.emptyList(); |
mcimadamore@895 | 60 | new T7015430(i); |
mcimadamore@895 | 61 | } |
mcimadamore@895 | 62 | |
mcimadamore@895 | 63 | /** |
mcimadamore@895 | 64 | * Constructor invocation, unchecked, inferred arguments |
mcimadamore@895 | 65 | * inferred: Exception - should fail |
mcimadamore@895 | 66 | */ |
mcimadamore@895 | 67 | void m5() { |
mcimadamore@895 | 68 | Iterable i = java.util.Collections.EMPTY_LIST; |
mcimadamore@895 | 69 | new T7015430(i); |
mcimadamore@895 | 70 | } |
mcimadamore@895 | 71 | |
mcimadamore@895 | 72 | /** |
mcimadamore@895 | 73 | * Constructor invocation, unchecked, explicit arguments |
mcimadamore@895 | 74 | * inferred: RuntimeException - should pass |
mcimadamore@895 | 75 | */ |
mcimadamore@895 | 76 | void m6() { |
mcimadamore@895 | 77 | Iterable i = java.util.Collections.EMPTY_LIST; |
mcimadamore@895 | 78 | new <RuntimeException>T7015430(i); |
mcimadamore@895 | 79 | } |
mcimadamore@895 | 80 | |
mcimadamore@895 | 81 | /** |
mcimadamore@895 | 82 | * Method invocation, no unchecked, inferred arguments |
mcimadamore@895 | 83 | * inferred: RuntimeException - should pass |
mcimadamore@895 | 84 | */ |
mcimadamore@895 | 85 | void m7() { |
mcimadamore@895 | 86 | Iterable i = java.util.Collections.EMPTY_LIST; |
mcimadamore@895 | 87 | Iterable<RuntimeException> e = empty2(i); |
mcimadamore@895 | 88 | } |
mcimadamore@895 | 89 | |
mcimadamore@895 | 90 | /** |
mcimadamore@895 | 91 | * Method invocation, no unchecked, inferred arguments |
mcimadamore@895 | 92 | * inferred: Exception - should fail |
mcimadamore@895 | 93 | */ |
mcimadamore@895 | 94 | void m8() { |
mcimadamore@895 | 95 | Iterable i = java.util.Collections.EMPTY_LIST; |
mcimadamore@895 | 96 | empty2(i); |
mcimadamore@895 | 97 | } |
mcimadamore@895 | 98 | |
mcimadamore@895 | 99 | /** |
mcimadamore@895 | 100 | * Constructor invocation, unchecked, explicit arguments |
mcimadamore@895 | 101 | * inferred: RuntimeException - should pass |
mcimadamore@895 | 102 | */ |
mcimadamore@895 | 103 | void m9() { |
mcimadamore@895 | 104 | Iterable i = java.util.Collections.EMPTY_LIST; |
mcimadamore@895 | 105 | new <RuntimeException> T7015430(i); |
mcimadamore@895 | 106 | } |
mcimadamore@895 | 107 | |
mcimadamore@895 | 108 | /** |
mcimadamore@895 | 109 | * Constructor invocation, unchecked, inferred arguments |
mcimadamore@895 | 110 | * inferred: Exception - should fail |
mcimadamore@895 | 111 | */ |
mcimadamore@895 | 112 | void m10() { |
mcimadamore@895 | 113 | Iterable i = java.util.Collections.EMPTY_LIST; |
mcimadamore@895 | 114 | new T7015430(i); |
mcimadamore@895 | 115 | } |
mcimadamore@895 | 116 | |
mcimadamore@895 | 117 | /** |
mcimadamore@895 | 118 | * Constructor invocation, no unchecked, inferred arguments (diamond) |
mcimadamore@895 | 119 | * inferred: RuntimeException - should pass |
mcimadamore@895 | 120 | */ |
mcimadamore@895 | 121 | void m11() { |
mcimadamore@895 | 122 | Foo<RuntimeException> o = new Foo<>(); |
mcimadamore@895 | 123 | } |
mcimadamore@895 | 124 | |
mcimadamore@895 | 125 | /** |
mcimadamore@895 | 126 | * Constructor invocation, no unchecked, inferred arguments (diamond) |
mcimadamore@895 | 127 | * inferred: Exception - should fail |
mcimadamore@895 | 128 | */ |
mcimadamore@895 | 129 | void m12() { |
mcimadamore@895 | 130 | new Foo<>(); |
mcimadamore@895 | 131 | } |
mcimadamore@895 | 132 | } |