Skip to content

Hide TestOutputHandler via annotations in AndroidX Test. - #2532

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

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

Conversation

@copybara-service

Copy link
Copy Markdown

Hide TestOutputHandler via annotations in AndroidX Test.

Mark TestOutputHandler with @RestrictTo(Scope.LIBRARY) in
open-source exports (via copybara:insert) and with a package-private
internal @HideFromApi annotation in google3 so Metalava and Dackka
exclude it without relying on @hide Javadoc tags.

In google3, external test harnesses still implement TestOutputHandler
(so active @RestrictTo triggers ErrorProne RestrictToEnforcer), and
package-level filtering cannot be used on
androidx.test.internal.platform.util because TestOutputEmitter in
the same package is part of monitor's current_internal.txt.

Using annotations instead of @hide doc tags:

  • Unlocks passing --ignore-comments on API signature generation,
    improving build performance and memory usage by skipping Javadoc/KDoc
    comment extraction and AST parsing.
  • Enables Metalava declarative <api-surfaces> XML configuration,
    which ignores @hide and @removed Javadoc tags by design.
  • Enforces @RestrictTo(Scope.LIBRARY) statically for external callers.

@copybara-service
copybara-service Bot force-pushed the piper_1015650486 branch 5 times, most recently from b6d0198 to 7f78a35 Compare November 9, 2026 20:38
Mark `TestOutputHandler` with `@RestrictTo(Scope.LIBRARY)` in
open-source exports (via `copybara:insert`) and with a package-private
internal `@HideFromApi` annotation in google3 so Metalava and Dackka
exclude it without relying on `@hide` Javadoc tags.

In google3, external test harnesses still implement `TestOutputHandler`
(so active `@RestrictTo` triggers ErrorProne `RestrictToEnforcer`), and
package-level filtering cannot be used on
`androidx.test.internal.platform.util` because `TestOutputEmitter` in
the same package is part of `monitor`'s `current_internal.txt`.

Using annotations instead of `@hide` doc tags:
- Unlocks passing `--ignore-comments` on API signature generation,
  improving build performance and memory usage by skipping Javadoc/KDoc
  comment extraction and AST parsing.
- Enables Metalava declarative `<api-surfaces>` XML configuration,
  which ignores `@hide` and `@removed` Javadoc tags by design.
- Enforces `@RestrictTo(Scope.LIBRARY)` statically for external callers.

PiperOrigin-RevId: 1017570068
@copybara-service
copybara-service Bot merged commit e7f2124 into main Nov 9, 2026
6 checks passed
@copybara-service
copybara-service Bot deleted the piper_1015650486 branch November 9, 2026 20:57
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