-
Notifications
You must be signed in to change notification settings - Fork 59
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
After upgrading to kotlin 1.5.0, the kotlin-parcelize generated code started to be reported as public by binary-compatibility-validator #55
Comments
Hi, either the compilation strategy between Kotlin 1.4.x and 1.5.0 regarding parcelize has been changed or this is indeed the issue of BCV. I'm not very familiar with parcelize, so if you could provide a sample project that reproduces the problem (e.g. I only update Kotlin/BCV version and the output of |
I will create one, thanks for responding so quickly 👍 |
Here is the sample project https://github.com/4brunu/kotlin-binary-compatibility-validator-issue To dump the API, just run Here is the api file with kotlin 1.4.32 Here is the api file with kotlin 1.5.0 |
Parcelize bug explanation: With Kotlin 1.4.x, the corresponding $Creator class has been generated properly as inner public class and his visibility was generated by internal outer class With Kotlin 1.5.0, $Creator is generated as local class within <clinit> block. Local classes do not have the corresponding 'outer_class_info_index' attribute and thus their visibility cannot be dominated by the outer class. But they do not constitute public API anyway. The bug was in incorrect detection on whether the class is local. Our isLocal check has been broken, but we had an additional guard in the code and also checked kotlinx.metadata.Flag.IS_LOCAL. Parcelize-generated classes lack such metadata and that guard also had failed Fixes #55
Parcelize bug explanation: With Kotlin 1.4.x, the corresponding $Creator class has been generated properly as an inner public class and its visibility was generated by internal outer class With Kotlin 1.5.0, $Creator is generated as local class within <clinit> block. Local classes do not have the corresponding 'outer_class_info_index' attribute and thus their visibility cannot be dominated by the outer class. But they do not constitute public API anyway. The bug was in incorrect detection on whether the class is local. Our isLocal check has been broken, but we had an additional guard in the code and also checked kotlinx.metadata.Flag.IS_LOCAL. Parcelize-generated classes lack such metadata and that guard also had failed Fixes #55
This PR #60 didn't fixed this issue. |
@qwwdfsad or should I open a new one? |
Please open a new one with a reproducer as well |
Hi,
I'm using
kotlin-parcelize
plugin to generate the parcelable code in the internal data classes in my project.Let's consider the following kotlin data class, that is marked as internal.
I have made the following tests with
binary-compatibility-validator
0.5.0.And there is a difference when using kotlin 1.5.0 and 1.4.32.
Before upgrading to kotlin 1.5.0, using kotlin 1.4.32, the command
./gradlew teleconsultationandroid:apiDump
wouldn't return any output related to the classCountry
.And to help debug this issue, here is the compiled code of
Country
in kotlin 1.4.32.Compiled `Country` data class using kotlin 1.4.32.
import android.os.Parcel; import android.os.Parcelable; import kotlin.Metadata; import kotlin.jvm.internal.Intrinsics; import kotlinx.parcelize.Parcelize; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable;@parcelize
@metadata(...)
/* compiled from: Country.kt */
public final class Country implements Parcelable {
public static final Parcelable.Creator CREATOR = new Creator();
@NotNull
private final String code;
@NotNull
private final String name;
}
But after upgrading to kotlin 1.5.0, the command
./gradlew teleconsultationandroid:apiDump
started returing the following output.And here is the output of the compiled code in kotlin 1.5.0.
Compiled `Country` data class using kotlin 1.5.0.
import android.os.Parcel; import android.os.Parcelable; import kotlin.Metadata; import kotlin.jvm.internal.Intrinsics; import kotlinx.parcelize.Parcelize; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable;@parcelize
@metadata(...)
/* compiled from: Country.kt */
public final class Country implements Parcelable {
@NotNull
public static final Parcelable.Creator CREATOR = new Creator();
@NotNull
private final String code;
@NotNull
private final String name;
}
Is this as issue of binary-compatibility-validator?
Thanks
The text was updated successfully, but these errors were encountered: