# HG changeset patch # User dholmes # Date 1341294089 14400 # Node ID 3f1ab0c19c30eb003ef9759249503a1633ca7f5f # Parent 24b9c7f4cae6ed8495d95b9308055ce73264b699 7179383: MaxDirectMemorySize argument parsing is broken for values >2G Summary: change hotspot flag to be unsigned Reviewed-by: dholmes, sla, fparain, brutisso Contributed-by: Chris Dennis diff -r 24b9c7f4cae6 -r 3f1ab0c19c30 src/share/vm/prims/jvm.cpp --- a/src/share/vm/prims/jvm.cpp Mon Jul 02 13:11:28 2012 -0400 +++ b/src/share/vm/prims/jvm.cpp Tue Jul 03 01:41:29 2012 -0400 @@ -345,9 +345,13 @@ // Do this after setting user properties to prevent people // from setting the value with a -D option, as requested. { - char as_chars[256]; - jio_snprintf(as_chars, sizeof(as_chars), INTX_FORMAT, MaxDirectMemorySize); - PUTPROP(props, "sun.nio.MaxDirectMemorySize", as_chars); + if (FLAG_IS_DEFAULT(MaxDirectMemorySize)) { + PUTPROP(props, "sun.nio.MaxDirectMemorySize", "-1"); + } else { + char as_chars[256]; + jio_snprintf(as_chars, sizeof(as_chars), UINTX_FORMAT, MaxDirectMemorySize); + PUTPROP(props, "sun.nio.MaxDirectMemorySize", as_chars); + } } // JVM monitoring and management support diff -r 24b9c7f4cae6 -r 3f1ab0c19c30 src/share/vm/runtime/arguments.cpp --- a/src/share/vm/runtime/arguments.cpp Mon Jul 02 13:11:28 2012 -0400 +++ b/src/share/vm/runtime/arguments.cpp Tue Jul 03 01:41:29 2012 -0400 @@ -2709,6 +2709,17 @@ return JNI_EINVAL; } FLAG_SET_CMDLINE(uintx, ConcGCThreads, conc_threads); + } else if (match_option(option, "-XX:MaxDirectMemorySize=", &tail)) { + julong max_direct_memory_size = 0; + ArgsRange errcode = parse_memory_size(tail, &max_direct_memory_size, 0); + if (errcode != arg_in_range) { + jio_fprintf(defaultStream::error_stream(), + "Invalid maximum direct memory size: %s\n", + option->optionString); + describe_range_error(errcode); + return JNI_EINVAL; + } + FLAG_SET_CMDLINE(uintx, MaxDirectMemorySize, max_direct_memory_size); } else if (match_option(option, "-XX:", &tail)) { // -XX:xxxx // Skip -XX:Flags= since that case has already been handled if (strncmp(tail, "Flags=", strlen("Flags=")) != 0) { diff -r 24b9c7f4cae6 -r 3f1ab0c19c30 src/share/vm/runtime/globals.hpp --- a/src/share/vm/runtime/globals.hpp Mon Jul 02 13:11:28 2012 -0400 +++ b/src/share/vm/runtime/globals.hpp Tue Jul 03 01:41:29 2012 -0400 @@ -3705,7 +3705,7 @@ \ /* Properties for Java libraries */ \ \ - product(intx, MaxDirectMemorySize, -1, \ + product(uintx, MaxDirectMemorySize, 0, \ "Maximum total size of NIO direct-buffer allocations") \ \ /* temporary developer defined flags */ \