Skip to content
Permalink
Browse files
8241618: Fix trivial unchecked warnings for jdk.hotspot.agent
Reviewed-by: cjplummer, sspitsyn
  • Loading branch information
magicus committed Apr 15, 2020
1 parent 919027a commit b0d709cc23184de0d6824802efa3b23e88f97299
Showing 117 changed files with 620 additions and 637 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2020, 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
@@ -37,7 +37,7 @@

protected ActionManager()
{
actions = new HashMap();
actions = new HashMap<>();
addActions();
}

@@ -93,7 +93,7 @@ public void setActionEnabled(String name, boolean enabled)
action.setEnabled(enabled);
}

private HashMap actions;
private HashMap<String, Action> actions;
private static ActionUtilities utilities = new ActionUtilities();
private static ActionManager manager;

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2020, 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
@@ -176,30 +176,30 @@ public static JCheckBox createCheckBox(String text)
return createCheckBox(text, -1, null, false);
}

public static JComboBox createComboBox(Object items[], ActionListener listener, boolean editable)
public static JComboBox<Object> createComboBox(Object items[], ActionListener listener, boolean editable)
{
JComboBox comboBox = new JComboBox(items);
JComboBox<Object> comboBox = new JComboBox<>(items);
if(listener != null)
comboBox.addActionListener(listener);
comboBox.setEditable(editable);
return comboBox;
}

public static JComboBox createComboBox(Object items[], boolean editable)
public static JComboBox<Object> createComboBox(Object items[], boolean editable)
{
return createComboBox(items, null, editable);
}

public static JComboBox createComboBox(Vector items, ActionListener listener, boolean editable)
public static JComboBox<Object> createComboBox(Vector<Object> items, ActionListener listener, boolean editable)
{
JComboBox comboBox = new JComboBox(items);
JComboBox<Object> comboBox = new JComboBox<>(items);
if(listener != null)
comboBox.addActionListener(listener);
comboBox.setEditable(editable);
return comboBox;
}

