Isolate the IServiceCallback registration behind its own class - #926
Merged
Conversation
ART resolves the superclass of every type a method mentions when it verifies that method, not when the branch mentioning it runs. The `Build.VERSION.SDK_INT >= R` gate therefore never got a chance to help: verifying registerProxyService resolved the anonymous callback, that resolved `android.os.IServiceCallback$Stub`, and on Android 9 the daemon logged a NoClassDefFoundError for its very first call even though the guarded code was never executed. Move the callback into a holder object that the gate only touches on R and newer, so the resolution is deferred to its class initialization, and pin the holder in the R8 rules so a release build cannot inline it back into the caller and reintroduce the reference. Fixes #925
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On Android 9 the daemon logs a
NoClassDefFoundErrorforandroid.os.IServiceCallback$Stubbefore it prints anything of its own. The reported stack tops out atVectorDaemon.mainwithClassLoader.loadClassframes, which is the giveaway: this is ART resolving classes while it verifiesregisterProxyService, not while it runs it.IServiceCallbackonly exists since Android R, and the callback was written as an anonymousobject : IServiceCallback.Stub()inside theSDK_INT >= Rbranch. That gate could never work — ART resolves every type a method mentions at verification time, and loading that type resolves its superclass, so the reference alone was enough.