{"action":"created","issue":{"url":"https://api.github.com/repos/google/dagger/issues/241","labels_url":"https://api.github.com/repos/google/dagger/issues/241/labels{/name}","comments_url":"https://api.github.com/repos/google/dagger/issues/241/comments","events_url":"https://api.github.com/repos/google/dagger/issues/241/events","html_url":"https://github.com/google/dagger/issues/241","id":109664644,"number":241,"title":"Component initialization happening in wrong order, causing crash","user":{"login":"spierce7","id":871169,"avatar_url":"https://avatars.githubusercontent.com/u/871169?v=3","gravatar_id":"","url":"https://api.github.com/users/spierce7","html_url":"https://github.com/spierce7","followers_url":"https://api.github.com/users/spierce7/followers","following_url":"https://api.github.com/users/spierce7/following{/other_user}","gists_url":"https://api.github.com/users/spierce7/gists{/gist_id}","starred_url":"https://api.github.com/users/spierce7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spierce7/subscriptions","organizations_url":"https://api.github.com/users/spierce7/orgs","repos_url":"https://api.github.com/users/spierce7/repos","events_url":"https://api.github.com/users/spierce7/events{/privacy}","received_events_url":"https://api.github.com/users/spierce7/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-10-04T05:45:35Z","updated_at":"2015-10-05T19:18:06Z","closed_at":"2015-10-05T19:18:06Z","body":"In one of the `*_MembersInjector` class I'm seeing a NPE crash in the `injectMembers()` method, on the line: `supertypeInjector.injectMembers(instance);`.\r\n\r\nAfter reviewing the generated code, I've been able to determine that supertypeInjector is null due to a bug in the initialization logic. The initialization logic has 6 steps for this component:\r\n\r\n```Java\r\n    private ActivityComponentImpl(ActivityModule activityModule) {  \r\n      if (activityModule == null) {\r\n        throw new NullPointerException();\r\n      }\r\n      this.activityModule = activityModule;\r\n      initialize();\r\n      initialize1();\r\n      initialize2();\r\n      initialize3();\r\n      initialize4();\r\n      initialize5();\r\n    }\r\n```\r\n\r\nin the `initialize()` method, the `baseActivityMembersInjector` is being passed in to the creation of the `MainActivity_MembersInjector.create()` as the `supertypeInjector`. At the point that it's being passed in though, it's null. The `baseActivityMembersInjector` is not actually being initialized until `initialize4()`.\r\n\r\nI've tinkered with it a bit, and I've been able to identify where the compiler is getting confused. I'll describe the system to you:\r\n\r\nI have 2 components:\r\n```Java\r\n@Singleton\r\n@Component\r\npublic interface ApplicationComponent {\r\n    ActivityComponent plus(ActivityModule activityModule);\r\n    void inject(Activity2 obj);\r\n}\r\n```\r\n\r\n```Java\r\n@Singleton\r\n@Subcomponent\r\npublic interface ActivityComponent {\r\n    void inject(MainActivity obj);\r\n}\r\n```\r\n\r\nI have 2 Activities: `MainActivity`, and `Activity2`. Both of these activities extend `BaseActivity`. `BaseActivity`'s MembersInjector creation time is the issue. When I move `void inject(Activity2 obj);` from the `ApplicationComponent` to the `ActivityComponent`, everything works out fine and the crash doesn't happen.\r\n\r\nThis is not a complete representation of the dagger setup in my project. My dependency graph is far larger, but this should isolate the issue so that it's reproducible."},"comment":{"url":"https://api.github.com/repos/google/dagger/issues/comments/145636648","html_url":"https://github.com/google/dagger/issues/241#issuecomment-145636648","issue_url":"https://api.github.com/repos/google/dagger/issues/241","id":145636648,"user":{"login":"spierce7","id":871169,"avatar_url":"https://avatars.githubusercontent.com/u/871169?v=3","gravatar_id":"","url":"https://api.github.com/users/spierce7","html_url":"https://github.com/spierce7","followers_url":"https://api.github.com/users/spierce7/followers","following_url":"https://api.github.com/users/spierce7/following{/other_user}","gists_url":"https://api.github.com/users/spierce7/gists{/gist_id}","starred_url":"https://api.github.com/users/spierce7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spierce7/subscriptions","organizations_url":"https://api.github.com/users/spierce7/orgs","repos_url":"https://api.github.com/users/spierce7/repos","events_url":"https://api.github.com/users/spierce7/events{/privacy}","received_events_url":"https://api.github.com/users/spierce7/received_events","type":"User","site_admin":false},"created_at":"2015-10-05T19:18:06Z","updated_at":"2015-10-05T19:18:06Z","body":"Looks like you are right. Thanks!"}}