From bdc60441c0663a268f36eff1715ba33345a35bdd Mon Sep 17 00:00:00 2001 From: Natalia Ukhorskaya Date: Fri, 20 Jun 2014 15:54:37 +0400 Subject: [PATCH] Try-catch exception value is not visible in debugger's local variables #KT-3070 Fixed --- .../jetbrains/jet/codegen/ExpressionCodegen.java | 5 +++++ .../checkLocalVariablesTable/catchClause.kt | 15 +++++++++++++++ .../CheckLocalVariablesTableTestGenerated.java | 5 +++++ 3 files changed, 25 insertions(+) create mode 100644 compiler/testData/checkLocalVariablesTable/catchClause.kt diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java index b92daaf9f44..3624ea3bb2a 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java @@ -3413,6 +3413,11 @@ The "returned" value of try expression with no finally is either the last expres myFrameMap.leave(descriptor); + Label clauseEnd = new Label(); + v.mark(clauseEnd); + + v.visitLocalVariable(descriptor.getName().asString(), descriptorType.getDescriptor(), null, clauseStart, clauseEnd, index); + genFinallyBlockOrGoto(finallyBlockStackElement, i != size - 1 || finallyBlock != null ? end : null); generateExceptionTable(clauseStart, tryBlockRegions, descriptorType.getInternalName()); diff --git a/compiler/testData/checkLocalVariablesTable/catchClause.kt b/compiler/testData/checkLocalVariablesTable/catchClause.kt new file mode 100644 index 00000000000..0c76d23638a --- /dev/null +++ b/compiler/testData/checkLocalVariablesTable/catchClause.kt @@ -0,0 +1,15 @@ +class A { + fun foo() { + try { + val a = 1 + } + catch(e : Throwable) { + + } + } +} + +// METHOD : A.foo()V +// VARIABLE : NAME=a TYPE=I INDEX=1 +// VARIABLE : NAME=e TYPE=Ljava/lang/Throwable; INDEX=1 +// VARIABLE : NAME=this TYPE=LA; INDEX=0 diff --git a/compiler/tests/org/jetbrains/jet/codegen/CheckLocalVariablesTableTestGenerated.java b/compiler/tests/org/jetbrains/jet/codegen/CheckLocalVariablesTableTestGenerated.java index dbbbb0b758f..79c77dbeeec 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/CheckLocalVariablesTableTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/codegen/CheckLocalVariablesTableTestGenerated.java @@ -36,6 +36,11 @@ public class CheckLocalVariablesTableTestGenerated extends AbstractCheckLocalVar JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/checkLocalVariablesTable"), Pattern.compile("^(.+)\\.kt$"), true); } + @TestMetadata("catchClause.kt") + public void testCatchClause() throws Exception { + doTest("compiler/testData/checkLocalVariablesTable/catchClause.kt"); + } + @TestMetadata("copyFunction.kt") public void testCopyFunction() throws Exception { doTest("compiler/testData/checkLocalVariablesTable/copyFunction.kt");