Skip to content
Permalink
Browse files
8274899: Replace usages of Collections.sort with List.sort call in jd…
…k.hotspot.agent

Reviewed-by: sspitsyn, cjplummer, ayang
  • Loading branch information
turbanoff authored and albertnetymk committed Oct 19, 2021
1 parent 002c538 commit a579483c88e94bdaa787d109e5ae204e7fb308c0
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2021, Oracle and/or its affiliates. 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
@@ -137,7 +137,7 @@ public void resolve(ResolveListener listener) {

// Sort blocks in ascending order of starting address (but do not
// change ordering among blocks with the same starting address)
Collections.sort(blocks, new Comparator<>() {
blocks.sort(new Comparator<>() {
public int compare(BlockSym b1, BlockSym b2) {
Address a1 = b1.getAddress();
Address a2 = b2.getAddress();
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2021, Oracle and/or its affiliates. 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
@@ -50,7 +50,7 @@ public void addLineNumberInfo(BasicLineNumberInfo info) {
counter. This must be done before any queries are made. */
public void sort() {
if (infoList == null) return;
Collections.sort(infoList, new Comparator<>() {
infoList.sort(new Comparator<>() {
public int compare(BasicLineNumberInfo l1, BasicLineNumberInfo l2) {
Address a1 = l1.getStartPC();
Address a2 = l2.getStartPC();
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. 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
@@ -365,7 +365,7 @@ private List<Address> collectLiveRegions() {
}

private void sortLiveRegions(List<Address> liveRegions) {
Collections.sort(liveRegions, new Comparator<Address>() {
liveRegions.sort(new Comparator<Address>() {
public int compare(Address a1, Address a2) {
if (AddressOps.lt(a1, a2)) {
return -1;
@@ -50,11 +50,7 @@ public void epilogue() {}
public List<ObjectHistogramElement> getElements() {
List<ObjectHistogramElement> list = new ArrayList<>();
list.addAll(map.values());
Collections.sort(list, new Comparator<>() {
public int compare(ObjectHistogramElement o1, ObjectHistogramElement o2) {
return o1.compare(o2);
}
});
list.sort(ObjectHistogramElement::compare);
return list;
}

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2021, Oracle and/or its affiliates. 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
@@ -30,7 +30,6 @@
import sun.jvm.hotspot.utilities.SystemDictionaryHelper;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;

@@ -126,11 +125,7 @@ public void doOop(OopField field, boolean isVMField) {
*/
ArrayList<ObjectHistogramElement> list = new ArrayList<>();
list.addAll(map.values());
Collections.sort(list, new Comparator<>() {
public int compare(ObjectHistogramElement o1, ObjectHistogramElement o2) {
return o1.compare(o2);
}
});
list.sort(ObjectHistogramElement::compare);

/*
* Print summary of objects in queue
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2021, Oracle and/or its affiliates. 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
@@ -28,7 +28,6 @@
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;

import sun.jvm.hotspot.debugger.*;
@@ -202,7 +201,7 @@ public int compare(ProcessInfo o1, ProcessInfo o2) {
}
};
}
Collections.sort(els, c);
els.sort(c);
}

private javax.swing.Timer getTimer() {
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2021, Oracle and/or its affiliates. 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
@@ -24,9 +24,6 @@

package sun.jvm.hotspot.ui.table;

import java.util.Collections;
import java.util.List;

import javax.swing.event.TableModelEvent;
import javax.swing.table.AbstractTableModel;

@@ -55,7 +52,7 @@ public void sortByColumn(int column, boolean ascending) {
comparator.addColumn(column);
comparator.setAscending(ascending);

Collections.sort(elements, comparator);
elements.sort(comparator);

fireTableChanged(new TableModelEvent(this));
}

1 comment on commit a579483

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on a579483 Oct 19, 2021

Choose a reason for hiding this comment

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

Please sign in to comment.