< prev index next >

test/lib/testlibrary/jdk/testlibrary/Utils.java

Print this page
rev 10787 : [mq]: incgc


 111      * Combines given arguments with default JTReg arguments for a jvm running a test.
 112      * This is the combination of JTReg arguments test.vm.opts and test.java.opts
 113      * @return The combination of JTReg test java options and user args.
 114      */
 115     public static String[] addTestJavaOpts(String... userArgs) {
 116         List<String> opts = new ArrayList<String>();
 117         Collections.addAll(opts, getTestJavaOpts());
 118         Collections.addAll(opts, userArgs);
 119         return opts.toArray(new String[0]);
 120     }
 121 
 122     /**
 123      * Removes any options specifying which GC to use, for example "-XX:+UseG1GC".
 124      * Removes any options matching: -XX:(+/-)Use*GC
 125      * Used when a test need to set its own GC version. Then any
 126      * GC specified by the framework must first be removed.
 127      * @return A copy of given opts with all GC options removed.
 128      */
 129     private static final Pattern useGcPattern = Pattern.compile(
 130             "(?:\\-XX\\:[\\+\\-]Use.+GC)"
 131             + "|(?:\\-Xconcgc)"
 132             + "|(?:\\-Xincgc)");
 133     public static List<String> removeGcOpts(List<String> opts) {
 134         List<String> optsWithoutGC = new ArrayList<String>();
 135         for (String opt : opts) {
 136             if (useGcPattern.matcher(opt).matches()) {
 137                 System.out.println("removeGcOpts: removed " + opt);
 138             } else {
 139                 optsWithoutGC.add(opt);
 140             }
 141         }
 142         return optsWithoutGC;
 143     }
 144 
 145     /**
 146      * Splits a string by white space.
 147      * Works like String.split(), but returns an empty array
 148      * if the string is null or empty.
 149      */
 150     private static String[] safeSplitString(String s) {
 151         if (s == null || s.trim().isEmpty()) {
 152             return new String[] {};




 111      * Combines given arguments with default JTReg arguments for a jvm running a test.
 112      * This is the combination of JTReg arguments test.vm.opts and test.java.opts
 113      * @return The combination of JTReg test java options and user args.
 114      */
 115     public static String[] addTestJavaOpts(String... userArgs) {
 116         List<String> opts = new ArrayList<String>();
 117         Collections.addAll(opts, getTestJavaOpts());
 118         Collections.addAll(opts, userArgs);
 119         return opts.toArray(new String[0]);
 120     }
 121 
 122     /**
 123      * Removes any options specifying which GC to use, for example "-XX:+UseG1GC".
 124      * Removes any options matching: -XX:(+/-)Use*GC
 125      * Used when a test need to set its own GC version. Then any
 126      * GC specified by the framework must first be removed.
 127      * @return A copy of given opts with all GC options removed.
 128      */
 129     private static final Pattern useGcPattern = Pattern.compile(
 130             "(?:\\-XX\\:[\\+\\-]Use.+GC)"
 131             + "|(?:\\-Xconcgc)");

 132     public static List<String> removeGcOpts(List<String> opts) {
 133         List<String> optsWithoutGC = new ArrayList<String>();
 134         for (String opt : opts) {
 135             if (useGcPattern.matcher(opt).matches()) {
 136                 System.out.println("removeGcOpts: removed " + opt);
 137             } else {
 138                 optsWithoutGC.add(opt);
 139             }
 140         }
 141         return optsWithoutGC;
 142     }
 143 
 144     /**
 145      * Splits a string by white space.
 146      * Works like String.split(), but returns an empty array
 147      * if the string is null or empty.
 148      */
 149     private static String[] safeSplitString(String s) {
 150         if (s == null || s.trim().isEmpty()) {
 151             return new String[] {};


< prev index next >