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

@ -4866,7 +4866,7 @@ public final class Main {
if (pos % 2 == 0) {
data[pos/2] = (byte)(hex << 4);
} else {
data[pos/2] += hex;
data[pos/2] += (byte)hex;
}
pos++;
}
@ -5338,4 +5338,3 @@ class 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.
*
* This code is free software; you can redistribute it and/or modify it
@ -142,9 +142,9 @@ public class BitArray {
int bit = position(index);
if (value) {
repn[idx] |= bit;
repn[idx] |= (byte) bit;
} 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.
*
* 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);
if (numOfPadBits != 0) {
// 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.
return retval;

View file

@ -524,10 +524,10 @@ public final class ObjectIdentifier implements Serializable {
// and move them!
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
((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
opos += count; // advance
}
@ -551,7 +551,7 @@ public final class ObjectIdentifier implements Serializable {
if (pack[i] != 0) {
firstNonZero = i;
}
pack[i] |= 0x80;
pack[i] |= (byte)0x80;
}
System.arraycopy(pack, firstNonZero,
out, ooffset, pack.length-firstNonZero);

View file

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