简体   繁体   中英

if two libraries have classes that have the same class& package name for their internal use

I have two jars that have the same package structure. And they have a class that have the same name. like..

lib1.jar
   - A.class
   - Same.class
lib2.jar
   - B.class
   - Same.class

Actually, I don't use Same.class but it is used by class A and B

Then, what happened?

If lib1.jar is loaded first, only Same.class in lib1.jar is used for both A.class and B.class?

or A & B will use different Same.class in their own jar?

If there isn't any special Class loader , which loads different classes at run time, the class loaded first will be used in both the places. Please check this for more info.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM