From b6aecf393347b177e91be506475cc1324132ca00 Mon Sep 17 00:00:00 2001 From: Yan Zhulanow Date: Mon, 29 Oct 2018 09:27:43 +0900 Subject: [PATCH] Remove hacky PluginURLClassLoader It was once needed for the compiler plugins bundled straight into the compiler (read: kapt1). Since there are no bundled plugins anymore, the parent-last plugin classloader itself is not needed anymore. --- .idea/dictionaries/yan.xml | 1 + .../kotlin/cli/jvm/plugins/PluginCliParser.kt | 3 +- .../cli/jvm/plugins/PluginURLClassLoader.kt | 52 ------------------- 3 files changed, 3 insertions(+), 53 deletions(-) delete mode 100644 compiler/cli/src/org/jetbrains/kotlin/cli/jvm/plugins/PluginURLClassLoader.kt diff --git a/.idea/dictionaries/yan.xml b/.idea/dictionaries/yan.xml index 68e55508f60..06e1c2e0ecd 100644 --- a/.idea/dictionaries/yan.xml +++ b/.idea/dictionaries/yan.xml @@ -3,6 +3,7 @@ debuggee deserializes + hacky impls kapt parceler diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/plugins/PluginCliParser.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/plugins/PluginCliParser.kt index e4527bd618e..3695e724100 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/plugins/PluginCliParser.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/plugins/PluginCliParser.kt @@ -25,6 +25,7 @@ import org.jetbrains.kotlin.cli.common.messages.MessageCollectorUtil import org.jetbrains.kotlin.compiler.plugin.* import org.jetbrains.kotlin.config.CompilerConfiguration import java.io.File +import java.net.URLClassLoader import java.util.* object PluginCliParser { @@ -58,7 +59,7 @@ object PluginCliParser { @JvmStatic fun loadPlugins(pluginClasspaths: Iterable?, pluginOptions: Iterable?, configuration: CompilerConfiguration) { - val classLoader = PluginURLClassLoader( + val classLoader = URLClassLoader( pluginClasspaths ?.map { File(it).toURI().toURL() } ?.toTypedArray() diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/plugins/PluginURLClassLoader.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/plugins/PluginURLClassLoader.kt deleted file mode 100644 index 399c77b72b7..00000000000 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/plugins/PluginURLClassLoader.kt +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2010-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.cli.jvm.plugins - -import java.net.URL -import java.net.URLClassLoader -import java.util.* - -internal class PluginURLClassLoader(urls: Array, parent: ClassLoader) : ClassLoader(Thread.currentThread().contextClassLoader) { - private val childClassLoader: SelfThenParentURLClassLoader = SelfThenParentURLClassLoader(urls, parent) - - @Synchronized - override fun loadClass(name: String, resolve: Boolean): Class<*> { - return try { - childClassLoader.findClass(name) - } catch (e: ClassNotFoundException) { - super.loadClass(name, resolve) - } - } - - override fun getResources(name: String): Enumeration = childClassLoader.getResources(name) - - private class SelfThenParentURLClassLoader(urls: Array, private val onFail: ClassLoader) : URLClassLoader(urls, null) { - - public override fun findClass(name: String): Class<*> { - val loaded = findLoadedClass(name) - if (loaded != null) { - return loaded - } - - return try { - super.findClass(name) - } catch (e: ClassNotFoundException) { - onFail.loadClass(name) - } - } - } -}