Unraveling Java class loaders
A few days ago I wrote about a singleton that was being created twice.
I blamed it on different class loaders, but my colleagues
were skeptical. “That might fix it, but that's not the cause.”
I was a little disappointed. I'd been rather proud of figuring it out on my own,
and I was sure I was right. Still, I couldn't explain exactly why it behaved that way.
About a week later, the java.cz mailing list was discussing
how files are deployed on a J2EE application server, so I took the opportunity
to ask. Martin Kuba (makub) explained that a class is uniquely identified
by its qualified name (package plus name) and the class loader that loaded it.
I was glad to have been right, and I left it there.
Today I came across an excellent article on ONJava.com by Andreas Schaefer,
Inside Class Loaders,
which cleared up practically everything about Java class loaders for me. I highly recommend it. This is the first part,
and the next installment will cover class loaders in the context of J2EE application servers and AOP.
Related articles
Related CZ Podcast episodes
- #3 · Java 6 SE, Vývoj webových aplikací
Dagi and Filemon discuss Java 6 and web application frameworks. · Czech audio
- #1 · Vývojová prostředí v Javě
The first CZ Podcast episode looks at Java development environments. · Czech audio