From 3940565598fbeafb8ae8df37ab9d7691a89e5d44 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Mon, 10 Nov 2014 16:05:22 +0100 Subject: [PATCH] IDEA-132625 (decompiler time limit) --- .../java/decompiler/main/rels/ClassWrapper.java | 2 +- .../main/rels/MethodProcessorRunnable.java | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/org/jetbrains/java/decompiler/main/rels/ClassWrapper.java b/src/org/jetbrains/java/decompiler/main/rels/ClassWrapper.java index 9320355..8f2958f 100644 --- a/src/org/jetbrains/java/decompiler/main/rels/ClassWrapper.java +++ b/src/org/jetbrains/java/decompiler/main/rels/ClassWrapper.java @@ -94,7 +94,7 @@ public class ClassWrapper { mtThread.start(); - while (mtThread.isAlive()) { + while (!mtProc.isFinished()) { synchronized (mtProc.lock) { mtProc.lock.wait(100); } diff --git a/src/org/jetbrains/java/decompiler/main/rels/MethodProcessorRunnable.java b/src/org/jetbrains/java/decompiler/main/rels/MethodProcessorRunnable.java index 3b2d72a..786babf 100644 --- a/src/org/jetbrains/java/decompiler/main/rels/MethodProcessorRunnable.java +++ b/src/org/jetbrains/java/decompiler/main/rels/MethodProcessorRunnable.java @@ -41,6 +41,7 @@ public class MethodProcessorRunnable implements Runnable { private volatile RootStatement root; private volatile Throwable error; + private volatile boolean finished = false; public MethodProcessorRunnable(StructMethod method, VarProcessor varProc, DecompilerContext parentContext) { this.method = method; @@ -57,10 +58,6 @@ public class MethodProcessorRunnable implements Runnable { try { root = codeToJava(method, varProc); - - synchronized (lock) { - lock.notifyAll(); - } } catch (ThreadDeath ex) { throw ex; @@ -68,6 +65,14 @@ public class MethodProcessorRunnable implements Runnable { catch (Throwable ex) { error = ex; } + finally { + DecompilerContext.setCurrentContext(null); + } + + finished = true; + synchronized (lock) { + lock.notifyAll(); + } } public static RootStatement codeToJava(StructMethod mt, VarProcessor varProc) throws IOException { @@ -206,7 +211,7 @@ public class MethodProcessorRunnable implements Runnable { return root; } - public Throwable getError() { - return error; + public boolean isFinished() { + return finished; } }