8286378: Address possibly lossy conversions in java.base

Reviewed-by: naoto, xuelei, bpb, alanb
This commit is contained in:
Roger Riggs 2022-05-12 16:50:36 +00:00
parent 0a6832b24c
commit 17c52789b7
32 changed files with 68 additions and 71 deletions

View File

@ -125,7 +125,7 @@ class EPollSelectorImpl extends SelectorImpl {
if (numEntries == IOStatus.INTERRUPTED && timedPoll) { if (numEntries == IOStatus.INTERRUPTED && timedPoll) {
// timed poll interrupted so need to adjust timeout // timed poll interrupted so need to adjust timeout
long adjust = System.nanoTime() - startTime; long adjust = System.nanoTime() - startTime;
to -= TimeUnit.MILLISECONDS.convert(adjust, TimeUnit.NANOSECONDS); to =- (int) TimeUnit.NANOSECONDS.toMillis(adjust);
if (to <= 0) { if (to <= 0) {
// timeout expired so no retry // timeout expired so no retry
numEntries = 0; numEntries = 0;

View File

@ -217,7 +217,7 @@ final class AESCrypt extends SymmetricCipher implements AESConstants
for (t = 0; t < 8; t++) { for (t = 0; t < 8; t++) {
cox[i][t] = B[t]; cox[i][t] = B[t];
for (j = 0; j < 8; j++) { for (j = 0; j < 8; j++) {
cox[i][t] ^= A[t][j] * box[i][j]; cox[i][t] ^= (byte)(A[t][j] * box[i][j]);
} }
} }
} }
@ -227,7 +227,7 @@ final class AESCrypt extends SymmetricCipher implements AESConstants
for (i = 0; i < 256; i++) { for (i = 0; i < 256; i++) {
S[i] = (byte)(cox[i][0] << 7); S[i] = (byte)(cox[i][0] << 7);
for (t = 1; t < 8; t++) { for (t = 1; t < 8; t++) {
S[i] ^= cox[i][t] << (7-t); S[i] ^= (byte)(cox[i][t] << (7-t));
} }
Si[S[i] & 0xFF] = (byte) i; Si[S[i] & 0xFF] = (byte) i;
} }
@ -276,7 +276,7 @@ final class AESCrypt extends SymmetricCipher implements AESConstants
for (t = 0; t < 4; t++) { for (t = 0; t < 4; t++) {
if (i != t) { if (i != t) {
for (j = i+1; j < 8; j++) { for (j = i+1; j < 8; j++) {
AA[t][j] ^= mul(AA[i][j], AA[t][i]); AA[t][j] ^= (byte)(mul(AA[i][j], AA[t][i]));
} }
AA[t][i] = 0; AA[t][i] = 0;
} }

View File

@ -246,9 +246,9 @@ final class Poly1305 {
keyBytes[7] &= 15; keyBytes[7] &= 15;
keyBytes[11] &= 15; keyBytes[11] &= 15;
keyBytes[15] &= 15; keyBytes[15] &= 15;
keyBytes[4] &= 252; keyBytes[4] &= (byte)252;
keyBytes[8] &= 252; keyBytes[8] &= (byte)252;
keyBytes[12] &= 252; keyBytes[12] &= (byte)252;
// Create IntegerModuloP elements from the r and s values // Create IntegerModuloP elements from the r and s values
r = ipl1305.getElement(keyBytes, 0, RS_LENGTH, (byte)0); r = ipl1305.getElement(keyBytes, 0, RS_LENGTH, (byte)0);

View File

@ -436,7 +436,7 @@ public class BufferedInputStream extends FilterInputStream {
} }
long skipped = (avail < n) ? avail : n; long skipped = (avail < n) ? avail : n;
pos += skipped; pos += (int)skipped;
return skipped; return skipped;
} }

View File

@ -475,7 +475,7 @@ public class BufferedReader extends Reader {
} }
long d = nChars - nextChar; long d = nChars - nextChar;
if (r <= d) { if (r <= d) {
nextChar += r; nextChar += (int)r;
r = 0; r = 0;
break; break;
} }

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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; k = n < 0 ? 0 : n;
} }
pos += k; pos += (int) k;
return k; return k;
} }

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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) { if (n < 0) {
return 0; return 0;
} }
pos += n; pos += (int) n;
return n; return n;
} }
} }

View File

@ -323,7 +323,7 @@ public class PushbackInputStream extends FilterInputStream {
if (n < pskip) { if (n < pskip) {
pskip = n; pskip = n;
} }
pos += pskip; pos += (int) pskip;
n -= pskip; n -= pskip;
} }
if (n > 0) { if (n > 0) {

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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; int avail = buf.length - pos;
if (avail > 0) { if (avail > 0) {
if (n <= avail) { if (n <= avail) {
pos += n; pos += (int)n;
return n; return n;
} else { } else {
pos = buf.length; pos = buf.length;

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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) { if (n > count - pos) {
n = count - pos; n = count - pos;
} }
pos += n; pos += (int) n;
return n; return n;
} }

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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 // Bound skip by beginning and end of the source
long r = Math.min(length - next, n); long r = Math.min(length - next, n);
r = Math.max(-next, r); r = Math.max(-next, r);
next += r; next += (int)r;
return r; return r;
} }
} }

View File

@ -720,7 +720,7 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
if (numBytes > 0) { if (numBytes > 0) {
rnd.nextBytes(randomBits); rnd.nextBytes(randomBits);
int excessBits = 8*numBytes - numBits; int excessBits = 8*numBytes - numBits;
randomBits[0] &= (1 << (8-excessBits)) - 1; randomBits[0] &= (byte)((1 << (8-excessBits)) - 1);
} }
return randomBits; return randomBits;
} }
@ -3389,7 +3389,7 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
// Mask out any excess bits // Mask out any excess bits
int excessBits = (numInts << 5) - p; 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)); return (mag[0] == 0 ? new BigInteger(1, mag) : new BigInteger(mag, 1));
} }

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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 + "\""); "White space not allowed in methods: \"" + methods + "\"");
} else { } else {
if (c >= 'a' && c <= 'z') { if (c >= 'a' && c <= 'z') {
c += 'A' - 'a'; c += (char) ('A' - 'a');
} }
b.append(c); b.append(c);
} }
@ -437,7 +437,7 @@ public final class URLPermission extends Permission {
char c = headers.charAt(i); char c = headers.charAt(i);
if (c >= 'a' && c <= 'z') { if (c >= 'a' && c <= 'z') {
if (capitalizeNext) { if (capitalizeNext) {
c += 'A' - 'a'; c += (char) ('A' - 'a');
capitalizeNext = false; capitalizeNext = false;
} }
b.append(c); b.append(c);

View File

@ -1532,7 +1532,7 @@ public class DecimalFormat extends NumberFormat {
cursor--) { cursor--) {
if (digitsCounter != 0) { if (digitsCounter != 0) {
// This is a digit char, we must localize it. // This is a digit char, we must localize it.
digitsBuffer[cursor] += fastPathData.zeroDelta; digitsBuffer[cursor] += (char)fastPathData.zeroDelta;
digitsCounter--; digitsCounter--;
} else { } else {
// Decimal separator or grouping char. Reinit counter only. // Decimal separator or grouping char. Reinit counter only.

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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; long secs = nanos / NANOS_PER_SECOND;
int nos = (int) (nanos % NANOS_PER_SECOND); int nos = (int) (nanos % NANOS_PER_SECOND);
if (nos < 0) { if (nos < 0) {
nos += NANOS_PER_SECOND; nos += (int) NANOS_PER_SECOND;
secs--; secs--;
} }
return create(secs, nos); return create(secs, nos);

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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); Temporal temp = temporal.with(DAY_OF_MONTH, 1);
int curDow = temp.get(DAY_OF_WEEK); int curDow = temp.get(DAY_OF_WEEK);
int dowDiff = (dowValue - curDow + 7) % 7; 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); return temp.plus(dowDiff, DAYS);
}; };
} else { } else {
@ -360,7 +360,7 @@ public final class TemporalAdjusters {
int curDow = temp.get(DAY_OF_WEEK); int curDow = temp.get(DAY_OF_WEEK);
int daysDiff = dowValue - curDow; int daysDiff = dowValue - curDow;
daysDiff = (daysDiff == 0 ? 0 : (daysDiff > 0 ? daysDiff - 7 : daysDiff)); 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); return temp.plus(daysDiff, DAYS);
}; };
} }

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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; fixedDate += time / ONE_DAY;
timeOfDay += (int) (time % ONE_DAY); timeOfDay += (int) (time % ONE_DAY);
if (timeOfDay >= ONE_DAY) { if (timeOfDay >= ONE_DAY) {
timeOfDay -= ONE_DAY; timeOfDay -= (int)ONE_DAY;
++fixedDate; ++fixedDate;
} else { } else {
while (timeOfDay < 0) { while (timeOfDay < 0) {
timeOfDay += ONE_DAY; timeOfDay += (int)ONE_DAY;
--fixedDate; --fixedDate;
} }
} }

View File

@ -1607,11 +1607,11 @@ class JapaneseImperialCalendar extends Calendar {
fixedDate += time / ONE_DAY; fixedDate += time / ONE_DAY;
timeOfDay += (int) (time % ONE_DAY); timeOfDay += (int) (time % ONE_DAY);
if (timeOfDay >= ONE_DAY) { if (timeOfDay >= ONE_DAY) {
timeOfDay -= ONE_DAY; timeOfDay -= (int) ONE_DAY;
++fixedDate; ++fixedDate;
} else { } else {
while (timeOfDay < 0) { while (timeOfDay < 0) {
timeOfDay += ONE_DAY; timeOfDay += (int) ONE_DAY;
--fixedDate; --fixedDate;
} }
} }

View File

@ -152,7 +152,7 @@ public final class UUID implements java.io.Serializable, Comparable<UUID> {
randomBytes[6] &= 0x0f; /* clear version */ randomBytes[6] &= 0x0f; /* clear version */
randomBytes[6] |= 0x40; /* set to version 4 */ randomBytes[6] |= 0x40; /* set to version 4 */
randomBytes[8] &= 0x3f; /* clear variant */ randomBytes[8] &= 0x3f; /* clear variant */
randomBytes[8] |= 0x80; /* set to IETF variant */ randomBytes[8] |= (byte) 0x80; /* set to IETF variant */
return new UUID(randomBytes); 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] &= 0x0f; /* clear version */
md5Bytes[6] |= 0x30; /* set to version 3 */ md5Bytes[6] |= 0x30; /* set to version 3 */
md5Bytes[8] &= 0x3f; /* clear variant */ md5Bytes[8] &= 0x3f; /* clear variant */
md5Bytes[8] |= 0x80; /* set to IETF variant */ md5Bytes[8] |= (byte) 0x80; /* set to IETF variant */
return new UUID(md5Bytes); return new UUID(md5Bytes);
} }

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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) { if (n > avail) {
n = avail; n = avail;
} }
pos += n; pos += (int) n;
return n; return n;
} }

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -2055,14 +2055,14 @@ final class Nodes {
else { else {
task.setPendingCount(task.node.getChildCount() - 1); task.setPendingCount(task.node.getChildCount() - 1);
int size = 0; long size = 0;
int i = 0; int i = 0;
for (;i < task.node.getChildCount() - 1; i++) { 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(); size += leftTask.node.count();
leftTask.fork(); leftTask.fork();
} }
task = task.makeChild(i, task.offset + size); task = task.makeChild(i, (int) (task.offset + size));
} }
} }
} }

View File

