Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed keeping INSTANCE field and serializer function for serializable objects in R8 full mode #2865

Merged
merged 2 commits into from
Nov 25, 2024

Conversation

shanshin
Copy link
Contributor

@shanshin shanshin requested a review from sandwwraith November 21, 2024 12:51
@shanshin shanshin changed the title Fixed keeping INSTANCE field and serializer function for serializable objects Fixed keeping INSTANCE field and serializer function for serializable objects in R8 full mode Nov 21, 2024
@sandwwraith
Copy link
Member

Why it is not

-if @kotlinx.serialization.Serializable class **
-keepclassmembers class <1> {
    public static <1> INSTANCE;
    kotlinx.serialization.KSerializer serializer(...);
}

as you advised in the original issue?

@shanshin
Copy link
Contributor Author

as you advised in the original issue?

current rule more strict, serializer function will be kept only if INSTANCE field is present.
If a less strict rule is also acceptable, then it is better to use

-keepclassmembers @kotlinx.serialization.Serializable class ** {
    public static ** INSTANCE;
    kotlinx.serialization.KSerializer serializer(...);
}

@shanshin
Copy link
Contributor Author

@sandwwraith, I simplify rule, and made it less strict. Now all INSTANCE fields and serializer function will be kept in any class marked as Serializable

@shanshin shanshin merged commit 1b0accd into dev Nov 25, 2024
4 checks passed
@shanshin shanshin deleted the r8-fix branch November 25, 2024 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants