You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The member injector would not be generated, but we need it. We could add @Injectto init, but @Override is not mandatory and if it is omitted, init would be called twice during initialization.
3) Let's imaging now a slightly different example:
This is an invalid use case.
Methods that are inject annotated should not be overriden.
They are similar to "constructors", constructor cannot be overriden.
They make it difficult for the user to understand what's going on.
From a technical point of view, it is not possible for TP to find out all overrides.
Thus, we discourage to override any inject annotated method. To make it clearer a warning is displayed whenever a inject annotated method has PUBLIC or PROTECTED visibility:
@Inject annotated methods should have protect visibility...
There are some issues regarding the Methods Injects, overrides and inheritance:
1) Initialization should use the order: First inject
@Inject
annotated fields, then call@Inject
annotated methods.However, for the example if we inject B, the order is:
Which is wrong. Inside its init method, B can assume all fields are injected, and this didn't happen yet.
2) If B was like this:
The
member injector
would not be generated, but we need it. We could add@Inject
toinit
, but@Override
is not mandatory and if it is omitted,init
would be called twice during initialization.3) Let's imaging now a slightly different example:
Will
init
be called when injecting B using its member injector?The text was updated successfully, but these errors were encountered: