[JBoss JIRA] Created: (WELD-218) Check and fix if type variables are allowed on observes methods
by Kabir Khan (JIRA)
Check and fix if type variables are allowed on observes methods
---------------------------------------------------------------
Key: WELD-218
URL: https://jira.jboss.org/jira/browse/WELD-218
Project: Weld
Issue Type: Feature Request
Affects Versions: 1.0.0.CR1
Reporter: Kabir Khan
Fix For: 1.0.0.CR2
Kabir:
I have tried;
public void processInjectionTarget(@Observes ProcessInjectionTarget<?> event)
{
AnnotatedType<?> type = event.getAnnotatedType();
WeldKernelControllerContext context = WeldFromMcRegistry.getContext(type);
if (context != null)
{
InjectionTarget<?> target = event.getInjectionTarget();
@SuppressWarnings("unchecked")
ExistingInstanceInjectionTarget<?> wrappedTarget = new ExistingInstanceInjectionTarget(target, context.getTarget());
event.setInjectionTarget(wrappedTarget);
}
}
This does not compile with the error:
The method setInjectionTarget(InjectionTarget<capture#6-of ?>) in the type ProcessInjectionTarget<capture#6-of ?> is not applicable for the arguments (ExistingInstanceInjectionTarget<capture#7-of ?>)
Pete:
Yes, this is the correct approach, as it will observe all events.
Kabir:
However, the call to event.setInjectionTarget() does not compile in this case. I've had to do the following:
public void processInjectionTarget(@Observes @SuppressWarnings("unchecked") ProcessInjectionTarget event)
{
AnnotatedType<?> type = event.getAnnotatedType();
WeldKernelControllerContext context = WeldFromMcRegistry.getContext(type);
if (context != null)
{
InjectionTarget<?> target = event.getInjectionTarget();
@SuppressWarnings("unchecked")
ExistingInstanceInjectionTarget tgt = new ExistingInstanceInjectionTarget(target, context.getTarget());
event.setInjectionTarget(tgt);
}
}
Pete:
Ok, this is fixable if type variables are allowed on observes methods.
Kabir:
public <X> void processInjectionTarget(@Observes ProcessInjectionTarget<X> event)
{
AnnotatedType<?> type = event.getAnnotatedType();
WeldKernelControllerContext context = WeldFromMcRegistry.getContext(type);
if (context != null)
{
InjectionTarget<X> target = event.getInjectionTarget();
ExistingInstanceInjectionTarget<X> wrappedTarget = new ExistingInstanceInjectionTarget<X>(target, context.getTarget());
event.setInjectionTarget(wrappedTarget);
}
}
which compiles, but gives:
org.jboss.weld.DefinitionException: Cannot use a type variable X in an parameterized type Observer Implementation:
Observer (Declaring) class: class org.jboss.test.kernel.weld.mctowb.support.validateobserver.TestObserver Observer method: method public void org.jboss.test.kernel.weld.mctowb.support.validateobserver.TestObserver.processInjectionTarget(javax.enterprise.inject.spi.ProcessInjectionTarget)
at org.jboss.weld.event.ObserverMethodImpl.checkObserverMethod(ObserverMethodImpl.java:118)
at org.jboss.weld.event.ObserverMethodImpl.initialize(ObserverMethodImpl.java:191)
Pete:
I *believe* this is a bug in the RI. Could you do me a favour, and scour the Events chapter, and make sure it doesn't restrict you from putting a parameterized type in an @Observes parameter? If it doesn't, file a bug for CR2. I will fix it asap.
Kabir:
I'm not 100% sure, but I don't think I saw anything there regarding type variables.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 6 months
[JBoss JIRA] Created: (WELD-216) testNonStaticInnerClassWithGenericTypes() is failing
by Shane Bryzak (JIRA)
testNonStaticInnerClassWithGenericTypes() is failing
----------------------------------------------------
Key: WELD-216
URL: https://jira.jboss.org/jira/browse/WELD-216
Project: Weld
Issue Type: Bug
Components: Testing Infrastructure (Mocks and Harness Integration)
Reporter: Shane Bryzak
In the package org.jboss.weld.test.unit.implementation.annotatedItem.ClassAnnotatedItemTest the test is failing:
java.lang.ArrayIndexOutOfBoundsException: 1
at org.jboss.weld.introspector.jlr.WeldConstructorImpl.<init>(WeldConstructorImpl.java:124)
at org.jboss.weld.introspector.jlr.WeldConstructorImpl.of(WeldConstructorImpl.java:81)
at org.jboss.weld.introspector.jlr.WeldClassImpl.<init>(WeldClassImpl.java:298)
at org.jboss.weld.introspector.jlr.WeldClassImpl.of(WeldClassImpl.java:137)
at org.jboss.weld.test.unit.implementation.annotatedItem.ClassAnnotatedItemTest.testNonStaticInnerClassWithGenericTypes(ClassAnnotatedItemTest.java:59)
at org.jboss.testharness.AbstractTest.run(AbstractTest.java:244)
at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:74)
at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:92)
at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
... Removed 29 stack frames
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 6 months
[JBoss JIRA] Closed: (WELD-14) Check passivating bean's interceptors are passivation capable
by Pete Muir (JIRA)
[ https://jira.jboss.org/jira/browse/WELD-14?page=com.atlassian.jira.plugin... ]
Pete Muir closed WELD-14.
-------------------------
> Check passivating bean's interceptors are passivation capable
> --------------------------------------------------------------
>
> Key: WELD-14
> URL: https://jira.jboss.org/jira/browse/WELD-14
> Project: Weld
> Issue Type: Bug
> Components: Class Beans (Managed and Session)
> Reporter: Pete Muir
> Assignee: Marius Bogoevici
> Fix For: 1.0.0.CR2
>
>
> org.jboss.jsr299.tck.tests.context.passivating.broken.enterpriseBeanWithNonPassivatingBeanConstructorParameterInInterceptor.EnterpriseBeanWithNonPassivatingBeanConstructorParameterInInterceptorTest.testSessionBeanWithNonPassivatingBeanConstructorParamInInterceptorFails()
> org.jboss.jsr299.tck.tests.context.passivating.broken.enterpriseBeanWithNonPassivatingInitializerParameterInInterceptor.EnterpriseBeanWithNonPassivatingInitializerParameterInInterceptorTest.testSessionBeanWithNonPassivatingInitializerParamInInterceptorFails()
> org.jboss.jsr299.tck.tests.context.passivating.broken.enterpriseBeanWithNonPassivatingInjectedFieldInInterceptor.EnterpriseBeanWithNonPassivatingInjectedFieldInInterceptorTest.testSessionBeanWithNonPassivatingInjectedFieldInInterceptorFails()
> org.jboss.jsr299.tck.tests.context.passivating.broken.interceptorWithNonPassivatingInitializerMethodParameter.PassivationCapableBeanWithNonPassivatingInterceptorTest.testPassivationCapableBeanWithNonPassivatingInterceptorFails()
> org.jboss.jsr299.tck.tests.context.passivating.broken.interceptorWithNonPassivatingBeanConstructorParameter.PassivationCapableBeanWithNonPassivatingInterceptorTest.testPassivationCapableBeanWithNonPassivatingInterceptorFails()
> org.jboss.jsr299.tck.tests.context.passivating.broken.managedBeanWithNonSerializableInterceptorClass.ManagedBeanWithNonSerializableInterceptorClassTest.testManagedBeanWithNonSerializableInterceptorClassNotOK()
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 6 months