Skip to content

Commit 6f76b65

Browse files
committed
8312573: Failure during CompileOnly parsing leads to ShouldNotReachHere
Reviewed-by: kvn, tholenstein
1 parent 5c6cd06 commit 6f76b65

File tree

2 files changed

+56
-15
lines changed

2 files changed

+56
-15
lines changed

src/hotspot/share/compiler/compilerOracle.cpp

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,21 +1050,10 @@ void CompilerOracle::parse_compile_only(char* line) {
10501050
}
10511051
}
10521052

1053-
if (*line == method_sep) {
1054-
if (className == nullptr) {
1055-
className = "";
1056-
c_match = MethodMatcher::Any;
1057-
}
1058-
} else {
1059-
// got foo or foo/bar
1060-
if (className == nullptr) {
1061-
ShouldNotReachHere();
1062-
} else {
1063-
// missing class name handled as "Any" class match
1064-
if (className[0] == '\0') {
1065-
c_match = MethodMatcher::Any;
1066-
}
1067-
}
1053+
if (className == nullptr || className[0] == '\0') {
1054+
// missing class name handled as "Any" class match
1055+
className = "";
1056+
c_match = MethodMatcher::Any;
10681057
}
10691058

10701059
// each directive is terminated by , or NUL or . followed by NUL
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
/*
25+
* @test
26+
* @bug 8312573
27+
* @summary Test -XX:CompileOnly= with invalid arguments
28+
* @library /test/lib /
29+
* @run driver compiler.compilercontrol.parser.TestCompileOnly
30+
*/
31+
32+
package compiler.compilercontrol.parser;
33+
34+
import jdk.test.lib.process.OutputAnalyzer;
35+
import jdk.test.lib.process.ProcessTools;
36+
37+
public class TestCompileOnly {
38+
39+
public static void main(String[] args) throws Exception {
40+
test(",");
41+
test(" ");
42+
test(", ");
43+
test(" ,");
44+
test(",,");
45+
test(" ");
46+
}
47+
48+
public static void test(String compileOnlyCommand) throws Exception {
49+
OutputAnalyzer output = ProcessTools.executeTestJvm("-XX:CompileOnly=" + compileOnlyCommand, "-version");
50+
output.shouldHaveExitValue(0);
51+
}
52+
}

0 commit comments

Comments
 (0)