8266972: Use String.concat() in j.l.Class where invokedynamic-based String concatenation is not available

Reviewed-by: redestad
This commit is contained in:
Sergey Tsypanov 2021-08-02 12:47:09 +00:00 committed by Claes Redestad
parent 72145f3b94
commit 6c4c48faea

View file

@ -232,8 +232,8 @@ public final class Class<T> implements java.io.Serializable,
* @return a string representation of this {@code Class} object.
*/
public String toString() {
return (isInterface() ? "interface " : (isPrimitive() ? "" : "class "))
+ getName();
String kind = isInterface() ? "interface " : isPrimitive() ? "" : "class ";
return kind.concat(getName());
}
/**
@ -1657,7 +1657,7 @@ public final class Class<T> implements java.io.Serializable,
private String getSimpleName0() {
if (isArray()) {
return getComponentType().getSimpleName() + "[]";
return getComponentType().getSimpleName().concat("[]");
}
String simpleName = getSimpleBinaryName();
if (simpleName == null) { // top level class
@ -1682,7 +1682,7 @@ public final class Class<T> implements java.io.Serializable,
dimensions++;
cl = cl.getComponentType();
} while (cl.isArray());
return cl.getName() + "[]".repeat(dimensions);
return cl.getName().concat("[]".repeat(dimensions));
} catch (Throwable e) { /*FALLTHRU*/ }
}
return getName();
@ -1717,7 +1717,7 @@ public final class Class<T> implements java.io.Serializable,
if (isArray()) {
String canonicalName = getComponentType().getCanonicalName();
if (canonicalName != null)
return canonicalName + "[]";
return canonicalName.concat("[]");
else
return ReflectionData.NULL_SENTINEL;
}