|
Java example source code file (TwrLint.java)
The TwrLint.java Java example source code/* * @test /nodynamiccopyright/ * @bug 6911256 6964740 6965277 6967065 * @author Joseph D. Darcy * @summary Check that -Xlint:twr warnings are generated as expected * @compile/ref=TwrLint.out -Xlint:try,deprecation -XDrawDiagnostics TwrLint.java */ class TwrLint implements AutoCloseable { private static void test1() { try(TwrLint r1 = new TwrLint(); TwrLint r2 = new TwrLint(); TwrLint r3 = new TwrLint()) { r1.close(); // The resource's close r2.close(42); // *Not* the resource's close // r3 not referenced } } @SuppressWarnings("try") private static void test2() { try(@SuppressWarnings("deprecation") AutoCloseable r4 = new DeprecatedAutoCloseable()) { // r4 not referenced - but no warning is generated because of @SuppressWarnings } catch(Exception e) { ; } } /** * The AutoCloseable method of a resource. */ @Override public void close () { return; } /** * <em>Not the AutoCloseable method of a resource. */ public void close (int arg) { return; } } @Deprecated class DeprecatedAutoCloseable implements AutoCloseable { public DeprecatedAutoCloseable(){super();} @Override public void close () { return; } } Other Java examples (source code examples)Here is a short list of links related to this Java TwrLint.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.