< prev index next >

test/serviceability/attach/AttachSetGetFlag.java

Print this page




  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 8054823
  27  * @summary Tests the setFlag and printFlag attach command
  28  * @library /testlibrary
  29  * @modules java.base/sun.misc
  30  *          java.compiler
  31  *          java.management
  32  *          jdk.attach/sun.tools.attach
  33  *          jdk.jvmstat/sun.jvmstat.monitor
  34  * @build com.oracle.java.testlibrary.* AttachSetGetFlag
  35  * @run driver AttachSetGetFlag
  36  */
  37 
  38 import java.io.BufferedReader;
  39 import java.io.InputStreamReader;
  40 import java.io.InputStream;
  41 import java.lang.reflect.Field;
  42 import java.nio.file.Files;
  43 import java.nio.file.Path;
  44 import java.nio.file.Paths;
  45 
  46 import sun.tools.attach.HotSpotVirtualMachine;
  47 
  48 import com.oracle.java.testlibrary.Asserts;
  49 import com.oracle.java.testlibrary.Platform;
  50 import com.oracle.java.testlibrary.ProcessTools;
  51 import com.sun.tools.attach.VirtualMachine;
  52 
  53 public class AttachSetGetFlag {
  54 
  55   public static void main(String... args) throws Exception {
  56     // Test a manageable uintx flag.
  57     testGetFlag("MaxHeapFreeRatio", "60");
  58     testSetFlag("MaxHeapFreeRatio", "50", "60");
  59 
  60     // Test a non-manageable size_t flag.
  61     // Since it is not manageable, we can't test the setFlag functionality.
  62     testGetFlag("ArrayAllocatorMallocLimit", "128");
  63     // testSetFlag("ArrayAllocatorMallocLimit", "64", "128");
  64   }
  65 
  66   public static ProcessBuilder runTarget(String flagName, String flagValue) throws Exception {
  67     return ProcessTools.createJavaProcessBuilder(
  68         "-XX:+UnlockExperimentalVMOptions",
  69         "-XX:" + flagName + "=" + flagValue,
  70         "AttachSetGetFlag$Target");




  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 8054823
  27  * @summary Tests the setFlag and printFlag attach command
  28  * @library /testlibrary
  29  * @modules java.base/sun.misc
  30  *          java.compiler
  31  *          java.management
  32  *          jdk.attach/sun.tools.attach
  33  *          jdk.jvmstat/sun.jvmstat.monitor
  34  * @build jdk.test.lib.* AttachSetGetFlag
  35  * @run driver AttachSetGetFlag
  36  */
  37 
  38 import java.io.BufferedReader;
  39 import java.io.InputStreamReader;
  40 import java.io.InputStream;
  41 import java.lang.reflect.Field;
  42 import java.nio.file.Files;
  43 import java.nio.file.Path;
  44 import java.nio.file.Paths;
  45 
  46 import sun.tools.attach.HotSpotVirtualMachine;
  47 
  48 import jdk.test.lib.Asserts;
  49 import jdk.test.lib.Platform;
  50 import jdk.test.lib.ProcessTools;
  51 import com.sun.tools.attach.VirtualMachine;
  52 
  53 public class AttachSetGetFlag {
  54 
  55   public static void main(String... args) throws Exception {
  56     // Test a manageable uintx flag.
  57     testGetFlag("MaxHeapFreeRatio", "60");
  58     testSetFlag("MaxHeapFreeRatio", "50", "60");
  59 
  60     // Test a non-manageable size_t flag.
  61     // Since it is not manageable, we can't test the setFlag functionality.
  62     testGetFlag("ArrayAllocatorMallocLimit", "128");
  63     // testSetFlag("ArrayAllocatorMallocLimit", "64", "128");
  64   }
  65 
  66   public static ProcessBuilder runTarget(String flagName, String flagValue) throws Exception {
  67     return ProcessTools.createJavaProcessBuilder(
  68         "-XX:+UnlockExperimentalVMOptions",
  69         "-XX:" + flagName + "=" + flagValue,
  70         "AttachSetGetFlag$Target");


< prev index next >