Skip to content

Commit 779ffd8

Browse files
committed
replace obsolete Hashtable class
1 parent 6201071 commit 779ffd8

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

visualvm/libs.profiler/lib.profiler/src/org/graalvm/visualvm/lib/jfluid/classfile/ClassFileCache.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@
2929
import java.io.IOException;
3030
import java.io.InputStream;
3131
import java.util.ArrayList;
32-
import java.util.Hashtable;
32+
import java.util.HashMap;
3333
import java.util.List;
34+
import java.util.Map;
3435
import java.util.zip.ZipEntry;
3536
import java.util.zip.ZipException;
3637
import java.util.zip.ZipFile;
@@ -56,7 +57,7 @@ public class ClassFileCache {
5657
//~ Instance fields ----------------------------------------------------------------------------------------------------------
5758

5859
private ClassPath classPath; // Used to quickly obtain an open JAR file for a given name
59-
private Hashtable vmSuppliedClassCache;
60+
private Map vmSuppliedClassCache;
6061
private byte[][] classFileBytes;
6162
private String[] classNameAndLocation;
6263
private long[] lastTimeUsed;
@@ -78,7 +79,7 @@ public class ClassFileCache {
7879
classFileBytes = new byte[capacity][];
7980
lastTimeUsed = new long[capacity];
8081

81-
vmSuppliedClassCache = new Hashtable();
82+
vmSuppliedClassCache = new HashMap();
8283
preloadNames = new ArrayList();
8384
preloadLoaderIds = new ArrayList();
8485
}

visualvm/libs.profiler/lib.profiler/src/org/graalvm/visualvm/lib/jfluid/results/cpu/CPUCCTClassContainer.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@
2626
package org.graalvm.visualvm.lib.jfluid.results.cpu;
2727

2828
import org.graalvm.visualvm.lib.jfluid.utils.IntVector;
29-
import java.util.Enumeration;
30-
import java.util.Hashtable;
29+
import java.util.HashSet;
30+
import java.util.Iterator;
31+
import java.util.Set;
3132

3233

3334
/**
@@ -127,7 +128,7 @@ protected int generateClassNodeFromMethodNodes(IntVector methodNodes, int dataOf
127128
// Now add all the children of methodNodes that have the same class, to thisNode, and collect the rest of the
128129
// children of methodNodes into sourceChildren vector.
129130
IntVector sourceChildren = new IntVector();
130-
Hashtable uniqChildrenCache = new Hashtable();
131+
Set uniqChildrenCache = new HashSet();
131132

132133
for (int i = 0; i < nMethodNodes; i++) {
133134
int methodNodeOfs = methodNodes.get(i);
@@ -174,12 +175,12 @@ protected int generateClassNodeFromMethodNodes(IntVector methodNodes, int dataOf
174175
.get(i)));
175176
}
176177

177-
Enumeration e = uniqChildrenCache.elements();
178+
Iterator e = uniqChildrenCache.iterator();
178179

179-
for (int i = 0; e.hasMoreElements(); i++) {
180+
for (int i = 0; e.hasNext(); i++) {
180181
sameTypeChildren.clear();
181182

182-
int sourceChildClassOrPackageId = ((Integer) e.nextElement()).intValue();
183+
int sourceChildClassOrPackageId = ((Integer) e.next()).intValue();
183184

184185
for (int j = 0; j < nAllChildren; j++) {
185186
if (sourceChildrenClassIds[j] == sourceChildClassOrPackageId) {
@@ -221,7 +222,7 @@ protected int generateClassNodeFromMethodNodes(IntVector methodNodes, int dataOf
221222
* 3. All other source children are added to allSourceChildren, but not to uniqChildCache.
222223
*/
223224
protected void processChildren(int dataOfs, int methodNodeOfs, int nChildren, IntVector allSourceChildren,
224-
Hashtable uniqChildCache) {
225+
Set uniqChildCache) {
225226
int thisNodeClassOrPackageId = getMethodIdForNodeOfs(dataOfs);
226227

227228
int nCalls = 0;
@@ -250,10 +251,7 @@ protected void processChildren(int dataOfs, int methodNodeOfs, int nChildren, In
250251

251252
Integer key = Integer.valueOf(sourceChildClassOrPackageId);
252253

253-
if (!uniqChildCache.containsKey(key)) {
254-
uniqChildCache.put(key, key);
255-
}
256-
254+
uniqChildCache.add(key);
257255
allSourceChildren.add(sourceChildOfs);
258256
}
259257
}

visualvm/libs.profiler/lib.profiler/src/org/graalvm/visualvm/lib/jfluid/results/threads/ThreadsDataManager.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@
2525

2626
package org.graalvm.visualvm.lib.jfluid.results.threads;
2727

28+
import java.util.HashMap;
29+
import java.util.Map;
2830
import org.graalvm.visualvm.lib.jfluid.client.MonitoredData;
2931
import org.graalvm.visualvm.lib.jfluid.global.CommonConstants;
3032
import org.graalvm.visualvm.lib.jfluid.results.DataManager;
31-
import java.util.Hashtable;
3233

3334

3435
/**
@@ -45,7 +46,7 @@
4546
public class ThreadsDataManager extends DataManager {
4647
//~ Instance fields ----------------------------------------------------------------------------------------------------------
4748

48-
private Hashtable idToIndex = new Hashtable(30);
49+
private Map idToIndex = new HashMap(30);
4950
private ThreadData[] threadData; // Per-thread array of points at which thread's state changes
5051
private boolean supportsSleepingState = true;
5152
private boolean threadsMonitoringEnabled = true;

0 commit comments

Comments
 (0)