-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Depedency Injection: Diagnostic for Ambigious Dependencies with @Inject
#163
Comments
Can you link/quote where in the spec this is mentioned and provide an example of how this might look? |
@Inject
and @Qualifiers
@Inject
and @Qualifiers
@Inject
, @Qualifiers
and @Default
@Inject
, @Qualifiers
and @Default
@Inject
, @Qualifiers
and @Default
@Inject
, @Qualifiers
and @Default
@Inject
, @Qualifiers
, @Default
and @Named
@AlvinTan2000 Does this section of the CDI spec cover the ambiguous injection you are referring to? If so, we need to come up with some concrete ways of checking whether it is an ambiguous injection |
@Inject
, @Qualifiers
, @Default
and @Named
@Inject
, @Qualifiers
, @Alternative
and @Named
@Inject
, @Qualifiers
, @Alternative
and @Named
@Inject
Provided some examples code demonstrating the errors. |
What conditions would we check for when delivering the diagnostic? |
We would check for the whether all the applicable sub-classes share the conflicting annotations, which would depend on #159 |
How to check for ambiguous injection (expanding on the error identification section above):
@Inject
private GreetingItf greeting;
public interface GreetingItf {
public String greet(String greeting);
}
Detecting if every implementation has the same bean attributes gets a bit tricky, the logic is if every implementation has:
To start, we can cover the base case and iteratively build up support.
@ApplicationScoped
public class GreetingA implements GreetingItf{
public String greet(String name) {
return "GreetingA, " + name;
}
} @ApplicationScoped
public class GreetingB implements GreetingItf{
public String greet(String name) {
return "GreetingB, " + name;
}
} We can break this issue down into subsequent tasks and iteratively build:
|
AND IF Don't think it is possible to purposely create an ambiguous error with just a single |
What is ambiguous dependency?
Dependency injection and lookup
Which Java classes are managed beans?
Beans and Attributes
Error Identification:
@Inject
and a set of default or user-specified bean attributes@Qualifiers
@Alternative
)@Priority
)@Named
@Type
(TODO)Note: if no classes match the set of bean attributes, it is an unsatisfied error, refer to #164
Potential Diagnostics:
@Inject
field/method/constructorExample error for
@Alternative
:Note: The diagnostics and error identification depends on #159 for reading class information across files.
Related to #153
The text was updated successfully, but these errors were encountered: