diff --git a/java/debugger/impl/src/com/intellij/debugger/jdi/VirtualMachineProxyImpl.java b/java/debugger/impl/src/com/intellij/debugger/jdi/VirtualMachineProxyImpl.java index 4246648c016a..e8a5f81a0fec 100644 --- a/java/debugger/impl/src/com/intellij/debugger/jdi/VirtualMachineProxyImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/jdi/VirtualMachineProxyImpl.java @@ -15,6 +15,7 @@ import com.intellij.debugger.impl.attach.SAJDWPRemoteConnection; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.ThrowableComputable; import com.intellij.util.containers.ContainerUtil; +import com.jetbrains.jdi.ReferenceTypeImpl; import com.jetbrains.jdi.ThreadReferenceImpl; import com.sun.jdi.*; import com.sun.jdi.request.EventRequestManager; @@ -111,9 +112,10 @@ public class VirtualMachineProxyImpl implements JdiTimer, VirtualMachineProxy { if (!candidates.isEmpty()) { // keep only direct nested types + // do not traverse all classes in vm, only the candidates list final Set nested2 = new HashSet<>(); for (final ReferenceType candidate : candidates) { - nested2.addAll(nestedTypes(candidate)); + addNestedTypes(candidate, candidates, nested2); } candidates.removeAll(nested2); } @@ -128,6 +130,24 @@ public class VirtualMachineProxyImpl implements JdiTimer, VirtualMachineProxy { return nestedTypes; } + /** + * Check {@link ReferenceTypeImpl#nestedTypes()} + */ + private static void addNestedTypes(ReferenceType base, Collection classes, Set nested) { + String baseName = base.name(); + int baseLength = baseName.length(); + classes.forEach(type -> { + String name = type.name(); + int length = name.length(); + if (length > baseLength && name.startsWith(baseName)) { + char c = name.charAt(baseLength); + if (c == '$' || c == '#') { + nested.add(type); + } + } + }); + } + @Override public List allClasses() { List allClasses = myAllClasses;