- assigned_to: nobody --> wpugh
- status: open --> open-accepted
Errors should flag s_atomic1, s_atomic2, and s_atomic3. s_atomic1's fieldName doesn't point to any member variable in Enhancement. s_atomic2's fieldName points to a member variable but it is of the wrong type. s_atomic3's fieldName points to a member variable but it isn't volatile.
private static final AtomicIntegerFieldUpdater<Bug> s_atomic1 = AtomicIntegerFieldUpdater.newUpdater(Bug.class, "noSuchField");
private static final AtomicIntegerFieldUpdater<Bug> s_atomic2 = AtomicIntegerFieldUpdater.newUpdater(Bug.class, "incorrectFieldType");
private static final AtomicIntegerFieldUpdater<Bug> s_atomic3 = AtomicIntegerFieldUpdater.newUpdater(Bug.class, "fieldNotVolatile");
private volatile long incorrectFieldType;
private int fieldNotVolatile;
In the byte code, we would see the following in the static initializer...
0: ldc #1 // class Bug
2: ldc #29 // String noSuchField
4: invokestatic #31 // Method
java/util/concurrent/atomic/AtomicIntegerFieldUpdater.newUpdater:(Ljava/lang/Class;Ljava/lang/String;)Ljava/util/concurrent/atomic/AtomicIntegerFieldUpdater;
7: putstatic #37 // Field
s_atomic1:Ljava/util/concurrent/atomic/AtomicIntegerFieldUpdater;
Here's how I envision the feature working. It will...
1) See the invokestatic instruction on Atomic___FieldUpdater.newUpdater.
2) Look at what class and string are being passed as a parameters.
3) Examine the fields of the referred class.
4) Find the field that has the same name as the string parameter.
a) If no field with that name exists, flag a problem.
5) Check the field to ensure it is the right type.
6) Check the field to ensure it is a volatile.