RFR: 8274319: Replace usages of Collections.sort with List.sort call in jdk.jfr
Erik Gahlin
egahlin at openjdk.java.net
Fri Oct 8 14:47:37 UTC 2021
On Sat, 25 Sep 2021 11:08:16 GMT, Andrey Turbanov <github.com+741251+turbanoff at openjdk.org> wrote:
> Collections.sort is just a wrapper, so it is better to use an instance method directly.
>
> Also Comparator's implementation can be cleaned up with help of static methods in `Comparator` class.
> E.g `(u, v) -> Long.compare(v.count, u.count)` can be replaced with `Comparator.comparingLong(v -> v.count)`
Changes requested by egahlin (Reviewer).
src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/AbstractDCmd.java line 172:
> 170: protected final List<Recording> getRecordings() {
> 171: List<Recording> list = new ArrayList<>(getFlightRecorder().getRecordings());
> 172: list.sort(Comparator.comparing(Recording::getId));
Use Comparator.comparingLong instead?
src/jdk.jfr/share/classes/jdk/jfr/internal/tool/Summary.java line 146:
> 144: println(" Duration: " + (totalDuration + 500_000_000) / 1_000_000_000 + " s");
> 145: List<Statistics> statsList = new ArrayList<>(stats.values());
> 146: statsList.sort(Comparator.comparingLong(v -> v.count));
This looks incorrect. the order is reversed compared to before.
Events with a high count should appear on top.
-------------
PR: https://git.openjdk.java.net/jdk/pull/5696
More information about the hotspot-jfr-dev
mailing list