IDEA-351461 Avoid dependency to kotlin in intellij.java.rt

GitOrigin-RevId: 47de00f563e617874f173f22e4d7a6ba11fd1254
This commit is contained in:
Egor Ushakov
2024-04-11 10:44:05 +02:00
committed by intellij-monorepo-bot
parent fc02ceff22
commit 5cdcf70555
2 changed files with 9 additions and 6 deletions

View File

@@ -34,6 +34,5 @@
</library>
</orderEntry>
<orderEntry type="library" name="JUnit4" level="project" />
<orderEntry type="library" name="kotlinx-coroutines-core" level="project" />
</component>
</module>

View File

@@ -4,14 +4,14 @@ package com.intellij.rt.debugger;
import java.util.ArrayList;
import java.util.List;
@SuppressWarnings({"KotlinInternalInJava", "UnnecessaryFullyQualifiedName"})
public final class CoroutinesDebugHelper {
public static long[] getCoroutinesRunningOnCurrentThread(kotlinx.coroutines.debug.internal.DebugProbesImpl instance) {
public static long[] getCoroutinesRunningOnCurrentThread(Object debugProbes) throws ReflectiveOperationException {
Thread currentThread = Thread.currentThread();
List<Long> coroutinesIds = new ArrayList<>();
for (kotlinx.coroutines.debug.internal.DebugCoroutineInfo info : instance.dumpCoroutinesInfo()) {
if (info.getLastObservedThread() == currentThread) {
coroutinesIds.add(info.getSequenceNumber());
List infos = (List)invoke(debugProbes, "dumpCoroutinesInfo");
for (Object info : infos) {
if (invoke(info, "getLastObservedThread") == currentThread) {
coroutinesIds.add((Long)invoke(info, "getSequenceNumber"));
}
}
long[] res = new long[coroutinesIds.size()];
@@ -20,4 +20,8 @@ public final class CoroutinesDebugHelper {
}
return res;
}
private static Object invoke(Object object, String methodName) throws ReflectiveOperationException {
return object.getClass().getMethod(methodName).invoke(object);
}
}