Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add apiguardian-api runtime dependency to satisfy ART's internal runtime annotation loader #306

Merged
merged 1 commit into from
Sep 16, 2023

Conversation

mannodermaus
Copy link
Owner

Essentially, @API is added to most of the JUnit 5 annotations. This is an annotation from a library called "API Guardian", which declares a RUNTIME visibility.

For Android specifically, this visibility makes it eligible for native annotation scanning when calling Class.isAnnotationPresent() on any of the JUnit 5 annotations with that meta-annotation. The problem is that JUnit Jupier declares its transitive dependency as "compile-only", causing @API to be absent at runtime. This creates a log statement every time an annotation is queried, causing very noisy logs.

The fix is to submit API Guardian as a runtime-only dependency to the instrumentation core.

Refs:
https://github.com/junit-team/junit5/blob/70e33483530259edef1ab3c1ba12971ac3fc7db7/junit-platform-commons/src/main/java/org/junit/platform/commons/util/AnnotationUtils.java#L136C38-L136C57 https://cs.android.com/android/platform/superproject/main/+/main:art/runtime/dex/dex_file_annotations.cc;l=780-781

Resolves #291.

…ime annotation loader

Essentially, `@API` is added to most of the JUnit 5 annotations. This is an annotation
from a library called "API Guardian", which declares a `RUNTIME` visibility.

For Android specifically, this visibility makes it eligible for native annotation scanning
when calling `Class.isAnnotationPresent()` on any of the JUnit 5 annotations with that meta-annotation.
The problem is that JUnit Jupier declares its transitive dependency as "compile-only",
causing `@API` to be absent at runtime. This creates a log statement every time an annotation
is queried, causing very noisy logs.

The fix is to submit API Guardian as a runtime-only dependency to the instrumentation core.

Refs:
https://github.com/junit-team/junit5/blob/70e33483530259edef1ab3c1ba12971ac3fc7db7/junit-platform-commons/src/main/java/org/junit/platform/commons/util/AnnotationUtils.java#L136C38-L136C57
https://cs.android.com/android/platform/superproject/main/+/main:art/runtime/dex/dex_file_annotations.cc;l=780-781

Resolves #291.
@mannodermaus mannodermaus self-assigned this Sep 16, 2023
@mannodermaus mannodermaus merged commit 562af69 into main Sep 16, 2023
@mannodermaus mannodermaus deleted the 291/fix-noisy-unresolve-annotation-class-logs branch September 16, 2023 15:39
mannodermaus added a commit that referenced this pull request Sep 17, 2023
@mannodermaus mannodermaus added this to the Instrumentation 1.4.0 milestone Sep 17, 2023
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.

Various 'Unable to resolve' log messages for Android tests
1 participant