As kotlinc and IDEA share some classes one must ensure we only use kotlinc classes, while in compiler process.
This commit is contained in:
@@ -171,22 +171,12 @@ public class JetCompiler implements TranslatingCompiler {
|
|||||||
Class<?> kompiler = Class.forName("org.jetbrains.jet.cli.KotlinCompiler", true, loader);
|
Class<?> kompiler = Class.forName("org.jetbrains.jet.cli.KotlinCompiler", true, loader);
|
||||||
Method exec = kompiler.getDeclaredMethod("exec", PrintStream.class, String[].class);
|
Method exec = kompiler.getDeclaredMethod("exec", PrintStream.class, String[].class);
|
||||||
|
|
||||||
Thread curThread = Thread.currentThread();
|
Object rc = exec.invoke(null, out, new String[]{"-module", scriptFile.getAbsolutePath(), "-output", path(outputDir)});
|
||||||
|
if (rc instanceof Integer) {
|
||||||
ClassLoader previousLoader = curThread.getContextClassLoader();
|
return ((Integer) rc).intValue();
|
||||||
curThread.setContextClassLoader(loader);
|
|
||||||
|
|
||||||
try {
|
|
||||||
Object rc = exec.invoke(null, out, new String[]{"-module", scriptFile.getAbsolutePath(), "-output", path(outputDir)});
|
|
||||||
if (rc instanceof Integer) {
|
|
||||||
return ((Integer) rc).intValue();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw new RuntimeException("Unexpected return: " + rc);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
finally {
|
else {
|
||||||
curThread.setContextClassLoader(previousLoader);
|
throw new RuntimeException("Unexpected return: " + rc);
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
LOG.error(e);
|
LOG.error(e);
|
||||||
@@ -216,7 +206,7 @@ public class JetCompiler implements TranslatingCompiler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new URLClassLoader(urls);
|
return new URLClassLoader(urls, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void runOutOfProcess(CompileContext compileContext, VirtualFile outputDir, File kotlinHome, File scriptFile) {
|
private static void runOutOfProcess(CompileContext compileContext, VirtualFile outputDir, File kotlinHome, File scriptFile) {
|
||||||
|
|||||||
Reference in New Issue
Block a user