11/*
2- * Copyright (c) 2013, 2024 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2013, 2025 , Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
@@ -47,24 +47,19 @@ enum Validation {
4747 COMBINATION_INVALID
4848 }
4949
50- private static void testMinMaxFreeRatio (String min , String max , Validation type ) throws Exception {
51- OutputAnalyzer output = GCArguments .executeTestJava (
52- "-Xminf" + min ,
53- "-Xmaxf" + max ,
54- "-version" );
55-
50+ private static void checkValidity (OutputAnalyzer output , String min , String max , Validation type ) {
5651 switch (type ) {
5752 case VALID :
5853 output .shouldNotContain ("Error" );
5954 output .shouldHaveExitValue (0 );
6055 break ;
6156 case MIN_INVALID :
62- output .shouldContain ("Bad min heap free percentage size : -Xminf" + min );
57+ output .shouldContain ("Bad min heap free ratio : -Xminf" + min );
6358 output .shouldContain ("Error" );
6459 output .shouldHaveExitValue (1 );
6560 break ;
6661 case MAX_INVALID :
67- output .shouldContain ("Bad max heap free percentage size : -Xmaxf" + max );
62+ output .shouldContain ("Bad max heap free ratio : -Xmaxf" + max );
6863 output .shouldContain ("Error" );
6964 output .shouldHaveExitValue (1 );
7065 break ;
@@ -74,7 +69,7 @@ private static void testMinMaxFreeRatio(String min, String max, Validation type)
7469 output .shouldHaveExitValue (1 );
7570 break ;
7671 case COMBINATION_INVALID :
77- output .shouldContain ("must be less than or equal to MaxHeapFreeRatio " );
72+ output .shouldMatch ("must be ( less|greater) than or equal to the implicit -Xm..f value " );
7873 output .shouldContain ("Error" );
7974 output .shouldHaveExitValue (1 );
8075 break ;
@@ -85,10 +80,29 @@ private static void testMinMaxFreeRatio(String min, String max, Validation type)
8580 System .out .println (output .getOutput ());
8681 }
8782
83+ private static void testMinMaxFreeRatio_Reordered (String min , String max , Validation type ) throws Exception {
84+ OutputAnalyzer output = GCArguments .executeTestJava (
85+ "-Xmaxf" + max ,
86+ "-Xminf" + min ,
87+ "-version" );
88+
89+ checkValidity (output , min , max , type );
90+ }
91+
92+ private static void testMinMaxFreeRatio (String min , String max , Validation type ) throws Exception {
93+ OutputAnalyzer output = GCArguments .executeTestJava (
94+ "-Xminf" + min ,
95+ "-Xmaxf" + max ,
96+ "-version" );
97+
98+ checkValidity (output , min , max , type );
99+ }
100+
88101 public static void main (String args []) throws Exception {
89- testMinMaxFreeRatio ( "0.1" , "0.5" , Validation .VALID );
90- testMinMaxFreeRatio ( ".1" , ".5" , Validation .VALID );
91- testMinMaxFreeRatio ( "0.5" , "0.5" , Validation .VALID );
102+ testMinMaxFreeRatio ( "0.1" , "0.5" , Validation .VALID );
103+ testMinMaxFreeRatio ( ".1" , ".5" , Validation .VALID );
104+ testMinMaxFreeRatio ( "0.5" , "0.5" , Validation .VALID );
105+ testMinMaxFreeRatio ( "0.0" ,"0.001" , Validation .VALID );
92106
93107 testMinMaxFreeRatio ("=0.1" , "0.5" , Validation .MIN_INVALID );
94108 testMinMaxFreeRatio ("0.1f" , "0.5" , Validation .MIN_INVALID );
@@ -103,14 +117,30 @@ public static void main(String args[]) throws Exception {
103117 testMinMaxFreeRatio ("-0.1" , "0.5" , Validation .OUT_OF_RANGE );
104118 testMinMaxFreeRatio ( "1.1" , "0.5" , Validation .OUT_OF_RANGE );
105119 testMinMaxFreeRatio (
106- "2147483647" , "0.5" , Validation .OUT_OF_RANGE );
120+ "2147483647" , "0.5" , Validation .OUT_OF_RANGE );
121+ testMinMaxFreeRatio (
122+ "-2147483647" , "0.5" , Validation .OUT_OF_RANGE );
107123 testMinMaxFreeRatio ( "0.1" , "-0.5" , Validation .OUT_OF_RANGE );
108124 testMinMaxFreeRatio ( "0.1" , "1.5" , Validation .OUT_OF_RANGE );
109125 testMinMaxFreeRatio (
110126 "0.1" , "2147483647" , Validation .OUT_OF_RANGE );
127+ testMinMaxFreeRatio (
128+ "0.1" , "-2147483647" , Validation .OUT_OF_RANGE );
129+
130+ testMinMaxFreeRatio ( "0.5" , "0.1" , Validation .COMBINATION_INVALID );
131+ testMinMaxFreeRatio ( ".5" , ".10" , Validation .COMBINATION_INVALID );
132+ testMinMaxFreeRatio ("0.12" , "0.100" , Validation .COMBINATION_INVALID );
133+
134+ // Default range is [0.40, 0.70]
135+ // setting minf to 0.80 violates minf < maxf
136+ testMinMaxFreeRatio ("0.80" , "0.90" , Validation .COMBINATION_INVALID );
137+
138+ // Options are re-ordered: -Xmaxf is given before -Xminf
139+
140+ // valid range, but acceptable only if maxf be set first
141+ testMinMaxFreeRatio_Reordered ("0.80" , "0.90" , Validation .VALID );
111142
112- testMinMaxFreeRatio ( "0.5" , "0.1" , Validation .COMBINATION_INVALID );
113- testMinMaxFreeRatio ( ".5" , ".10" , Validation .COMBINATION_INVALID );
114- testMinMaxFreeRatio ("0.12" ,"0.100" , Validation .COMBINATION_INVALID );
143+ // although a valid range, but setting maxf first violates minf < maxf
144+ testMinMaxFreeRatio_Reordered ("0.10" , "0.30" , Validation .COMBINATION_INVALID );
115145 }
116146}
0 commit comments