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

Create SnapshotsPreviewRuntimeRetentionTransform to change Previews to runtime retention #139

Conversation

rbro112
Copy link
Contributor

@rbro112 rbro112 commented May 17, 2024

Creates an instrumentation/transform that finds all Preview/Preview.Container (repeatable) annotations and forces them to be runtime visible. This is a workaround to https://issuetracker.google.com/issues/168524920, as D8 will unexpectedly strip Binary/Class annotations.

Also:

  • adds debugOptions and the ability to force invalidate a transform using a system time to make sure transforms aren't cached (taken from here).
  • Adds snapshots.experimentalTransformEnabled which can act as an opt-in to this behavior until we've fully tested and are ready for 1.0

): MethodVisitor {
val mv = super.visitMethod(access, name, descriptor, signature, exceptions)

return object : MethodVisitor(api, mv) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the need for this? Does the other override fun visitAnnotation() not cover all cases?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, that will only cover the annotations on the class-level. We need a separate method visitor to visit the annotations on each method, which is what this is doing.

Without this, we'd just be marking class-level Preview annotations as runtime, instead of class and method level which is what we want.

The class annotation visitor handles multipreview annotation classes that have the preview annotation, and the method annotation visitor handles actual preview methods annotated with Preview.

@rbro112 rbro112 force-pushed the 03-27-Reflectively_invoking_composables_pt_1_-_SDK branch from dc4c21f to ebb84c5 Compare May 17, 2024 19:08
@rbro112 rbro112 force-pushed the ryan/create_snapshotspreviewruntimeretentiontransform_to_change_previews_to_runtime_retention branch from 243fa6c to 2374b92 Compare May 17, 2024 19:08
Base automatically changed from 03-27-Reflectively_invoking_composables_pt_1_-_SDK to main May 17, 2024 19:47
@rbro112 rbro112 force-pushed the ryan/create_snapshotspreviewruntimeretentiontransform_to_change_previews_to_runtime_retention branch from 2374b92 to 799dad1 Compare May 17, 2024 20:02
@rbro112 rbro112 merged commit 3d02e12 into main May 17, 2024
8 checks passed
@rbro112 rbro112 deleted the ryan/create_snapshotspreviewruntimeretentiontransform_to_change_previews_to_runtime_retention branch May 17, 2024 20:41
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