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 TestG1HeapRegionSize 26 * @key gc 27 * @bug 8021879 28 * @requires vm.gc.G1 29 * @summary Verify that the flag G1HeapRegionSize is updated properly 30 * @modules java.base/jdk.internal.misc 31 * @modules java.management/sun.management 32 * @library /testlibrary 33 * @run main TestG1HeapRegionSize 34 */ 35 36 import java.util.regex.Matcher; 37 import java.util.regex.Pattern; 38 39 import java.util.ArrayList; 40 import java.util.Arrays; 41 42 import jdk.test.lib.*; 43 44 public class TestG1HeapRegionSize { 45 46 private static void checkG1HeapRegionSize(String[] flags, int expectedValue, int exitValue) throws Exception { 47 ArrayList<String> flagList = new ArrayList<String>(); 48 flagList.addAll(Arrays.asList(flags)); 49 flagList.add("-XX:+UseG1GC"); 50 flagList.add("-XX:+PrintFlagsFinal"); 51 flagList.add("-version"); 52 53 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(flagList.toArray(new String[0])); 54 OutputAnalyzer output = new OutputAnalyzer(pb.start()); 55 output.shouldHaveExitValue(exitValue); 56 57 if (exitValue == 0) { 58 String stdout = output.getStdout(); 59 int flagValue = getFlagValue("G1HeapRegionSize", stdout); 60 if (flagValue != expectedValue) { 61 throw new RuntimeException("Wrong value for G1HeapRegionSize. Expected " + expectedValue + " but got " + flagValue); 62 } | 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 TestG1HeapRegionSize 26 * @key gc 27 * @bug 8021879 28 * @requires vm.gc.G1 29 * @summary Verify that the flag G1HeapRegionSize is updated properly 30 * @modules java.base/jdk.internal.misc 31 * @modules java.management/sun.management 32 * @library /test/lib 33 * @run main TestG1HeapRegionSize 34 */ 35 36 import java.util.regex.Matcher; 37 import java.util.regex.Pattern; 38 39 import java.util.ArrayList; 40 import java.util.Arrays; 41 42 import jdk.test.lib.process.OutputAnalyzer; 43 import jdk.test.lib.process.ProcessTools; 44 45 public class TestG1HeapRegionSize { 46 47 private static void checkG1HeapRegionSize(String[] flags, int expectedValue, int exitValue) throws Exception { 48 ArrayList<String> flagList = new ArrayList<String>(); 49 flagList.addAll(Arrays.asList(flags)); 50 flagList.add("-XX:+UseG1GC"); 51 flagList.add("-XX:+PrintFlagsFinal"); 52 flagList.add("-version"); 53 54 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(flagList.toArray(new String[0])); 55 OutputAnalyzer output = new OutputAnalyzer(pb.start()); 56 output.shouldHaveExitValue(exitValue); 57 58 if (exitValue == 0) { 59 String stdout = output.getStdout(); 60 int flagValue = getFlagValue("G1HeapRegionSize", stdout); 61 if (flagValue != expectedValue) { 62 throw new RuntimeException("Wrong value for G1HeapRegionSize. Expected " + expectedValue + " but got " + flagValue); 63 } |