Repository navigation
feat(compiler): add KSP2 support with compatibility and performance validation - #1088
Merged
Merged
Conversation
Preserve the runtime registration ABI while adding a standalone KSP2 build, mixed APT/KSP Android consumer, incremental checks, and CI. The first milestone explicitly diagnoses source injection and interceptor annotations. Validated 15 KSP integration tests, 7 existing compiler tests, the legacy KAPT compilation chain, and API 34 Debug/Release R8 navigation.
Preserve field defaults, explicit nulls, provider requirements and concrete generic type tokens. Support writable JVM fields and nested injector names with coordinated multi-round validation and explicit diagnostics for unsupported Kotlin property shapes. Validated 27 real KSP integration tests and mixed KAPT/KSP Android injection, inheritance, interception, cancellation and incremental cleanup on API 34 Debug and Release/R8.
Match JVM field wildcard variance and recursively preserve parameterized Java owners. Add reflection-based coverage for raw/star/wildcard types, arrays, providers and nested owners. Validate exact AGP 8.12, 9.0 and 9.3 toolchains with observed version fingerprints, isolated artifact snapshots, 33 JVM regressions and eight Debug/Release R8 device executions on API 21 and 34.
Use identical generated sources, frozen artifacts, isolated Gradle homes and verified K2 compiler options. Measure seven scenarios with two warmups and ten paired samples per backend, with post-timing bytecode and route output checks. Validated 140 measured samples plus 28 warmups and both backend device preflights. Record scenario-specific results without claiming a universal speedup.
Share round-local ancestry results, stop at known routing roots, and avoid provider traversal for JVM scalars and arrays. Associate aggregate registries only with their annotated roots while retaining traced parent and field dependencies. Validated 35 KSP tests, inherited-dependency mutation builds, Debug/Release R8 navigation, and 100 paired before/after measurements with 134 byte-identical generated Java files.
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.
Summary / 变更说明
Add a standalone KSP2 compiler so Android modules can generate ARouter route/provider registries, injection helpers, interceptor registries and route documentation without running ARouter through KAPT. Keep the existing APT/KAPT compiler and runtime contracts intact; mixed applications can use different backends in separate modules, including precompiled KAPT parents.
The implementation includes deferred symbol handling, explicit diagnostics for unsupported Kotlin fields, inherited/generic field mapping, and incremental deletion/ancestor-change coverage. Round-scoped analysis and narrower aggregate dependencies reduce redundant compiler work while preserving generated output.
Related issue / 关联 Issue
Related to #959. The new artifact is a local development snapshot; publishing a release is outside this PR.
Compatibility / 兼容性
@JvmFieldandlateinitfields; ordinary properties and other unsupported cases receive documented diagnostics.Validation / 验证
c8e7b528b6ea53f4621670b173ff4479214637e3, including the analysis optimization, Debug/Release-R8 device tests and incremental mutation checks.BENCHMARK.mdandOPTIMIZATION.md; no universal speedup is claimed.develop.license/clapassed on this PR).Final CI: all 20 checks passed. Build run: https://github.com/alibaba/ARouter/actions/runs/34693662788