-
Notifications
You must be signed in to change notification settings - Fork 620
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix IllegalAccessException being thrown on an attempt to retrieve ser…
…ializer for some private implementation classes from stdlib. Fixes #2449
- Loading branch information
1 parent
a675cb3
commit 243eab4
Showing
4 changed files
with
75 additions
and
11 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
17 changes: 17 additions & 0 deletions
17
formats/json-tests/jvmTest/src/kotlinx/serialization/test/TypeToken.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,17 @@ | ||
/* | ||
* Copyright 2017-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
package kotlinx.serialization.test | ||
|
||
import java.lang.reflect.* | ||
|
||
|
||
@PublishedApi | ||
internal open class TypeBase<T> | ||
|
||
public inline fun <reified T> typeTokenOf(): Type { | ||
val base = object : TypeBase<T>() {} | ||
val superType = base::class.java.genericSuperclass!! | ||
return (superType as ParameterizedType).actualTypeArguments.first()!! | ||
} |
I think it would be better to check whether the class itself is not accessible (private), using
Modifier.isPublic(modifiers)
although I haven't checked that that works for all cases.