Reflection: fix exceptions on concurrent access to some properties

Using `ReflectionProperties.lazy` is incorrect because it allows several
threads to observe different resulting values if they're computing it
simultaneously (unlike `lazy(PUBLICATION)`, which always returns the
value that "won the race").

In the case of property delegates, for example, if we're invoking
`isAccessible = true` and then `getDelegate()` concurrently, it might
happen that when some thread invokes `getDelegate()`, it gets the
underlying Field object which was written by another thread and which
has not yet been made accessible, leading to
IllegalPropertyDelegateAccessException.

 #KT-27585 Fixed
This commit is contained in:
Alexander Udalov
2023-01-24 16:34:00 +01:00
committed by Space Team
parent e8f95a3376
commit 99b38ccb74
9 changed files with 137 additions and 31 deletions
+1 -1
View File
@@ -164,7 +164,7 @@
/compiler/testData/psi/ "Kotlin Compiler Core"
/compiler/testData/psiUtil/ "Kotlin Compiler Core"
/compiler/testData/recursiveProcessor/ "Kotlin Compiler Core"
/compiler/testData/reflection/classLoaderForBuiltIns/ "Kotlin Libraries"
/compiler/testData/reflection/ "Kotlin Libraries"
/compiler/testData/repl/ "Kotlin Compiler Core"
/compiler/testData/resolve/ "Kotlin Compiler Core"
/compiler/testData/resolveAnnotations/ "Kotlin Compiler Core"