/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 7023233
* @summary False positive for -Xlint:try with nested try with resources blocks
*/
public class UnusedResourcesTest {
enum XlintOption {
}
return "-Xlint:" + opt;
}
}
enum TwrStmt {
this.resourceName = resourceName;
}
}
enum SuppressLevel {
NONE,
return this == SUPPRESS ?
"@SuppressWarnings(\"try\")" :
"";
}
}
enum ResourceUsage {
}
}
}
"";
}
}
"public void close() {}\n" +
"}\n" +
"class Test {\n" +
"void use(Resource r) {}\n" +
"#S void test() {\n" +
"try (Resource #R1 = new Resource()) {\n" +
"#U1_R1\n" +
"#U1_R2\n" +
"#U1_R3\n" +
"try (Resource #R2 = new Resource()) {\n" +
"#U2_R1\n" +
"#U2_R2\n" +
"#U2_R3\n" +
"try (Resource #R3 = new Resource()) {\n" +
"#U3_R1\n" +
"#U3_R2\n" +
"#U3_R3\n" +
"}\n" +
"}\n" +
"}\n" +
"}\n" +
"}\n";
}
return source;
}
}
usage3);
}
}
}
}
}
}
// Create a single file manager and reuse it for each compile to save time.
}
boolean[] usedResources = { false, false, false };
break outer;
}
}
}
}
throw new Error("invalid diagnostics for source:\n" +
source.getCharContent(true) +
}
}
}
boolean unused_r1 = false;
boolean unused_r2 = false;
boolean unused_r3 = false;
unused_r1 = true;
unused_r2 = true;
unused_r3 = true;
}
}
}
if (diagnostic instanceof JCDiagnostic)
return (JCDiagnostic) diagnostic;
throw new IllegalArgumentException();
}
}
}