mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +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:
+14
@@ -452,4 +452,18 @@ class CompoundAssign {
|
||||
<error descr="Variable 'i' might not have been initialized">i</error> += i = 2;
|
||||
System.out.println(i);
|
||||
}
|
||||
}
|
||||
|
||||
class BreakAndFinally {
|
||||
void f() {
|
||||
final int i;
|
||||
t:
|
||||
try {
|
||||
break t;
|
||||
}
|
||||
finally {
|
||||
i = 1;
|
||||
}
|
||||
System.out.println(i);
|
||||
}
|
||||
}
|
||||
+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