问题
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