Make Throwable.addSuppressed extension work without kotlin-stdlib-jdk7*
*given that it runs on JDK7 and higher. The addSuppressed member is called with reflection when it's available. kotlin-stdlib-jdk7 extension still overrides that and calls addSuppressed member statically as before. #KT-30560 Fixed
This commit is contained in:
@@ -5,14 +5,24 @@
|
||||
|
||||
package kotlin.internal
|
||||
|
||||
import java.lang.reflect.Method
|
||||
import java.util.regex.MatchResult
|
||||
import kotlin.random.FallbackThreadLocalRandom
|
||||
import kotlin.random.Random
|
||||
|
||||
internal open class PlatformImplementations {
|
||||
|
||||
private object ReflectAddSuppressedMethod {
|
||||
@JvmField
|
||||
public val method: Method? = Throwable::class.java.let { throwableClass ->
|
||||
throwableClass.methods.find {
|
||||
it.name == "addSuppressed" && it.parameterTypes.singleOrNull() == throwableClass
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public open fun addSuppressed(cause: Throwable, exception: Throwable) {
|
||||
// do nothing
|
||||
ReflectAddSuppressedMethod.method?.invoke(cause, exception)
|
||||
}
|
||||
|
||||
public open fun getMatchResultNamedGroup(matchResult: MatchResult, name: String): MatchGroup? {
|
||||
|
||||
Reference in New Issue
Block a user