Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8082666 | emb-9 | Max Ockner | P3 | Resolved | Fixed | team |
After fixing JDK-8060449 Java 9 consider deprecated integer options as invalid.
For example, if we run Java 8 with "-XX:MaxPermSize=384m", then we got message that "ignoring option MaxPermSize=384m; support was removed in 8.0"
But if we ran Java 9 with deprecated in JDK9 integer option, e.g. with "-XX:NmethodSweepFraction=10", then Java reports an error and exit: "Unrecognized VM option 'NmethodSweepFraction=10'".
The problem in modified if statement in "Arguments::is_newly_obsolete" method in "src/share/vm/runtime/arguments.cpp":
333 bool Arguments::is_newly_obsolete(const char *s, JDK_Version* version) {
...
341 if (((strncmp(flag_status.name, s, len) == 0) &&
342 (strlen(s) == len)) ||
343 ((s[0] == '+' || s[0] == '-') &&
344 (strncmp(flag_status.name, &s[1], len) == 0) &&
345 (strlen(&s[1]) == len))) {
Now function check that passed argument have the exactly the same length as defined in obsolete_jvm_flags, so "MaxPermSize=384m" and "MaxPermSize" are different.
Special case should be added for integer options.
Also,JDK-8060449 fix add call of "is_newly_obsolete" function for fuzzy matched option in Arguments::process_arguments function:
jio_fprintf(defaultStream::error_stream(),
"Unrecognized VM option '%s'\n", argname);
Flag* fuzzy_matched = Flag::fuzzy_match((const char*)argname, arg_len, true);
if (fuzzy_matched != NULL) {
jio_fprintf(defaultStream::error_stream(),
"Did you mean '%s%s%s'? ",
(fuzzy_matched->is_bool()) ? "(+/-)" : "",
fuzzy_matched->_name,
(fuzzy_matched->is_bool()) ? "" : "=<value>");
if (is_newly_obsolete(fuzzy_matched->_name, &since)) {
char version[256];
since.to_string(version, sizeof(version));
jio_fprintf(defaultStream::error_stream(),
"Warning: support for %s was removed in %s\n",
fuzzy_matched->_name,
version);
}
But in this case it senseless, because fuzzy_match take flags from flag table, i.e. from non-deprecated flags and is_newly_obsolete get flags from obsolete_jvm_flags table. In normal conditions the option can not exist in two tables at the same time. So, is_newly_obsolete will always return false in this case.
But if added "if (is_newly_obsolete)" will be deleted, then "test/runtime/CommandLine/ObsoleteFlagErrorMessage.java" test should be corrected. The following line should be deleted from test:
output.shouldContain("support").shouldContain("removed"); // Should warn user that the option they are trying to use is no longer supported.
The interesting thing, that now test passed, because test use "-XX:UseBoundThreads" option which incorrectly exists in obsolete_jvm_flags and in normal flag table. And in this case "fuzzy_match" found this option in flag table. But this is incorrect situation and soon "-XX:UseBoundThreads" will be deleted from set of existing flags.
For example, if we run Java 8 with "-XX:MaxPermSize=384m", then we got message that "ignoring option MaxPermSize=384m; support was removed in 8.0"
But if we ran Java 9 with deprecated in JDK9 integer option, e.g. with "-XX:NmethodSweepFraction=10", then Java reports an error and exit: "Unrecognized VM option 'NmethodSweepFraction=10'".
The problem in modified if statement in "Arguments::is_newly_obsolete" method in "src/share/vm/runtime/arguments.cpp":
333 bool Arguments::is_newly_obsolete(const char *s, JDK_Version* version) {
...
341 if (((strncmp(flag_status.name, s, len) == 0) &&
342 (strlen(s) == len)) ||
343 ((s[0] == '+' || s[0] == '-') &&
344 (strncmp(flag_status.name, &s[1], len) == 0) &&
345 (strlen(&s[1]) == len))) {
Now function check that passed argument have the exactly the same length as defined in obsolete_jvm_flags, so "MaxPermSize=384m" and "MaxPermSize" are different.
Special case should be added for integer options.
Also,
jio_fprintf(defaultStream::error_stream(),
"Unrecognized VM option '%s'\n", argname);
Flag* fuzzy_matched = Flag::fuzzy_match((const char*)argname, arg_len, true);
if (fuzzy_matched != NULL) {
jio_fprintf(defaultStream::error_stream(),
"Did you mean '%s%s%s'? ",
(fuzzy_matched->is_bool()) ? "(+/-)" : "",
fuzzy_matched->_name,
(fuzzy_matched->is_bool()) ? "" : "=<value>");
if (is_newly_obsolete(fuzzy_matched->_name, &since)) {
char version[256];
since.to_string(version, sizeof(version));
jio_fprintf(defaultStream::error_stream(),
"Warning: support for %s was removed in %s\n",
fuzzy_matched->_name,
version);
}
But in this case it senseless, because fuzzy_match take flags from flag table, i.e. from non-deprecated flags and is_newly_obsolete get flags from obsolete_jvm_flags table. In normal conditions the option can not exist in two tables at the same time. So, is_newly_obsolete will always return false in this case.
But if added "if (is_newly_obsolete)" will be deleted, then "test/runtime/CommandLine/ObsoleteFlagErrorMessage.java" test should be corrected. The following line should be deleted from test:
output.shouldContain("support").shouldContain("removed"); // Should warn user that the option they are trying to use is no longer supported.
The interesting thing, that now test passed, because test use "-XX:UseBoundThreads" option which incorrectly exists in obsolete_jvm_flags and in normal flag table. And in this case "fuzzy_match" found this option in flag table. But this is incorrect situation and soon "-XX:UseBoundThreads" will be deleted from set of existing flags.
- backported by
-
JDK-8082666 Deprecated integer options are considered as invalid instead of deprecated in Java 9
-
- Resolved
-
- blocks
-
JDK-8074026 Deprecated UseBoundThreads, DefaultThreadPriority and NoYieldsInMicrolock VM options still defined in globals.hpp
-
- Resolved
-
- relates to
-
JDK-8060449 Obsolete command line flags accept arbitrary appendix
-
- Resolved
-
-
JDK-8129786 Buffer overrun when passing long not existing option in JDK 9
-
- Closed
-