Trying to understand Java Classloading
Posted
by Jens
on Stack Overflow
See other posts from Stack Overflow
or by Jens
Published on 2010-04-13T23:27:07Z
Indexed on
2010/04/13
23:43 UTC
Read the original article
Hit count: 503
Hello,
I'm currently getting to know Java and OSGi, so I've read a few books. In one particular book the class loading is described.
You can download it (free and legal) from the authors page (Neil Bartlett): OSGi Book
On page 9 and 10 are this pictures:
It seems like there is the possibility that our class "Foo" won't use the class "Bar" of foobar.jar, but instead class "Bar" from naughty.jar.
Because of the flat and global structure of the Java classpath this could be, but as far as I know you would define a package from where you want to import a certain class:
import foobar.Bar
This should prevent loading the wrong class, shouldn't it? Of course assuming that the package is called "foobar".
© Stack Overflow or respective owner