@ -297,7 +297,7 @@ public class CipherInputStream extends FilterInputStream {
if (n < 0) { if (n < 0) {
return 0; return 0;
} }
ostart += n; ostart += (int) n;
return n; return n;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1996, 2016, 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -834,7 +834,7 @@ public class FloatingDecimal{
} }
} }
private static int insignificantDigits(int insignificant) { private static int insignificantDigits(long insignificant) {
int i; int i;
for ( i = 0; insignificant >= 10L; i++ ) { for ( i = 0; insignificant >= 10L; i++ ) {
insignificant /= 10L; insignificant /= 10L;

View File

@ -611,11 +611,11 @@ class Frame {
*/ */
private void pop(final int elements) { private void pop(final int elements) {
if (outputStackTop >= elements) { if (outputStackTop >= elements) {
outputStackTop -= elements; outputStackTop -= (short) elements;
} else { } else {
// If the number of elements to be popped is greater than the number of elements in the output // If the number of elements to be popped is greater than the number of elements in the output
// stack, clear it, and pop the remaining elements from the input stack. // stack, clear it, and pop the remaining elements from the input stack.
outputStackStart -= elements - outputStackTop; outputStackStart -= (short) (elements - outputStackTop);
outputStackTop = 0; outputStackTop = 0;
} }
} }
@ -1503,4 +1503,3 @@ class Frame {
} }
} }
} }

View File

@ -1244,7 +1244,7 @@ final class MethodWriter extends MethodVisitor {
// one place, but this does not work for labels which have not been visited yet. // one place, but this does not work for labels which have not been visited yet.
// Therefore, when we detect here two labels having the same bytecode offset, we need to // Therefore, when we detect here two labels having the same bytecode offset, we need to
// - consolidate the state scattered in these two instances into the canonical instance: // - consolidate the state scattered in these two instances into the canonical instance:
currentBasicBlock.flags |= (label.flags & Label.FLAG_JUMP_TARGET); currentBasicBlock.flags |= (short) (label.flags & Label.FLAG_JUMP_TARGET);
// - make sure the two instances share the same Frame instance (the implementation of // - make sure the two instances share the same Frame instance (the implementation of
// {@link Label#getCanonicalInstance} relies on this property; here label.frame should be // {@link Label#getCanonicalInstance} relies on this property; here label.frame should be
// null): // null):
@ -1260,7 +1260,7 @@ final class MethodWriter extends MethodVisitor {
if (lastBasicBlock != null) { if (lastBasicBlock != null) {
if (label.bytecodeOffset == lastBasicBlock.bytecodeOffset) { if (label.bytecodeOffset == lastBasicBlock.bytecodeOffset) {
// Same comment as above. // Same comment as above.
lastBasicBlock.flags |= (label.flags & Label.FLAG_JUMP_TARGET); lastBasicBlock.flags |= (short) (label.flags & Label.FLAG_JUMP_TARGET);
// Here label.frame should be null. // Here label.frame should be null.
label.frame = lastBasicBlock.frame; label.frame = lastBasicBlock.frame;
currentBasicBlock = lastBasicBlock; currentBasicBlock = lastBasicBlock;
@ -2424,4 +2424,3 @@ final class MethodWriter extends MethodVisitor {
attributePrototypes.addAttributes(firstCodeAttribute); attributePrototypes.addAttributes(firstCodeAttribute);
} }
} }

View File

@ -4866,7 +4866,7 @@ public final class Main {
if (pos % 2 == 0) { if (pos % 2 == 0) {
data[pos/2] = (byte)(hex << 4); data[pos/2] = (byte)(hex << 4);
} else { } else {
data[pos/2] += hex; data[pos/2] += (byte)hex;
} }
pos++; pos++;
} }
@ -5338,4 +5338,3 @@ class Pair<A, B> {
return new Pair<>(a,b); return new Pair<>(a,b);
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2021, 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -142,9 +142,9 @@ public class BitArray {
int bit = position(index); int bit = position(index);
if (value) { if (value) {
repn[idx] |= bit; repn[idx] |= (byte) bit;
} else { } else {
repn[idx] &= ~bit; repn[idx] &= (byte) ~bit;
} }
} }

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -717,7 +717,7 @@ public class DerValue {
byte[] retval = Arrays.copyOfRange(buffer, start + 1, end); byte[] retval = Arrays.copyOfRange(buffer, start + 1, end);
if (numOfPadBits != 0) { if (numOfPadBits != 0) {
// get rid of the padding bits // get rid of the padding bits
retval[end - start - 2] &= (0xff << numOfPadBits); retval[end - start - 2] &= (byte)((0xff << numOfPadBits));
} }
data.pos = data.end; // Compatibility. Reach end. data.pos = data.end; // Compatibility. Reach end.
return retval; return retval;

View File

@ -524,10 +524,10 @@ public final class ObjectIdentifier implements Serializable {
// and move them! // and move them!
out[opos/ow] |= // paste! out[opos/ow] |= // paste!
(((in[ioffset+ipos/iw]+256) // locate the byte (+256 so that it's never negative) (byte)((((in[ioffset+ipos/iw]+256) // locate the byte (+256 so that it's never negative)
>> (iw-ipos%iw-count)) & // move to the end of a byte >> (iw-ipos%iw-count)) & // move to the end of a byte
((1 << (count))-1)) // zero out all other bits ((1 << (count))-1)) // zero out all other bits
<< (ow-opos%ow-count); // move to the output position << (ow-opos%ow-count)); // move to the output position
ipos += count; // advance ipos += count; // advance
opos += count; // advance opos += count; // advance
} }
@ -551,7 +551,7 @@ public final class ObjectIdentifier implements Serializable {
if (pack[i] != 0) { if (pack[i] != 0) {
firstNonZero = i; firstNonZero = i;
} }
pack[i] |= 0x80; pack[i] |= (byte)0x80;
} }
System.arraycopy(pack, firstNonZero, System.arraycopy(pack, firstNonZero,
out, ooffset, pack.length-firstNonZero); out, ooffset, pack.length-firstNonZero);

View File

@ -420,8 +420,8 @@ public abstract sealed class IntegerPolynomial implements IntegerFieldModuloP
int bitsAdded = bitsPerLimb - bitPos; int bitsAdded = bitsPerLimb - bitPos;
int bitsLeft = 8 - bitsAdded; int bitsLeft = 8 - bitsAdded;
dst[dstIndex] += (curLimbValue & (0xFF >> bitsAdded)) dst[dstIndex] += (byte) ((curLimbValue & (0xFF >> bitsAdded))
<< bitsAdded; << bitsAdded);
curLimbValue >>= bitsLeft; curLimbValue >>= bitsLeft;
bitPos = bitsLeft; bitPos = bitsLeft;
} else { } else {

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -190,12 +190,12 @@ public final class ZoneInfoFile {
char[] buf = new char[] { 'G', 'M', 'T', sign, '0', '0', ':', '0', '0' }; char[] buf = new char[] { 'G', 'M', 'T', sign, '0', '0', ':', '0', '0' };
if (hh >= 10) { if (hh >= 10) {
buf[4] += hh / 10; buf[4] += (char)(hh / 10);
} }
buf[5] += hh % 10; buf[5] += (char)(hh % 10);
if (mm != 0) { if (mm != 0) {
buf[7] += mm / 10; buf[7] += (char)(mm / 10);
buf[8] += mm % 10; buf[8] += (char)(mm % 10);
} }
return new String(buf); return new String(buf);
} }

View File

@ -120,7 +120,7 @@ class PollSelectorImpl extends SelectorImpl {
if (numPolled == IOStatus.INTERRUPTED && timedPoll) { if (numPolled == IOStatus.INTERRUPTED && timedPoll) {
// timed poll interrupted so need to adjust timeout // timed poll interrupted so need to adjust timeout
long adjust = System.nanoTime() - startTime; long adjust = System.nanoTime() - startTime;
to -= TimeUnit.MILLISECONDS.convert(adjust, TimeUnit.NANOSECONDS); to =- (int) TimeUnit.NANOSECONDS.toMillis(adjust);
if (to <= 0) { if (to <= 0) {
// timeout expired so no retry // timeout expired so no retry
numPolled = 0; numPolled = 0;