mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8286378: Address possibly lossy conversions in java.base
Reviewed-by: naoto, xuelei, bpb, alanb
This commit is contained in:
parent
0a6832b24c
commit
17c52789b7
32 changed files with 68 additions and 71 deletions
|
@ -436,7 +436,7 @@ public class BufferedInputStream extends FilterInputStream {
|
|||
}
|
||||
|
||||
long skipped = (avail < n) ? avail : n;
|
||||
pos += skipped;
|
||||
pos += (int)skipped;
|
||||
return skipped;
|
||||
}
|
||||
|
||||
|
|
|
@ -475,7 +475,7 @@ public class BufferedReader extends Reader {
|
|||
}
|
||||
long d = nChars - nextChar;
|
||||
if (r <= d) {
|
||||
nextChar += r;
|
||||
nextChar += (int)r;
|
||||
r = 0;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1994, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1994, 2022, 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
|
||||
|
@ -228,7 +228,7 @@ public class ByteArrayInputStream extends InputStream {
|
|||
k = n < 0 ? 0 : n;
|
||||
}
|
||||
|
||||
pos += k;
|
||||
pos += (int) k;
|
||||
return k;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2022, 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
|
||||
|
@ -196,7 +196,7 @@ public class CharArrayReader extends Reader {
|
|||
if (n < 0) {
|
||||
return 0;
|
||||
}
|
||||
pos += n;
|
||||
pos += (int) n;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -323,7 +323,7 @@ public class PushbackInputStream extends FilterInputStream {
|
|||
if (n < pskip) {
|
||||
pskip = n;
|
||||
}
|
||||
pos += pskip;
|
||||
pos += (int) pskip;
|
||||
n -= pskip;
|
||||
}
|
||||
if (n > 0) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2022, 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
|
||||
|
@ -251,7 +251,7 @@ public class PushbackReader extends FilterReader {
|
|||
int avail = buf.length - pos;
|
||||
if (avail > 0) {
|
||||
if (n <= avail) {
|
||||
pos += n;
|
||||
pos += (int)n;
|
||||
return n;
|
||||
} else {
|
||||
pos = buf.length;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1995, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1995, 2022, 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
|
||||
|
@ -145,7 +145,7 @@ public class StringBufferInputStream extends InputStream {
|
|||
if (n > count - pos) {
|
||||
n = count - pos;
|
||||
}
|
||||
pos += n;
|
||||
pos += (int) n;
|
||||
return n;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2022, 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
|
||||
|
@ -136,7 +136,7 @@ public class StringReader extends Reader {
|
|||
// Bound skip by beginning and end of the source
|
||||
long r = Math.min(length - next, n);
|
||||
r = Math.max(-next, r);
|
||||
next += r;
|
||||
next += (int)r;
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -720,7 +720,7 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
|||
if (numBytes > 0) {
|
||||
rnd.nextBytes(randomBits);
|
||||
int excessBits = 8*numBytes - numBits;
|
||||
randomBits[0] &= (1 << (8-excessBits)) - 1;
|
||||
randomBits[0] &= (byte)((1 << (8-excessBits)) - 1);
|
||||
}
|
||||
return randomBits;
|
||||
}
|
||||
|
@ -3389,7 +3389,7 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
|||
|
||||
// Mask out any excess bits
|
||||
int excessBits = (numInts << 5) - p;
|
||||
mag[0] &= (1L << (32-excessBits)) - 1;
|
||||
mag[0] &= (int)((1L << (32-excessBits)) - 1);
|
||||
|
||||
return (mag[0] == 0 ? new BigInteger(1, mag) : new BigInteger(mag, 1));
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2022, 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
|
||||
|
@ -418,7 +418,7 @@ public final class URLPermission extends Permission {
|
|||
"White space not allowed in methods: \"" + methods + "\"");
|
||||
} else {
|
||||
if (c >= 'a' && c <= 'z') {
|
||||
c += 'A' - 'a';
|
||||
c += (char) ('A' - 'a');
|
||||
}
|
||||
b.append(c);
|
||||
}
|
||||
|
@ -437,7 +437,7 @@ public final class URLPermission extends Permission {
|
|||
char c = headers.charAt(i);
|
||||
if (c >= 'a' && c <= 'z') {
|
||||
if (capitalizeNext) {
|
||||
c += 'A' - 'a';
|
||||
c += (char) ('A' - 'a');
|
||||
capitalizeNext = false;
|
||||
}
|
||||
b.append(c);
|
||||
|
|
|
@ -1532,7 +1532,7 @@ public class DecimalFormat extends NumberFormat {
|
|||
cursor--) {
|
||||
if (digitsCounter != 0) {
|
||||
// This is a digit char, we must localize it.
|
||||
digitsBuffer[cursor] += fastPathData.zeroDelta;
|
||||
digitsBuffer[cursor] += (char)fastPathData.zeroDelta;
|
||||
digitsCounter--;
|
||||
} else {
|
||||
// Decimal separator or grouping char. Reinit counter only.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2022, 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
|
||||
|
@ -283,7 +283,7 @@ public final class Duration
|
|||
long secs = nanos / NANOS_PER_SECOND;
|
||||
int nos = (int) (nanos % NANOS_PER_SECOND);
|
||||
if (nos < 0) {
|
||||
nos += NANOS_PER_SECOND;
|
||||
nos += (int) NANOS_PER_SECOND;
|
||||
secs--;
|
||||
}
|
||||
return create(secs, nos);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2022, 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
|
||||
|
@ -351,7 +351,7 @@ public final class TemporalAdjusters {
|
|||
Temporal temp = temporal.with(DAY_OF_MONTH, 1);
|
||||
int curDow = temp.get(DAY_OF_WEEK);
|
||||
int dowDiff = (dowValue - curDow + 7) % 7;
|
||||
dowDiff += (ordinal - 1L) * 7L; // safe from overflow
|
||||
dowDiff += (int) ((ordinal - 1L) * 7L); // safe from overflow
|
||||
return temp.plus(dowDiff, DAYS);
|
||||
};
|
||||
} else {
|
||||
|
@ -360,7 +360,7 @@ public final class TemporalAdjusters {
|
|||
int curDow = temp.get(DAY_OF_WEEK);
|
||||
int daysDiff = dowValue - curDow;
|
||||
daysDiff = (daysDiff == 0 ? 0 : (daysDiff > 0 ? daysDiff - 7 : daysDiff));
|
||||
daysDiff -= (-ordinal - 1L) * 7L; // safe from overflow
|
||||
daysDiff -= (int) ((-ordinal - 1L) * 7L); // safe from overflow
|
||||
return temp.plus(daysDiff, DAYS);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2022, 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
|
||||
|
@ -2323,11 +2323,11 @@ public class GregorianCalendar extends Calendar {
|
|||
fixedDate += time / ONE_DAY;
|
||||
timeOfDay += (int) (time % ONE_DAY);
|
||||
if (timeOfDay >= ONE_DAY) {
|
||||
timeOfDay -= ONE_DAY;
|
||||
timeOfDay -= (int)ONE_DAY;
|
||||
++fixedDate;
|
||||
} else {
|
||||
while (timeOfDay < 0) {
|
||||
timeOfDay += ONE_DAY;
|
||||
timeOfDay += (int)ONE_DAY;
|
||||
--fixedDate;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1607,11 +1607,11 @@ class JapaneseImperialCalendar extends Calendar {
|
|||
fixedDate += time / ONE_DAY;
|
||||
timeOfDay += (int) (time % ONE_DAY);
|
||||
if (timeOfDay >= ONE_DAY) {
|
||||
timeOfDay -= ONE_DAY;
|
||||
timeOfDay -= (int) ONE_DAY;
|
||||
++fixedDate;
|
||||
} else {
|
||||
while (timeOfDay < 0) {
|
||||
timeOfDay += ONE_DAY;
|
||||
timeOfDay += (int) ONE_DAY;
|
||||
--fixedDate;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -152,7 +152,7 @@ public final class UUID implements java.io.Serializable, Comparable<UUID> {
|
|||
randomBytes[6] &= 0x0f; /* clear version */
|
||||
randomBytes[6] |= 0x40; /* set to version 4 */
|
||||
randomBytes[8] &= 0x3f; /* clear variant */
|
||||
randomBytes[8] |= 0x80; /* set to IETF variant */
|
||||
randomBytes[8] |= (byte) 0x80; /* set to IETF variant */
|
||||
return new UUID(randomBytes);
|
||||
}
|
||||
|
||||
|
@ -176,7 +176,7 @@ public final class UUID implements java.io.Serializable, Comparable<UUID> {
|
|||
md5Bytes[6] &= 0x0f; /* clear version */
|
||||
md5Bytes[6] |= 0x30; /* set to version 3 */
|
||||
md5Bytes[8] &= 0x3f; /* clear variant */
|
||||
md5Bytes[8] |= 0x80; /* set to IETF variant */
|
||||
md5Bytes[8] |= (byte) 0x80; /* set to IETF variant */
|
||||
return new UUID(md5Bytes);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2022, 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
|
||||
|
@ -533,7 +533,7 @@ public class Manifest implements Cloneable {
|
|||
if (n > avail) {
|
||||
n = avail;
|
||||
}
|
||||
pos += n;
|
||||
pos += (int) n;
|
||||
return n;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2022, 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
|
||||
|
@ -2055,14 +2055,14 @@ final class Nodes {
|
|||
else {
|
||||
task.setPendingCount(task.node.getChildCount() - 1);
|
||||
|
||||
int size = 0;
|
||||
long size = 0;
|
||||
int i = 0;
|
||||
for (;i < task.node.getChildCount() - 1; i++) {
|
||||
K leftTask = task.makeChild(i, task.offset + size);
|
||||
K leftTask = task.makeChild(i, (int) (task.offset + size));
|
||||
size += leftTask.node.count();
|
||||
leftTask.fork();
|
||||
}
|
||||
task = task.makeChild(i, task.offset + size);
|
||||
task = task.makeChild(i, (int) (task.offset + size));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue