Skip to content

Hide @RestrictTo APIs in AndroidX Test Metalava API generation. - #2531

Merged
copybara-service[bot] merged 1 commit into
mainfrom
piper_1015649620
Nov 9, 2026
Merged

copybara-service[bot] merged 1 commit into
mainfrom
piper_1015649620

Conversation

@copybara-service

Copy link
Copy Markdown

Hide @RestrictTo APIs in AndroidX Test Metalava API generation.

Pass --hide-annotation androidx.annotation.RestrictTo in
generate_api.bzl (alongside the existing --show-annotation for
RestrictTo(Scope.LIBRARY_GROUP) on internal API checks) and update the
two current_public.txt files where @RestrictTo declarations had
leaked into the public signature surface:

  • espresso: Remove IInteractionExecutionStatus (.aidl annotated
    with @RestrictTo(Scope.LIBRARY_GROUP) via @JavaPassthrough, which
    leaked into current_public.txt after the AIDL compiler stopped
    emitting @hide in generated Javadoc comments).
  • monitor: Elide internal @RestrictTo(Scope.LIBRARY) superclass
    ExposedInstrumentationApi on MonitoringInstrumentation (loaded
    from compiled classpath bytecode where Javadoc @hide is absent) to
    android.app.Instrumentation.

Hiding internal APIs via @RestrictTo instead of @hide doc tags:

  • Unlocks removing redundant @hide tags and passing
    --ignore-comments to Metalava, improving build performance and
    memory usage by skipping Javadoc/KDoc comment parsing.
  • Enables Metalava declarative <api-surfaces> XML configuration,
    which ignores @hide and @removed Javadoc tags by design.
  • Aligns Metalava visibility with compiler, Lint, and IDE enforcement.

@copybara-service
copybara-service Bot force-pushed the piper_1015649620 branch 4 times, most recently from 0d885e2 to 27960cb Compare November 9, 2026 18:54
Pass `--hide-annotation androidx.annotation.RestrictTo` in
`generate_api.bzl` (alongside the existing `--show-annotation` for
`RestrictTo(Scope.LIBRARY_GROUP)` on internal API checks) and update the
two `current_public.txt` files where `@RestrictTo` declarations had
leaked into the public signature surface:

- `espresso`: Remove `IInteractionExecutionStatus` (`.aidl` annotated
  with `@RestrictTo(Scope.LIBRARY_GROUP)` via `@JavaPassthrough`, which
  leaked into `current_public.txt` after the AIDL compiler stopped
  emitting `@hide` in generated Javadoc comments).
- `monitor`: Elide internal `@RestrictTo(Scope.LIBRARY)` superclass
  `ExposedInstrumentationApi` on `MonitoringInstrumentation` (loaded
  from compiled classpath bytecode where Javadoc `@hide` is absent) to
  `android.app.Instrumentation`.

Hiding internal APIs via `@RestrictTo` instead of `@hide` doc tags:
- Unlocks removing redundant `@hide` tags and passing
  `--ignore-comments` to Metalava, improving build performance and
  memory usage by skipping Javadoc/KDoc comment parsing.
- Enables Metalava declarative `<api-surfaces>` XML configuration,
  which ignores `@hide` and `@removed` Javadoc tags by design.
- Aligns Metalava visibility with compiler, Lint, and IDE enforcement.

PiperOrigin-RevId: 1017491336
@copybara-service
copybara-service Bot merged commit 761fb9e into main Nov 9, 2026
6 checks passed
@copybara-service
copybara-service Bot deleted the piper_1015649620 branch November 9, 2026 19:18
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