Trying to understand Java Classloading
- by Jens
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".