mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 09:19:13 +07:00
Java control flow: Detect unreachable code when a break or continue in the try block is overridden in the finally block of the same try statement (IDEA-35597)
This commit is contained in:
+66
@@ -402,3 +402,69 @@ class Good3 {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class ContinueFromFinally {
|
||||
void foo() {
|
||||
while (true) {
|
||||
try {
|
||||
break;
|
||||
} finally {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
<error descr="Unreachable statement">System.out.println();</error>
|
||||
}
|
||||
}
|
||||
|
||||
class BreakFromNestedTry {
|
||||
void foo() {
|
||||
outer:
|
||||
{
|
||||
inner:
|
||||
try {
|
||||
try {
|
||||
break inner;
|
||||
} finally {
|
||||
System.out.println();
|
||||
}
|
||||
} finally {
|
||||
break outer;
|
||||
}
|
||||
<error descr="Unreachable statement">System.out.println();</error>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class BreakFromNestedFinally {
|
||||
void foo() {
|
||||
outer:
|
||||
{
|
||||
inner:
|
||||
try {
|
||||
try {
|
||||
} finally {
|
||||
break inner;
|
||||
}
|
||||
} finally {
|
||||
break outer;
|
||||
}
|
||||
<error descr="Unreachable statement">System.out.println();</error>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ContinueFromTry {
|
||||
void foo() {
|
||||
outer:
|
||||
{
|
||||
do {
|
||||
try {
|
||||
continue;
|
||||
} finally {
|
||||
break outer;
|
||||
}
|
||||
} while (false);
|
||||
<error descr="Unreachable statement">System.out.println();</error>
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user