Skip to content

Commit 17c5278

Browse files
author
Roger Riggs
committed
8286378: Address possibly lossy conversions in java.base
Reviewed-by: naoto, xuelei, bpb, alanb
1 parent 0a6832b commit 17c5278

32 files changed

+68
-71
lines changed

src/java.base/linux/classes/sun/nio/ch/EPollSelectorImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ protected int doSelect(Consumer<SelectionKey> action, long timeout)
125125
if (numEntries == IOStatus.INTERRUPTED && timedPoll) {
126126
// timed poll interrupted so need to adjust timeout
127127
long adjust = System.nanoTime() - startTime;
128-
to -= TimeUnit.MILLISECONDS.convert(adjust, TimeUnit.NANOSECONDS);
128+
to =- (int) TimeUnit.NANOSECONDS.toMillis(adjust);
129129
if (to <= 0) {
130130
// timeout expired so no retry
131131
numEntries = 0;

src/java.base/share/classes/com/sun/crypto/provider/AESCrypt.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ private static final int[] expandToSubKey(int[][] kr, boolean decrypting) {
217217
for (t = 0; t < 8; t++) {
218218
cox[i][t] = B[t];
219219
for (j = 0; j < 8; j++) {
220-
cox[i][t] ^= A[t][j] * box[i][j];
220+
cox[i][t] ^= (byte)(A[t][j] * box[i][j]);
221221
}
222222
}
223223
}
@@ -227,7 +227,7 @@ private static final int[] expandToSubKey(int[][] kr, boolean decrypting) {
227227
for (i = 0; i < 256; i++) {
228228
S[i] = (byte)(cox[i][0] << 7);
229229
for (t = 1; t < 8; t++) {
230-
S[i] ^= cox[i][t] << (7-t);
230+
S[i] ^= (byte)(cox[i][t] << (7-t));
231231
}
232232
Si[S[i] & 0xFF] = (byte) i;
233233
}
@@ -276,7 +276,7 @@ private static final int[] expandToSubKey(int[][] kr, boolean decrypting) {
276276
for (t = 0; t < 4; t++) {
277277
if (i != t) {
278278
for (j = i+1; j < 8; j++) {
279-
AA[t][j] ^= mul(AA[i][j], AA[t][i]);
279+
AA[t][j] ^= (byte)(mul(AA[i][j], AA[t][i]));
280280
}
281281
AA[t][i] = 0;
282282
}

src/java.base/share/classes/com/sun/crypto/provider/Poly1305.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,9 @@ private void setRSVals() {
246246
keyBytes[7] &= 15;
247247
keyBytes[11] &= 15;
248248
keyBytes[15] &= 15;
249-
keyBytes[4] &= 252;
250-
keyBytes[8] &= 252;
251-
keyBytes[12] &= 252;
249+
keyBytes[4] &= (byte)252;
250+
keyBytes[8] &= (byte)252;
251+
keyBytes[12] &= (byte)252;
252252

253253
// Create IntegerModuloP elements from the r and s values
254254
r = ipl1305.getElement(keyBytes, 0, RS_LENGTH, (byte)0);

src/java.base/share/classes/java/io/BufferedInputStream.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ private long implSkip(long n) throws IOException {
436436
}
437437

438438
long skipped = (avail < n) ? avail : n;
439-
pos += skipped;
439+
pos += (int)skipped;
440440
return skipped;
441441
}
442442

src/java.base/share/classes/java/io/BufferedReader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ private long implSkip(long n) throws IOException {
475475
}
476476
long d = nChars - nextChar;
477477
if (r <= d) {
478-
nextChar += r;
478+
nextChar += (int)r;
479479
r = 0;
480480
break;
481481
}

src/java.base/share/classes/java/io/ByteArrayInputStream.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1994, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1994, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -228,7 +228,7 @@ public synchronized long skip(long n) {
228228
k = n < 0 ? 0 : n;
229229
}
230230

231-
pos += k;
231+
pos += (int) k;
232232
return k;
233233
}
234234

src/java.base/share/classes/java/io/CharArrayReader.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -196,7 +196,7 @@ public long skip(long n) throws IOException {
196196
if (n < 0) {
197197
return 0;
198198
}
199-
pos += n;
199+
pos += (int) n;
200200
return n;
201201
}
202202
}

src/java.base/share/classes/java/io/PushbackInputStream.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ public long skip(long n) throws IOException {
323323
if (n < pskip) {
324324
pskip = n;
325325
}
326-
pos += pskip;
326+
pos += (int) pskip;
327327
n -= pskip;
328328
}
329329
if (n > 0) {

src/java.base/share/classes/java/io/PushbackReader.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -251,7 +251,7 @@ public long skip(long n) throws IOException {
251251
int avail = buf.length - pos;
252252
if (avail > 0) {
253253
if (n <= avail) {
254-
pos += n;
254+
pos += (int)n;
255255
return n;
256256
} else {
257257
pos = buf.length;

src/java.base/share/classes/java/io/StringBufferInputStream.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1995, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1995, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -145,7 +145,7 @@ public synchronized long skip(long n) {
145145
if (n > count - pos) {
146146
n = count - pos;
147147
}
148-
pos += n;
148+
pos += (int) n;
149149
return n;
150150
}
151151

0 commit comments

Comments
 (0)