Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8271461: CompileCommand support for hidden class methods #4926

Closed
wants to merge 14 commits into from
17 changes: 15 additions & 2 deletions src/hotspot/share/compiler/methodMatcher.cpp
Expand Up @@ -115,8 +115,21 @@ bool MethodMatcher::canonicalize(char * line, const char *& error_msg) {
}

if (*lp == '/') {
error_msg = "Method pattern uses '/' together with '::'";
return false;
// Check wether it's a hidden class method.
Copy link
Member

Choose a reason for hiding this comment

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

whether

Copy link
Member Author

Choose a reason for hiding this comment

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

whether

Good catch!
Fixed.
Thanks.

// According to ClassFileParser::mangle_hidden_class_name, the pattern of
// hidden class name in the VM should be: _class_name, "+", and &ik
// But "+" will be replaced with "/" when it is printed by PrintCompilation.
// So if "/" is followed with a digit or "*", it may be a hidden class method.
// There may be false positive cases, but all of them are harmless and won't make anything worse.
char next = *(lp + 1);
if (('0' <= next && next <= '9') || next == '*') {
Copy link
Member

Choose a reason for hiding this comment

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

Please use isdigit(next)

Copy link
Member Author

Choose a reason for hiding this comment

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

Please use isdigit(next)

Good suggestion.
Updated.
Thanks.

// May be a hidden class method, so replace '/' with '+'
*lp = '+';
} else {
// Not a hidden class method
error_msg = "Method pattern uses '/' together with '::'";
return false;
}
}
}
}
Expand Down
@@ -0,0 +1,56 @@
/*
* Copyright (C) 2021 THL A29 Limited, a Tencent company. 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 8271461
* @summary the CompileCommand support for hidden class methods
* @library /test/lib
* @requires vm.flagless
* @requires vm.compiler1.enabled | vm.compiler2.enabled
*
* @run driver compiler.compilercontrol.TestHiddenClassMethod
*/

package compiler.compilercontrol;

import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools;

public class TestHiddenClassMethod {
public static void main(String[] args) throws Exception {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
"-XX:CompileCommand=exclude,java.util.ResourceBundle$$Lambda$1/0x00000008010413c8::run",
"-version");
OutputAnalyzer analyzer = new OutputAnalyzer(pb.start());
analyzer.shouldHaveExitValue(0);
analyzer.shouldNotContain("Error: Method pattern uses '/' together with '::'");

pb = ProcessTools.createJavaProcessBuilder(
"-XX:CompileCommand=exclude,java.util.ResourceBundle$$Lambda$1/*::run",
"-version");
analyzer = new OutputAnalyzer(pb.start());
analyzer.shouldHaveExitValue(0);
analyzer.shouldNotContain("Error: Method pattern uses '/' together with '::'");
}
}