[
https://issues.jboss.org/browse/SOLDER-331?page=com.atlassian.jira.plugin...
]
Richard Kennard updated SOLDER-331:
-----------------------------------
Description:
The Solder annotation @Exact does not do what its name implies/JavaDoc states:
"An injection point qualifier that may be used to select the exact bean to be
injected, by specifying its implementation class."
In the test suite it tests:
{{@Inject @Exact(Greyhound.class) private Dog dog;}}
But all @Exact does behind the scenes (in CoreExtension.java) is:
{{if (f.isAnnotationPresent(Exact.class)) { ... builder.overrideFieldType(f, type);}}
So whilst you can make Dog 'exact' into Greyhound, if there exists another class
BetterGreyhound:
{{package org.jboss.solder.test.core; public class BetterGreyhound extends Greyhound}}
You *cannot* make BetterGreyhound into Greyhound. If BetterGreyhound exists and you try:
{{@Inject @Exact(Greyhound.class) private Dog dog;}}
You'll get:
WELD-001409 Ambiguous dependencies for type [Greyhound] with qualifiers [@Default] at
injection point [[field] @Exact @Inject private org.jboss.solder.test.core.RaceTrack.dog].
Possible dependencies [[Managed Bean [class org.jboss.solder.test.core.Greyhound] with
qualifiers [@Any @Default @Named], Managed Bean [class
org.jboss.solder.test.core.BetterGreyhound] with qualifiers [@Any @Default @Named]]]
I think @Exact either:
* needs to be a @Qualifier (which it used to be, and which its JavaDoc states it still
is); or
* needs to be renamed to @AtLeast; or
* needs its JavaDoc fixed to clarify that it can only resolve ambiguious superclasses, not
subclasses
was:
The Solder annotation @Exact is poorly defined, IMHO, because it does not do what its name
implies/JavaDoc states:
"An injection point qualifier that may be used to select the exact bean to be
injected, by specifying its implementation class."
In the test suite it tests:
{{@Inject @Exact(Greyhound.class) private Dog dog;}}
But all @Exact does behind the scenes (in CoreExtension.java) is:
{{if (f.isAnnotationPresent(Exact.class)) { ... builder.overrideFieldType(f, type);}}
So whilst you can make Dog 'exact' into Greyhound, if there exists another class
BetterGreyhound:
{{package org.jboss.solder.test.core; public class BetterGreyhound extends Greyhound {
}}}
You *cannot* make BetterGreyhound into Greyhound. If BetterGreyhound exists and you try:
{{@Inject @Exact(Greyhound.class) private Dog dog;}}
You'll get:
WELD-001409 Ambiguous dependencies for type [Greyhound] with qualifiers [@Default] at
injection point [[field] @Exact @Inject private org.jboss.solder.test.core.RaceTrack.dog].
Possible dependencies [[Managed Bean [class org.jboss.solder.test.core.Greyhound] with
qualifiers [@Any @Default @Named], Managed Bean [class
org.jboss.solder.test.core.BetterGreyhound] with qualifiers [@Any @Default @Named]]]
I think @Exact either:
* needs to be a @Qualifier (which it used to be, and which its JavaDoc states it still
is); or
* needs to be renamed to @AtLeast; or
* needs its JavaDoc fixed to clarify that it can only resolve ambiguious superclasses, not
subclasses
Steps to Reproduce:
Add the following class to the Seam Solder test suite:
{{package org.jboss.solder.test.core; public class BetterGreyhound extends Greyhound}}
Then run 'CoreTest.testExact' and it will fail
was:
Add the following class to the Seam Solder test suite:
{{package org.jboss.solder.test.core; public class BetterGreyhound extends Greyhound {
}}}
Then run 'CoreTest.testExact' and it will fail
@Exact does not do what its name implies/JavaDoc states
-------------------------------------------------------
Key: SOLDER-331
URL:
https://issues.jboss.org/browse/SOLDER-331
Project: Solder
Issue Type: Bug
Components: Core
Affects Versions: 3.1.0.Final
Reporter: Richard Kennard
The Solder annotation @Exact does not do what its name implies/JavaDoc states:
"An injection point qualifier that may be used to select the exact bean to be
injected, by specifying its implementation class."
In the test suite it tests:
{{@Inject @Exact(Greyhound.class) private Dog dog;}}
But all @Exact does behind the scenes (in CoreExtension.java) is:
{{if (f.isAnnotationPresent(Exact.class)) { ... builder.overrideFieldType(f, type);}}
So whilst you can make Dog 'exact' into Greyhound, if there exists another class
BetterGreyhound:
{{package org.jboss.solder.test.core; public class BetterGreyhound extends Greyhound}}
You *cannot* make BetterGreyhound into Greyhound. If BetterGreyhound exists and you try:
{{@Inject @Exact(Greyhound.class) private Dog dog;}}
You'll get:
WELD-001409 Ambiguous dependencies for type [Greyhound] with qualifiers [@Default] at
injection point [[field] @Exact @Inject private org.jboss.solder.test.core.RaceTrack.dog].
Possible dependencies [[Managed Bean [class org.jboss.solder.test.core.Greyhound] with
qualifiers [@Any @Default @Named], Managed Bean [class
org.jboss.solder.test.core.BetterGreyhound] with qualifiers [@Any @Default @Named]]]
I think @Exact either:
* needs to be a @Qualifier (which it used to be, and which its JavaDoc states it still
is); or
* needs to be renamed to @AtLeast; or
* needs its JavaDoc fixed to clarify that it can only resolve ambiguious superclasses,
not subclasses
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see:
http://www.atlassian.com/software/jira