Skip to content

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

Open
copybara-service[bot] wants to merge 1 commit into
mainfrom
piper_1015649620
Open

copybara-service[bot] wants to merge 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.

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: 1015649620

This branch has not been deployed

No deployments
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