Skip to content

Test JVM flag stripping against the generated accessor - #312

Merged
kirich1409 merged 1 commit into
developfrom
fea-3-jvm-flag-stripping
Nov 6, 2026
Merged

kirich1409 merged 1 commit into
developfrom
fea-3-jvm-flag-stripping

Conversation

@kirich1409

@kirich1409 kirich1409 commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Closes #212

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Chore / refactor

Checklist

  • Tests added or updated
  • Docs updated (KDoc, README, CHANGELOG)
  • ./gradlew spotlessCheck passes
  • CHANGELOG.md updated

Notes for reviewers

A local boolean with default = false is a release constant when the plugin-generated -assumevalues file 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. registerProguardTask already writes build/featured/proguard-featured.pro for non-Android modules. The check applies that file unchanged. No generator change was required: the emitted method name matches the method Kotlin compiled.

JvmFlagStrippingTest is the regression test. It parses build/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. ReleaseDceGuaranteeTest stays 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 = false evidence.

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

Copilot AI balanced review requested due to automatic review settings November 6, 2026 21:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 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
kirich1409 force-pushed the fea-3-jvm-flag-stripping branch from 7cfa11f to 8285748 Compare November 6, 2026 21:45
Copilot AI balanced review requested due to automatic review settings November 6, 2026 21:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues were identified in the JVM flag-stripping regression test or its supporting fixture.

No open issues 🎉

Review effort: Balanced

@kirich1409
kirich1409 merged commit 7170dd6 into develop Nov 6, 2026
9 checks passed
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