-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[KxSerialization] Fix "IllegalAccessError: Update to static final field"
Fixed #KT-57647 For value classes, if you add code to companion anonymous init block in IR, it will be executed in the instance constructor. This causes an error when initializing static fields, because writing to them can only occur from the <clinit> method. The solution is to transfer the static field initialization code from an anonymous init block to the IR initializer of this field
- Loading branch information
Showing
11 changed files
with
130 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
plugins/kotlinx-serialization/testData/jdk11BoxIr/kt57647.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// TARGET_BACKEND: JVM_IR | ||
|
||
// WITH_STDLIB | ||
// IGNORE_DEXING | ||
|
||
import kotlinx.serialization.* | ||
import java.util.UUID | ||
|
||
@Serializable | ||
@JvmInline | ||
value class Id(val id: @Contextual UUID) { | ||
companion object { | ||
fun random() = Id(UUID.randomUUID()) | ||
} | ||
} | ||
|
||
@Serializable | ||
@JvmInline | ||
value class Parametrized<T: Any>(val l: List<T>) | ||
|
||
fun pageMain () { | ||
val id: Id = Id.random() | ||
println(id) | ||
} | ||
|
||
|
||
fun box(): String { | ||
println(System.getProperty("java.version")) | ||
pageMain() | ||
return "OK" | ||
} |
33 changes: 33 additions & 0 deletions
33
...gen/org/jetbrains/kotlinx/serialization/runners/SerializationJdk11IrBoxTestGenerated.java
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters