/**
* @test
* @bug 7088367
* @summary SourceDataLine.write and TargetDataLine.read don't throw ArrayIndexOutOfBoundsException
* @author Alex Menkov
*/
public class DataLine_ArrayIndexOutOfBounds {
// shared buffer for all tests
// the class describes different test scenarios (buffer properties)
static abstract class Scenario {
}
// scenarios to tests
new Scenario() {
return "offset is near Integer.MAX_VALUE";
}
}
return 65536;
}
},
new Scenario() {
return "offset is less than buffer.length, length is large";
}
}
}
}
};
try {
}
} catch (LineUnavailableException ex) {
}
}
if (failed == 0) {
} else {
throw new Exception("Test FAILED");
}
}
// starts the thread and waits until it becomes ready
synchronized (readyEvent) {
try {
readyEvent.wait();
} catch (InterruptedException ex) { }
}
}
// makes the delay and then stops the line
public void schedule() {
synchronized(startEvent) {
}
}
public void force() {
try {
} catch (InterruptedException ex) {
}
}
// Runnable implementation
public void run() {
try {
synchronized(readyEvent) {
}
synchronized(startEvent) {
startEvent.wait();
}
// delay
} catch (InterruptedException ex) {
}
// and flush
log(" stop...");
log(" close...");
}
}
try {
log(" open...");
} catch (IllegalArgumentException ex) {
log(" unsupported (IllegalArgumentException)");
return;
} catch (LineUnavailableException ex) {
return;
}
total++;
log(" start...");
// ensure len represents integral number of frames
log(" write...");
try {
log(" ERROR: didn't get ArrayIndexOutOfBoundsException");
failed++;
} catch (ArrayIndexOutOfBoundsException ex) {
}
lineStopper.force();
}
try {
log(" open...");
} catch (IllegalArgumentException ex) {
log(" unsupported (IllegalArgumentException)");
return;
} catch (LineUnavailableException ex) {
return;
}
total++;
log(" start...");
// ensure len represents integral number of frames
log(" read...");
try {
log(" ERROR: didn't get ArrayIndexOutOfBoundsException");
failed++;
} catch (ArrayIndexOutOfBoundsException ex) {
}
lineStopper.force();
}
}
}