mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 22:34:27 +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
|
@ -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);
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue