mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fix dfa offset management when handling possible exceptions in finally
This commit is contained in:
+3
-1
@@ -720,11 +720,12 @@ class ControlFlowAnalyzer extends JavaElementVisitor {
|
||||
if (exceptionClass == null) return;
|
||||
for (int i = myCatchStack.size() - 1; i >= 0; i--) {
|
||||
CatchDescriptor cd = myCatchStack.get(i);
|
||||
flushVariablesInsideTry(cd);
|
||||
if (cd.isFinally()) {
|
||||
flushVariablesInsideTry(cd);
|
||||
addInstruction(new GosubInstruction(cd.getJumpOffset(this)));
|
||||
}
|
||||
else if (cd.getType().isAssignableFrom(exceptionClass)) { // Definite catch.
|
||||
flushVariablesInsideTry(cd);
|
||||
addGotoCatch(cd);
|
||||
return;
|
||||
}
|
||||
@@ -733,6 +734,7 @@ class ControlFlowAnalyzer extends JavaElementVisitor {
|
||||
pushUnknown();
|
||||
final ConditionalGotoInstruction branch = new ConditionalGotoInstruction(null, false, null);
|
||||
addInstruction(branch);
|
||||
flushVariablesInsideTry(cd);
|
||||
addGotoCatch(cd);
|
||||
branch.setOffset(myCurrentFlow.getInstructionCount());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import java.io.*;
|
||||
|
||||
class Foo {
|
||||
|
||||
public void read() {
|
||||
try {
|
||||
final FileInputStream input = new FileInputStream(new File("foo"));
|
||||
try {
|
||||
}
|
||||
finally {
|
||||
input.close();
|
||||
}
|
||||
}
|
||||
catch (FileNotFoundException ignored) {
|
||||
}
|
||||
catch (IOException e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -68,6 +68,7 @@ public class DataFlowInspectionTest extends LightCodeInsightFixtureTestCase {
|
||||
public void testTernaryInWhileNotComplex() throws Throwable { doTest(); }
|
||||
public void testTryCatchInForNotComplex() throws Throwable { doTest(); }
|
||||
public void testNestedTryInWhileNotComplex() throws Throwable { doTest(); }
|
||||
public void testExceptionFromFinally() throws Throwable { doTest(); }
|
||||
public void testFieldChangedBetweenSynchronizedBlocks() throws Throwable { doTest(); }
|
||||
|
||||
public void testGeneratedEquals() throws Throwable { doTest(); }
|
||||
|
||||
Reference in New Issue
Block a user