Mon, 21 Jan 2013 11:16:28 -0800
Merge
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * @test /nodynamiccopyright/ |
aoqi@0 | 3 | * @bug 6911256 6964740 6965277 6967065 |
aoqi@0 | 4 | * @author Joseph D. Darcy |
aoqi@0 | 5 | * @summary Check that -Xlint:twr warnings are generated as expected |
aoqi@0 | 6 | * @compile/ref=TwrLint.out -Xlint:try,deprecation -XDrawDiagnostics TwrLint.java |
aoqi@0 | 7 | */ |
aoqi@0 | 8 | |
aoqi@0 | 9 | class TwrLint implements AutoCloseable { |
aoqi@0 | 10 | private static void test1() { |
aoqi@0 | 11 | try(TwrLint r1 = new TwrLint(); |
aoqi@0 | 12 | TwrLint r2 = new TwrLint(); |
aoqi@0 | 13 | TwrLint r3 = new TwrLint()) { |
aoqi@0 | 14 | r1.close(); // The resource's close |
aoqi@0 | 15 | r2.close(42); // *Not* the resource's close |
aoqi@0 | 16 | // r3 not referenced |
aoqi@0 | 17 | } |
aoqi@0 | 18 | |
aoqi@0 | 19 | } |
aoqi@0 | 20 | |
aoqi@0 | 21 | @SuppressWarnings("try") |
aoqi@0 | 22 | private static void test2() { |
aoqi@0 | 23 | try(@SuppressWarnings("deprecation") AutoCloseable r4 = |
aoqi@0 | 24 | new DeprecatedAutoCloseable()) { |
aoqi@0 | 25 | // r4 not referenced - but no warning is generated because of @SuppressWarnings |
aoqi@0 | 26 | } catch(Exception e) { |
aoqi@0 | 27 | ; |
aoqi@0 | 28 | } |
aoqi@0 | 29 | } |
aoqi@0 | 30 | |
aoqi@0 | 31 | /** |
aoqi@0 | 32 | * The AutoCloseable method of a resource. |
aoqi@0 | 33 | */ |
aoqi@0 | 34 | @Override |
aoqi@0 | 35 | public void close () { |
aoqi@0 | 36 | return; |
aoqi@0 | 37 | } |
aoqi@0 | 38 | |
aoqi@0 | 39 | /** |
aoqi@0 | 40 | * <em>Not</em> the AutoCloseable method of a resource. |
aoqi@0 | 41 | */ |
aoqi@0 | 42 | public void close (int arg) { |
aoqi@0 | 43 | return; |
aoqi@0 | 44 | } |
aoqi@0 | 45 | } |
aoqi@0 | 46 | |
aoqi@0 | 47 | @Deprecated |
aoqi@0 | 48 | class DeprecatedAutoCloseable implements AutoCloseable { |
aoqi@0 | 49 | public DeprecatedAutoCloseable(){super();} |
aoqi@0 | 50 | |
aoqi@0 | 51 | @Override |
aoqi@0 | 52 | public void close () { |
aoqi@0 | 53 | return; |
aoqi@0 | 54 | } |
aoqi@0 | 55 | } |