From c5cb5b2ac5a2231bf9ccb54003f79f5477de1dc7 Mon Sep 17 00:00:00 2001
From: Doug Lea
Date: Mon, 5 Dec 2011 13:58:44 +0000
Subject: [PATCH] 7117360: Warnings in java.util.concurrent.atomic package
Reviewed-by: chegar, dholmes
---
.../util/concurrent/atomic/AtomicBoolean.java | 8 ++++----
.../util/concurrent/atomic/AtomicInteger.java | 11 +++++------
.../concurrent/atomic/AtomicIntegerArray.java | 1 -
.../atomic/AtomicIntegerFieldUpdater.java | 7 +++----
.../java/util/concurrent/atomic/AtomicLong.java | 15 +++++++--------
.../util/concurrent/atomic/AtomicLongArray.java | 2 --
.../concurrent/atomic/AtomicLongFieldUpdater.java | 12 ++++++------
.../util/concurrent/atomic/AtomicReference.java | 8 ++++----
.../concurrent/atomic/AtomicReferenceArray.java | 3 ++-
.../atomic/AtomicReferenceFieldUpdater.java | 7 ++++---
.../concurrent/atomic/AtomicStampedReference.java | 1 -
11 files changed, 35 insertions(+), 40 deletions(-)
diff --git a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicBoolean.java b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicBoolean.java
index c21df7bab8c..a4d6d8297da 100644
--- a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicBoolean.java
+++ b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicBoolean.java
@@ -54,10 +54,10 @@ public class AtomicBoolean implements java.io.Serializable {
private static final long valueOffset;
static {
- try {
- valueOffset = unsafe.objectFieldOffset
- (AtomicBoolean.class.getDeclaredField("value"));
- } catch (Exception ex) { throw new Error(ex); }
+ try {
+ valueOffset = unsafe.objectFieldOffset
+ (AtomicBoolean.class.getDeclaredField("value"));
+ } catch (Exception ex) { throw new Error(ex); }
}
private volatile int value;
diff --git a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicInteger.java b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicInteger.java
index ec68acd781a..1bc7fa2aa44 100644
--- a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicInteger.java
+++ b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicInteger.java
@@ -57,10 +57,10 @@ public class AtomicInteger extends Number implements java.io.Serializable {
private static final long valueOffset;
static {
- try {
- valueOffset = unsafe.objectFieldOffset
- (AtomicInteger.class.getDeclaredField("value"));
- } catch (Exception ex) { throw new Error(ex); }
+ try {
+ valueOffset = unsafe.objectFieldOffset
+ (AtomicInteger.class.getDeclaredField("value"));
+ } catch (Exception ex) { throw new Error(ex); }
}
private volatile int value;
@@ -247,8 +247,7 @@ public class AtomicInteger extends Number implements java.io.Serializable {
/**
- * Returns the value of this {@code AtomicInteger} as an
- * {@code int}.
+ * Returns the value of this {@code AtomicInteger} as an {@code int}.
*/
public int intValue() {
return get();
diff --git a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java
index 46227019856..9928e5974fa 100644
--- a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java
+++ b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java
@@ -35,7 +35,6 @@
package java.util.concurrent.atomic;
import sun.misc.Unsafe;
-import java.util.*;
/**
* An {@code int} array in which elements may be updated atomically.
diff --git a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java
index aed5d1fc170..9f4fee4aa84 100644
--- a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java
+++ b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java
@@ -135,7 +135,6 @@ public abstract class AtomicIntegerFieldUpdater {
*/
public abstract void lazySet(T obj, int newValue);
-
/**
* Gets the current value held in the field of the given object managed
* by this updater.
@@ -266,11 +265,11 @@ public abstract class AtomicIntegerFieldUpdater {
private static final Unsafe unsafe = Unsafe.getUnsafe();
private final long offset;
private final Class tclass;
- private final Class cclass;
+ private final Class> cclass;
AtomicIntegerFieldUpdaterImpl(Class tclass, String fieldName) {
Field field = null;
- Class caller = null;
+ Class> caller = null;
int modifiers = 0;
try {
field = tclass.getDeclaredField(fieldName);
@@ -283,7 +282,7 @@ public abstract class AtomicIntegerFieldUpdater {
throw new RuntimeException(ex);
}
- Class fieldt = field.getType();
+ Class> fieldt = field.getType();
if (fieldt != int.class)
throw new IllegalArgumentException("Must be integer type");
diff --git a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicLong.java b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicLong.java
index bf2c71a340a..f503d577d1b 100644
--- a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicLong.java
+++ b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicLong.java
@@ -71,10 +71,10 @@ public class AtomicLong extends Number implements java.io.Serializable {
private static native boolean VMSupportsCS8();
static {
- try {
- valueOffset = unsafe.objectFieldOffset
- (AtomicLong.class.getDeclaredField("value"));
- } catch (Exception ex) { throw new Error(ex); }
+ try {
+ valueOffset = unsafe.objectFieldOffset
+ (AtomicLong.class.getDeclaredField("value"));
+ } catch (Exception ex) { throw new Error(ex); }
}
private volatile long value;
@@ -270,8 +270,7 @@ public class AtomicLong extends Number implements java.io.Serializable {
}
/**
- * Returns the value of this {@code AtomicLong} as a {@code long}
- * value.
+ * Returns the value of this {@code AtomicLong} as a {@code long}.
*/
public long longValue() {
return get();
@@ -287,8 +286,8 @@ public class AtomicLong extends Number implements java.io.Serializable {
}
/**
- * Returns the value of this {@code AtomicLong} as a {@code
- * double} after a widening primitive conversion.
+ * Returns the value of this {@code AtomicLong} as a {@code double}
+ * after a widening primitive conversion.
* @jls 5.1.2 Widening Primitive Conversions
*/
public double doubleValue() {
diff --git a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicLongArray.java b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicLongArray.java
index ece5b6ad9b0..856ab39e0c6 100644
--- a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicLongArray.java
+++ b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicLongArray.java
@@ -35,7 +35,6 @@
package java.util.concurrent.atomic;
import sun.misc.Unsafe;
-import java.util.*;
/**
* A {@code long} array in which elements may be updated atomically.
@@ -136,7 +135,6 @@ public class AtomicLongArray implements java.io.Serializable {
unsafe.putOrderedLong(array, checkedByteOffset(i), newValue);
}
-
/**
* Atomically sets the element at position {@code i} to the given value
* and returns the old value.
diff --git a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java
index fa0a857152d..ccc5acbfe21 100644
--- a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java
+++ b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java
@@ -265,11 +265,11 @@ public abstract class AtomicLongFieldUpdater {
private static final Unsafe unsafe = Unsafe.getUnsafe();
private final long offset;
private final Class tclass;
- private final Class cclass;
+ private final Class> cclass;
CASUpdater(Class tclass, String fieldName) {
Field field = null;
- Class caller = null;
+ Class> caller = null;
int modifiers = 0;
try {
field = tclass.getDeclaredField(fieldName);
@@ -282,7 +282,7 @@ public abstract class AtomicLongFieldUpdater {
throw new RuntimeException(ex);
}
- Class fieldt = field.getType();
+ Class> fieldt = field.getType();
if (fieldt != long.class)
throw new IllegalArgumentException("Must be long type");
@@ -348,11 +348,11 @@ public abstract class AtomicLongFieldUpdater {
private static final Unsafe unsafe = Unsafe.getUnsafe();
private final long offset;
private final Class tclass;
- private final Class cclass;
+ private final Class> cclass;
LockedUpdater(Class tclass, String fieldName) {
Field field = null;
- Class caller = null;
+ Class> caller = null;
int modifiers = 0;
try {
field = tclass.getDeclaredField(fieldName);
@@ -365,7 +365,7 @@ public abstract class AtomicLongFieldUpdater {
throw new RuntimeException(ex);
}
- Class fieldt = field.getType();
+ Class> fieldt = field.getType();
if (fieldt != long.class)
throw new IllegalArgumentException("Must be long type");
diff --git a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicReference.java b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicReference.java
index 3178ca1579f..978664e2d83 100644
--- a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicReference.java
+++ b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicReference.java
@@ -51,10 +51,10 @@ public class AtomicReference implements java.io.Serializable {
private static final long valueOffset;
static {
- try {
- valueOffset = unsafe.objectFieldOffset
- (AtomicReference.class.getDeclaredField("value"));
- } catch (Exception ex) { throw new Error(ex); }
+ try {
+ valueOffset = unsafe.objectFieldOffset
+ (AtomicReference.class.getDeclaredField("value"));
+ } catch (Exception ex) { throw new Error(ex); }
}
private volatile V value;
diff --git a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java
index b173f26808b..d92bdb5f2f4 100644
--- a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java
+++ b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java
@@ -113,6 +113,7 @@ public class AtomicReferenceArray implements java.io.Serializable {
return getRaw(checkedByteOffset(i));
}
+ @SuppressWarnings("unchecked")
private E getRaw(long offset) {
return (E) unsafe.getObjectVolatile(array, offset);
}
@@ -150,7 +151,7 @@ public class AtomicReferenceArray implements java.io.Serializable {
public final E getAndSet(int i, E newValue) {
long offset = checkedByteOffset(i);
while (true) {
- E current = (E) getRaw(offset);
+ E current = getRaw(offset);
if (compareAndSetRaw(offset, current, newValue))
return current;
}
diff --git a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java
index 7b72f0ff494..f2e0118aae7 100644
--- a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java
+++ b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java
@@ -183,7 +183,7 @@ public abstract class AtomicReferenceFieldUpdater {
private final long offset;
private final Class tclass;
private final Class vclass;
- private final Class cclass;
+ private final Class> cclass;
/*
* Internal type checks within all update methods contain
@@ -201,8 +201,8 @@ public abstract class AtomicReferenceFieldUpdater {
Class vclass,
String fieldName) {
Field field = null;
- Class fieldClass = null;
- Class caller = null;
+ Class> fieldClass = null;
+ Class> caller = null;
int modifiers = 0;
try {
field = tclass.getDeclaredField(fieldName);
@@ -280,6 +280,7 @@ public abstract class AtomicReferenceFieldUpdater {
unsafe.putOrderedObject(obj, offset, newValue);
}
+ @SuppressWarnings("unchecked")
public V get(T obj) {
if (obj == null || obj.getClass() != tclass || cclass != null)
targetCheck(obj);
diff --git a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicStampedReference.java b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicStampedReference.java
index 90aa3a0c538..5f8f1a03db9 100644
--- a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicStampedReference.java
+++ b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicStampedReference.java
@@ -155,7 +155,6 @@ public class AtomicStampedReference {
casPair(current, Pair.of(newReference, newStamp)));
}
-
/**
* Unconditionally sets the value of both the reference and stamp.
*