Menu

#287 new rule: avoid Thread.getContextClassLoader()

open
nobody
None
5
2013-02-16
2011-05-24
No

new rule: avoid Thread.getContextClassLoader()
There are almost always better ways to load classes than to access the context class loader:

From http://www.osgi.org/blog/2011/05/what-you-should-know-about-class.html
"for some reason they used the Thread Context Class Loader (you're in deep s**t if that one becomes necessary), and Class.forName. Completely unnecessary because they had access to the delegate object and thus its class loader... Reasoning about the context in which a class is loaded can prevent problems.

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.