[kotlin.reflect] Introduce ClassValue-based cache for KClassImpl
* Replace pcollections with ClassValue/ConcurrentHashMap-based caches * Do not store weak references, instead cache strong references and count on ClassValue to unload the corresponding classloader if necessary * ConcurrentHashMap does not rely on WeakReference as it's only selected on Android where classloader leaks don't exist * Update reflect/scripting JDK requirement to Java 8 in order to proceed #KT-53454 #KT-50705 Merge-request: KT-MR-6788 Merged-by: Vsevolod Tolstopyatov <qwwdfsad@gmail.com>
This commit is contained in:
committed by
Space
parent
d5164fbc86
commit
14b13a2f17
-46
@@ -19022,52 +19022,6 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/codegen/box/hashPMap")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class HashPMap {
|
||||
@Test
|
||||
public void testAllFilesPresentInHashPMap() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/hashPMap"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("empty.kt")
|
||||
public void testEmpty() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/hashPMap/empty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("manyNumbers.kt")
|
||||
public void testManyNumbers() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/hashPMap/manyNumbers.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("rewriteWithDifferent.kt")
|
||||
public void testRewriteWithDifferent() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/hashPMap/rewriteWithDifferent.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("rewriteWithEqual.kt")
|
||||
public void testRewriteWithEqual() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/hashPMap/rewriteWithEqual.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simplePlusGet.kt")
|
||||
public void testSimplePlusGet() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/hashPMap/simplePlusGet.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simplePlusMinus.kt")
|
||||
public void testSimplePlusMinus() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/hashPMap/simplePlusMinus.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/codegen/box/ieee754")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
|
||||
-26
@@ -1,26 +0,0 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
|
||||
// WITH_REFLECT
|
||||
|
||||
import kotlin.reflect.jvm.internal.pcollections.HashPMap
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val map = HashPMap.empty<String, Any>()!!
|
||||
|
||||
assertEquals(0, map.size())
|
||||
|
||||
assertFalse(map.containsKey(""))
|
||||
assertFalse(map.containsKey("abacaba"))
|
||||
assertEquals(null, map[""])
|
||||
assertEquals(null, map["lol"])
|
||||
|
||||
// Check that doesn't create a new map
|
||||
assertEquals(map, map.minus(""))
|
||||
|
||||
// Check that all empty()s are equal
|
||||
val other = HashPMap.empty<String, Any>()!!
|
||||
assertEquals(map, other)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
|
||||
// Out of memory on Android 4.4
|
||||
// IGNORE_BACKEND: ANDROID
|
||||
|
||||
// WITH_REFLECT
|
||||
|
||||
import java.util.*
|
||||
import kotlin.reflect.jvm.internal.pcollections.HashPMap
|
||||
import kotlin.test.*
|
||||
|
||||
fun digitSum(number: Int): Int {
|
||||
var x = number
|
||||
var ans = 0
|
||||
while (x != 0) {
|
||||
ans += x % 10
|
||||
x /= 10
|
||||
}
|
||||
return ans
|
||||
}
|
||||
|
||||
val N = 1000000
|
||||
|
||||
fun box(): String {
|
||||
var map = HashPMap.empty<Int, Any>()!!
|
||||
|
||||
for (x in 1..N) {
|
||||
map = map.plus(x, digitSum(x))!!
|
||||
}
|
||||
|
||||
assertEquals(N, map.size())
|
||||
|
||||
// Check in reverse order just in case
|
||||
for (x in N downTo 1) {
|
||||
assertTrue(map.containsKey(x), "Not found: $x")
|
||||
assertEquals(digitSum(x), map[x], "Incorrect value for $x")
|
||||
}
|
||||
|
||||
// Delete in random order
|
||||
val list = (1..N).toCollection(ArrayList<Int>())
|
||||
Collections.shuffle(list, Random(42))
|
||||
for (x in list) {
|
||||
map = map.minus(x)!!
|
||||
}
|
||||
|
||||
assertEquals(0, map.size())
|
||||
|
||||
for (x in 1..N) {
|
||||
assertFalse(map.containsKey(x), "Incorrectly found: $x")
|
||||
assertEquals(null, map[x], "Incorrectly found value for $x")
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
|
||||
// WITH_REFLECT
|
||||
|
||||
import kotlin.reflect.jvm.internal.pcollections.HashPMap
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
var map = HashPMap.empty<String, Any>()!!
|
||||
|
||||
map = map.plus("lol", 42)!!
|
||||
map = map.plus("lol", 239)!!
|
||||
|
||||
assertEquals(1, map.size())
|
||||
assertTrue(map.containsKey("lol"))
|
||||
assertFalse(map.containsKey(""))
|
||||
assertEquals(239, map["lol"])
|
||||
assertEquals(null, map[""])
|
||||
|
||||
map = map.plus("", 0)!!
|
||||
map = map.plus("", 2.71828)!!
|
||||
map = map.plus("lol", 42)!!
|
||||
map = map.plus("", 3.14)!!
|
||||
|
||||
assertEquals(2, map.size())
|
||||
assertTrue(map.containsKey("lol"))
|
||||
assertTrue(map.containsKey(""))
|
||||
assertEquals(42, map["lol"])
|
||||
assertEquals(3.14, map[""])
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
|
||||
// WITH_REFLECT
|
||||
|
||||
import kotlin.reflect.jvm.internal.pcollections.HashPMap
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
var map = HashPMap.empty<String, Any>()!!
|
||||
|
||||
map = map.plus("lol", 42)!!
|
||||
map = map.plus("lol", 42)!!
|
||||
|
||||
assertEquals(1, map.size())
|
||||
assertTrue(map.containsKey("lol"))
|
||||
assertFalse(map.containsKey(""))
|
||||
assertEquals(42, map["lol"])
|
||||
assertEquals(null, map[""])
|
||||
|
||||
map = map.plus("", 0)!!
|
||||
map = map.plus("", 0)!!
|
||||
map = map.plus("lol", 42)!!
|
||||
map = map.plus("", 0)!!
|
||||
|
||||
assertEquals(2, map.size())
|
||||
assertTrue(map.containsKey("lol"))
|
||||
assertTrue(map.containsKey(""))
|
||||
assertEquals(42, map["lol"])
|
||||
assertEquals(0, map[""])
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
|
||||
// WITH_REFLECT
|
||||
|
||||
import kotlin.reflect.jvm.internal.pcollections.HashPMap
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
var map = HashPMap.empty<String, Any>()!!
|
||||
|
||||
map = map.plus("lol", 42)!!
|
||||
|
||||
assertEquals(1, map.size())
|
||||
assertTrue(map.containsKey("lol"))
|
||||
assertFalse(map.containsKey(""))
|
||||
assertEquals(42, map["lol"])
|
||||
assertEquals(null, map[""])
|
||||
|
||||
map = map.plus("", 0)!!
|
||||
|
||||
assertEquals(2, map.size())
|
||||
assertTrue(map.containsKey("lol"))
|
||||
assertTrue(map.containsKey(""))
|
||||
assertEquals(42, map["lol"])
|
||||
assertEquals(0, map[""])
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
|
||||
// WITH_REFLECT
|
||||
|
||||
import kotlin.reflect.jvm.internal.pcollections.HashPMap
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
var map = HashPMap.empty<String, Any>()!!
|
||||
|
||||
map = map.plus("lol", 42)!!
|
||||
map = map.minus("lol")!!
|
||||
|
||||
assertEquals(0, map.size())
|
||||
assertFalse(map.containsKey("lol"))
|
||||
assertEquals(null, map["lol"])
|
||||
|
||||
map = map.plus("abc", "a")!!
|
||||
map = map.minus("abc")!!
|
||||
map = map.plus("abc", "d")!!
|
||||
|
||||
assertEquals(1, map.size())
|
||||
assertTrue(map.containsKey("abc"))
|
||||
assertEquals("d", map["abc"])
|
||||
|
||||
return "OK"
|
||||
}
|
||||
-46
@@ -18452,52 +18452,6 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/codegen/box/hashPMap")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class HashPMap {
|
||||
@Test
|
||||
public void testAllFilesPresentInHashPMap() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/hashPMap"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("empty.kt")
|
||||
public void testEmpty() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/hashPMap/empty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("manyNumbers.kt")
|
||||
public void testManyNumbers() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/hashPMap/manyNumbers.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("rewriteWithDifferent.kt")
|
||||
public void testRewriteWithDifferent() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/hashPMap/rewriteWithDifferent.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("rewriteWithEqual.kt")
|
||||
public void testRewriteWithEqual() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/hashPMap/rewriteWithEqual.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simplePlusGet.kt")
|
||||
public void testSimplePlusGet() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/hashPMap/simplePlusGet.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simplePlusMinus.kt")
|
||||
public void testSimplePlusMinus() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/hashPMap/simplePlusMinus.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/codegen/box/ieee754")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
|
||||
-46
@@ -19022,52 +19022,6 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/codegen/box/hashPMap")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class HashPMap {
|
||||
@Test
|
||||
public void testAllFilesPresentInHashPMap() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/hashPMap"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("empty.kt")
|
||||
public void testEmpty() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/hashPMap/empty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("manyNumbers.kt")
|
||||
public void testManyNumbers() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/hashPMap/manyNumbers.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("rewriteWithDifferent.kt")
|
||||
public void testRewriteWithDifferent() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/hashPMap/rewriteWithDifferent.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("rewriteWithEqual.kt")
|
||||
public void testRewriteWithEqual() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/hashPMap/rewriteWithEqual.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simplePlusGet.kt")
|
||||
public void testSimplePlusGet() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/hashPMap/simplePlusGet.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simplePlusMinus.kt")
|
||||
public void testSimplePlusMinus() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/hashPMap/simplePlusMinus.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/codegen/box/ieee754")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
|
||||
-43
@@ -15341,49 +15341,6 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/hashPMap")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class HashPMap extends AbstractLightAnalysisModeTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInHashPMap() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/hashPMap"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
@TestMetadata("empty.kt")
|
||||
public void testEmpty() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/hashPMap/empty.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("manyNumbers.kt")
|
||||
public void testManyNumbers() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/hashPMap/manyNumbers.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("rewriteWithDifferent.kt")
|
||||
public void testRewriteWithDifferent() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/hashPMap/rewriteWithDifferent.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("rewriteWithEqual.kt")
|
||||
public void testRewriteWithEqual() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/hashPMap/rewriteWithEqual.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("simplePlusGet.kt")
|
||||
public void testSimplePlusGet() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/hashPMap/simplePlusGet.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("simplePlusMinus.kt")
|
||||
public void testSimplePlusMinus() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/hashPMap/simplePlusMinus.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/ieee754")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
@@ -31,7 +31,6 @@ class CodeConformanceTest : TestCase() {
|
||||
"compiler/testData/psi/kdoc",
|
||||
"compiler/tests/org/jetbrains/kotlin/code/CodeConformanceTest.kt",
|
||||
"compiler/util/src/org/jetbrains/kotlin/config/MavenComparableVersion.java",
|
||||
"core/reflection.jvm/src/kotlin/reflect/jvm/internal/pcollections",
|
||||
"dependencies",
|
||||
"dependencies/protobuf/protobuf-relocated/build",
|
||||
"dist",
|
||||
|
||||
Reference in New Issue
Block a user