Skip to content

ADFA-5068: Fix javac-services dependency scope without breaking AGP's consistency check - #1643

Open
davidschachterADFA wants to merge 1 commit into
task/ADFA-5053-lazy-load-javac-carrierfrom
task/ADFA-5068-javac-services-dep-scope
Open

ADFA-5068: Fix javac-services dependency scope without breaking AGP's consistency check#1643
davidschachterADFA wants to merge 1 commit into
task/ADFA-5053-lazy-load-javac-carrierfrom
task/ADFA-5068-javac-services-dep-scope

Conversation

@davidschachterADFA

@davidschachterADFA davidschachterADFA commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

Stacked on #1638 (ADFA-5053) -- this needs its java-compiler-carrier module and ADR 0012.

Follow-up from ADFA-5053's APK size audit (ADFA-5068). javac-services declared kotlin-stdlib, guava, :common, and :logger as implementation even though all four are resident, leaking androidx.core's ~2.87MB of dead resources plus duplicate guava/kotlin-stdlib bytecode into java-compiler-carrier.apk. Switching those to compileOnly broke AGP's compileClasspath.shouldResolveConsistentlyWith(runtimeClasspath) check one level up in java-compiler-impl, once :common's androidx graph stopped incidentally anchoring a high-enough version against AGP's own low-pinned viewbinding injection.

  • Relocated ReflectUtils (the one :common symbol javac-services actually uses -- VMUtils/ILogger already lived in :shared/:logger) from :common to :shared.
  • javac-services: common.kotlin/projects.common/projects.logger -> compileOnly(shared)/compileOnly(logger)/compileOnly(kotlin); dropped the guava line entirely (confirmed dead -- javac-services' own code never references it).
  • Added a constraints {} block in java-compiler-impl pinning androidx.annotation/kotlin-stdlib/org.jetbrains:annotations to the versions already used elsewhere in the project. A constraint only rescopes an edge already reachable via AGP's injected viewbinding, so it doesn't reintroduce the duplication this fix removes -- just a version bump on a few KB of annotation classes.
  • Documented the pattern in ADR 0012 (Negative/costs) as a third worked example of the resident-vs-isolated compileOnly rule.

Verified

From-scratch java-compiler-carrier:assembleV8Release:

  • APK: 32.4MB -> 10.2MB
  • resources.arsc: 2.27MB -> 40 bytes (empty; all androidx.core res/ entries gone)
  • dex: 9.1+8.1+10.5+2.6MB across 5 files -> 8.4+2.1MB across 2

Test plan

  • :shared:test, :subprojects:javac-services:testV8DebugUnitTest, :lsp:java-compiler-impl:testV8DebugUnitTest, :common:testV8DebugUnitTest all green
  • Clean :subprojects:java-compiler-carrier:assembleV8Release succeeds and byte sizes confirmed above
  • spotlessApply clean

🤖 Generated with Claude Code

… consistency check

javac-services declared kotlin-stdlib, guava, :common, and :logger as
implementation even though all are resident, leaking androidx.core's
2.87MB of dead resources and duplicate guava/kotlin-stdlib bytecode
into java-compiler-carrier.apk. Switching those to compileOnly broke
AGP's compileClasspath.shouldResolveConsistentlyWith(runtimeClasspath)
check one level up in java-compiler-impl: removing :common's implicit
implementation edge meant nothing but AGP's own low-pinned viewbinding
was left providing androidx.annotation/kotlin-stdlib/org.jetbrains:
annotations on the runtime classpath, while compileOnly deps (sora-
editor, appcompat, material, lsp:indexing) still demanded much higher
versions on the compile side.

Relocated ReflectUtils (the one :common symbol javac-services actually
uses; VMUtils and ILogger already lived in :shared/:logger) there, and
added a constraints{} block in java-compiler-impl pinning the three
conflicting artifacts to the versions already used everywhere else in
the project -- harmonizing both classpaths without re-adding a real
dependency edge. guava was dropped outright: javac-services' own code
never references it directly.

Verified via a from-scratch java-compiler-carrier release build:
32.4MB -> 10.2MB, resources.arsc 2.27MB -> 40 bytes (empty), dex
9.1+8.1+10.5+2.6MB across 5 files -> 8.4+2.1MB across 2.

@claude claude Bot 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.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

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.

1 participant