简体   繁体   English

如果两个库的类具有相同的类和包名称供其内部使用

[英]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实际上,我不使用 Same.class 但它被 A 类和 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?如果先加载lib1.jar,那么A.class和B.class都只使用lib1.jar中的Same.class?

or A & B will use different Same.class in their own jar?或者 A & B 会在他们自己的 jar 中使用不同的 Same.class?

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.如果没有任何特殊的Class loader在运行时加载不同的类,那么首先加载的类将在两个地方使用。 Please check this for more info.请检查以获取更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 是否可以在同一包中有两个具有相同名称的类? - Is it possible to have 2 classes with the same name and in the same package? 我在不同的jar中有两个具有相同名称和相同包结构的类。 是否可以从jar中专门选择一个类? - I have two classes with same name and same package structure in different jars. Is it possbile to choose a class from jar specifically? 使用两个类具有相同的 XML 类型名称 - Use two classes have the same XML type name 两个类具有相同的 XML 类型名称 - Two Classes have same XML type name Java:在不同的库中使用相同的程序包名称是不好的做法吗? - Java: Is it bad practice to have same package name in the different libraries? 可以使用两个具有相同名称和相同包的java类吗? - Possible to use two java classes with same name and same package? 同一源代码包中是否可以包含.class和.java类? - is it possible to have .class and .java classes inside the same source code package? 同一个类的两个类是否具有相同的哈希码,它们被认为是相同的吗? - Do two classes of the same class have the same hashcode and are they considered equal? 两个类具有相同的XML类型名称“objectFactory” - Two classes have the same XML type name “objectFactory” IllegalAnnotationException:两个类具有相同的 XML 类型名称 - IllegalAnnotationException: Two classes have the same XML type name
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM