[seam-dev] Seam3: Will injection become available with in final methods?

Jason Porter lightguard.jp at gmail.com
Thu Jun 3 09:08:50 EDT 2010


Seam2 uses javassit, not cglib.  It makes sense once you understand
it, and I think the documentation says injection cannot be done with
final methods / variables.  I know I was bit by this early on in my
Seam usage.  It may just be an issue getting to know Seam.

On Thu, Jun 3, 2010 at 03:17, Michael Schütz <michaelschuetz83 at gmail.com> wrote:
> OK,
> in CDI it's disallowed by spec:
> " 5.4.1.Unproxyable bean types
> Certain legal bean types cannot be proxied by the container:
> •classes which don't have a non-private constructor with no parameters,
> •classes which are declared final or have final methods
>
> If an injection point whose declared type cannot be proxied by the container
> resolves to a bean with a normal scope, the
>  container automatically detects the problem and treats it as a deployment
> problem."
>
> Anyway, the NPE in Seam2 is misleading. A cglib exception is swallowed.
> Correct?
>
> Michael
>
>
> 2010/6/3 Michael Schütz <michaelschuetz83 at gmail.com>
>>
>> Hi to all,
>>
>> in Seam2, using injected member within final method will cause an NPE at
>> Runtime. The reason for that is, that Seam2 uses cglib for dynamic proxying
>> und subclassing is not possible for final methods.
>>
>> Example:
>> @Name("simpleSeamComp")
>> public class SimpleSeamComponent {
>>     public String getName() {
>>         return "Sam";
>>     }
>> }
>>
>> @Name("finalSeamComp")
>> public class FinalSeamComponent {
>>
>>     @In(create = true)
>>     private SimpleSeamComponent simpleSeamComp;
>>
>>     // causes NullPointerException
>>     public final String getHello() {
>>         return simpleSeamComp.getName();
>>     }
>> }
>>
>>
>> How will Seam3/CDI behave in that case?
>>
>>
>>
>> Thanks and regards
>> Michael
>>
>
>
> _______________________________________________
> seam-dev mailing list
> seam-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/seam-dev
>
>



-- 
Jason Porter

Software Engineer
Open Source Advocate

PGP key id: 926CCFF5
PGP key available at: keyserver.net, pgp.mit.edu



More information about the seam-dev mailing list