-
Notifications
You must be signed in to change notification settings - Fork 44
Full reflection with obfuscation #209
Description
We've been wanting to switch to full reflection for a while, but are worried about not being able to obfuscate the class names of our components. The concern here is that if we have a component named SecretExperimentalFeatureComponent, we may expose info on a feature that is hidden behind an experiment.
With the current approach this library takes there's really no getting around the requirement for unobfuscated component class names, so I was wondering how a new approach would be received.
The idea is that we add a new annotation processor that would be run in release mode (or whenever the current dagger-codegen artifact would be used). This processor would go module by module, creating a registry for each. The registry would essentially be a Map<Class, () -> (Component|Builder|Factory)>. An example entry in this map would be key: MyComponent.Factory.class value: { DaggerMyComponent.factory() }. This creates a mapping to generated components that would survive obfuscation. The top-level component would then aggregate these registries and would be able to discover all dagger-generated components using the same Dagger.create, Dagger.factory, and Dagger.builder calls that are already used.
A minor secondary benefit to this approach would be that we'd be back to using no reflection at all for release builds. An obvious downside is that more codegen is required, but it would only be needed for release mode.
I'd be happy to open a PR if there's agreement on this approach. Also very interested to hear what other opinions people might have on this.