8312573: Failure during CompileOnly parsing leads to ShouldNotReachHere

Reviewed-by: kvn, tholenstein
This commit is contained in:
Tobias Hartmann
2023-08-02 06:36:48 +00:00
committed by Vitaly Provodin
parent 072adeda9a
commit c897d45c33
2 changed files with 56 additions and 15 deletions

View File

@@ -1050,21 +1050,10 @@ void CompilerOracle::parse_compile_only(char* line) {
}
}
if (*line == method_sep) {
if (className == nullptr) {
className = "";
c_match = MethodMatcher::Any;
}
} else {
// got foo or foo/bar
if (className == nullptr) {
ShouldNotReachHere();
} else {
// missing class name handled as "Any" class match
if (className[0] == '\0') {
c_match = MethodMatcher::Any;
}
}
if (className == nullptr || className[0] == '\0') {
// missing class name handled as "Any" class match
className = "";
c_match = MethodMatcher::Any;
}
// each directive is terminated by , or NUL or . followed by NUL

View File

@@ -0,0 +1,52 @@
/*
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8312573
* @summary Test -XX:CompileOnly= with invalid arguments
* @library /test/lib /
* @run driver compiler.compilercontrol.parser.TestCompileOnly
*/
package compiler.compilercontrol.parser;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools;
public class TestCompileOnly {
public static void main(String[] args) throws Exception {
test(",");
test(" ");
test(", ");
test(" ,");
test(",,");
test(" ");
}
public static void test(String compileOnlyCommand) throws Exception {
OutputAnalyzer output = ProcessTools.executeTestJvm("-XX:CompileOnly=" + compileOnlyCommand, "-version");
output.shouldHaveExitValue(0);
}
}