Hi Andy,

already started to use it in TomEE so i hope that's fine ;)

*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*



2013/2/11 AndyG <andy.gumbre...@orprovision.com>

> A thought aloud.
>
> As more and more of my code and several libraries that I use slide towards
> generics I have found 'class.isInstance' far more useful than 'instanceOf',
> to the point where I literally never use it.
>
>
> http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Class.html#isInstance%28java.lang.Object%29
>
> if (beanManager instanceof WebappBeanManager) {
>
> Simply becomes...
>
> if (WebappBeanManager.class.isInstance(beanManager)) {
>
> For example, should 'WebappBeanManager' ever become 'WebappBeanManager<T>'
> (Probably a bad example here, but you get the idea) then instanceOf will
> break silently.
>
> I have never benchmarked it, but am quite sure the overhead is negligible.
>
> I would like to suggest that we prefer to use it. What do you think?
>
> Andy.
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/Generics-safety-class-isInstance-vs-instanceOf-tp4660675.html
> Sent from the OpenEJB Dev mailing list archive at Nabble.com.
>

Reply via email to