How does java classloader identifies duplicate classes?

ぃ、小莉子 提交于 2019-12-11 14:52:09

问题


Let us say I have a java project where I have added 2 different jars in my classpath. Java classloader found some duplicate classes in the 2 jar and then only one among them will be loaded.

How does classloader decide that 2 classes in the classpath are same ? Just by class Name or packageName.className Or it compares each byte code of those classes ?


回答1:


It decides just by fully-qualified name (package + class name), and it loads (in general - depends on classloader), the first class found on the classpath. There is no bytecode comparision.



来源:https://stackoverflow.com/questions/59197687/how-does-java-classloader-identifies-duplicate-classes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!