// We have to be careful here to distinguish method by both name
// and argument lists.
// This method gets called a *lot, so we try to be efficient.
String name = descriptor.getMethod().getName();
MethodDescriptor old = methods.get(name);
if (old == null)
{
// This is the common case.
methods.put(name, descriptor);
return;
}
// We have a collision on method names. This is rare.
// Check if old and descriptor have the same type.
Class p1[] = descriptor.getMethod().getParameterTypes();
Class p2[] = old.getMethod().getParameterTypes();
boolean match = false;
if (p1.length == p2.length)
{
match = true;
for (int i = 0; i < p1.length; i++)
{
if (p1[i] != p2[i])
{
match = false;
break;
}
}
}
if (match)
{
MethodDescriptor composite = _createMergedMethodDescriptor(old,
descriptor);
methods.put(name, composite);
return;
}
// We have a collision on method names with different type signatures.
// This is very rare.
String longKey = _makeQualifiedMethodName(descriptor);
old = methods.get(longKey);
if (old == null)
{
methods.put(longKey, descriptor);
return;
}
MethodDescriptor composite = _createMergedMethodDescriptor(old,
descriptor);
methods.put(longKey, composite);
}