test/jdk/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java
changeset 59053 ba6c248cae19
parent 51675 b487c1e914d0
equal deleted inserted replaced
59051:f0312c7d5b37 59053:ba6c248cae19
     1 /*
     1 /*
     2  * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2013, 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.
    23 
    23 
    24 /*
    24 /*
    25  * @test
    25  * @test
    26  * @bug 8028994
    26  * @bug 8028994
    27  * @author Staffan Larsen
    27  * @author Staffan Larsen
    28  * @comment Graal does not support CMS
       
    29  * @requires !vm.graal.enabled
       
    30  * @library /test/lib
    28  * @library /test/lib
    31  * @modules jdk.attach/sun.tools.attach
    29  * @modules jdk.attach/sun.tools.attach
    32  *          jdk.management
    30  *          jdk.management
    33  * @run main CheckOrigin
    31  * @run main CheckOrigin
    34  */
    32  */
    61             }
    59             }
    62 
    60 
    63             ProcessBuilder pb = ProcessTools.
    61             ProcessBuilder pb = ProcessTools.
    64                 createJavaProcessBuilder(
    62                 createJavaProcessBuilder(
    65                     "--add-exports", "jdk.attach/sun.tools.attach=ALL-UNNAMED",
    63                     "--add-exports", "jdk.attach/sun.tools.attach=ALL-UNNAMED",
    66                     "-XX:+UseConcMarkSweepGC",  // this will cause MaxNewSize to be FLAG_SET_ERGO
    64                     "-XX:+UseG1GC",  // this will cause MaxNewSize to be FLAG_SET_ERGO
    67                     "-XX:+UseCodeAging",
    65                     "-XX:+UseCodeAging",
    68                     "-XX:+UseCerealGC",         // Should be ignored.
    66                     "-XX:+UseCerealGC",         // Should be ignored.
    69                     "-XX:Flags=" + flagsFile.getAbsolutePath(),
    67                     "-XX:Flags=" + flagsFile.getAbsolutePath(),
    70                     "-Djdk.attach.allowAttachSelf",
    68                     "-Djdk.attach.allowAttachSelf",
    71                     "-cp", System.getProperty("test.class.path"),
    69                     "-cp", System.getProperty("test.class.path"),
    72                     "CheckOrigin",
    70                     "CheckOrigin",
    73                     "-runtests");
    71                     "-runtests");
    74 
    72 
    75             Map<String, String> env = pb.environment();
    73             Map<String, String> env = pb.environment();
    76             // "UseCMSGC" should be ignored.
    74             env.put("_JAVA_OPTIONS", "-XX:+CheckJNICalls");
    77             env.put("_JAVA_OPTIONS", "-XX:+CheckJNICalls -XX:+UseCMSGC");
       
    78             // "UseGOneGC" should be ignored.
    75             // "UseGOneGC" should be ignored.
    79             env.put("JAVA_TOOL_OPTIONS", "-XX:+IgnoreUnrecognizedVMOptions "
    76             env.put("JAVA_TOOL_OPTIONS", "-XX:+IgnoreUnrecognizedVMOptions "
    80                 + "-XX:+PrintVMOptions -XX:+UseGOneGC");
    77                 + "-XX:+PrintVMOptions -XX:+UseGOneGC");
    81 
    78 
    82             pb.redirectOutput(ProcessBuilder.Redirect.INHERIT);
    79             pb.redirectOutput(ProcessBuilder.Redirect.INHERIT);
   108             checkOrigin("PrintVMOptions", Origin.ENVIRON_VAR);
   105             checkOrigin("PrintVMOptions", Origin.ENVIRON_VAR);
   109             // Set in -XX:Flags file
   106             // Set in -XX:Flags file
   110             checkOrigin("PrintVMQWaitTime", Origin.CONFIG_FILE);
   107             checkOrigin("PrintVMQWaitTime", Origin.CONFIG_FILE);
   111             // Set through j.l.m
   108             // Set through j.l.m
   112             checkOrigin("HeapDumpOnOutOfMemoryError", Origin.MANAGEMENT);
   109             checkOrigin("HeapDumpOnOutOfMemoryError", Origin.MANAGEMENT);
   113             // Should be set by the VM, when we set UseConcMarkSweepGC
   110             // Should be set by the VM, when we set UseG1GC
   114             checkOrigin("MaxNewSize", Origin.ERGONOMIC);
   111             checkOrigin("MaxNewSize", Origin.ERGONOMIC);
   115             // Set using attach
   112             // Set using attach
   116             checkOrigin("HeapDumpPath", Origin.ATTACH_ON_DEMAND);
   113             checkOrigin("HeapDumpPath", Origin.ATTACH_ON_DEMAND);
   117         }
   114         }
   118     }
   115     }