/**
* @test
* @bug 6359397
* @summary Test if RandomAccessFile methods will check if the stream
* has been closed.
*/
public enum OpsAfterClose {
try {
r.read();
} catch (IOException io) {
return true;
}
return false;
} },
try {
byte buf[] = new byte[2];
int len = 1;
} catch (IOException io) {
return true;
}
return false;
} },
r.getChannel();
return true;
} },
try {
r.getFD();
return true;
} catch (IOException io) {
return false;
}
} },
try {
r.getFilePointer();
} catch (IOException io) {
return true;
}
return false;
} },
try {
r.length();
} catch (IOException io) {
return true;
}
return false;
} },
try {
r.seek(1);
} catch (IOException io) {
return true;
}
return false;
} },
try {
r.setLength(1);
} catch (IOException io) {
return true;
}
return false;
} },
try {
r.skipBytes(1);
} catch (IOException io) {
return true;
}
return false;
} },
try {
r.write(1);
} catch (IOException io) {
return true;
}
return false;
} },
try {
byte buf[] = new byte[2];
int len = 1;
} catch (IOException io) {
return true;
}
return false;
} },
try {
r.close();
return true; // No Exception thrown on windows
} catch (IOException io) {
return true; // Exception thrown on solaris and linux
}
} };
boolean failed = false;
"raf.txt");
f.createNewFile();
f.deleteOnExit();
if (testRandomAccessFile(raf)) {
throw new Exception("Test failed for some of the operation{s}" +
" on RandomAccessFile, check the messages");
}
}
throws Exception {
r.close();
boolean failed = false;
boolean result;
if (!result) {
failed = true;
}
}
if (failed) {
" above for the RandomAccessFile:" + r);
}
return failed;
}
}