b73be50e5b
Codegen generates static backing fields for object properties. They are initialized in class constructor but some of them are final static and such access is prohibited in specification but it's allowed in java bytecode <= 1.8. Such access in 1.9 bytecode cause "IllegalAccessError: Update to static final field Object.INSTANCE attempted from a different method (<init>) than the initializer method <clinit>" Added additional hidden field in interface companion to pass out companion instance from <clinit>. #KT-15894 Fixed
27 lines
796 B
Kotlin
Vendored
27 lines
796 B
Kotlin
Vendored
// TODO: muted automatically, investigate should it be ran for JS or not
|
|
// IGNORE_BACKEND: JS, NATIVE
|
|
|
|
// WITH_REFLECT
|
|
|
|
object O {
|
|
val f = {}
|
|
}
|
|
|
|
fun box(): String {
|
|
val javaClass = O.f.javaClass
|
|
|
|
val enclosingMethod = javaClass.getEnclosingMethod()
|
|
if (enclosingMethod != null) return "method: $enclosingMethod"
|
|
|
|
val enclosingConstructor = javaClass.getEnclosingConstructor()
|
|
if (enclosingConstructor != null) return "field should be initialized in clInit"
|
|
|
|
val enclosingClass = javaClass.getEnclosingClass()
|
|
if (enclosingClass?.getName() != "O") return "enclosing class: $enclosingClass"
|
|
|
|
val declaringClass = javaClass.getDeclaringClass()
|
|
if (declaringClass != null) return "anonymous function has a declaring class: $declaringClass"
|
|
|
|
return "OK"
|
|
}
|