< prev index next >

test/serviceability/attach/AttachSetGetFlag.java

Print this page




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  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/jdk.internal.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 main 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     // Test a uint flag.
  66     testGetFlag("ParallelGCThreads", "10");
  67   }
  68 
  69   public static ProcessBuilder runTarget(String flagName, String flagValue) throws Exception {
  70     return ProcessTools.createJavaProcessBuilder(




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  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 /test/lib
  29  * @modules java.base/jdk.internal.misc
  30  *          java.compiler
  31  *          java.management
  32  *          jdk.attach/sun.tools.attach
  33  *          jdk.jvmstat/sun.jvmstat.monitor

  34  * @run main AttachSetGetFlag
  35  */
  36 
  37 import java.io.BufferedReader;
  38 import java.io.InputStreamReader;
  39 import java.io.InputStream;
  40 import java.lang.reflect.Field;
  41 import java.nio.file.Files;
  42 import java.nio.file.Path;
  43 import java.nio.file.Paths;
  44 
  45 import sun.tools.attach.HotSpotVirtualMachine;
  46 
  47 import jdk.test.lib.Asserts;
  48 import jdk.test.lib.Platform;
  49 import jdk.test.lib.process.ProcessTools;
  50 import com.sun.tools.attach.VirtualMachine;
  51 
  52 public class AttachSetGetFlag {
  53 
  54   public static void main(String... args) throws Exception {
  55     // Test a manageable uintx flag.
  56     testGetFlag("MaxHeapFreeRatio", "60");
  57     testSetFlag("MaxHeapFreeRatio", "50", "60");
  58 
  59     // Test a non-manageable size_t flag.
  60     // Since it is not manageable, we can't test the setFlag functionality.
  61     testGetFlag("ArrayAllocatorMallocLimit", "128");
  62     // testSetFlag("ArrayAllocatorMallocLimit", "64", "128");
  63 
  64     // Test a uint flag.
  65     testGetFlag("ParallelGCThreads", "10");
  66   }
  67 
  68   public static ProcessBuilder runTarget(String flagName, String flagValue) throws Exception {
  69     return ProcessTools.createJavaProcessBuilder(


< prev index next >