...
Code Block | ||
---|---|---|
| ||
class LongContainer { private static long i = 0; static void one(long j) { i = j; } static void two() { System.out.println("i = " + i); } } |
...
Code Block | ||
---|---|---|
| ||
class LongContainer { private static volatile long i = 0; static void one(long j) { i = j; } static void two() { System.out.println("i = " + i); } } |
It is important to ensure that the argument to method one()
is obtained from a volatile
variable or as a result of explicitly passing an integer value. Otherwise, a read of the variable argument may itself expose a vulnerability.
...