diff --git a/compiler/daemon/src/org/jetbrains/kotlin/daemon/CompileServiceImpl.kt b/compiler/daemon/src/org/jetbrains/kotlin/daemon/CompileServiceImpl.kt index f882ff752b7..794b314bea2 100644 --- a/compiler/daemon/src/org/jetbrains/kotlin/daemon/CompileServiceImpl.kt +++ b/compiler/daemon/src/org/jetbrains/kotlin/daemon/CompileServiceImpl.kt @@ -17,6 +17,7 @@ package org.jetbrains.kotlin.daemon import com.intellij.openapi.vfs.impl.ZipHandler +import com.intellij.openapi.vfs.impl.jar.CoreJarFileSystem import org.jetbrains.kotlin.cli.common.CLICompiler import org.jetbrains.kotlin.cli.common.ExitCode import org.jetbrains.kotlin.cli.common.KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY @@ -39,7 +40,8 @@ import java.util.concurrent.atomic.AtomicInteger import java.util.concurrent.locks.ReentrantReadWriteLock import java.util.logging.Level import java.util.logging.Logger -import kotlin.comparisons.* +import kotlin.comparisons.compareBy +import kotlin.comparisons.reversed import kotlin.concurrent.read import kotlin.concurrent.schedule import kotlin.concurrent.write @@ -486,28 +488,7 @@ class CompileServiceImpl( private fun clearJarCache() { ZipHandler.clearFileAccessorCache() - val classloader = javaClass.classLoader - // TODO: replace the following code with direct call to CoreJarFileSystem. as soon as it will be available (hopefully in 15.02) - try { - KotlinCoreEnvironment.applicationEnvironment?.jarFileSystem.let { jarfs -> - val jarfsClass = classloader.loadClass("com.intellij.openapi.vfs.impl.jar.CoreJarFileSystem") - val privateHandlersField = jarfsClass.getDeclaredField("myHandlers") - privateHandlersField.isAccessible = true - privateHandlersField.get(jarfs)?.let { - val clearMethod = privateHandlersField.type.getMethod("clear") - if (clearMethod != null) { - clearMethod.invoke(it) - log.info("successfully cleared com.intellij.openapi.vfs.impl.jar.CoreJarFileSystem.myHandlers") - } - else { - log.info("unable to access com.intellij.openapi.vfs.impl.jar.CoreJarFileSystem.myHandlers.clear") - } - } ?: log.info("unable to access CoreJarFileSystem.myHandlers (${privateHandlersField.get(jarfs)})") - } - } - catch (e: Exception) { - log.log(Level.SEVERE, "error clearing CoreJarFileSystem", e) - } + (KotlinCoreEnvironment.applicationEnvironment?.jarFileSystem as? CoreJarFileSystem)?.clearHandlersCache() } // copied (with edit) from gradle plugin