Repository navigation
Test JVM flag stripping against the generated accessor - #312
Merged
Merged
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
The guarantee depends on unrun Gradle TestKit compilation and R8 processing checks, so the targeted JvmFlagStrippingTest needs verification on JDK 17 before approval.
No open issues 🎉
What changed in this PR
Adds a JVM regression test for the Boolean flag-stripping portion of #212, checking that the plugin-generated rules remove a disabled branch during an R8 ClassFile pass. No JVM/Desktop minify task is added.
Changes:
- Compiles the generated accessor, verifies its signature, and replaces its body with an unknown field read to prevent constant folding without rules.
- Checks branch retention with and without the unchanged generated rules file.
- Adds a minimal Kotlin/JVM fixture declaring a local Boolean flag with
default = false.
| File | Description |
|---|---|
featured-gradle-plugin/src/test/kotlin/dev/androidbroadcast/featured/gradle/JvmFlagStrippingTest.kt |
Adds generated-signature validation and paired R8 stripping checks. |
featured-gradle-plugin/src/test/fixtures/jvm-dce-project/src/main/kotlin/dev/androidbroadcast/featured/FeaturedRuntimeStub.kt |
Supplies runtime stubs for compiling generated sources. |
featured-gradle-plugin/src/test/fixtures/jvm-dce-project/settings.gradle.kts |
Configures fixture repositories and project name. |
featured-gradle-plugin/src/test/fixtures/jvm-dce-project/build.gradle.kts |
Applies the JVM and Featured plugins and declares the disabled flag. |
Review effort: Balanced
A plain-JVM fixture compiles the plugin-generated accessor and feeds proguard-featured.pro to R8 unchanged. The disabled branch must disappear only when that file is applied.
kirich1409
force-pushed
the
fea-3-jvm-flag-stripping
branch
from
November 6, 2026 21:45
7cfa11f to
8285748
Compare
4 tasks
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #212
Type of change
Checklist
./gradlew spotlessCheckpassesNotes for reviewers
A local boolean with
default = falseis a release constant when the plugin-generated-assumevaluesfile is applied to a JVM R8 ClassFile pass. Code reached only through the compiled accessor is removed. The same code remains when that file is not applied.This does not auto-wire a JVM or Compose Desktop minify task.
registerProguardTaskalready writesbuild/featured/proguard-featured.profor non-Android modules. The check applies that file unchanged. No generator change was required: the emitted method name matches the method Kotlin compiled.JvmFlagStrippingTestis the regression test. It parsesbuild/featured/proguard-featured.pro, requires that method on the compiled class, rewrites only that body, then runs R8 in ClassFile mode. With the generated file applied, the disabled branch is absent and the live branch remains. Without that file, the disabled branch remains.ReleaseDceGuaranteeTeststays the Android closed loop and does not cover this. Shrinker tests that hand-write the accessor and the rule are not this check.Docs, changelog, Int flags, and ProGuard CLI are out of scope. The issue can be closed from the boolean
default = falseevidence.Verified locally:
./gradlew :featured-gradle-plugin:test --tests dev.androidbroadcast.featured.gradle.JvmFlagStrippingTest --offline— 1 test, 0 failures, 0 skipped (28.8s)./gradlew spotlessCheck --offline— passed