Passing condition to prefer parent class loader as a parameter to preloader.
This commit is contained in:
@@ -20,6 +20,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.cli.common.messages.MessageCollector;
|
||||
import org.jetbrains.jet.config.CompilerServices;
|
||||
import org.jetbrains.jet.preloading.ClassCondition;
|
||||
import org.jetbrains.jet.utils.KotlinPaths;
|
||||
import org.jetbrains.jet.utils.PathUtil;
|
||||
|
||||
@@ -34,9 +35,10 @@ public final class CompilerEnvironment {
|
||||
@NotNull KotlinPaths kotlinPaths,
|
||||
@Nullable File outputDir,
|
||||
@Nullable ClassLoader parentClassLoader,
|
||||
@NotNull ClassCondition classesToLoadByParent,
|
||||
@NotNull CompilerServices compilerServices
|
||||
) {
|
||||
return new CompilerEnvironment(kotlinPaths, outputDir, parentClassLoader, compilerServices);
|
||||
return new CompilerEnvironment(kotlinPaths, outputDir, parentClassLoader, classesToLoadByParent, compilerServices);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -45,6 +47,8 @@ public final class CompilerEnvironment {
|
||||
private final File output;
|
||||
@Nullable
|
||||
private final ClassLoader parentClassLoader;
|
||||
@Nullable
|
||||
private final ClassCondition classesToLoadByParent;
|
||||
@NotNull
|
||||
private final CompilerServices services;
|
||||
|
||||
@@ -52,11 +56,13 @@ public final class CompilerEnvironment {
|
||||
@NotNull KotlinPaths kotlinPaths,
|
||||
@Nullable File output,
|
||||
@Nullable ClassLoader parentClassLoader,
|
||||
@NotNull ClassCondition classesToLoadByParent,
|
||||
@NotNull CompilerServices services
|
||||
) {
|
||||
this.kotlinPaths = kotlinPaths;
|
||||
this.output = output;
|
||||
this.parentClassLoader = parentClassLoader;
|
||||
this.classesToLoadByParent = classesToLoadByParent;
|
||||
this.services = services;
|
||||
}
|
||||
|
||||
@@ -80,6 +86,11 @@ public final class CompilerEnvironment {
|
||||
return parentClassLoader;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ClassCondition getClassesToLoadByParent() {
|
||||
return classesToLoadByParent;
|
||||
}
|
||||
|
||||
public void reportErrorsTo(@NotNull MessageCollector messageCollector) {
|
||||
if (output == null) {
|
||||
messageCollector.report(ERROR, "[Internal Error] No output directory", NO_LOCATION);
|
||||
|
||||
@@ -20,7 +20,7 @@ import com.intellij.util.Function;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.cli.common.messages.MessageCollector;
|
||||
import org.jetbrains.jet.config.CompilerServices;
|
||||
import org.jetbrains.jet.preloading.ClassCondition;
|
||||
import org.jetbrains.jet.preloading.ClassPreloadingUtils;
|
||||
import org.jetbrains.jet.utils.KotlinPaths;
|
||||
|
||||
@@ -60,13 +60,14 @@ public class CompilerRunnerUtil {
|
||||
public static ClassLoader getOrCreatePreloader(
|
||||
@NotNull KotlinPaths paths,
|
||||
@Nullable ClassLoader parentClassLoader,
|
||||
@Nullable ClassCondition classToLoadByParent,
|
||||
@NotNull MessageCollector messageCollector
|
||||
) {
|
||||
ClassLoader answer = ourClassLoaderRef.get();
|
||||
if (answer == null) {
|
||||
try {
|
||||
int estimatedClassNumber = 4096;
|
||||
answer = ClassPreloadingUtils.preloadClasses(kompilerClasspath(paths, messageCollector), estimatedClassNumber, parentClassLoader);
|
||||
answer = ClassPreloadingUtils.preloadClasses(kompilerClasspath(paths, messageCollector), estimatedClassNumber, parentClassLoader, classToLoadByParent);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
@@ -119,7 +120,8 @@ public class CompilerRunnerUtil {
|
||||
MessageCollector messageCollector, PrintStream out, boolean usePreloader
|
||||
) throws Exception {
|
||||
ClassLoader loader = usePreloader
|
||||
? getOrCreatePreloader(environment.getKotlinPaths(), environment.getParentClassLoader(), messageCollector)
|
||||
? getOrCreatePreloader(environment.getKotlinPaths(), environment.getParentClassLoader(),
|
||||
environment.getClassesToLoadByParent(), messageCollector)
|
||||
: getOrCreateClassLoader(environment.getKotlinPaths(), messageCollector);
|
||||
|
||||
Class<?> kompiler = Class.forName(compilerClassName, true, loader);
|
||||
|
||||
Reference in New Issue
Block a user