Skip to content

Commit 955dcb3

Browse files
committed
8312573: Failure during CompileOnly parsing leads to ShouldNotReachHere
Reviewed-by: phh Backport-of: 6f76b65ace50b2361221dddab120e91b057497c1
1 parent bc7699a commit 955dcb3

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
@@ -992,21 +992,10 @@ void CompilerOracle::parse_compile_only(char* line) {
992992
}
993993
}
994994

995-
if (*line == method_sep) {
996-
if (className == NULL) {
997-
className = "";
998-
c_match = MethodMatcher::Any;
999-
}
1000-
} else {
1001-
// got foo or foo/bar
1002-
if (className == NULL) {
1003-
ShouldNotReachHere();
1004-
} else {
1005-
// missing class name handled as "Any" class match
1006-
if (className[0] == '\0') {
1007-
c_match = MethodMatcher::Any;
1008-
}
1009-
}
995+
if (className == nullptr || className[0] == '\0') {
996+
// missing class name handled as "Any" class match
997+
className = "";
998+
c_match = MethodMatcher::Any;
1010999
}
10111000

10121001
// 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)