You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openwebbeans.apache.org by Romain Manni-Bucau <rm...@gmail.com> on 2012/08/15 16:31:28 UTC

OWB and finalize filtering

Hi,

with javassist it is important to filter finalize method (it is a jira if i
remember) however i don't get the way we do it:

        if (method.getName() == FINALIZE &&   // Method.getName() is
defined to return .intern() in the VM spec.
            method.getParameterTypes().length == 0 &&
            method.getReturnType() == Void.TYPE)
        {
            // we should NOT invoke the bean's finalize() from proxied
            // finalize() method since JVM will invoke it directly.
            // OWB-366
            return null;
        }

using javassist 3.15 i got weird stuff. It looked finalize() was redirected
to _d2finalize (not sure why).

i updated locally OWB to use on the ProxyFactory (in JavassistProxyFactory):

fact.setFilter(new MethodFilter() { // TODO if relevant: create
FinalizerMethodFilter singleton + intern usage for method name
            public boolean isHandled(Method method)
            {
                return !(method.getName().equals("finalize") &&
method.getParameterTypes().length == 0 &&
                            method.getReturnType() == Void.TYPE);
            }
        });


and i didn't see the errors anymore :)

now the question ;): any reason we are not filtering this way?

btw i could dump bytecode before/after if needed

- Romain

Re: OWB and finalize filtering

Posted by Mark Struberg <st...@yahoo.de>.
too bad you catch this after all the work is done already and I just wait for all mirrors to pick up the owb-1.1.5 release to write the announcement ;)


LieGrue,
strub

>________________________________
> From: Romain Manni-Bucau <rm...@gmail.com>
>To: dev@openwebbeans.apache.org; Mark Struberg <st...@yahoo.de> 
>Sent: Wednesday, August 15, 2012 6:33 PM
>Subject: Re: OWB and finalize filtering
> 
>
>well in openejb we use a newer version (to be compatible with some other lib) so we have the issue, we can still fork all handlers but...
>
>- Romain
>
>
>
>2012/8/15 Mark Struberg <st...@yahoo.de>
>
>Hmm, maybe that's the reason why I saw mem leaks after updating to a newer javassist version?
>>
>>For now I think it's good for just remaining with the old javassist version and get rid of javassist in the next OWB release completely ;)
>>
>>LieGrue,
>>strub
>>
>>
>>
>>
>>----- Original Message -----
>>> From: Romain Manni-Bucau <rm...@gmail.com>
>>> To: dev@openwebbeans.apache.org
>>> Cc:
>>> Sent: Wednesday, August 15, 2012 4:31 PM
>>> Subject: OWB and finalize filtering
>>>
>>> Hi,
>>>
>>> with javassist it is important to filter finalize method (it is a jira if i
>>> remember) however i don't get the way we do it:
>>>
>>>         if (method.getName() == FINALIZE &&   // Method.getName() is
>>> defined to return .intern() in the VM spec.
>>>             method.getParameterTypes().length == 0 &&
>>>             method.getReturnType() == Void.TYPE)
>>>         {
>>>             // we should NOT invoke the bean's finalize() from proxied
>>>             // finalize() method since JVM will invoke it directly.
>>>             // OWB-366
>>>             return null;
>>>         }
>>>
>>> using javassist 3.15 i got weird stuff. It looked finalize() was redirected
>>> to _d2finalize (not sure why).
>>>
>>> i updated locally OWB to use on the ProxyFactory (in JavassistProxyFactory):
>>>
>>> fact.setFilter(new MethodFilter() { // TODO if relevant: create
>>> FinalizerMethodFilter singleton + intern usage for method name
>>>             public boolean isHandled(Method method)
>>>             {
>>>                 return !(method.getName().equals("finalize")
>>> &&
>>> method.getParameterTypes().length == 0 &&
>>>                             method.getReturnType() == Void.TYPE);
>>>             }
>>>         });
>>>
>>>
>>> and i didn't see the errors anymore :)
>>>
>>> now the question ;): any reason we are not filtering this way?
>>>
>>> btw i could dump bytecode before/after if needed
>>>
>>> - Romain
>>>
>>
>
>
>

