From 9300c07dafd68ea3e8216b3ffe151820a422ccae Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Mon, 16 Feb 2015 17:54:47 +0400 Subject: [PATCH] Fix dependency bug with monitorenter/monitorexit --- .../teavm/dependency/DependencyGraphBuilder.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/teavm-core/src/main/java/org/teavm/dependency/DependencyGraphBuilder.java b/teavm-core/src/main/java/org/teavm/dependency/DependencyGraphBuilder.java index 7a817708a..39aa16b9d 100644 --- a/teavm-core/src/main/java/org/teavm/dependency/DependencyGraphBuilder.java +++ b/teavm-core/src/main/java/org/teavm/dependency/DependencyGraphBuilder.java @@ -495,16 +495,20 @@ class DependencyGraphBuilder { @Override public void monitorEnter(VariableReader objectRef) { - dependencyChecker.linkMethod( - new MethodReference(Object.class, "monitorEnter", Object.class, void.class), - new CallLocation(caller.getMethod(), currentLocation)).use(); + MethodDependency methodDep = dependencyChecker.linkMethod( + new MethodReference(Object.class, "monitorEnter", Object.class, void.class), + new CallLocation(caller.getMethod(), currentLocation)); + nodes[objectRef.getIndex()].connect(methodDep.getVariable(1)); + methodDep.use(); } @Override public void monitorExit(VariableReader objectRef) { - dependencyChecker.linkMethod( + MethodDependency methodDep = dependencyChecker.linkMethod( new MethodReference(Object.class, "monitorExit", Object.class, void.class), - new CallLocation(caller.getMethod(), currentLocation)).use(); + new CallLocation(caller.getMethod(), currentLocation)); + nodes[objectRef.getIndex()].connect(methodDep.getVariable(1)); + methodDep.use(); } }; }