jdk-24/test/langtools/tools/javac/warnings/Finally.java

72 lines
1.3 KiB
Java
Raw Normal View History

2007-12-01 00:00:00 +00:00
/*
* @test /nodynamiccopyright/
2007-12-01 00:00:00 +00:00
* @bug 4986256
* @compile/ref=Finally.out -XDrawDiagnostics -Xlint:all Finally.java
2007-12-01 00:00:00 +00:00
*/
// control: this class should generate a warning
class Finally
{
int m1(int i) {
try {
return 0;
}
finally {
throw new IllegalArgumentException();
}
}
}
// tests: the warnings that would otherwise be generated should all be suppressed
@SuppressWarnings("finally")
class Finally1
{
int m1(int i) {
try {
return 0;
}
finally {
throw new IllegalArgumentException();
}
}
}
class Finally2
{
@SuppressWarnings("finally")
class Bar {
int m1(int i) {
try {
return 0;
}
finally {
throw new IllegalArgumentException();
}
}
}
@SuppressWarnings("finally")
int m2(int i) {
try {
return 0;
}
finally {
throw new IllegalArgumentException();
}
}
@SuppressWarnings("finally")
static int x = new Finally2() {
int m1(int i) {
try {
return 0;
}
finally {
throw new IllegalArgumentException();
}
}
}.m1(0);
}