[reflect] Fix flaky tests that depend on Reflection.clearCaches()
* Use ReflectionFactoryImpl as single point of synchronization * Synchronize all cache-sensitive tests on it in order to be robust in parallel test runners * Remove redundant cache clear after each test Merge-request: KT-MR-6842 Merged-by: Vsevolod Tolstopyatov <qwwdfsad@gmail.com>
This commit is contained in:
committed by
Space
parent
94abeb64c5
commit
e32e5c26a4
@@ -2,12 +2,15 @@
|
||||
// FULL_JDK
|
||||
// WITH_REFLECT
|
||||
import kotlin.jvm.internal.*
|
||||
import kotlin.reflect.jvm.internal.*
|
||||
|
||||
class A
|
||||
fun box(): String {
|
||||
val pckg = Reflection.getOrCreateKotlinPackage(A::class.java)
|
||||
System.gc()
|
||||
val pckg2 = Reflection.getOrCreateKotlinPackage(A::class.java)
|
||||
if (pckg === pckg2) return "OK"
|
||||
return "Fail"
|
||||
return synchronized(ReflectionFactoryImpl::class.java) {
|
||||
val pckg = Reflection.getOrCreateKotlinPackage(A::class.java)
|
||||
System.gc()
|
||||
val pckg2 = Reflection.getOrCreateKotlinPackage(A::class.java)
|
||||
if (pckg === pckg2) return@synchronized "OK"
|
||||
return@synchronized "Fail"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user