test/testlibrary/com/oracle/java/testlibrary/InputArguments.java

Print this page
rev 5230 : 8024718: Metaspace performance counters and memory pools should report the same data


  22  */
  23 
  24 package com.oracle.java.testlibrary;
  25 
  26 import java.lang.management.RuntimeMXBean;
  27 import java.lang.management.ManagementFactory;
  28 import java.util.List;
  29 
  30 /**
  31  * This class provides access to the input arguments to the VM.
  32  */
  33 public class InputArguments {
  34     private static final List<String> args;
  35 
  36     static {
  37         RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean();
  38         args = runtimeMxBean.getInputArguments();
  39     }
  40 
  41     /**
  42      * Returns true if {@code arg} is an input argument to the VM.

  43      *
  44      * @param arg The name of the argument.
  45      * @return {@code true} if the given argument is an input argument,
  46      *         otherwise {@code false}.
  47      */
  48     public static boolean contains(String arg) {
  49         return args.contains(arg);





  50     }
  51 }


  22  */
  23 
  24 package com.oracle.java.testlibrary;
  25 
  26 import java.lang.management.RuntimeMXBean;
  27 import java.lang.management.ManagementFactory;
  28 import java.util.List;
  29 
  30 /**
  31  * This class provides access to the input arguments to the VM.
  32  */
  33 public class InputArguments {
  34     private static final List<String> args;
  35 
  36     static {
  37         RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean();
  38         args = runtimeMxBean.getInputArguments();
  39     }
  40 
  41     /**
  42      * Returns true if {@code prefix} is the start of an input argument to the
  43      * VM.
  44      *
  45      * @param prefix The start of the argument.
  46      * @return {@code true} if the given argument is the start of an input
  47      *         argument, otherwise {@code false}.
  48      */
  49     public static boolean contains(String prefix) {
  50         for (String arg : args) {
  51             if (arg.startsWith(prefix)) {
  52                 return true;
  53             }
  54         }
  55         return false;
  56     }
  57 }