Move object initialization from <init> to <clinit>
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
This commit is contained in:
committed by
Ilya Gorbunov
parent
de004337a2
commit
b73be50e5b
+1
-1
@@ -14,7 +14,7 @@ fun box(): String {
|
||||
if (enclosingMethod != null) return "method: $enclosingMethod"
|
||||
|
||||
val enclosingConstructor = javaClass.getEnclosingConstructor()
|
||||
if (enclosingConstructor == null) return "no enclosing constructor"
|
||||
if (enclosingConstructor != null) return "field should be initialized in clInit"
|
||||
|
||||
val enclosingClass = javaClass.getEnclosingClass()
|
||||
if (enclosingClass?.getName() != "O") return "enclosing class: $enclosingClass"
|
||||
|
||||
Reference in New Issue
Block a user