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
Closed
Changes from 3 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
ea3874f
8271461: CompileCommand support for hidden class methods
DamonFool 39efab4
Fix macOS build warning
DamonFool 211ee2b
Add jtreg test
DamonFool 3f92066
Use isdigit
DamonFool 0e4d149
wether --> whether
DamonFool 8af1571
More strict hidden class name replacement
DamonFool c2f5ef3
Don't apply to package names
DamonFool 0b426d9
Refine the test
DamonFool 278803b
Add Dean's test cases
DamonFool abf4df5
Move tests in MethodMatcherTest.java
DamonFool c8d9045
To be conservative for /*:: pattern and add Ioi's test
DamonFool 6bdcff2
Fix code style
DamonFool 62a09b8
Revert changes
DamonFool c16ef75
Improve error msg
DamonFool File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
// 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 == '*') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use isdigit(next) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Good suggestion. |
||
// 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; | ||
} | ||
} | ||
} | ||
} | ||
|
56 changes: 56 additions & 0 deletions
56
test/hotspot/jtreg/compiler/compilercontrol/TestHiddenClassMethod.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 '::'"); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whether
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
Fixed.
Thanks.