src/share/classes/java/util/concurrent/ArrayBlockingQueue.java
Print this page
*** 129,140 ****
}
/**
* Returns item at index i.
*/
final E itemAt(int i) {
! return this.<E>cast(items[i]);
}
/**
* Throws NullPointerException if argument is null.
*
--- 129,141 ----
}
/**
* Returns item at index i.
*/
+ @SuppressWarnings("unchecked")
final E itemAt(int i) {
! return (E) items[i];
}
/**
* Throws NullPointerException if argument is null.
*
*** 160,170 ****
* Extracts element at current take position, advances, and signals.
* Call only when holding lock.
*/
private E extract() {
final Object[] items = this.items;
! E x = this.<E>cast(items[takeIndex]);
items[takeIndex] = null;
takeIndex = inc(takeIndex);
--count;
notFull.signal();
return x;
--- 161,171 ----
* Extracts element at current take position, advances, and signals.
* Call only when holding lock.
*/
private E extract() {
final Object[] items = this.items;
! @SuppressWarnings("unchecked") E x = (E) items[takeIndex];
items[takeIndex] = null;
takeIndex = inc(takeIndex);
--count;
notFull.signal();
return x;
*** 645,655 ****
try {
int i = takeIndex;
int n = 0;
int max = count;
while (n < max) {
! c.add(this.<E>cast(items[i]));
items[i] = null;
i = inc(i);
++n;
}
if (n > 0) {
--- 646,657 ----
try {
int i = takeIndex;
int n = 0;
int max = count;
while (n < max) {
! @SuppressWarnings("unchecked") E x = (E) items[i];
! c.add(x);
items[i] = null;
i = inc(i);
++n;
}
if (n > 0) {
*** 682,692 ****
try {
int i = takeIndex;
int n = 0;
int max = (maxElements < count) ? maxElements : count;
while (n < max) {
! c.add(this.<E>cast(items[i]));
items[i] = null;
i = inc(i);
++n;
}
if (n > 0) {
--- 684,695 ----
try {
int i = takeIndex;
int n = 0;
int max = (maxElements < count) ? maxElements : count;
while (n < max) {
! @SuppressWarnings("unchecked") E x = (E) items[i];
! c.add(x);
items[i] = null;
i = inc(i);
++n;
}
if (n > 0) {