Skip to content

Use generics instead of raw types where possible #149

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -17,3 +17,6 @@
/l10n/en.nbms/
/l10n/l10nantext.jar
/plugins/nbproject/private/
*.iml
/out/
/.idea/
Original file line number Diff line number Diff line change
@@ -45,7 +45,7 @@ public final class ColorIcon implements javax.swing.Icon {
private final boolean shadow;
private final Color color;

private static final Map<Color, ColorIcon> icons = new HashMap();
private static final Map<Color, ColorIcon> icons = new HashMap<>();


private ColorIcon(Color color) {
Original file line number Diff line number Diff line change
@@ -257,20 +257,17 @@ private static String formatJVMArgs(String jvmargs) {

private static String formatSystemProperties(Properties properties) {
StringBuilder text = new StringBuilder(200);
List keys = new ArrayList();
List<String> keys = new ArrayList<>();
Enumeration en = properties.propertyNames();
Iterator keyIt;


while (en.hasMoreElements()) {
keys.add(en.nextElement());
keys.add((String) en.nextElement());
}

Collections.sort(keys);
keyIt = keys.iterator();
while (keyIt.hasNext()) {
String key = (String) keyIt.next();
for (String key : keys) {
String val = properties.getProperty(key);

if ("line.separator".equals(key) && val != null) { // NOI18N
val = val.replace("\n", "\\n"); // NOI18N
val = val.replace("\r", "\\r"); // NOI18N
Original file line number Diff line number Diff line change
@@ -311,7 +311,7 @@ final boolean hasRemovedListeners() {
}

final synchronized Set<ComparableWeakReference<DataRemovedListener>> getRemovedListeners() {
if (!hasRemovedListeners()) removedListeners = Collections.synchronizedSet(new HashSet());
if (!hasRemovedListeners()) removedListeners = Collections.synchronizedSet(new HashSet<>());
return removedListeners;
}

Original file line number Diff line number Diff line change
@@ -51,8 +51,8 @@ public class DataSourceProvider {
Boolean.getBoolean(DataSourceProvider.class.getName() + ".suppressExceptionsUI"); // NOI18N
private static final Logger LOGGER = Logger.getLogger(DataSourceProvider.class.getName());

private final Set<DataSource> dataSources = Collections.synchronizedSet(new HashSet());
private final Map<DataChangeListener<? extends DataSource>, Class<? extends DataSource>> listeners = new HashMap();
private final Set<DataSource> dataSources = Collections.synchronizedSet(new HashSet<>());
private final Map<DataChangeListener<? extends DataSource>, Class<? extends DataSource>> listeners = new HashMap<>();


/**
@@ -196,7 +196,7 @@ void unregisterDataSourcesImpl(Set<? extends DataSource> removed) {
}

private Set<? extends DataSource> checkAdded(Set<? extends DataSource> added) {
Set<? extends DataSource> uniqueAdded = new HashSet(added);
Set<? extends DataSource> uniqueAdded = new HashSet<>(added);
Iterator<? extends DataSource> it = uniqueAdded.iterator();

while(it.hasNext()) {
@@ -211,7 +211,7 @@ private Set<? extends DataSource> checkAdded(Set<? extends DataSource> added) {
}

private Set<? extends DataSource> checkRemoved(Set<? extends DataSource> removed) {
Set<? extends DataSource> uniqueRemoved = new HashSet(removed);
Set<? extends DataSource> uniqueRemoved = new HashSet<>(removed);
Iterator<? extends DataSource> it = uniqueRemoved.iterator();

while(it.hasNext()) {
Original file line number Diff line number Diff line change
@@ -94,7 +94,7 @@ public void run() {

private static class ChangeSupport<X> {

private Set<DataChangeListener<X>> listeners = new HashSet();
private Set<DataChangeListener<X>> listeners = new HashSet<>();
private Set<X> currentSet;

private void addChangeListener(DataChangeListener<X> listener) {
Original file line number Diff line number Diff line change
@@ -412,7 +412,7 @@ protected int getRelativePosition(DataSource d, int positionType) {
}


private static class IndexNodePair implements Comparable {
private static class IndexNodePair implements Comparable<IndexNodePair> {

public int index;
public ExplorerNode node;
@@ -422,8 +422,7 @@ public IndexNodePair(int index, ExplorerNode node) {
this.node = node;
}

public int compareTo(Object o) {
IndexNodePair pair = (IndexNodePair)o;
public int compareTo(IndexNodePair pair) {
if (index == pair.index) return 0;
if (index > pair.index) return 1;
else return -1;
Original file line number Diff line number Diff line change
@@ -49,7 +49,7 @@ public final class DataSourceViewsManager {
private static DataSourceViewsManager sharedInstance;

// TODO: implement some better data structure for cheaper providers query
private final Map<DataSourceViewProvider, Class<? extends DataSource>> providers = Collections.synchronizedMap(new HashMap());
private final Map<DataSourceViewProvider, Class<? extends DataSource>> providers = Collections.synchronizedMap(new HashMap<>());


/**
Original file line number Diff line number Diff line change
@@ -54,7 +54,7 @@ final class CoreDumpsSorting implements Presenter.Menu {

private static final Comparator<DataSource> BY_TIME_COMPARATOR = byTimeComparator();
private static final Comparator<DataSource> BY_NAME_COMPARATOR = byNameComparator();
private static final List<Comparator<DataSource>> COMPARATORS = new ArrayList();
private static final List<Comparator<DataSource>> COMPARATORS = new ArrayList<>();
static { COMPARATORS.add(BY_TIME_COMPARATOR); COMPARATORS.add(BY_NAME_COMPARATOR); }

private final Preferences prefs;
Original file line number Diff line number Diff line change
@@ -206,9 +206,9 @@ public boolean accept(File dir, String name) {
}
});

Set<File> unresolvedCoreDumpsF = new HashSet();
Set<String> unresolvedCoreDumpsS = new HashSet();
Set<CoreDumpImpl> coredumps = new HashSet();
Set<File> unresolvedCoreDumpsF = new HashSet<>();
Set<String> unresolvedCoreDumpsS = new HashSet<>();
Set<CoreDumpImpl> coredumps = new HashSet<>();
for (File file : files) {
Storage storage = new Storage(file.getParentFile(), file.getName());
String[] propNames = new String[] {
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@
public abstract class ContainerNode<T> extends HeapViewerNode {

protected final int maxNodes;
protected final List<T> items;
protected final List<T> items = new ArrayList<>();

protected final String name;

@@ -63,8 +63,6 @@ public ContainerNode(String name) {
public ContainerNode(String name, int maxNodes) {
this.name = name;
this.maxNodes = maxNodes;

items = new ArrayList();
}

public String getName() {
Original file line number Diff line number Diff line change
@@ -90,7 +90,7 @@ public synchronized void set(List<OQLSupport.Query> queries) {
}

public synchronized List<OQLSupport.Query> list() {
List<OQLSupport.Query> list = new ArrayList();
List<OQLSupport.Query> list = new ArrayList<>();
for (OQLSupport.Query query : customQueries)
list.add(new OQLSupport.Query(query.getScript(), query.getName(), query.getDescription()));
return list;
@@ -148,7 +148,7 @@ private static Properties listToProperties(List<OQLSupport.Query> queries) {
private CustomOQLQueries() {
assert !SwingUtilities.isEventDispatchThread();

customQueries = new ArrayList();
customQueries = new ArrayList<>();

try {
Properties p = new Properties();
Original file line number Diff line number Diff line change
@@ -58,7 +58,7 @@ public final class HeapUtils {
// --- Heap utils ----------------------------------------------------------

public static Collection<JavaClass> getSubclasses(Heap heap, String baseClass) {
HashSet subclasses = new HashSet();
HashSet<JavaClass> subclasses = new HashSet<>();

String escapedClassName = "\\Q" + baseClass + "\\E"; // NOI18N
Collection<JavaClass> jClasses = heap.getJavaClassesByRegExp(escapedClassName);
4 changes: 2 additions & 2 deletions visualvm/host/src/org/graalvm/visualvm/host/impl/Ping.java
Original file line number Diff line number Diff line change
@@ -164,10 +164,10 @@ void processPendingTargets() throws IOException {
// Process keys that have become selected
//
void processSelectedKeys() throws IOException {
for (Iterator i = sel.selectedKeys().iterator(); i.hasNext();) {
for (Iterator<SelectionKey> i = sel.selectedKeys().iterator(); i.hasNext();) {

// Retrieve the next key and remove it from the set
SelectionKey sk = (SelectionKey)i.next();
SelectionKey sk = i.next();
i.remove();

// Retrieve the target and the channel
Original file line number Diff line number Diff line change
@@ -179,7 +179,7 @@ boolean isPersistent(Storage storage) {

// NOTE: clears the pword parameter!
private static Map<String, ?> createMap(String username, char[] pword) {
Map map = new HashMap();
Map<String, String[]> map = new HashMap<>();

if (username != null && !username.isEmpty()) {
map.put(JMXConnector.CREDENTIALS, new String[] { username, pword == null ? null : new String(decodePassword(pword)) });
Original file line number Diff line number Diff line change
@@ -122,7 +122,7 @@ private static DefaultTableModel getModel(Set<ConnectionDescriptor> descriptors)
}

private static Set<ConnectionDescriptor> getDescriptors(DefaultTableModel model) {
Set<ConnectionDescriptor> descriptors = new HashSet();
Set<ConnectionDescriptor> descriptors = new HashSet<>();
for (int i = 0; i < model.getRowCount(); i++)
descriptors.add((ConnectionDescriptor)model.getValueAt(i, 0));
return descriptors;
@@ -184,7 +184,7 @@ private boolean containsConnection(ConnectionDescriptor d) {
}

private int getUnusedPort() {
Set<Integer> ports = new HashSet();
Set<Integer> ports = new HashSet<>();
for (int i = 0; i < table.getRowCount(); i++)
ports.add(((ConnectionDescriptor)table.getValueAt(i, 0)).getPort());
for (int i = ConnectionDescriptor.createDefault().getPort() + 1; i < 65536; i++)
Original file line number Diff line number Diff line change
@@ -68,7 +68,7 @@ public class CrossBorderLayout implements LayoutManager2 {

private static final int NONE = Integer.MIN_VALUE;

private Map<Component, Integer[]> map = new HashMap();
private Map<Component, Integer[]> map = new HashMap<>();

private Component north;
private Component west;
Original file line number Diff line number Diff line change
@@ -76,7 +76,7 @@
public class BarChart extends JComponent implements ComponentListener, AncestorListener, ChartModelListener, Accessible {
//~ Instance fields ----------------------------------------------------------------------------------------------------------

List horizAxisXes = new ArrayList();
List<Integer> horizAxisXes = new ArrayList<>();
int horizAxisHeight = 0;
int horizLegendWidth = 0;
int vertAxisWidth = 0;
@@ -513,14 +513,14 @@ protected void drawChart(Graphics2D g2) {
offScreenImageInvalid = false;
}

protected void drawHorizontalAxis(Graphics2D g2, List horizAxisXes, String[] xItems) {
protected void drawHorizontalAxis(Graphics2D g2, List<Integer> horizAxisXes, String[] xItems) {
g2.setPaint(axisPaint);
g2.setStroke(axisStroke);

g2.drawLine(vertAxisWidth - 3, drawHeight - horizAxisHeight, drawWidth, drawHeight - horizAxisHeight);

for (int i = 0; i < horizAxisXes.size(); i++) {
int x = ((Integer) horizAxisXes.get(i)).intValue();
int x = horizAxisXes.get(i).intValue();
g2.drawLine(x, drawHeight - horizAxisHeight + 1, x, drawHeight - horizAxisHeight + 3);
drawHorizontalAxisLegendItem(g2, x, xItems[i]);
}
Original file line number Diff line number Diff line change
@@ -134,8 +134,8 @@ public Collection toggleState() {
}
}

protected Collection setPartiallyChecked() {
Set changedNodes = new HashSet();
protected Collection<TreeNode> setPartiallyChecked() {
Set<TreeNode> changedNodes = new HashSet<>();
changedNodes.add(this);

// Check if change is needed
@@ -160,8 +160,8 @@ protected Collection setPartiallyChecked() {
// ---------------------------------------------------------------------------

// --- Private implementation ------------------------------------------------
private Collection setFullyChecked() {
Set changedNodes = new HashSet();
private Collection<TreeNode> setFullyChecked() {
Set<TreeNode> changedNodes = new HashSet<>();
changedNodes.add(this);

// Check if change is needed
@@ -198,8 +198,8 @@ private Collection setFullyChecked() {
return changedNodes;
}

private Collection setUnchecked() {
Set changedNodes = new HashSet();
private Collection<TreeNode> setUnchecked() {
Set<TreeNode> changedNodes = new HashSet<>();
changedNodes.add(this);

// Check if change is needed
Original file line number Diff line number Diff line change
@@ -62,6 +62,7 @@
import org.graalvm.visualvm.lib.ui.components.treetable.JTreeTablePanel;
import org.graalvm.visualvm.lib.ui.components.treetable.TreeTableModel;
import org.graalvm.visualvm.lib.jfluid.utils.StringUtils;
import java.awt.AWTKeyStroke;
import java.awt.KeyboardFocusManager;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
@@ -560,11 +561,11 @@ public void actionPerformed(ActionEvent e) {
}); // NOI18N

// Disable traversing table cells using TAB and Shift+TAB
Set keys = new HashSet(treeTable.getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS));
Set<AWTKeyStroke> keys = new HashSet<>(treeTable.getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS));
keys.add(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0));
treeTable.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, keys);

keys = new HashSet(treeTable.getFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS));
keys = new HashSet<>(treeTable.getFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS));
keys.add(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK));
treeTable.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, keys);

Original file line number Diff line number Diff line change
@@ -54,6 +54,7 @@
import org.graalvm.visualvm.lib.ui.components.table.ExtendedTableModel;
import org.graalvm.visualvm.lib.ui.components.table.LabelBracketTableCellRenderer;
import org.graalvm.visualvm.lib.ui.components.table.SortableTableModel;
import java.awt.AWTKeyStroke;
import java.awt.KeyboardFocusManager;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@@ -305,11 +306,11 @@ public void doLayout() {
resTable.setRowHeight(UIUtils.getDefaultRowHeight() + 2);

// Disable traversing table cells using TAB and Shift+TAB
Set keys = new HashSet(resTable.getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS));
Set<AWTKeyStroke> keys = new HashSet<>(resTable.getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS));
keys.add(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0));
resTable.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, keys);

keys = new HashSet(resTable.getFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS));
keys = new HashSet<>(resTable.getFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS));
keys.add(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK));
resTable.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, keys);

Loading