We recently ran into a scenarium that we have two corporate dependencies and each one of them has a specific method with the same name, parameters and class, probably a copy-and-paste. Both dependencies are declared as direct dependency in my actual microservice.
Imagine something like:
-- Microservice
|-- Corporate dependency A
|-- com.enterprise.project.UtilityClass
| public static String someMethod(String someParameter)
|-- Corporate dependency B
|-- com.enterprise.project.UtilityClass
| public static String someMethod(String someParameter)
We noticed the problem because maven reported it in our build when we added the second dependency, we checked and even thought the output is the same, they have slightly different implementations. My question is, how does the JVM decides which one of this methods to use in runtime?