-
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.
Skip properties from Java classes for which the getter type is unknown
thus avoiding NPE when auto-generating external serializers. #KT-55681 Fixed (cherry picked from commit 0b4f534)
- Loading branch information
1 parent
c8a4ba1
commit d5e97c6
Showing
4 changed files
with
43 additions
and
2 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
29 changes: 29 additions & 0 deletions
29
plugins/kotlinx-serialization/testData/boxIr/externalSerialierJava.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,29 @@ | ||
// IGNORE_BACKEND_FIR: JVM_IR | ||
// TARGET_BACKEND: JVM_IR | ||
|
||
// WITH_STDLIB | ||
|
||
import kotlinx.serialization.* | ||
import kotlinx.serialization.descriptors.* | ||
import kotlinx.serialization.encoding.* | ||
import java.net.URL | ||
|
||
|
||
// @Serializer should do nothing if all methods are overriden | ||
@Serializer(forClass = URL::class) | ||
object URLSerializer : KSerializer<URL> { | ||
override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("java.net.URL", PrimitiveKind.STRING) | ||
|
||
override fun serialize(encoder: Encoder, value: URL) { | ||
TODO() | ||
} | ||
|
||
override fun deserialize(decoder: Decoder): URL { | ||
TODO() | ||
} | ||
} | ||
|
||
fun box(): String { | ||
if (URLSerializer.descriptor.toString() != "PrimitiveDescriptor(java.net.URL)") return URLSerializer.descriptor.toString() | ||
return "OK" | ||
} |
6 changes: 6 additions & 0 deletions
6
...en/org/jetbrains/kotlinx/serialization/runners/SerializationFirBlackBoxTestGenerated.java
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
...ests-gen/org/jetbrains/kotlinx/serialization/runners/SerializationIrBoxTestGenerated.java
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.