Skip to content

Commit

Permalink
Do not print void warning with -XX:-PrintWarnings
Browse files Browse the repository at this point in the history
  • Loading branch information
shipilev committed Dec 4, 2020
1 parent f0d5f73 commit 306cd96
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 13 deletions.
5 changes: 2 additions & 3 deletions src/hotspot/share/compiler/compilerOracle.cpp
Expand Up @@ -414,9 +414,8 @@ bool CompilerOracle::should_blackhole(const methodHandle& method) {
if (method->result_type() == T_VOID) {
return true;
} else {
ttyLocker ttyl;
tty->print_cr("Warning: blackhole compile command only works for methods with void type: %s",
method->name_and_sig_as_C_string());
warning("blackhole compile command only works for methods with void type: %s",
method->name_and_sig_as_C_string());
}
}
return false;
Expand Down
38 changes: 28 additions & 10 deletions test/hotspot/jtreg/compiler/blackhole/BlackholeNonVoidWarning.java
Expand Up @@ -48,16 +48,34 @@ public static void main(String[] args) throws IOException {
}

public static void driver() throws IOException {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
"-Xmx128m",
"-XX:CompileCommand=quiet",
"-XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*",
"compiler.blackhole.BlackholeNonVoidWarning",
"run"
);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldHaveExitValue(0);
output.shouldContain("blackhole compile command only works for methods with void type: compiler.blackhole.BlackholeTarget.bh_sr_int(I)I");
final String msg = "blackhole compile command only works for methods with void type: compiler.blackhole.BlackholeTarget.bh_sr_int(I)I";

{
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
"-Xmx128m",
"-XX:CompileCommand=quiet",
"-XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*",
"compiler.blackhole.BlackholeNonVoidWarning",
"run"
);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldHaveExitValue(0);
output.shouldContain(msg);
}

{
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
"-Xmx128m",
"-XX:-PrintWarnings",
"-XX:CompileCommand=quiet",
"-XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*",
"compiler.blackhole.BlackholeNonVoidWarning",
"run"
);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldHaveExitValue(0);
output.shouldNotContain(msg);
}
}

public static void runner() {
Expand Down

0 comments on commit 306cd96

Please sign in to comment.