Re: OWB and finalize filtering

Posted by Romain Manni-Bucau <rm...@gmail.com>.
well in openejb we use a newer version (to be compatible with some other
lib) so we have the issue, we can still fork all handlers but...

- Romain


2012/8/15 Mark Struberg <st...@yahoo.de>

> Hmm, maybe that's the reason why I saw mem leaks after updating to a newer
> javassist version?
>
> For now I think it's good for just remaining with the old javassist
> version and get rid of javassist in the next OWB release completely ;)
>
> LieGrue,
> strub
>
>
>
> ----- Original Message -----
> > From: Romain Manni-Bucau <rm...@gmail.com>
> > To: dev@openwebbeans.apache.org
> > Cc:
> > Sent: Wednesday, August 15, 2012 4:31 PM
> > Subject: OWB and finalize filtering
> >
> > Hi,
> >
> > with javassist it is important to filter finalize method (it is a jira
> if i
> > remember) however i don't get the way we do it:
> >
> >         if (method.getName() == FINALIZE &&   // Method.getName() is
> > defined to return .intern() in the VM spec.
> >             method.getParameterTypes().length == 0 &&
> >             method.getReturnType() == Void.TYPE)
> >         {
> >             // we should NOT invoke the bean's finalize() from proxied
> >             // finalize() method since JVM will invoke it directly.
> >             // OWB-366
> >             return null;
> >         }
> >
> > using javassist 3.15 i got weird stuff. It looked finalize() was
> redirected
> > to _d2finalize (not sure why).
> >
> > i updated locally OWB to use on the ProxyFactory (in
> JavassistProxyFactory):
> >
> > fact.setFilter(new MethodFilter() { // TODO if relevant: create
> > FinalizerMethodFilter singleton + intern usage for method name
> >             public boolean isHandled(Method method)
> >             {
> >                 return !(method.getName().equals("finalize")
> > &&
> > method.getParameterTypes().length == 0 &&
> >                             method.getReturnType() == Void.TYPE);
> >             }
> >         });
> >
> >
> > and i didn't see the errors anymore :)
> >
> > now the question ;): any reason we are not filtering this way?
> >
> > btw i could dump bytecode before/after if needed
> >
> > - Romain
> >
>

Re: OWB and finalize filtering

Posted by Mark Struberg <st...@yahoo.de>.
Hmm, maybe that's the reason why I saw mem leaks after updating to a newer javassist version? 

For now I think it's good for just remaining with the old javassist version and get rid of javassist in the next OWB release completely ;)

LieGrue,
strub



----- Original Message -----
> From: Romain Manni-Bucau <rm...@gmail.com>
> To: dev@openwebbeans.apache.org
> Cc: 
> Sent: Wednesday, August 15, 2012 4:31 PM
> Subject: OWB and finalize filtering
> 
> Hi,
> 
> with javassist it is important to filter finalize method (it is a jira if i
> remember) however i don't get the way we do it:
> 
>         if (method.getName() == FINALIZE &&   // Method.getName() is
> defined to return .intern() in the VM spec.
>             method.getParameterTypes().length == 0 &&
>             method.getReturnType() == Void.TYPE)
>         {
>             // we should NOT invoke the bean's finalize() from proxied
>             // finalize() method since JVM will invoke it directly.
>             // OWB-366
>             return null;
>         }
> 
> using javassist 3.15 i got weird stuff. It looked finalize() was redirected
> to _d2finalize (not sure why).
> 
> i updated locally OWB to use on the ProxyFactory (in JavassistProxyFactory):
> 
> fact.setFilter(new MethodFilter() { // TODO if relevant: create
> FinalizerMethodFilter singleton + intern usage for method name
>             public boolean isHandled(Method method)
>             {
>                 return !(method.getName().equals("finalize") 
> &&
> method.getParameterTypes().length == 0 &&
>                             method.getReturnType() == Void.TYPE);
>             }
>         });
> 
> 
> and i didn't see the errors anymore :)
> 
> now the question ;): any reason we are not filtering this way?
> 
> btw i could dump bytecode before/after if needed
> 
> - Romain
>