kotlin.coroutines.* classes must be loaded from platform provided library otherwise plugin cannot use platform API that uses coroutines

GitOrigin-RevId: 6f951c368ad37ff07a3756608a104d5eda17bd8e
This commit is contained in:
Vladimir Krivosheev
2020-10-21 08:29:26 +00:00
committed by intellij-monorepo-bot
parent bf362bcf0e
commit f600f9cdfb
@@ -239,13 +239,15 @@ public final class PluginClassLoader extends UrlClassLoader implements PluginAwa
}
@SuppressWarnings("SSBasedInspection")
private static final Set<String> KOTLIN_STDLIB_CLASSES_USED_IN_SIGNATURES = new HashSet<>(Arrays.asList("kotlin.sequences.Sequence",
"kotlin.Lazy", "kotlin.Unit",
"kotlin.Pair", "kotlin.Triple",
"kotlin.jvm.internal.DefaultConstructorMarker",
"kotlin.jvm.internal.ClassBasedDeclarationContainer",
"kotlin.properties.ReadWriteProperty",
"kotlin.properties.ReadOnlyProperty"));
private static final Set<String> KOTLIN_STDLIB_CLASSES_USED_IN_SIGNATURES = new HashSet<>(Arrays.asList(
"kotlin.sequences.Sequence",
"kotlin.Lazy", "kotlin.Unit",
"kotlin.Pair", "kotlin.Triple",
"kotlin.jvm.internal.DefaultConstructorMarker",
"kotlin.jvm.internal.ClassBasedDeclarationContainer",
"kotlin.properties.ReadWriteProperty",
"kotlin.properties.ReadOnlyProperty"
));
private static boolean mustBeLoadedByPlatform(@NonNls String className) {
if (className.startsWith("java.")) {
@@ -256,6 +258,7 @@ public final class PluginClassLoader extends UrlClassLoader implements PluginAwa
// of kotlin-runtime.jar it won't be possible to call platform's methods with these types in signatures from such a plugin.
// We assume that these classes don't change between Kotlin versions so it's safe to always load them from platform's kotlin-runtime.
return className.startsWith("kotlin.") && (className.startsWith("kotlin.jvm.functions.") ||
className.startsWith("kotlin.coroutines.") ||
(className.startsWith("kotlin.reflect.") &&
className.indexOf('.', 15 /* "kotlin.reflect".length */) < 0) ||
KOTLIN_STDLIB_CLASSES_USED_IN_SIGNATURES.contains(className));