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;
|
package org.jetbrains.jet.compiler.runner;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import org.jetbrains.jet.cli.common.messages.MessageCollector;
|
import org.jetbrains.jet.cli.common.messages.MessageCollector;
|
||||||
import org.jetbrains.jet.config.Services;
|
import org.jetbrains.jet.config.Services;
|
||||||
import org.jetbrains.jet.preloading.ClassCondition;
|
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;
|
import static org.jetbrains.jet.cli.common.messages.CompilerMessageSeverity.ERROR;
|
||||||
|
|
||||||
public final class CompilerEnvironment {
|
public final class CompilerEnvironment {
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static CompilerEnvironment getEnvironmentFor(
|
public static CompilerEnvironment getEnvironmentFor(
|
||||||
@NotNull KotlinPaths kotlinPaths,
|
@NotNull KotlinPaths kotlinPaths,
|
||||||
@Nullable ClassLoader parentClassLoader,
|
|
||||||
@NotNull ClassCondition classesToLoadByParent,
|
@NotNull ClassCondition classesToLoadByParent,
|
||||||
@NotNull Services compilerServices
|
@NotNull Services compilerServices
|
||||||
) {
|
) {
|
||||||
return new CompilerEnvironment(kotlinPaths, parentClassLoader, classesToLoadByParent, compilerServices);
|
return new CompilerEnvironment(kotlinPaths, classesToLoadByParent, compilerServices);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private final KotlinPaths kotlinPaths;
|
private final KotlinPaths kotlinPaths;
|
||||||
@Nullable
|
|
||||||
private final ClassLoader parentClassLoader;
|
|
||||||
@NotNull
|
|
||||||
private final ClassCondition classesToLoadByParent;
|
private final ClassCondition classesToLoadByParent;
|
||||||
@NotNull
|
|
||||||
private final Services services;
|
private final Services services;
|
||||||
|
|
||||||
private CompilerEnvironment(
|
private CompilerEnvironment(
|
||||||
@NotNull KotlinPaths kotlinPaths,
|
@NotNull KotlinPaths kotlinPaths,
|
||||||
@Nullable ClassLoader parentClassLoader,
|
|
||||||
@NotNull ClassCondition classesToLoadByParent,
|
@NotNull ClassCondition classesToLoadByParent,
|
||||||
@NotNull Services services
|
@NotNull Services services
|
||||||
) {
|
) {
|
||||||
this.kotlinPaths = kotlinPaths;
|
this.kotlinPaths = kotlinPaths;
|
||||||
this.parentClassLoader = parentClassLoader;
|
|
||||||
this.classesToLoadByParent = classesToLoadByParent;
|
this.classesToLoadByParent = classesToLoadByParent;
|
||||||
this.services = services;
|
this.services = services;
|
||||||
}
|
}
|
||||||
@@ -69,11 +59,6 @@ public final class CompilerEnvironment {
|
|||||||
return kotlinPaths;
|
return kotlinPaths;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public ClassLoader getParentClassLoader() {
|
|
||||||
return parentClassLoader;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public ClassCondition getClassesToLoadByParent() {
|
public ClassCondition getClassesToLoadByParent() {
|
||||||
return classesToLoadByParent;
|
return classesToLoadByParent;
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class CompilerRunnerUtil {
|
|||||||
) throws IOException {
|
) throws IOException {
|
||||||
ClassLoader classLoader = ourClassLoaderRef.get();
|
ClassLoader classLoader = ourClassLoaderRef.get();
|
||||||
if (classLoader == null) {
|
if (classLoader == null) {
|
||||||
classLoader = createClassLoader(libPath, environment.getParentClassLoader(), environment.getClassesToLoadByParent());
|
classLoader = createClassLoader(libPath, CompilerRunnerUtil.class.getClassLoader(), environment.getClassesToLoadByParent());
|
||||||
ourClassLoaderRef = new SoftReference<ClassLoader>(classLoader);
|
ourClassLoaderRef = new SoftReference<ClassLoader>(classLoader);
|
||||||
}
|
}
|
||||||
return classLoader;
|
return classLoader;
|
||||||
|
|||||||
@@ -169,16 +169,14 @@ public class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR
|
|||||||
.register(javaClass<IncrementalCacheProvider>(), IncrementalCacheProviderImpl(incrementalCaches))
|
.register(javaClass<IncrementalCacheProvider>(), IncrementalCacheProviderImpl(incrementalCaches))
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
val environment = CompilerEnvironment.getEnvironmentFor(
|
return CompilerEnvironment.getEnvironmentFor(
|
||||||
PathUtil.getKotlinPathsForJpsPluginOrJpsTests(),
|
PathUtil.getKotlinPathsForJpsPluginOrJpsTests(),
|
||||||
javaClass.getClassLoader(),
|
|
||||||
{ className ->
|
{ 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"
|
|| className == "org.jetbrains.jet.config.Services"
|
||||||
},
|
},
|
||||||
compilerServices
|
compilerServices
|
||||||
)
|
)
|
||||||
return environment
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getOutputItemsAndTargets(
|
private fun getOutputItemsAndTargets(
|
||||||
|
|||||||
Reference in New Issue
Block a user