Skip to content

Commit

Permalink
Code refinement for JDK-picked classes (alibaba#1014)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaoyuguang authored and sczyh30 committed Aug 26, 2019
1 parent 820ff92 commit 1253471
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class LongAdder extends Striped64 implements Serializable {
/**
* Version of plus for use in retryUpdate
*/
@Override
final long fn(long v, long x) { return v + x; }

/**
Expand Down Expand Up @@ -153,6 +154,7 @@ public long sumThenReset() {
*
* @return the String representation of the {@link #sum}
*/
@Override
public String toString() {
return Long.toString(sum());
}
Expand All @@ -162,6 +164,7 @@ public String toString() {
*
* @return the sum
*/
@Override
public long longValue() {
return sum();
}
Expand All @@ -170,6 +173,7 @@ public long longValue() {
* Returns the {@link #sum} as an {@code int} after a narrowing
* primitive conversion.
*/
@Override
public int intValue() {
return (int)sum();
}
Expand All @@ -178,6 +182,7 @@ public int intValue() {
* Returns the {@link #sum} as a {@code float}
* after a widening primitive conversion.
*/
@Override
public float floatValue() {
return (float)sum();
}
Expand All @@ -186,6 +191,7 @@ public float floatValue() {
* Returns the {@link #sum} as a {@code double} after a widening
* primitive conversion.
*/
@Override
public double doubleValue() {
return (double)sum();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ static final class HashCode {
* The corresponding ThreadLocal class
*/
static final class ThreadHashCode extends ThreadLocal<HashCode> {
@Override
public HashCode initialValue() { return new HashCode(); }
}

Expand Down Expand Up @@ -330,6 +331,7 @@ private static sun.misc.Unsafe getUnsafe() {
return java.security.AccessController.doPrivileged
(new java.security
.PrivilegedExceptionAction<sun.misc.Unsafe>() {
@Override
public sun.misc.Unsafe run() throws Exception {
java.lang.reflect.Field f = sun.misc
.Unsafe.class.getDeclaredField("theUnsafe");
Expand Down

0 comments on commit 1253471

Please sign in to comment.