-
Bug
-
Resolution: Fixed
-
P4
-
21
-
b26
-
Verified
I noticed the math problem in jdk.internal.classfile.impl.EntryMap::nextPowerOfTwo:
% jshell
| Welcome to JShell -- Version 19.0.2
| For an introduction type: /help intro
jshell> public static long nextPowerOfTwo( long x ) {
...> x = -1 >>> Long.numberOfLeadingZeros(x - 1);
...> return x + 1;
...> }
| created method nextPowerOfTwo(long)
jshell> nextPowerOfTwo(0)
$2 ==> 0
jshell> nextPowerOfTwo(1)
$3 ==> 0
jshell> nextPowerOfTwo(2)
$4 ==> 2
jshell> nextPowerOfTwo(3)
$5 ==> 4
Note how "1" yields "0" as the next power of two.
Also check if you really need "next" power of two, which should give next(2) = 4. Maybe this is just "round"?
% jshell
| Welcome to JShell -- Version 19.0.2
| For an introduction type: /help intro
jshell> public static long nextPowerOfTwo( long x ) {
...> x = -1 >>> Long.numberOfLeadingZeros(x - 1);
...> return x + 1;
...> }
| created method nextPowerOfTwo(long)
jshell> nextPowerOfTwo(0)
$2 ==> 0
jshell> nextPowerOfTwo(1)
$3 ==> 0
jshell> nextPowerOfTwo(2)
$4 ==> 2
jshell> nextPowerOfTwo(3)
$5 ==> 4
Note how "1" yields "0" as the next power of two.
Also check if you really need "next" power of two, which should give next(2) = 4. Maybe this is just "round"?
- relates to
-
JDK-8294982 Implementation of Classfile API
-
- Resolved
-