RFR: JDK-8261095: Add test for clhsdb "symbol" command
Chris Plummer
cjplummer at openjdk.java.net
Tue Mar 9 02:39:07 UTC 2021
On Tue, 9 Mar 2021 02:16:30 GMT, Yasumasa Suenaga <ysuenaga at openjdk.org> wrote:
>> test/hotspot/jtreg/serviceability/sa/ClhsdbSymbol.java line 61:
>>
>>> 59: String classOutput = test.run(theApp.getPid(), cmds, expStrMap, null);
>>> 60: String threadAddress = null;
>>> 61: String[] parts = classOutput.split("\n");
>>
>> I think you should be using the line.separator properly instead of "\n".
>> ` String linesep = System.getProperty("line.separator");`
>
> It might be more simple if you use [String::lines](https://docs.oracle.com/en/java/javase/15/docs/api/java.base/java/lang/String.html#lines()) and stream API.
Yes. Coincidentally I was just having an internal chat about `split(linesep)`, and `String.lines()` was mentioned. We have a lot of existing code that uses `split(linesep)` because `String.lines()` has only been around since JDK 11, and even some newer test code we have uses `split(linsep)` because it was copied from older tests.
-------------
PR: https://git.openjdk.java.net/jdk/pull/2863
More information about the serviceability-dev
mailing list