harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Ellison <t.p.elli...@gmail.com>
Subject Re: [classlib]Make harmony's modularity better
Date Thu, 18 Dec 2008 17:13:49 GMT
Alexey Varlamov wrote:
>>> What we need is a performant version of something like ...
>>>    boolean instanceOf(Object obj, String typeName)
>> No more ideas, seem we have to chose between these,
>> 1. try/catch
>> 2. reflection
>> The former has more overhead whereas the later has less compiler checking.
> AFAIU classloading is involved in both cases, moreover VM neccessarily
> records resolution results thus this should not be a performance
> issue. In general, reflection has not less overhead at least, and if
> we take into account that void catch clause is easily optimized by
> JIT, 1st solution is absolute winner.
> IMO no need to look for better solution here, numerous reflection
> calls around beans would absorb that small potential gain anyway. I
> bet no benchmark would show any boost even if we'd implement such
> instanceOf(Object obj, String typeName) via vmmagics.

Agreed.  I was thinking ahead to the implications in a dynamic world
rather than performance in today's static world.

As you point out, both solutions will cause a classload attempt of
Applet.  The solutions above will both cause Applet to be loaded if it
can be loaded, and allow Beans to continue if Applet cannot be loaded.

However, this would be bad in a dynamic world -- where the mere
reference to the Applet.class would cause the VM to go and download it
from harmony.apache.org.  Especially since it would necessarily figure
out that the bean is *not* an instanceof Applet (otherwise Applet would
have been already referenced).

If we had asked if the bean is an instanceof Applet by using the String
name (so as not to load it) then we would have saved an unneeded download.

Anyway, I'm happy to live in the static world for the moment and option
(1) is ok :-)


View raw message