DRY: use existing method Type::getInternalName in Type::appendDescriptor
String name = currentClass.getName();
int nameLength = name.length();
for (int i = 0; i < nameLength; ++i) {
char car = name.charAt(i);
stringBuilder.append(car == '.' ? '/' : car);
}
this code appends the name of currentClass having all dots replaced with '/'. However the same class already contains method doing exactly the same
public static String getInternalName(final Class<?> clazz) {
return clazz.getName().replace('.', '/');
}
This one is not only more readable and likely to be faster as it yields the whole String at once instead of appending char by char inflating original StringBuilder.
Original PR: https://github.com/spring-projects/spring-framework/pull/22299