8344336: SM cleanup of java.lang.System, Runtime, String, StackWalker

Reviewed-by: dfuchs, alanb, lancea
This commit is contained in:
Roger Riggs 2024-11-21 21:50:41 +00:00
parent 0f458e2c3e
commit c199f5326b
6 changed files with 14 additions and 219 deletions

View file

@ -685,12 +685,6 @@ public final class String
cd.onMalformedInput(CodingErrorAction.REPLACE)
.onUnmappableCharacter(CodingErrorAction.REPLACE);
char[] ca = new char[en];
if (charset.getClass().getClassLoader0() != null &&
System.getSecurityManager() != null) {
bytes = Arrays.copyOfRange(bytes, offset, offset + length);
offset = 0;
}
int caLen;
try {
caLen = decodeWithDecoder(cd, ca, bytes, offset, length);
@ -828,10 +822,6 @@ public final class String
}
int en = scale(len, cd.maxCharsPerByte());
char[] ca = new char[en];
if (cs.getClass().getClassLoader0() != null &&
System.getSecurityManager() != null) {
src = Arrays.copyOf(src, len);
}
int caLen;
try {
caLen = decodeWithDecoder(cd, ca, src, 0, src.length);
@ -850,9 +840,8 @@ public final class String
private static final char REPL = '\ufffd';
// Trim the given byte array to the given length
@SuppressWarnings("removal")
private static byte[] safeTrim(byte[] ba, int len, boolean isTrusted) {
if (len == ba.length && (isTrusted || System.getSecurityManager() == null)) {
private static byte[] trimArray(byte[] ba, int len) {
if (len == ba.length) {
return ba;
} else {
return Arrays.copyOf(ba, len);
@ -907,7 +896,7 @@ public final class String
int blen = (coder == LATIN1) ? ae.encodeFromLatin1(val, 0, len, ba)
: ae.encodeFromUTF16(val, 0, len, ba);
if (blen != -1) {
return safeTrim(ba, blen, true);
return trimArray(ba, blen);
}
}
@ -937,7 +926,7 @@ public final class String
throw new Error(x);
}
}
return safeTrim(ba, bb.position(), cs.getClass().getClassLoader0() == null);
return trimArray(ba, bb.position());
}
/*