diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/MethodEvaluator.java b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/MethodEvaluator.java index 28a3560a7774..57b455b445b2 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/MethodEvaluator.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/MethodEvaluator.java @@ -32,7 +32,6 @@ import com.intellij.debugger.impl.DebuggerUtilsEx; import com.intellij.debugger.jdi.VirtualMachineProxyImpl; import com.intellij.openapi.diagnostic.Logger; import com.intellij.rt.debugger.DefaultMethodInvoker; -import com.intellij.util.containers.ContainerUtil; import com.sun.jdi.*; import java.util.ArrayList; @@ -127,18 +126,7 @@ public class MethodEvaluator implements Evaluator { final String methodName = DebuggerUtilsEx.methodName(referenceType.name(), myMethodName, signature); if (isInvokableType(object)) { if (isInvokableType(referenceType)) { - Method jdiMethod; - if (signature != null) { - if (referenceType instanceof ClassType) { - jdiMethod = ((ClassType)referenceType).concreteMethodByName(myMethodName, signature); - } - else { - jdiMethod = ContainerUtil.getFirstItem(referenceType.methodsByName(myMethodName, signature)); - } - } - else { - jdiMethod = ContainerUtil.getFirstItem(referenceType.methodsByName(myMethodName)); - } + Method jdiMethod = DebuggerUtils.findMethod(referenceType, myMethodName, signature); if (jdiMethod != null && jdiMethod.isStatic()) { if (referenceType instanceof ClassType) { return debugProcess.invokeMethod(context, (ClassType)referenceType, jdiMethod, args); diff --git a/java/debugger/openapi/src/com/intellij/debugger/engine/DebuggerUtils.java b/java/debugger/openapi/src/com/intellij/debugger/engine/DebuggerUtils.java index 92e2e0498a59..7819a3dd076d 100644 --- a/java/debugger/openapi/src/com/intellij/debugger/engine/DebuggerUtils.java +++ b/java/debugger/openapi/src/com/intellij/debugger/engine/DebuggerUtils.java @@ -42,6 +42,7 @@ import com.intellij.psi.util.InheritanceUtil; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.util.IncorrectOperationException; import com.intellij.util.StringBuilderSpinAllocator; +import com.intellij.util.containers.ContainerUtil; import com.sun.jdi.*; import org.jdom.Element; import org.jetbrains.annotations.NonNls; @@ -149,7 +150,7 @@ public abstract class DebuggerUtils { } @Nullable - public static Method findMethod(@NotNull ReferenceType refType, @NonNls String methodName, @NonNls String methodSignature) { + public static Method findMethod(@NotNull ReferenceType refType, @NonNls String methodName, @Nullable @NonNls String methodSignature) { if (refType instanceof ArrayType) { // for array types methodByName() in JDI always returns empty list final Method method = findMethod(refType.virtualMachine().classesByName(CommonClassNames.JAVA_LANG_OBJECT).get(0), methodName, methodSignature); @@ -164,20 +165,11 @@ public abstract class DebuggerUtils { method = ((ClassType)refType).concreteMethodByName(methodName, methodSignature); } if (method == null) { - final List methods = refType.methodsByName(methodName, methodSignature); - if (methods.size() > 0) { - method = methods.get(0); - } + method = ContainerUtil.getFirstItem(refType.methodsByName(methodName, methodSignature)); } } else { - List methods = null; - if (refType instanceof ClassType) { - methods = refType.methodsByName(methodName); - } - if (methods != null && methods.size() > 0) { - method = methods.get(0); - } + method = ContainerUtil.getFirstItem(refType.methodsByName(methodName)); } return method; }