Skip to content

Commit

Permalink
8312573: Failure during CompileOnly parsing leads to ShouldNotReachHere
Browse files Browse the repository at this point in the history
Reviewed-by: kvn, tholenstein
  • Loading branch information
TobiHartmann committed Aug 2, 2023
1 parent 5c6cd06 commit 6f76b65
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 15 deletions.
19 changes: 4 additions & 15 deletions src/hotspot/share/compiler/compilerOracle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}

1 comment on commit 6f76b65

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.