Don't store class loader in CompilerEnvironment
Modules jps-plugin and ide-compiler-runner are loaded by the same class loader
This commit is contained in:
@@ -17,7 +17,6 @@
|
||||
package org.jetbrains.jet.compiler.runner;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.cli.common.messages.MessageCollector;
|
||||
import org.jetbrains.jet.config.Services;
|
||||
import org.jetbrains.jet.preloading.ClassCondition;
|
||||
@@ -28,34 +27,25 @@ import static org.jetbrains.jet.cli.common.messages.CompilerMessageLocation.NO_L
|
||||
import static org.jetbrains.jet.cli.common.messages.CompilerMessageSeverity.ERROR;
|
||||
|
||||
public final class CompilerEnvironment {
|
||||
|
||||
@NotNull
|
||||
public static CompilerEnvironment getEnvironmentFor(
|
||||
@NotNull KotlinPaths kotlinPaths,
|
||||
@Nullable ClassLoader parentClassLoader,
|
||||
@NotNull ClassCondition classesToLoadByParent,
|
||||
@NotNull Services compilerServices
|
||||
) {
|
||||
return new CompilerEnvironment(kotlinPaths, parentClassLoader, classesToLoadByParent, compilerServices);
|
||||
return new CompilerEnvironment(kotlinPaths, classesToLoadByParent, compilerServices);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private final KotlinPaths kotlinPaths;
|
||||
@Nullable
|
||||
private final ClassLoader parentClassLoader;
|
||||
@NotNull
|
||||
private final ClassCondition classesToLoadByParent;
|
||||
@NotNull
|
||||
private final Services services;
|
||||
|
||||
private CompilerEnvironment(
|
||||
@NotNull KotlinPaths kotlinPaths,
|
||||
@Nullable ClassLoader parentClassLoader,
|
||||
@NotNull ClassCondition classesToLoadByParent,
|
||||
@NotNull Services services
|
||||
) {
|
||||
this.kotlinPaths = kotlinPaths;
|
||||
this.parentClassLoader = parentClassLoader;
|
||||
this.classesToLoadByParent = classesToLoadByParent;
|
||||
this.services = services;
|
||||
}
|
||||
@@ -69,11 +59,6 @@ public final class CompilerEnvironment {
|
||||
return kotlinPaths;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ClassLoader getParentClassLoader() {
|
||||
return parentClassLoader;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ClassCondition getClassesToLoadByParent() {
|
||||
return classesToLoadByParent;
|
||||
|
||||
@@ -53,7 +53,7 @@ public class CompilerRunnerUtil {
|
||||
) throws IOException {
|
||||
ClassLoader classLoader = ourClassLoaderRef.get();
|
||||
if (classLoader == null) {
|
||||
classLoader = createClassLoader(libPath, environment.getParentClassLoader(), environment.getClassesToLoadByParent());
|
||||
classLoader = createClassLoader(libPath, CompilerRunnerUtil.class.getClassLoader(), environment.getClassesToLoadByParent());
|
||||
ourClassLoaderRef = new SoftReference<ClassLoader>(classLoader);
|
||||
}
|
||||
return classLoader;
|
||||
|
||||
@@ -169,16 +169,14 @@ public class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR
|
||||
.register(javaClass<IncrementalCacheProvider>(), IncrementalCacheProviderImpl(incrementalCaches))
|
||||
.build()
|
||||
|
||||
val environment = CompilerEnvironment.getEnvironmentFor(
|
||||
return CompilerEnvironment.getEnvironmentFor(
|
||||
PathUtil.getKotlinPathsForJpsPluginOrJpsTests(),
|
||||
javaClass.getClassLoader(),
|
||||
{ className ->
|
||||
className!!.startsWith("org.jetbrains.jet.lang.resolve.kotlin.incremental.cache.")
|
||||
className.startsWith("org.jetbrains.jet.lang.resolve.kotlin.incremental.cache.")
|
||||
|| className == "org.jetbrains.jet.config.Services"
|
||||
},
|
||||
compilerServices
|
||||
)
|
||||
return environment
|
||||
}
|
||||
|
||||
private fun getOutputItemsAndTargets(
|
||||
|
||||
Reference in New Issue
Block a user