mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 22:34:27 +02:00
8333833: Remove the use of ByteArrayLittleEndian from UUID::toString
Reviewed-by: liach, redestad
This commit is contained in:
parent
de55db2352
commit
8aa35cacfc
2 changed files with 31 additions and 51 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -31,7 +31,6 @@ import java.security.*;
|
|||
|
||||
import jdk.internal.access.JavaLangAccess;
|
||||
import jdk.internal.access.SharedSecrets;
|
||||
import jdk.internal.util.ByteArrayLittleEndian;
|
||||
import jdk.internal.util.HexDigits;
|
||||
|
||||
/**
|
||||
|
@ -467,38 +466,24 @@ public final class UUID implements java.io.Serializable, Comparable<UUID> {
|
|||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
long lsb = leastSigBits;
|
||||
long msb = mostSigBits;
|
||||
byte[] buf = new byte[36];
|
||||
ByteArrayLittleEndian.setLong(
|
||||
buf,
|
||||
0,
|
||||
HexDigits.packDigits((int) (msb >> 56), (int) (msb >> 48), (int) (msb >> 40), (int) (msb >> 32)));
|
||||
buf[8] = '-';
|
||||
ByteArrayLittleEndian.setInt(
|
||||
buf,
|
||||
9,
|
||||
HexDigits.packDigits(((int) msb) >> 24, ((int) msb) >> 16));
|
||||
buf[13] = '-';
|
||||
ByteArrayLittleEndian.setInt(
|
||||
buf,
|
||||
14,
|
||||
HexDigits.packDigits(((int) msb) >> 8, (int) msb));
|
||||
buf[18] = '-';
|
||||
ByteArrayLittleEndian.setInt(
|
||||
buf,
|
||||
19,
|
||||
HexDigits.packDigits((int) (lsb >> 56), (int) (lsb >> 48)));
|
||||
buf[23] = '-';
|
||||
ByteArrayLittleEndian.setLong(
|
||||
buf,
|
||||
24,
|
||||
HexDigits.packDigits((int) (lsb >> 40), (int) (lsb >> 32), ((int) lsb) >> 24, ((int) lsb) >> 16));
|
||||
ByteArrayLittleEndian.setInt(
|
||||
buf,
|
||||
32,
|
||||
HexDigits.packDigits(((int) lsb) >> 8, (int) lsb));
|
||||
int i0 = (int) (mostSigBits >> 32);
|
||||
int i1 = (int) mostSigBits;
|
||||
int i2 = (int) (leastSigBits >> 32);
|
||||
int i3 = (int) leastSigBits;
|
||||
|
||||
byte[] buf = new byte[36];
|
||||
HexDigits.put4(buf, 0, i0 >> 16);
|
||||
HexDigits.put4(buf, 4, i0);
|
||||
buf[8] = '-';
|
||||
HexDigits.put4(buf, 9, i1 >> 16);
|
||||
buf[13] = '-';
|
||||
HexDigits.put4(buf, 14, i1);
|
||||
buf[18] = '-';
|
||||
HexDigits.put4(buf, 19, i2 >> 16);
|
||||
buf[23] = '-';
|
||||
HexDigits.put4(buf, 24, i2);
|
||||
HexDigits.put4(buf, 28, i3 >> 16);
|
||||
HexDigits.put4(buf, 32, i3);
|
||||
try {
|
||||
return jla.newStringNoRepl(buf, StandardCharsets.ISO_8859_1);
|
||||
} catch (CharacterCodingException cce) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue