diff --git a/core/runtime.jvm/src/kotlin/reflect/jvm/internal/foreignKClasses.kt b/core/runtime.jvm/src/kotlin/reflect/jvm/internal/foreignKClasses.kt index d13dd573029..adf795c49ce 100644 --- a/core/runtime.jvm/src/kotlin/reflect/jvm/internal/foreignKClasses.kt +++ b/core/runtime.jvm/src/kotlin/reflect/jvm/internal/foreignKClasses.kt @@ -24,7 +24,7 @@ import kotlin.reflect.jvm.internal.pcollections.HashPMap // Arrays are needed because the same class can be loaded by different class loaders, which results in different Class instances. // This variable is not volatile intentionally: we don't care if there's a data race on it and some KClass instances will be lost. // We do care however about general performance on read access to it, thus no synchronization is done here whatsoever -private var FOREIGN_K_CLASSES = HashPMap.empty()!! +private var FOREIGN_K_CLASSES = HashPMap.empty() // This function is invoked on each reflection access to Java classes, properties, etc. Performance is critical here. fun foreignKotlinClass(jClass: Class): KClassImpl { @@ -55,11 +55,11 @@ fun foreignKotlinClass(jClass: Class): KClassImpl { System.arraycopy(cached, 0, newArray, 0, size) val newKClass = KClassImpl(jClass) newArray[size] = WeakReference(newKClass) - FOREIGN_K_CLASSES = FOREIGN_K_CLASSES.plus(name, newArray)!! + FOREIGN_K_CLASSES = FOREIGN_K_CLASSES.plus(name, newArray) return newKClass } val newKClass = KClassImpl(jClass) - FOREIGN_K_CLASSES = FOREIGN_K_CLASSES.plus(name, WeakReference(newKClass))!! + FOREIGN_K_CLASSES = FOREIGN_K_CLASSES.plus(name, WeakReference(newKClass)) return newKClass } diff --git a/core/runtime.jvm/src/kotlin/reflect/jvm/internal/pcollections/HashPMap.java b/core/runtime.jvm/src/kotlin/reflect/jvm/internal/pcollections/HashPMap.java index 6909aa304c6..473b2d6d922 100644 --- a/core/runtime.jvm/src/kotlin/reflect/jvm/internal/pcollections/HashPMap.java +++ b/core/runtime.jvm/src/kotlin/reflect/jvm/internal/pcollections/HashPMap.java @@ -16,6 +16,8 @@ package kotlin.reflect.jvm.internal.pcollections; +import org.jetbrains.annotations.NotNull; + /** * A persistent map from non-null keys to non-null values. */ @@ -23,6 +25,7 @@ public final class HashPMap { private static final HashPMap EMPTY = new HashPMap(IntTreePMap.>>empty(), 0); @SuppressWarnings("unchecked") + @NotNull public static HashPMap empty() { return (HashPMap) HashPMap.EMPTY; } @@ -51,6 +54,7 @@ public final class HashPMap { return null; } + @NotNull public HashPMap plus(K key, V value) { ConsPStack> entries = getEntries(key.hashCode()); int size0 = entries.size(); @@ -60,6 +64,7 @@ public final class HashPMap { return new HashPMap(intMap.plus(key.hashCode(), entries), size - size0 + entries.size()); } + @NotNull public HashPMap minus(Object key) { ConsPStack> entries = getEntries(key.hashCode()); int i = keyIndexIn(entries, key);