You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openwebbeans.apache.org by "Bill Wigger (JIRA)" <ji...@apache.org> on 2010/01/21 19:44:54 UTC
[jira] Created: (OWB-245) Using parameterized type varaibles fails
for Producer Method injection
Using parameterized type varaibles fails for Producer Method injection
----------------------------------------------------------------------
Key: OWB-245
URL: https://issues.apache.org/jira/browse/OWB-245
Project: OpenWebBeans
Issue Type: Bug
Components: Injection and Lookup
Affects Versions: M3
Environment: Windows, Eclipse running Jetty.
Reporter: Bill Wigger
Assignee: Gurkan Erdogdu
Fix For: M3
As per section 3.3 of the spec:
"If the producer method return type is a parameterized type, it must specify an actual type parameter or type variable for each type parameter."
Problem using @Inject
The below code fragment is for a parameterized type variable, and the inject is yielding an exception, instead of being injected properly.
public class MethodTypeProduces1<T> {
@Produces @Dependent @Named("ProMethodParameterized3") ArrayList<T> methodPT3() { ... }
}
Inject it as follows:
public @Inject @Dependent @Named("ProMethodParameterized3") ArrayList<String> pt3;
the following error occurs:
javax.enterprise.inject.UnsatisfiedResolutionException: Api type [java.util.ArrayList] is not found with the qualifiers [@javax.inject.Named(value=ProMethodParameterized3)]
at org.apache.webbeans.container.ResolutionUtil.checkResolvedBeans(ResolutionUtil.java:93)
at org.apache.webbeans.container.InjectionResolver.getInjectionPointBean(InjectionResolver.java:232)
Problem when access via the Bean Manager:
Using this as the producer:
@Produces @Dependent @Named("ProMethodParameterized3S") ArrayList<String> methodPT4() { .. }
I can get a reference to it with the following code:
TypeLiteral<ArrayList<String>> x = new TypeLiteral<ArrayList<String>>() { };
Bean<ArrayList<String>> iBean = (Bean<ArrayList<String>>) manager.getBeans("ProMethodParameterized3S").iterator().next();
ArrayList<String> as = (ArrayList<String>) manager.getReference(iBean, x.getType() , manager.createCreationalContext(iBean));
But it this is the producer:
public class MethodTypeProduces1<T> {
//Test: Parameterized Field
@Produces @Dependent @Named("ProMethodParameterized3") ArrayList<T> methodPT3() { ... }
then the following fails:
TypeLiteral<ArrayList<String>> x = new TypeLiteral<ArrayList<String>>() { };
Bean<ArrayList<String>> iBean = (Bean<ArrayList<String>>) manager.getBeans("ProMethodParameterized3").iterator().next();
ArrayList<String> as = (ArrayList<String>) manager.getReference(iBean, x.getType() , manager.createCreationalContext(iBean));
with an exception when the manager.getReference(....) is called:
java.lang.IllegalArgumentException: Given bean type : java.util.ArrayList<java.lang.String> is not applicable for the bean instance : Name:ProMethodParameterized3,WebBeans Type:PRODUCERMETHOD,API Types:...java.util.ArrayList...
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Closed: (OWB-245) Using parameterized type varaibles fails
for Producer Method injection
Posted by "Gurkan Erdogdu (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/OWB-245?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Gurkan Erdogdu closed OWB-245.
------------------------------
Resolution: Fixed
> Using parameterized type varaibles fails for Producer Method injection
> ----------------------------------------------------------------------
>
> Key: OWB-245
> URL: https://issues.apache.org/jira/browse/OWB-245
> Project: OpenWebBeans
> Issue Type: Bug
> Components: Injection and Lookup
> Affects Versions: M3
> Environment: Windows, Eclipse running Jetty.
> Reporter: Bill Wigger
> Assignee: Gurkan Erdogdu
> Fix For: 1.0.0
>
>
> As per section 3.3 of the spec:
> "If the producer method return type is a parameterized type, it must specify an actual type parameter or type variable for each type parameter."
> Problem using @Inject
> The below code fragment is for a parameterized type variable, and the inject is yielding an exception, instead of being injected properly.
> public class MethodTypeProduces1<T> {
> @Produces @Dependent @Named("ProMethodParameterized3") ArrayList<T> methodPT3() { ... }
> }
>
> Inject it as follows:
> public @Inject @Dependent @Named("ProMethodParameterized3") ArrayList<String> pt3;
> the following error occurs:
> javax.enterprise.inject.UnsatisfiedResolutionException: Api type [java.util.ArrayList] is not found with the qualifiers [@javax.inject.Named(value=ProMethodParameterized3)]
> at org.apache.webbeans.container.ResolutionUtil.checkResolvedBeans(ResolutionUtil.java:93)
> at org.apache.webbeans.container.InjectionResolver.getInjectionPointBean(InjectionResolver.java:232)
> Problem when access via the Bean Manager:
> Using this as the producer:
> @Produces @Dependent @Named("ProMethodParameterized3S") ArrayList<String> methodPT4() { .. }
> I can get a reference to it with the following code:
> TypeLiteral<ArrayList<String>> x = new TypeLiteral<ArrayList<String>>() { };
> Bean<ArrayList<String>> iBean = (Bean<ArrayList<String>>) manager.getBeans("ProMethodParameterized3S").iterator().next();
> ArrayList<String> as = (ArrayList<String>) manager.getReference(iBean, x.getType() , manager.createCreationalContext(iBean));
> But it this is the producer:
> public class MethodTypeProduces1<T> {
>
> //Test: Parameterized Field
> @Produces @Dependent @Named("ProMethodParameterized3") ArrayList<T> methodPT3() { ... }
> then the following fails:
> TypeLiteral<ArrayList<String>> x = new TypeLiteral<ArrayList<String>>() { };
> Bean<ArrayList<String>> iBean = (Bean<ArrayList<String>>) manager.getBeans("ProMethodParameterized3").iterator().next();
> ArrayList<String> as = (ArrayList<String>) manager.getReference(iBean, x.getType() , manager.createCreationalContext(iBean));
> with an exception when the manager.getReference(....) is called:
> java.lang.IllegalArgumentException: Given bean type : java.util.ArrayList<java.lang.String> is not applicable for the bean instance : Name:ProMethodParameterized3,WebBeans Type:PRODUCERMETHOD,API Types:...java.util.ArrayList...
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (OWB-245) Using parameterized type varaibles fails
for Producer Method injection
Posted by "Gurkan Erdogdu (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/OWB-245?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Gurkan Erdogdu updated OWB-245:
-------------------------------
Fix Version/s: (was: M3)
1.0.0
If this will be evaluated as Bug, fixed to version 1.0.0
> Using parameterized type varaibles fails for Producer Method injection
> ----------------------------------------------------------------------
>
> Key: OWB-245
> URL: https://issues.apache.org/jira/browse/OWB-245
> Project: OpenWebBeans
> Issue Type: Bug
> Components: Injection and Lookup
> Affects Versions: M3
> Environment: Windows, Eclipse running Jetty.
> Reporter: Bill Wigger
> Assignee: Gurkan Erdogdu
> Fix For: 1.0.0
>
>
> As per section 3.3 of the spec:
> "If the producer method return type is a parameterized type, it must specify an actual type parameter or type variable for each type parameter."
> Problem using @Inject
> The below code fragment is for a parameterized type variable, and the inject is yielding an exception, instead of being injected properly.
> public class MethodTypeProduces1<T> {
> @Produces @Dependent @Named("ProMethodParameterized3") ArrayList<T> methodPT3() { ... }
> }
>
> Inject it as follows:
> public @Inject @Dependent @Named("ProMethodParameterized3") ArrayList<String> pt3;
> the following error occurs:
> javax.enterprise.inject.UnsatisfiedResolutionException: Api type [java.util.ArrayList] is not found with the qualifiers [@javax.inject.Named(value=ProMethodParameterized3)]
> at org.apache.webbeans.container.ResolutionUtil.checkResolvedBeans(ResolutionUtil.java:93)
> at org.apache.webbeans.container.InjectionResolver.getInjectionPointBean(InjectionResolver.java:232)
> Problem when access via the Bean Manager:
> Using this as the producer:
> @Produces @Dependent @Named("ProMethodParameterized3S") ArrayList<String> methodPT4() { .. }
> I can get a reference to it with the following code:
> TypeLiteral<ArrayList<String>> x = new TypeLiteral<ArrayList<String>>() { };
> Bean<ArrayList<String>> iBean = (Bean<ArrayList<String>>) manager.getBeans("ProMethodParameterized3S").iterator().next();
> ArrayList<String> as = (ArrayList<String>) manager.getReference(iBean, x.getType() , manager.createCreationalContext(iBean));
> But it this is the producer:
> public class MethodTypeProduces1<T> {
>
> //Test: Parameterized Field
> @Produces @Dependent @Named("ProMethodParameterized3") ArrayList<T> methodPT3() { ... }
> then the following fails:
> TypeLiteral<ArrayList<String>> x = new TypeLiteral<ArrayList<String>>() { };
> Bean<ArrayList<String>> iBean = (Bean<ArrayList<String>>) manager.getBeans("ProMethodParameterized3").iterator().next();
> ArrayList<String> as = (ArrayList<String>) manager.getReference(iBean, x.getType() , manager.createCreationalContext(iBean));
> with an exception when the manager.getReference(....) is called:
> java.lang.IllegalArgumentException: Given bean type : java.util.ArrayList<java.lang.String> is not applicable for the bean instance : Name:ProMethodParameterized3,WebBeans Type:PRODUCERMETHOD,API Types:...java.util.ArrayList...
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (OWB-245) Using parameterized type varaibles
fails for Producer Method injection
Posted by "Gurkan Erdogdu (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/OWB-245?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12803761#action_12803761 ]
Gurkan Erdogdu commented on OWB-245:
------------------------------------
Please look at test case using generics:
https://svn.apache.org/repos/asf/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/generic/GenericBeanTest.java
> Using parameterized type varaibles fails for Producer Method injection
> ----------------------------------------------------------------------
>
> Key: OWB-245
> URL: https://issues.apache.org/jira/browse/OWB-245
> Project: OpenWebBeans
> Issue Type: Bug
> Components: Injection and Lookup
> Affects Versions: M3
> Environment: Windows, Eclipse running Jetty.
> Reporter: Bill Wigger
> Assignee: Gurkan Erdogdu
> Fix For: 1.0.0
>
>
> As per section 3.3 of the spec:
> "If the producer method return type is a parameterized type, it must specify an actual type parameter or type variable for each type parameter."
> Problem using @Inject
> The below code fragment is for a parameterized type variable, and the inject is yielding an exception, instead of being injected properly.
> public class MethodTypeProduces1<T> {
> @Produces @Dependent @Named("ProMethodParameterized3") ArrayList<T> methodPT3() { ... }
> }
>
> Inject it as follows:
> public @Inject @Dependent @Named("ProMethodParameterized3") ArrayList<String> pt3;
> the following error occurs:
> javax.enterprise.inject.UnsatisfiedResolutionException: Api type [java.util.ArrayList] is not found with the qualifiers [@javax.inject.Named(value=ProMethodParameterized3)]
> at org.apache.webbeans.container.ResolutionUtil.checkResolvedBeans(ResolutionUtil.java:93)
> at org.apache.webbeans.container.InjectionResolver.getInjectionPointBean(InjectionResolver.java:232)
> Problem when access via the Bean Manager:
> Using this as the producer:
> @Produces @Dependent @Named("ProMethodParameterized3S") ArrayList<String> methodPT4() { .. }
> I can get a reference to it with the following code:
> TypeLiteral<ArrayList<String>> x = new TypeLiteral<ArrayList<String>>() { };
> Bean<ArrayList<String>> iBean = (Bean<ArrayList<String>>) manager.getBeans("ProMethodParameterized3S").iterator().next();
> ArrayList<String> as = (ArrayList<String>) manager.getReference(iBean, x.getType() , manager.createCreationalContext(iBean));
> But it this is the producer:
> public class MethodTypeProduces1<T> {
>
> //Test: Parameterized Field
> @Produces @Dependent @Named("ProMethodParameterized3") ArrayList<T> methodPT3() { ... }
> then the following fails:
> TypeLiteral<ArrayList<String>> x = new TypeLiteral<ArrayList<String>>() { };
> Bean<ArrayList<String>> iBean = (Bean<ArrayList<String>>) manager.getBeans("ProMethodParameterized3").iterator().next();
> ArrayList<String> as = (ArrayList<String>) manager.getReference(iBean, x.getType() , manager.createCreationalContext(iBean));
> with an exception when the manager.getReference(....) is called:
> java.lang.IllegalArgumentException: Given bean type : java.util.ArrayList<java.lang.String> is not applicable for the bean instance : Name:ProMethodParameterized3,WebBeans Type:PRODUCERMETHOD,API Types:...java.util.ArrayList...
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (OWB-245) Using parameterized type varaibles
fails for Producer Method injection
Posted by "Gurkan Erdogdu (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/OWB-245?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12803437#action_12803437 ]
Gurkan Erdogdu commented on OWB-245:
------------------------------------
Please look at section 5.2.3. Assignability of raw and parameterized types. I think that OWB behaves correctly.
> Using parameterized type varaibles fails for Producer Method injection
> ----------------------------------------------------------------------
>
> Key: OWB-245
> URL: https://issues.apache.org/jira/browse/OWB-245
> Project: OpenWebBeans
> Issue Type: Bug
> Components: Injection and Lookup
> Affects Versions: M3
> Environment: Windows, Eclipse running Jetty.
> Reporter: Bill Wigger
> Assignee: Gurkan Erdogdu
> Fix For: M3
>
>
> As per section 3.3 of the spec:
> "If the producer method return type is a parameterized type, it must specify an actual type parameter or type variable for each type parameter."
> Problem using @Inject
> The below code fragment is for a parameterized type variable, and the inject is yielding an exception, instead of being injected properly.
> public class MethodTypeProduces1<T> {
> @Produces @Dependent @Named("ProMethodParameterized3") ArrayList<T> methodPT3() { ... }
> }
>
> Inject it as follows:
> public @Inject @Dependent @Named("ProMethodParameterized3") ArrayList<String> pt3;
> the following error occurs:
> javax.enterprise.inject.UnsatisfiedResolutionException: Api type [java.util.ArrayList] is not found with the qualifiers [@javax.inject.Named(value=ProMethodParameterized3)]
> at org.apache.webbeans.container.ResolutionUtil.checkResolvedBeans(ResolutionUtil.java:93)
> at org.apache.webbeans.container.InjectionResolver.getInjectionPointBean(InjectionResolver.java:232)
> Problem when access via the Bean Manager:
> Using this as the producer:
> @Produces @Dependent @Named("ProMethodParameterized3S") ArrayList<String> methodPT4() { .. }
> I can get a reference to it with the following code:
> TypeLiteral<ArrayList<String>> x = new TypeLiteral<ArrayList<String>>() { };
> Bean<ArrayList<String>> iBean = (Bean<ArrayList<String>>) manager.getBeans("ProMethodParameterized3S").iterator().next();
> ArrayList<String> as = (ArrayList<String>) manager.getReference(iBean, x.getType() , manager.createCreationalContext(iBean));
> But it this is the producer:
> public class MethodTypeProduces1<T> {
>
> //Test: Parameterized Field
> @Produces @Dependent @Named("ProMethodParameterized3") ArrayList<T> methodPT3() { ... }
> then the following fails:
> TypeLiteral<ArrayList<String>> x = new TypeLiteral<ArrayList<String>>() { };
> Bean<ArrayList<String>> iBean = (Bean<ArrayList<String>>) manager.getBeans("ProMethodParameterized3").iterator().next();
> ArrayList<String> as = (ArrayList<String>) manager.getReference(iBean, x.getType() , manager.createCreationalContext(iBean));
> with an exception when the manager.getReference(....) is called:
> java.lang.IllegalArgumentException: Given bean type : java.util.ArrayList<java.lang.String> is not applicable for the bean instance : Name:ProMethodParameterized3,WebBeans Type:PRODUCERMETHOD,API Types:...java.util.ArrayList...
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (OWB-245) Using parameterized type varaibles
fails for Producer Method injection
Posted by "Bill Wigger (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/OWB-245?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12803693#action_12803693 ]
Bill Wigger commented on OWB-245:
---------------------------------
in section 5.2.3 it says: "the required type parameter is an actual type, the bean type parameter is a type variable and the actual type is assignable to the upper bound, if any, of the type variable, or ....
and in section 3.3 is says:
""If the producer method return type is a parameterized type, it must specify an actual type parameter or type variable for each type parameter."
So in the code above my reasoning was tht the bean type is a type variable. So why are those exampes wrong? and what would then be an example of valid parameterized type variable usage?
> Using parameterized type varaibles fails for Producer Method injection
> ----------------------------------------------------------------------
>
> Key: OWB-245
> URL: https://issues.apache.org/jira/browse/OWB-245
> Project: OpenWebBeans
> Issue Type: Bug
> Components: Injection and Lookup
> Affects Versions: M3
> Environment: Windows, Eclipse running Jetty.
> Reporter: Bill Wigger
> Assignee: Gurkan Erdogdu
> Fix For: M3
>
>
> As per section 3.3 of the spec:
> "If the producer method return type is a parameterized type, it must specify an actual type parameter or type variable for each type parameter."
> Problem using @Inject
> The below code fragment is for a parameterized type variable, and the inject is yielding an exception, instead of being injected properly.
> public class MethodTypeProduces1<T> {
> @Produces @Dependent @Named("ProMethodParameterized3") ArrayList<T> methodPT3() { ... }
> }
>
> Inject it as follows:
> public @Inject @Dependent @Named("ProMethodParameterized3") ArrayList<String> pt3;
> the following error occurs:
> javax.enterprise.inject.UnsatisfiedResolutionException: Api type [java.util.ArrayList] is not found with the qualifiers [@javax.inject.Named(value=ProMethodParameterized3)]
> at org.apache.webbeans.container.ResolutionUtil.checkResolvedBeans(ResolutionUtil.java:93)
> at org.apache.webbeans.container.InjectionResolver.getInjectionPointBean(InjectionResolver.java:232)
> Problem when access via the Bean Manager:
> Using this as the producer:
> @Produces @Dependent @Named("ProMethodParameterized3S") ArrayList<String> methodPT4() { .. }
> I can get a reference to it with the following code:
> TypeLiteral<ArrayList<String>> x = new TypeLiteral<ArrayList<String>>() { };
> Bean<ArrayList<String>> iBean = (Bean<ArrayList<String>>) manager.getBeans("ProMethodParameterized3S").iterator().next();
> ArrayList<String> as = (ArrayList<String>) manager.getReference(iBean, x.getType() , manager.createCreationalContext(iBean));
> But it this is the producer:
> public class MethodTypeProduces1<T> {
>
> //Test: Parameterized Field
> @Produces @Dependent @Named("ProMethodParameterized3") ArrayList<T> methodPT3() { ... }
> then the following fails:
> TypeLiteral<ArrayList<String>> x = new TypeLiteral<ArrayList<String>>() { };
> Bean<ArrayList<String>> iBean = (Bean<ArrayList<String>>) manager.getBeans("ProMethodParameterized3").iterator().next();
> ArrayList<String> as = (ArrayList<String>) manager.getReference(iBean, x.getType() , manager.createCreationalContext(iBean));
> with an exception when the manager.getReference(....) is called:
> java.lang.IllegalArgumentException: Given bean type : java.util.ArrayList<java.lang.String> is not applicable for the bean instance : Name:ProMethodParameterized3,WebBeans Type:PRODUCERMETHOD,API Types:...java.util.ArrayList...
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.