> > 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. -- Alexey
