From 4d5bf19bfa40c02beda8f3cb6eada15883c2c486 Mon Sep 17 00:00:00 2001 From: Egor Ushakov Date: Wed, 5 Dec 2018 20:40:46 +0300 Subject: [PATCH] cleanup --- .../debugger/engine/DebugProcessImpl.java | 41 +++++++++---------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java b/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java index 3d5a8f3cf720..e122e4ee0f71 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java @@ -50,10 +50,7 @@ import com.intellij.openapi.roots.ModuleRootEvent; import com.intellij.openapi.roots.ModuleRootListener; import com.intellij.openapi.ui.MessageType; import com.intellij.openapi.ui.Messages; -import com.intellij.openapi.util.Disposer; -import com.intellij.openapi.util.Pair; -import com.intellij.openapi.util.SystemInfo; -import com.intellij.openapi.util.UserDataHolderBase; +import com.intellij.openapi.util.*; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.wm.ToolWindowId; import com.intellij.openapi.wm.impl.status.StatusBarUtil; @@ -1047,9 +1044,8 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb ClassNotLoadedException, IncompatibleThreadStateException, InvalidTypeException { - final int invokePolicy = getInvokePolicy(context); - final Exception[] exception = new Exception[1]; - final Value[] result = new Value[1]; + Ref exception = Ref.create(); + Ref result = Ref.create(); getManagerThread().startLongProcessAndFork(() -> { ThreadReferenceProxyImpl thread = context.getThread(); try { @@ -1113,7 +1109,7 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb }); } - result[0] = invokeMethod(invokePolicy, myMethod, myArgs); + result.set(invokeMethod(getInvokePolicy(context), myMethod, myArgs)); } finally { if (Patches.JDK_BUG_WITH_TRACE_SEND && (ourTraceMask & VirtualMachine.TRACE_SENDS) != 0) { @@ -1127,32 +1123,33 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb } } catch (Exception e) { - exception[0] = e; + exception.set(e); } }); - if (exception[0] != null) { - if (exception[0] instanceof InvocationException) { - throw (InvocationException)exception[0]; + Exception ex = exception.get(); + if (ex != null) { + if (ex instanceof InvocationException) { + throw (InvocationException)ex; } - else if (exception[0] instanceof ClassNotLoadedException) { - throw (ClassNotLoadedException)exception[0]; + else if (ex instanceof ClassNotLoadedException) { + throw (ClassNotLoadedException)ex; } - else if (exception[0] instanceof IncompatibleThreadStateException) { - throw (IncompatibleThreadStateException)exception[0]; + else if (ex instanceof IncompatibleThreadStateException) { + throw (IncompatibleThreadStateException)ex; } - else if (exception[0] instanceof InvalidTypeException) { - throw (InvalidTypeException)exception[0]; + else if (ex instanceof InvalidTypeException) { + throw (InvalidTypeException)ex; } - else if (exception[0] instanceof RuntimeException) { - throw (RuntimeException)exception[0]; + else if (ex instanceof RuntimeException) { + throw (RuntimeException)ex; } else { - LOG.error("Unexpected exception", new Throwable().initCause(exception[0])); + LOG.error("Unexpected exception", new Throwable(ex)); } } - return (E)result[0]; + return result.get(); } private void assertThreadSuspended(final ThreadReferenceProxyImpl thread, final SuspendContextImpl context) {