|
15 | 15 | */ |
16 | 16 | package java.lang; |
17 | 17 |
|
18 | | -/** |
19 | | - * Wraps a primitive <code>long</code> as an object. |
20 | | - */ |
| 18 | +/** Wraps a primitive <code>long</code> as an object. */ |
21 | 19 | public final class Long extends Number implements Comparable<Long> { |
22 | 20 |
|
23 | | - /** |
24 | | - * Use nested class to avoid clinit on outer. |
25 | | - */ |
| 21 | + /** Use nested class to avoid clinit on outer. */ |
26 | 22 | static class BoxedValues { |
27 | 23 | // Box values according to JLS - between -128 and 127 |
28 | 24 | static Long[] boxedValues = new Long[256]; |
@@ -56,7 +52,9 @@ public static Long decode(String s) throws NumberFormatException { |
56 | 52 | } |
57 | 53 |
|
58 | 54 | public static int hashCode(long l) { |
59 | | - return (int) l; |
| 55 | + int high = (int) (l >>> 32); |
| 56 | + int low = (int) l; |
| 57 | + return high ^ low; |
60 | 58 | } |
61 | 59 |
|
62 | 60 | public static long highestOneBit(long i) { |
@@ -109,15 +107,13 @@ public static long parseLong(String s, int radix) throws NumberFormatException { |
109 | 107 | public static long reverse(long i) { |
110 | 108 | int high = (int) (i >>> 32); |
111 | 109 | int low = (int) i; |
112 | | - return ((long) Integer.reverse(low) << 32) |
113 | | - | (Integer.reverse(high) & 0xffffffffL); |
| 110 | + return ((long) Integer.reverse(low) << 32) | (Integer.reverse(high) & 0xffffffffL); |
114 | 111 | } |
115 | 112 |
|
116 | 113 | public static long reverseBytes(long i) { |
117 | 114 | int high = (int) (i >>> 32); |
118 | 115 | int low = (int) i; |
119 | | - return ((long) Integer.reverseBytes(low) << 32) |
120 | | - | (Integer.reverseBytes(high) & 0xffffffffL); |
| 116 | + return ((long) Integer.reverseBytes(low) << 32) | (Integer.reverseBytes(high) & 0xffffffffL); |
121 | 117 | } |
122 | 118 |
|
123 | 119 | public static long rotateLeft(long i, int distance) { |
|
0 commit comments