In rare cases it is possible for distinct HostedMethod instances to have the the same declaring class and method name and the same parameter types and return types in their signature (PR #4627 details one example of how this can happen). Unfortunately, the current implementation of method HostedMethod.compareTo relies solely on recursively comparing these elements of the method structure when comparing two methods. This means that it sometimes assimilates methods that it is desirable to distinguish. For example, if both HostedMethod instances get compiled, they will then be used as keys for the associated compilation results in the map maintained by the CodeCache. This results in one of the results being dropped and the other being keyed by the wrong HostedMethod(as detailed in PR #4627).
The implementation of HostedType.compareTo may be susceptible to the same issue although at present there is no known case where two type types that should be distinguished end up being created with the same FQN.