1
1
/*
2
- * Copyright 2010-2015 JetBrains s.r.o.
2
+ * Copyright 2010-2017 JetBrains s.r.o.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
14
14
* limitations under the License.
15
15
*/
16
16
17
- package org.jetbrains.kotlin.cli.jvm
17
+ package org.jetbrains.kotlin.cli.jvm.plugins
18
18
19
19
import com.intellij.util.containers.MultiMap
20
20
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
21
+ import org.jetbrains.kotlin.cli.jvm.BundledCompilerPlugins
21
22
import org.jetbrains.kotlin.compiler.plugin.*
22
23
import org.jetbrains.kotlin.config.CompilerConfiguration
23
24
import java.io.File
24
25
import java.net.URL
25
- import java.net.URLClassLoader
26
26
import java.util.*
27
27
28
-
29
28
object PluginCliParser {
30
-
31
29
@JvmStatic
32
30
fun loadPlugins (arguments : CommonCompilerArguments , configuration : CompilerConfiguration ) {
33
31
val classLoader = PluginURLClassLoader (
@@ -64,9 +62,7 @@ object PluginCliParser {
64
62
65
63
for (optionValue in optionValuesByPlugin[processor.pluginId].orEmpty()) {
66
64
val option = declaredOptions[optionValue!! .optionName]
67
- if (option == null ) {
68
- throw CliOptionProcessingException (" Unsupported plugin option: $optionValue " )
69
- }
65
+ ? : throw CliOptionProcessingException (" Unsupported plugin option: $optionValue " )
70
66
optionsToValues.putValue(option, optionValue)
71
67
}
72
68
@@ -92,37 +88,3 @@ object PluginCliParser {
92
88
}
93
89
}
94
90
}
95
-
96
- private class PluginURLClassLoader (urls : Array <URL >, parent : ClassLoader ) : ClassLoader(Thread .currentThread().contextClassLoader) {
97
- private val childClassLoader: SelfThenParentURLClassLoader = SelfThenParentURLClassLoader (urls, parent)
98
-
99
- @Synchronized
100
- override fun loadClass (name : String , resolve : Boolean ): Class <* > {
101
- return try {
102
- childClassLoader.findClass(name)
103
- }
104
- catch (e: ClassNotFoundException ) {
105
- super .loadClass(name, resolve)
106
- }
107
- }
108
-
109
- override fun getResources (name : String ) = childClassLoader.getResources(name)
110
-
111
- private class SelfThenParentURLClassLoader (urls : Array <URL >, val onFail : ClassLoader ) : URLClassLoader(urls, null ) {
112
-
113
- public override fun findClass (name : String ): Class <* > {
114
- val loaded = findLoadedClass(name)
115
- if (loaded != null ) {
116
- return loaded
117
- }
118
-
119
- return try {
120
- super .findClass(name)
121
- }
122
- catch (e: ClassNotFoundException ) {
123
- onFail.loadClass(name)
124
- }
125
-
126
- }
127
- }
128
- }
0 commit comments