test/hotspot/jtreg/vmTestbase/nsk/jvmti/ResourceExhausted/resexhausted003.java
changeset 54279 368757835b97
parent 50260 46c67f5e27c2
equal deleted inserted replaced
54278:16999bd91ba6 54279:368757835b97
     1 /*
     1 /*
     2  * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    24 
    24 
    25 import java.io.File;
    25 import java.io.File;
    26 import java.io.FileInputStream;
    26 import java.io.FileInputStream;
    27 import java.io.PrintStream;
    27 import java.io.PrintStream;
    28 import java.security.ProtectionDomain;
    28 import java.security.ProtectionDomain;
       
    29 import java.util.regex.Pattern;
       
    30 import java.util.regex.Matcher;
    29 
    31 
    30 import nsk.share.Consts;
    32 import nsk.share.Consts;
    31 import nsk.share.test.Stresser;
    33 import nsk.share.test.Stresser;
    32 
    34 
    33 public class resexhausted003 {
    35 public class resexhausted003 {
    75         }
    77         }
    76     }
    78     }
    77 
    79 
    78 
    80 
    79     public static int run(String args[], PrintStream out) {
    81     public static int run(String args[], PrintStream out) {
    80         if ( args == null || args.length < 1 ) {
    82         String testclasspath = System.getProperty("test.class.path");
    81             System.err.println("TEST BUG: Classes directory should be the first argument. Check .cfg file.");
    83         String [] testpaths = testclasspath.split(System.getProperty("path.separator"));
       
    84         String classesDir = "";
       
    85 
       
    86         Pattern pattern = Pattern.compile("^(.*)classes(.*)vmTestbase(.*)$");
       
    87         for (int i = 0 ; i < testpaths.length; i++) {
       
    88             if (pattern.matcher(testpaths[i]).matches()) {
       
    89                 classesDir = testpaths[i];
       
    90             }
       
    91         }
       
    92         if (classesDir.equals("")) {
       
    93             System.err.println("TEST BUG: Classes directory not found in test,class.path.");
    82             return Consts.TEST_FAILED;
    94             return Consts.TEST_FAILED;
    83         }
    95         }
    84 
       
    85         String classesDir = args[0];
       
    86         Stresser stress = new Stresser(args);
    96         Stresser stress = new Stresser(args);
    87 
    97 
    88         String className = Helper.class.getName();
    98         String className = Helper.class.getName();
    89         byte[] bloatBytes = fileBytes(classesDir + File.separator + className.replace('.', '/') + ".class");
    99         byte[] bloatBytes = fileBytes(classesDir + File.separator + className.replace('.', '/') + ".class");
    90 
   100