Skip to content

Pre-filter candidate test classes via DEX bytecode tables. - #2510

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

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

Conversation

@copybara-service

Copy link
Copy Markdown

Pre-filter candidate test classes via DEX bytecode tables.

On-device test discovery loads every non-excluded top-level class in the APK via Class.forName() before JUnit inspects annotations or superclasses, causing high startup latency and ClassLoader heap exhaustion on large APKs.

DexBytecodeScanner reads each classes*.dex entry in turn (memory-mapped if stored uncompressed, otherwise via ZipFile) and checks its string/type tables and class_def_item inheritance chains for JUnit3 (TestCase, suite()) and JUnit4 (@Test, @RunWith, @Ignore) signals before class loading. Marker descriptors are derived from class literals so they match ProGuard/R8-obfuscated APKs. Falls back to DexFile scanning if the APK has no JUnit4 marker types or no candidates are found.

The scanner is disabled by default. AndroidClasspathSuite enables it when the useDexBytecodeScanner instrumentation argument is true (-e useDexBytecodeScanner true).

On-device test discovery loads every non-excluded top-level class in the APK via `Class.forName()` before JUnit inspects annotations or superclasses, causing high startup latency and `ClassLoader` heap exhaustion on large APKs.

`DexBytecodeScanner` reads each `classes*.dex` entry in turn (memory-mapped if stored uncompressed, otherwise via `ZipFile`) and checks its string/type tables and `class_def_item` inheritance chains for JUnit3 (`TestCase`, `suite()`) and JUnit4 (`@Test`, `@RunWith`, `@Ignore`) signals before class loading. Marker descriptors are derived from class literals so they match ProGuard/R8-obfuscated APKs. Falls back to `DexFile` scanning if the APK has no JUnit4 marker types or no candidates are found.

The scanner is disabled by default. `AndroidClasspathSuite` enables it when the `useDexBytecodeScanner` instrumentation argument is `true` (`-e useDexBytecodeScanner true`).

PiperOrigin-RevId: 994609846

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