From 93bdc45d48286bf900b2b161df20064966a51651 Mon Sep 17 00:00:00 2001 From: Maxim Shafirov Date: Thu, 9 Feb 2012 20:30:45 +0400 Subject: [PATCH] As kotlinc and IDEA share some classes one must ensure we only use kotlinc classes, while in compiler process. --- .../jet/plugin/compiler/JetCompiler.java | 22 +++++-------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/idea/src/org/jetbrains/jet/plugin/compiler/JetCompiler.java b/idea/src/org/jetbrains/jet/plugin/compiler/JetCompiler.java index daa8e2ff0db..73619ef2cdd 100644 --- a/idea/src/org/jetbrains/jet/plugin/compiler/JetCompiler.java +++ b/idea/src/org/jetbrains/jet/plugin/compiler/JetCompiler.java @@ -171,22 +171,12 @@ public class JetCompiler implements TranslatingCompiler { Class kompiler = Class.forName("org.jetbrains.jet.cli.KotlinCompiler", true, loader); Method exec = kompiler.getDeclaredMethod("exec", PrintStream.class, String[].class); - Thread curThread = Thread.currentThread(); - - ClassLoader previousLoader = curThread.getContextClassLoader(); - 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); - } + Object rc = exec.invoke(null, out, new String[]{"-module", scriptFile.getAbsolutePath(), "-output", path(outputDir)}); + if (rc instanceof Integer) { + return ((Integer) rc).intValue(); } - finally { - curThread.setContextClassLoader(previousLoader); + else { + throw new RuntimeException("Unexpected return: " + rc); } } catch (Throwable 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) {