Merge

Tue, 15 Oct 2013 04:29:21 -0700

author
mgerdin
date
Tue, 15 Oct 2013 04:29:21 -0700
changeset 5936
82fcc0567fef
parent 5934
d6818f623792
parent 5935
027006a47a6d
child 5940
f16726924734

Merge

     1.1 --- a/src/share/vm/runtime/arguments.cpp	Tue Oct 15 11:18:42 2013 +0200
     1.2 +++ b/src/share/vm/runtime/arguments.cpp	Tue Oct 15 04:29:21 2013 -0700
     1.3 @@ -2694,8 +2694,9 @@
     1.4        FLAG_SET_CMDLINE(uintx, MaxHeapSize, (uintx)long_max_heap_size);
     1.5      // Xmaxf
     1.6      } else if (match_option(option, "-Xmaxf", &tail)) {
     1.7 -      int maxf = (int)(atof(tail) * 100);
     1.8 -      if (maxf < 0 || maxf > 100) {
     1.9 +      char* err;
    1.10 +      int maxf = (int)(strtod(tail, &err) * 100);
    1.11 +      if (*err != '\0' || maxf < 0 || maxf > 100) {
    1.12          jio_fprintf(defaultStream::error_stream(),
    1.13                      "Bad max heap free percentage size: %s\n",
    1.14                      option->optionString);
    1.15 @@ -2705,8 +2706,9 @@
    1.16        }
    1.17      // Xminf
    1.18      } else if (match_option(option, "-Xminf", &tail)) {
    1.19 -      int minf = (int)(atof(tail) * 100);
    1.20 -      if (minf < 0 || minf > 100) {
    1.21 +      char* err;
    1.22 +      int minf = (int)(strtod(tail, &err) * 100);
    1.23 +      if (*err != '\0' || minf < 0 || minf > 100) {
    1.24          jio_fprintf(defaultStream::error_stream(),
    1.25                      "Bad min heap free percentage size: %s\n",
    1.26                      option->optionString);
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/test/gc/arguments/TestHeapFreeRatio.java	Tue Oct 15 04:29:21 2013 -0700
     2.3 @@ -0,0 +1,105 @@
     2.4 +/*
     2.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
     2.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2.7 + *
     2.8 + * This code is free software; you can redistribute it and/or modify it
     2.9 + * under the terms of the GNU General Public License version 2 only, as
    2.10 + * published by the Free Software Foundation.
    2.11 + *
    2.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    2.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    2.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    2.15 + * version 2 for more details (a copy is included in the LICENSE file that
    2.16 + * accompanied this code).
    2.17 + *
    2.18 + * You should have received a copy of the GNU General Public License version
    2.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    2.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    2.21 + *
    2.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    2.23 + * or visit www.oracle.com if you need additional information or have any
    2.24 + * questions.
    2.25 + */
    2.26 +
    2.27 +/*
    2.28 + * @test TestHeapFreeRatio
    2.29 + * @key gc
    2.30 + * @bug 8025661
    2.31 + * @summary Test parsing of -Xminf and -Xmaxf
    2.32 + * @library /testlibrary
    2.33 + * @run main/othervm TestHeapFreeRatio
    2.34 + */
    2.35 +
    2.36 +import com.oracle.java.testlibrary.*;
    2.37 +
    2.38 +public class TestHeapFreeRatio {
    2.39 +
    2.40 +  enum Validation {
    2.41 +    VALID,
    2.42 +    MIN_INVALID,
    2.43 +    MAX_INVALID,
    2.44 +    COMBINATION_INVALID
    2.45 +  }
    2.46 +
    2.47 +  private static void testMinMaxFreeRatio(String min, String max, Validation type) throws Exception {
    2.48 +    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
    2.49 +        "-Xminf" + min,
    2.50 +        "-Xmaxf" + max,
    2.51 +        "-version");
    2.52 +    OutputAnalyzer output = new OutputAnalyzer(pb.start());
    2.53 +
    2.54 +    switch (type) {
    2.55 +    case VALID:
    2.56 +      output.shouldNotContain("Error");
    2.57 +      output.shouldHaveExitValue(0);
    2.58 +      break;
    2.59 +    case MIN_INVALID:
    2.60 +      output.shouldContain("Bad min heap free percentage size: -Xminf" + min);
    2.61 +      output.shouldContain("Error");
    2.62 +      output.shouldHaveExitValue(1);
    2.63 +      break;
    2.64 +    case MAX_INVALID:
    2.65 +      output.shouldContain("Bad max heap free percentage size: -Xmaxf" + max);
    2.66 +      output.shouldContain("Error");
    2.67 +      output.shouldHaveExitValue(1);
    2.68 +      break;
    2.69 +    case COMBINATION_INVALID:
    2.70 +      output.shouldContain("must be less than or equal to MaxHeapFreeRatio");
    2.71 +      output.shouldContain("Error");
    2.72 +      output.shouldHaveExitValue(1);
    2.73 +      break;
    2.74 +    default:
    2.75 +      throw new IllegalStateException("Must specify expected validation type");
    2.76 +    }
    2.77 +
    2.78 +    System.out.println(output.getOutput());
    2.79 +  }
    2.80 +
    2.81 +  public static void main(String args[]) throws Exception {
    2.82 +    testMinMaxFreeRatio( "0.1", "0.5", Validation.VALID);
    2.83 +    testMinMaxFreeRatio(  ".1",  ".5", Validation.VALID);
    2.84 +    testMinMaxFreeRatio( "0.5", "0.5", Validation.VALID);
    2.85 +
    2.86 +    testMinMaxFreeRatio("-0.1", "0.5", Validation.MIN_INVALID);
    2.87 +    testMinMaxFreeRatio( "1.1", "0.5", Validation.MIN_INVALID);
    2.88 +    testMinMaxFreeRatio("=0.1", "0.5", Validation.MIN_INVALID);
    2.89 +    testMinMaxFreeRatio("0.1f", "0.5", Validation.MIN_INVALID);
    2.90 +    testMinMaxFreeRatio(
    2.91 +                     "INVALID", "0.5", Validation.MIN_INVALID);
    2.92 +    testMinMaxFreeRatio(
    2.93 +                  "2147483647", "0.5", Validation.MIN_INVALID);
    2.94 +
    2.95 +    testMinMaxFreeRatio( "0.1", "-0.5", Validation.MAX_INVALID);
    2.96 +    testMinMaxFreeRatio( "0.1",  "1.5", Validation.MAX_INVALID);
    2.97 +    testMinMaxFreeRatio( "0.1", "0.5f", Validation.MAX_INVALID);
    2.98 +    testMinMaxFreeRatio( "0.1", "=0.5", Validation.MAX_INVALID);
    2.99 +    testMinMaxFreeRatio(
   2.100 +                     "0.1",  "INVALID", Validation.MAX_INVALID);
   2.101 +    testMinMaxFreeRatio(
   2.102 +                   "0.1", "2147483647", Validation.MAX_INVALID);
   2.103 +
   2.104 +    testMinMaxFreeRatio( "0.5",  "0.1", Validation.COMBINATION_INVALID);
   2.105 +    testMinMaxFreeRatio(  ".5",  ".10", Validation.COMBINATION_INVALID);
   2.106 +    testMinMaxFreeRatio("0.12","0.100", Validation.COMBINATION_INVALID);
   2.107 +  }
   2.108 +}

mercurial