[jboss-dev-forums] [Design of OSGi Integration] - Re: Why Class.forName sucks!
adrian@jboss.org
do-not-reply at jboss.com
Tue Mar 4 09:54:07 EST 2008
It doesn't just suck, it is evil. It caches things it shouldn't.
We were forced into it for java6 array problem. But its only really required
if the classname looks like an array class.
You changed too much for this. e.g. you changed all the classloader
stuff, even though the entry point loadClass() already has the checking.
| if (classNameLooksLikeAnError)
| useClassForName();
| else
| loadClassFromClassLoaderNormally();
|
But you can't rely on our classloader being the entry point all the time,
so a helper class that does this would be ok.
i.e. invoke the helper doing the code above instead of Class.forName() directly.
Another workaround would be to byte code weave all classes using
Class.forName() to our helper using a Transformer on the classloader.
The ironic part is that Java6 on Sun has a rewritten constraint checker that is
much faster. ;-)
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4133925#4133925
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4133925
More information about the jboss-dev-forums
mailing list