test/java/lang/Runtime/exec/LotsOfOutput.java
Print this page
@@ -26,20 +26,20 @@
* @bug 4369826
* @summary Process with lots of output should not crash VM
* @author kladko
*/
-import java.io.File;
-
public class LotsOfOutput {
- static final String CAT = "/usr/bin/cat";
+ static final boolean isWindows =
+ System.getProperty("os.name", "unknown").startsWith("Windows");
- public static void main(String[] args) throws Exception{
- if (File.separatorChar == '\\' || // Windows
- !new File(CAT).exists()) // no cat
+ public static void main(String[] args) throws Exception {
+ if (isWindows) {
+ System.err.println("Not for Windows");
return;
- Process p = Runtime.getRuntime().exec(CAT + " /dev/zero");
+ }
+ Process p = Runtime.getRuntime().exec("cat /dev/zero");
long initMemory = Runtime.getRuntime().totalMemory();
for (int i=1; i< 10; i++) {
Thread.sleep(100);
if (Runtime.getRuntime().totalMemory() > initMemory + 1000000)
throw new Exception("Process consumes memory.");