Skip to content

Commit 8336e3e

Browse files
Andrew LuGoeLin
Andrew Lu
authored andcommittedOct 11, 2023
8312573: Failure during CompileOnly parsing leads to ShouldNotReachHere
Reviewed-by: phh Backport-of: 6f76b65ace50b2361221dddab120e91b057497c1
1 parent a75f34f commit 8336e3e

File tree

2 files changed

+56
-15
lines changed

2 files changed

+56
-15
lines changed
 

‎src/hotspot/share/compiler/compilerOracle.cpp

+4-15
Original file line numberDiff line numberDiff line change
@@ -827,21 +827,10 @@ void CompilerOracle::parse_compile_only(char * line) {
827827
}
828828
}
829829

830-
if (*line == method_sep) {
831-
if (className == NULL) {
832-
className = "";
833-
c_match = MethodMatcher::Any;
834-
}
835-
} else {
836-
// got foo or foo/bar
837-
if (className == NULL) {
838-
ShouldNotReachHere();
839-
} else {
840-
// missing class name handled as "Any" class match
841-
if (className[0] == '\0') {
842-
c_match = MethodMatcher::Any;
843-
}
844-
}
830+
if (className == NULL || className[0] == '\0') {
831+
// missing class name handled as "Any" class match
832+
className = "";
833+
c_match = MethodMatcher::Any;
845834
}
846835

847836
// each directive is terminated by , or NUL or . followed by NUL
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+
}

1 commit comments

Comments
 (1)

openjdk-notifier[bot] commented on Oct 11, 2023

@openjdk-notifier[bot]
Please sign in to comment.