public static JComboBox createComboBox(Vector items, boolean editable)
public static JComboBox<Object> createComboBox(Vector<Object> items, boolean editable)
{
return createComboBox(items, null, editable);
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2020, 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
@@ -127,7 +127,7 @@ public static void main(String args[])
JPanel p4 = new JPanel();
p4.add(new JButton("Four"));
p4.setName("Four");
Vector panels = new Vector();
Vector<JPanel> panels = new Vector<>();
panels.addElement(p1);
panels.addElement(p2);
panels.addElement(p3);
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2020, 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
@@ -178,7 +178,7 @@ public static void main(String args[])
p3.add(new JButton("Three"));
JPanel p4 = new JPanel();
p4.add(new JButton("Four"));
Vector panels = new Vector();
Vector<JPanel> panels = new Vector<>();
panels.addElement(p1);
panels.addElement(p2);
panels.addElement(p3);
@@ -128,7 +128,7 @@ public boolean canInclude(InstanceKlass kls) {
}

public static class NonBootFilter implements ClassFilter {
private HashMap emitted = new HashMap();
private HashMap<Symbol, InstanceKlass> emitted = new HashMap<>();
public boolean canInclude(InstanceKlass kls) {
if (kls.getClassLoader() == null) return false;
if (emitted.get(kls.getName()) != null) {
@@ -156,7 +156,7 @@ String[] splitWhitespace(String cmd) {
return t;
}

void add(String s, ArrayList t) {
void add(String s, ArrayList<String> t) {
if (s.length() > 0) {
t.add(s);
}
@@ -167,7 +167,7 @@ void add(String s, ArrayList t) {

// check for quoting
int quote = cmd.indexOf('"');
ArrayList t = new ArrayList();
ArrayList<String> t = new ArrayList<>();
if (quote != -1) {
while (cmd.length() > 0) {
if (quote != -1) {
@@ -682,7 +682,7 @@ public void doit(Tokens t) {
} else if (tokens == 0) {
out.println("Available commands:");
Object[] keys = commands.keySet().toArray();
Arrays.sort(keys, new Comparator() {
Arrays.sort(keys, new Comparator<>() {
public int compare(Object o1, Object o2) {
return o1.toString().compareTo(o2.toString());
}
@@ -993,8 +993,8 @@ public void doit(Tokens t) {
// be read back.
Iterator i = agent.getTypeDataBase().getTypes();
// Make sure the types are emitted in an order than can be read back in
HashSet emitted = new HashSet();
Stack pending = new Stack();
HashSet<String> emitted = new HashSet<>();
Stack<Type> pending = new Stack<>();
while (i.hasNext()) {
Type n = (Type)i.next();
if (emitted.contains(n.getName())) {
@@ -1389,8 +1389,8 @@ public void doit(Tokens t) {
} else {
Iterator i = agent.getTypeDataBase().getTypes();
// Make sure the types are emitted in an order than can be read back in
HashSet emitted = new HashSet();
Stack pending = new Stack();
HashSet<String> emitted = new HashSet<>();
Stack<Type> pending = new Stack<>();
while (i.hasNext()) {
Type n = (Type)i.next();
if (emitted.contains(n.getName())) {
@@ -1640,7 +1640,7 @@ public void doit(Tokens t) {
if (t.countTokens() != 0) {
usage();
} else {
ArrayList nmethods = new ArrayList();
ArrayList<NMethod> nmethods = new ArrayList<>();
Threads threads = VM.getVM().getThreads();
HTMLGenerator gen = new HTMLGenerator(false);
for (int i = 0; i < threads.getNumberOfThreads(); i++) {
@@ -1832,8 +1832,8 @@ public void visit(Klass k) {
};

private boolean verboseExceptions = false;
private ArrayList history = new ArrayList();
private HashMap commands = new HashMap();
private ArrayList<String> history = new ArrayList<>();
private HashMap<String, Command> commands = new HashMap<>();
private boolean doEcho = false;

private Command findCommand(String key) {
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2020, 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
@@ -66,10 +66,8 @@ public static void main(String[] args) {
private boolean attached;
private boolean argError;
private JFrame frame;
/** List <JMenuItem> */
private java.util.List attachMenuItems;
/** List <JMenuItem> */
private java.util.List detachMenuItems;
private java.util.List<JMenuItem> attachMenuItems;
private java.util.List<JMenuItem> detachMenuItems;
private JMenu toolsMenu;
private JMenuItem showDbgConsoleMenuItem;
private JMenuItem computeRevPtrsMenuItem;
@@ -155,8 +153,8 @@ public void run() {

agent = new HotSpotAgent();
workerThread = new WorkerThread();
attachMenuItems = new java.util.ArrayList();
detachMenuItems = new java.util.ArrayList();
attachMenuItems = new java.util.ArrayList<>();
detachMenuItems = new java.util.ArrayList<>();


JMenuBar menuBar = new JMenuBar();
@@ -875,7 +873,7 @@ public void run() {
// frames in a table and one which finds Java frames and if they
// are in the table indicates that they were interrupted by a signal.

Map interruptedFrameMap = new HashMap();
Map<sun.jvm.hotspot.runtime.Frame, SignalInfo> interruptedFrameMap = new HashMap<>();
{
sun.jvm.hotspot.runtime.Frame tmpFrame = thread.getCurrentFrameGuess();
RegisterMap tmpMap = thread.newRegisterMap(false);
@@ -1845,9 +1843,9 @@ private String formatMessage(String message, int charsPerLine) {
return buf.toString();
}

private void setMenuItemsEnabled(java.util.List items, boolean enabled) {
for (Iterator iter = items.iterator(); iter.hasNext(); ) {
((JMenuItem) iter.next()).setEnabled(enabled);
private void setMenuItemsEnabled(java.util.List<JMenuItem> items, boolean enabled) {
for (Iterator<JMenuItem> iter = items.iterator(); iter.hasNext(); ) {
iter.next().setEnabled(enabled);
}
}
}
@@ -483,7 +483,7 @@ private void setupDebuggerExisting() {
private void setupDebuggerAlternate(String alternateName) {

try {
Class c = Class.forName(alternateName);
Class<?> c = Class.forName(alternateName);
Constructor cons = c.getConstructor();
debugger = (JVMDebugger) cons.newInstance();
attachDebugger();
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2020, 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
@@ -63,13 +63,13 @@ private static synchronized void initialize(TypeDataBase db) throws WrongTypeExc
public static ciObject get(Address addr) {
if (addr == null) return null;

return (ciObject)ciObjectConstructor.instantiateWrapperFor(addr);
return ciObjectConstructor.instantiateWrapperFor(addr);
}

public static ciMetadata getMetadata(Address addr) {
if (addr == null) return null;

return (ciMetadata)ciMetadataConstructor.instantiateWrapperFor(addr);
return ciMetadataConstructor.instantiateWrapperFor(addr);
}

public GrowableArray<ciMetadata> objects() {
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2020, 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
@@ -49,8 +49,8 @@ private static synchronized void initialize(TypeDataBase db) {
// Get array of CodeHeaps
// Note: CodeHeap may be subclassed with optional private heap mechanisms.
Type codeHeapType = db.lookupType("CodeHeap");
VirtualBaseConstructor heapConstructor =
new VirtualBaseConstructor(db, codeHeapType, "sun.jvm.hotspot.memory", CodeHeap.class);
VirtualBaseConstructor<CodeHeap> heapConstructor =
new VirtualBaseConstructor<>(db, codeHeapType, "sun.jvm.hotspot.memory", CodeHeap.class);

AddressField heapsField = type.getAddressField("_heaps");
heapArray = GrowableArray.create(heapsField.getValue(), heapConstructor);
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2020, 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
@@ -34,7 +34,7 @@
public class DebugInfoReadStream extends CompressedReadStream {
private NMethod code;
private int InvocationEntryBCI;
private List objectPool; // ArrayList<ObjectValue>
private List<ObjectValue> objectPool;

public DebugInfoReadStream(NMethod code, int offset) {
super(code.scopesDataBegin(), offset);
@@ -43,7 +43,7 @@ public DebugInfoReadStream(NMethod code, int offset) {
this.objectPool = null;
}

public DebugInfoReadStream(NMethod code, int offset, List objectPool) {
public DebugInfoReadStream(NMethod code, int offset, List<ObjectValue> objectPool) {
super(code.scopesDataBegin(), offset);
InvocationEntryBCI = VM.getVM().getInvocationEntryBCI();
this.code = code;
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2020, 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
@@ -416,8 +416,8 @@ public ScopeDesc getScopeDescNearDbg(Address pc) {
return new ScopeDesc(this, pd.getScopeDecodeOffset(), pd.getObjDecodeOffset(), pd.getReexecute());
}

public Map/*<Address, PCDesc>*/ getSafepoints() {
Map safepoints = new HashMap(); // Map<Address, PCDesc>
public Map<sun.jvm.hotspot.debugger.Address, PCDesc> getSafepoints() {
Map<sun.jvm.hotspot.debugger.Address, PCDesc> safepoints = new HashMap<>();
sun.jvm.hotspot.debugger.Address p = null;
for (p = scopesPCsBegin(); p.lessThan(scopesPCsEnd());
p = p.addOffsetTo(pcDescSize)) {
@@ -474,7 +474,7 @@ public String getName() {
}

public void dumpReplayData(PrintStream out) {
HashMap h = new HashMap();
HashMap<Metadata, Metadata> h = new HashMap<>();
for (int i = 1; i < getMetadataLength(); i++) {
Metadata meta = Metadata.instantiateWrapperFor(getMetadataAt(i));
System.err.println(meta);
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2009, 2020, 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
@@ -33,23 +33,23 @@
/** An ObjectValue describes an object eliminated by escape analysis. */

public class ObjectValue extends ScopeValue {
private int id;
private ScopeValue klass;
private List fieldsValue; // ArrayList<ScopeValue>
private int id;
private ScopeValue klass;
private List<ScopeValue> fieldsValue;

// Field "boolean visited" is not implemented here since
// it is used only a during debug info creation.

public ObjectValue(int id) {
this.id = id;
klass = null;
fieldsValue = new ArrayList();
fieldsValue = new ArrayList<>();
}

public boolean isObject() { return true; }
public int id() { return id; }
public ScopeValue getKlass() { return klass; }
public List getFieldsValue() { return fieldsValue; }
public List<ScopeValue> getFieldsValue() { return fieldsValue; }
public ScopeValue getFieldAt(int i) { return (ScopeValue)fieldsValue.get(i); }
public int fieldsSize() { return fieldsValue.size(); }

0 comments on commit b0d709c

Please sign in to comment.