8242943: Fix all remaining unchecked warnings in jdk.hotspot.agent
Reviewed-by: darcy, sspitsyn, dholmes
This commit is contained in:
parent
48569d9da0
commit
93032c637b
@ -303,8 +303,8 @@ jdk.compiler_CLEAN_FILES += $(wildcard \
|
||||
|
||||
################################################################################
|
||||
|
||||
jdk.hotspot.agent_DISABLED_WARNINGS += rawtypes serial unchecked \
|
||||
cast static overrides fallthrough
|
||||
jdk.hotspot.agent_DISABLED_WARNINGS += rawtypes serial cast static overrides \
|
||||
fallthrough
|
||||
jdk.hotspot.agent_COPY += .gif .png sa.js .properties
|
||||
|
||||
################################################################################
|
||||
|
@ -338,10 +338,14 @@ public class ciMethodData extends ciMetadata implements MethodDataInterface<ciKl
|
||||
ProfileData pdata = firstData();
|
||||
for ( ; isValid(pdata); pdata = nextData(pdata)) {
|
||||
if (pdata instanceof ReceiverTypeData) {
|
||||
count = dumpReplayDataReceiverTypeHelper(out, round, count, (ReceiverTypeData<ciKlass,ciMethod>)pdata);
|
||||
@SuppressWarnings("unchecked")
|
||||
ReceiverTypeData<ciKlass,ciMethod> receiverTypeData = (ReceiverTypeData<ciKlass,ciMethod>)pdata;
|
||||
count = dumpReplayDataReceiverTypeHelper(out, round, count, receiverTypeData);
|
||||
}
|
||||
if (pdata instanceof CallTypeDataInterface) {
|
||||
count = dumpReplayDataCallTypeHelper(out, round, count, (CallTypeDataInterface<ciKlass>)pdata);
|
||||
@SuppressWarnings("unchecked")
|
||||
CallTypeDataInterface<ciKlass> callTypeData = (CallTypeDataInterface<ciKlass>)pdata;
|
||||
count = dumpReplayDataCallTypeHelper(out, round, count, callTypeData);
|
||||
}
|
||||
}
|
||||
if (parameters != null) {
|
||||
|
@ -36,7 +36,7 @@ import sun.jvm.hotspot.utilities.*;
|
||||
import sun.jvm.hotspot.utilities.Observable;
|
||||
import sun.jvm.hotspot.utilities.Observer;
|
||||
|
||||
public class ConstMethod extends VMObject {
|
||||
public class ConstMethod extends Metadata {
|
||||
static {
|
||||
VM.registerVMInitializedObserver(new Observer() {
|
||||
public void update(Observable o, Object data) {
|
||||
|
@ -55,7 +55,7 @@ abstract public class Metadata extends VMObject {
|
||||
private static VirtualBaseConstructor<Metadata> metadataConstructor;
|
||||
|
||||
private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
|
||||
metadataConstructor = new VirtualBaseConstructor<Metadata>(db, db.lookupType("Metadata"), null, null);
|
||||
metadataConstructor = new VirtualBaseConstructor<>(db, db.lookupType("Metadata"), null, null);
|
||||
// Define an explicit mapping since the C++ and Java type names don't match.
|
||||
metadataConstructor.addMapping("Metadata", Metadata.class);
|
||||
metadataConstructor.addMapping("Klass", Klass.class);
|
||||
|
@ -523,10 +523,14 @@ public class MethodData extends Metadata implements MethodDataInterface<Klass,Me
|
||||
ProfileData pdata = firstData();
|
||||
for ( ; isValid(pdata); pdata = nextData(pdata)) {
|
||||
if (pdata instanceof ReceiverTypeData) {
|
||||
count = dumpReplayDataReceiverTypeHelper(out, round, count, (ReceiverTypeData<Klass,Method>)pdata);
|
||||
@SuppressWarnings("unchecked")
|
||||
ReceiverTypeData<Klass,Method> receiverTypeData = (ReceiverTypeData<Klass,Method>)pdata;
|
||||
count = dumpReplayDataReceiverTypeHelper(out, round, count, receiverTypeData);
|
||||
}
|
||||
if (pdata instanceof CallTypeDataInterface) {
|
||||
count = dumpReplayDataCallTypeHelper(out, round, count, (CallTypeDataInterface<Klass>)pdata);
|
||||
@SuppressWarnings("unchecked")
|
||||
CallTypeDataInterface<Klass> callTypeData = (CallTypeDataInterface<Klass>)pdata;
|
||||
count = dumpReplayDataCallTypeHelper(out, round, count, callTypeData);
|
||||
}
|
||||
}
|
||||
if (parameters != null) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 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
|
||||
@ -34,19 +34,19 @@ import sun.jvm.hotspot.HotSpotTypeDataBase;
|
||||
|
||||
/** Instantiate wrappers for statically typed instances. */
|
||||
|
||||
public class StaticBaseConstructor<T> extends InstanceConstructor {
|
||||
private Class staticType;
|
||||
public class StaticBaseConstructor<T extends VMObject> extends InstanceConstructor<T> {
|
||||
private Class<T> staticType;
|
||||
|
||||
public StaticBaseConstructor(Class<T> t) {
|
||||
staticType = t;
|
||||
}
|
||||
|
||||
/** Instantiate a wrapper using staticType */
|
||||
public VMObject instantiateWrapperFor(Address addr) throws WrongTypeException {
|
||||
public T instantiateWrapperFor(Address addr) throws WrongTypeException {
|
||||
if (addr == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (VMObject) VMObjectFactory.newObject(staticType, addr);
|
||||
return VMObjectFactory.newObject(staticType, addr);
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
@ -44,7 +44,7 @@ import sun.jvm.hotspot.types.*;
|
||||
one.) </P>
|
||||
*/
|
||||
|
||||
public class VMObjectFactory {
|
||||
public class VMObjectFactory<T extends VMObject> {
|
||||
public static <T> T newObject(Class<T> clazz, Address addr)
|
||||
throws ConstructionException {
|
||||
try {
|
||||
|
@ -36,13 +36,13 @@ import sun.jvm.hotspot.HotSpotTypeDataBase;
|
||||
* type is know and the expected subclasses are within a particular
|
||||
* package. */
|
||||
|
||||
public class VirtualBaseConstructor<T> extends InstanceConstructor {
|
||||
public class VirtualBaseConstructor<T> extends InstanceConstructor<T> {
|
||||
private TypeDataBase db;
|
||||
private Map<String, Class<?>> map;
|
||||
private Map<String, Class<? extends T>> map;
|
||||
private Type baseType;
|
||||
private Class unknownTypeHandler;
|
||||
private Class<T> unknownTypeHandler;
|
||||
|
||||
public VirtualBaseConstructor(TypeDataBase db, Type baseType, String packageName, Class unknownTypeHandler) {
|
||||
public VirtualBaseConstructor(TypeDataBase db, Type baseType, String packageName, Class<T> unknownTypeHandler) {
|
||||
this.db = (HotSpotTypeDataBase)db;
|
||||
map = new HashMap<>();
|
||||
this.baseType = baseType;
|
||||
@ -59,10 +59,12 @@ public class VirtualBaseConstructor<T> extends InstanceConstructor {
|
||||
}
|
||||
if (superType == baseType) {
|
||||
superType = t;
|
||||
Class c = null;
|
||||
Class<? extends T> c = null;
|
||||
while (c == null && superType != null) {
|
||||
try {
|
||||
c = Class.forName(packageName + "." + superType.getName());
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<? extends T> lookedUpClass = (Class<? extends T>)Class.forName(packageName + "." + superType.getName());
|
||||
c = lookedUpClass;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
if (c == null) superType = superType.getSuperclass();
|
||||
@ -80,7 +82,7 @@ public class VirtualBaseConstructor<T> extends InstanceConstructor {
|
||||
class. The latter must be a subclass of
|
||||
sun.jvm.hotspot.runtime.VMObject. Returns false if there was
|
||||
already a class for this type name in the map. */
|
||||
public boolean addMapping(String cTypeName, Class clazz) {
|
||||
public boolean addMapping(String cTypeName, Class<? extends T> clazz) {
|
||||
if (map.get(cTypeName) != null) {
|
||||
return false;
|
||||
}
|
||||
@ -101,9 +103,9 @@ public class VirtualBaseConstructor<T> extends InstanceConstructor {
|
||||
|
||||
Type type = db.findDynamicTypeForAddress(addr, baseType);
|
||||
if (type != null) {
|
||||
return (T) VMObjectFactory.newObject((Class) map.get(type.getName()), addr);
|
||||
return VMObjectFactory.newObject(map.get(type.getName()), addr);
|
||||
} else if (unknownTypeHandler != null) {
|
||||
return (T) VMObjectFactory.newObject(unknownTypeHandler, addr);
|
||||
return VMObjectFactory.newObject(unknownTypeHandler, addr);
|
||||
}
|
||||
|
||||
throw newWrongTypeException(addr);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2011, 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
|
||||
@ -40,18 +40,18 @@ import sun.jvm.hotspot.types.*;
|
||||
|
||||
public class VirtualConstructor extends InstanceConstructor<VMObject> {
|
||||
private TypeDataBase db;
|
||||
private Map map; // Map<String, Class>
|
||||
private Map<String, Class<? extends VMObject>> map;
|
||||
|
||||
public VirtualConstructor(TypeDataBase db) {
|
||||
this.db = db;
|
||||
map = new HashMap();
|
||||
map = new HashMap<>();
|
||||
}
|
||||
|
||||
/** Adds a mapping from the given C++ type name to the given Java
|
||||
class. The latter must be a subclass of
|
||||
sun.jvm.hotspot.runtime.VMObject. Returns false if there was
|
||||
already a class for this type name in the map. */
|
||||
public boolean addMapping(String cTypeName, Class clazz) {
|
||||
public boolean addMapping(String cTypeName, Class<? extends VMObject> clazz) {
|
||||
if (map.get(cTypeName) != null) {
|
||||
return false;
|
||||
}
|
||||
@ -70,10 +70,10 @@ public class VirtualConstructor extends InstanceConstructor<VMObject> {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (Iterator iter = map.keySet().iterator(); iter.hasNext(); ) {
|
||||
String typeName = (String) iter.next();
|
||||
for (Iterator<String> iter = map.keySet().iterator(); iter.hasNext(); ) {
|
||||
String typeName = iter.next();
|
||||
if (db.addressTypeIsEqualToType(addr, db.lookupType(typeName))) {
|
||||
return (VMObject) VMObjectFactory.newObject((Class) map.get(typeName), addr);
|
||||
return VMObjectFactory.newObject(map.get(typeName), addr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -160,7 +160,7 @@ public class ObjectHistogramPanel extends JPanel implements ActionListener {
|
||||
/**
|
||||
* A table model which encapsulates the ObjectHistogram
|
||||
*/
|
||||
private class ObjectHistogramTableModel extends SortableTableModel {
|
||||
private class ObjectHistogramTableModel extends SortableTableModel<ObjectHistogramElement> {
|
||||
private String[] columnNames = { "Size", "Count", "Class Description" };
|
||||
private Class[] columnClasses = { Long.class, Long.class, String.class };
|
||||
|
||||
@ -191,7 +191,7 @@ public class ObjectHistogramPanel extends JPanel implements ActionListener {
|
||||
return getValueForColumn(getElement(row), col);
|
||||
}
|
||||
|
||||
public Object getValueForColumn(Object obj, int col) {
|
||||
public Comparable<?> getValueForColumn(Object obj, int col) {
|
||||
ObjectHistogramElement el = (ObjectHistogramElement)obj;
|
||||
switch (col) {
|
||||
case 0:
|
||||
@ -206,7 +206,7 @@ public class ObjectHistogramPanel extends JPanel implements ActionListener {
|
||||
}
|
||||
|
||||
public ObjectHistogramElement getElement(int index) {
|
||||
return (ObjectHistogramElement) elements.get(index);
|
||||
return elements.get(index);
|
||||
}
|
||||
|
||||
private class ObjectHistogramComparator extends TableModelComparator {
|
||||
@ -222,7 +222,7 @@ public class ObjectHistogramPanel extends JPanel implements ActionListener {
|
||||
* @param obj Object that was passed for Comparator
|
||||
* @param column the column to retrieve
|
||||
*/
|
||||
public Object getValueForColumn(Object obj, int column) {
|
||||
public Comparable<?> getValueForColumn(Object obj, int column) {
|
||||
ObjectHistogramTableModel omodel = (ObjectHistogramTableModel)model;
|
||||
return omodel.getValueForColumn(obj, column);
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ import sun.jvm.hotspot.ui.tree.*;
|
||||
public class ObjectListPanel extends SAPanel {
|
||||
private ObjectListTableModel dataModel;
|
||||
private JTable table;
|
||||
private java.util.List elements;
|
||||
private java.util.List<Oop> elements;
|
||||
private HeapProgressThunk thunk;
|
||||
private boolean checkedForArrays;
|
||||
private boolean hasArrays;
|
||||
@ -55,7 +55,7 @@ public class ObjectListPanel extends SAPanel {
|
||||
|
||||
/** Takes a List<Oop> in constructor, and an optional
|
||||
HeapProgressThunk used if computing liveness */
|
||||
public ObjectListPanel(java.util.List els,
|
||||
public ObjectListPanel(java.util.List<Oop> els,
|
||||
HeapProgressThunk thunk) {
|
||||
super();
|
||||
|
||||
@ -120,7 +120,7 @@ public class ObjectListPanel extends SAPanel {
|
||||
// Internals only below this point
|
||||
//
|
||||
|
||||
private static class AddressWrapper implements Comparable {
|
||||
private static class AddressWrapper implements Comparable<AddressWrapper> {
|
||||
private Address address;
|
||||
|
||||
private AddressWrapper(Address address) {
|
||||
@ -131,8 +131,7 @@ public class ObjectListPanel extends SAPanel {
|
||||
return address.toString();
|
||||
}
|
||||
|
||||
public int compareTo(Object o) {
|
||||
AddressWrapper wrapper = (AddressWrapper) o;
|
||||
public int compareTo(AddressWrapper wrapper) {
|
||||
Address addr = wrapper.address;
|
||||
if (AddressOps.lessThan(address, addr)) return -1;
|
||||
if (AddressOps.greaterThan(address, addr)) return 1;
|
||||
@ -140,7 +139,7 @@ public class ObjectListPanel extends SAPanel {
|
||||
}
|
||||
}
|
||||
|
||||
private class ObjectListTableModel extends SortableTableModel {
|
||||
private class ObjectListTableModel extends SortableTableModel<Oop> {
|
||||
public ObjectListTableModel() {
|
||||
// Set the rows
|
||||
this.elements = ObjectListPanel.this.elements;
|
||||
@ -180,7 +179,7 @@ public class ObjectListPanel extends SAPanel {
|
||||
return getValueForColumn(oop, col);
|
||||
}
|
||||
|
||||
public Object getValueForColumn(Oop oop, int col) {
|
||||
public Comparable<?> getValueForColumn(Oop oop, int col) {
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
|
||||
switch (col) {
|
||||
@ -241,7 +240,7 @@ public class ObjectListPanel extends SAPanel {
|
||||
* @param obj Object that was passed for Comparator
|
||||
* @param column the column to retrieve
|
||||
*/
|
||||
public Object getValueForColumn(Object obj, int column) {
|
||||
public Comparable<?> getValueForColumn(Object obj, int column) {
|
||||
ObjectListTableModel omodel = (ObjectListTableModel)model;
|
||||
return omodel.getValueForColumn((Oop) obj, column);
|
||||
}
|
||||
@ -254,7 +253,7 @@ public class ObjectListPanel extends SAPanel {
|
||||
return;
|
||||
}
|
||||
|
||||
Oop oop = (Oop) elements.get(i);
|
||||
Oop oop = elements.get(i);
|
||||
|
||||
for (Iterator iter = listeners.iterator(); iter.hasNext(); ) {
|
||||
SAListener listener = (SAListener) iter.next();
|
||||
@ -311,7 +310,7 @@ public class ObjectListPanel extends SAPanel {
|
||||
return;
|
||||
}
|
||||
|
||||
Oop oop = (Oop) elements.get(i);
|
||||
Oop oop = elements.get(i);
|
||||
LivenessPathList list = LivenessAnalysis.computeAllLivenessPaths(oop);
|
||||
if (list == null) {
|
||||
return; // dead object
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 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
|
||||
@ -35,14 +35,14 @@ import javax.swing.table.AbstractTableModel;
|
||||
* of the list may be sortable by column. The TableModelComparator
|
||||
* must be set for sorting to be enabled.
|
||||
*/
|
||||
public abstract class SortableTableModel extends AbstractTableModel {
|
||||
public abstract class SortableTableModel<T> extends AbstractTableModel {
|
||||
|
||||
private TableModelComparator comparator;
|
||||
|
||||
/**
|
||||
* All the rows are stored as a List.
|
||||
*/
|
||||
protected java.util.List elements;
|
||||
protected java.util.List<T> elements;
|
||||
|
||||
/**
|
||||
* This comparator must be set.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 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
|
||||
@ -32,7 +32,7 @@ import javax.swing.event.TableModelEvent;
|
||||
/**
|
||||
* A comparator which compares rows in a table model
|
||||
*/
|
||||
public abstract class TableModelComparator implements Comparator {
|
||||
public abstract class TableModelComparator implements Comparator<Object> {
|
||||
|
||||
private boolean ascending;
|
||||
protected TableModel model;
|
||||
@ -81,8 +81,10 @@ public abstract class TableModelComparator implements Comparator {
|
||||
public int compare(Object row1, Object row2) {
|
||||
for (int i = 0; i < columns.length; i++) {
|
||||
|
||||
Object o1 = getValueForColumn(row1, columns[i]);
|
||||
Object o2 = getValueForColumn(row2, columns[i]);
|
||||
@SuppressWarnings("unchecked")
|
||||
Comparable<Object> o1 = (Comparable<Object>) getValueForColumn(row1, columns[i]);
|
||||
@SuppressWarnings("unchecked")
|
||||
Comparable<Object> o2 = (Comparable<Object>) getValueForColumn(row2, columns[i]);
|
||||
|
||||
// If both values are null, return 0.
|
||||
if (o1 == null && o2 == null) {
|
||||
@ -93,19 +95,7 @@ public abstract class TableModelComparator implements Comparator {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int result = 0;
|
||||
|
||||
if (o1 instanceof Comparable) {
|
||||
Comparable c1 = (Comparable)o1;
|
||||
Comparable c2 = (Comparable)o2;
|
||||
|
||||
result = c1.compareTo(c2);
|
||||
}
|
||||
|
||||
// XXX Should have some sort of provision for determininte
|
||||
// if there is another way of comparing the objects.
|
||||
// Perhaps we should add the requirement that all table
|
||||
// values be Compabable.
|
||||
int result = o1.compareTo(o2);
|
||||
|
||||
if (result != 0) {
|
||||
return ascending ? result : -result;
|
||||
@ -121,6 +111,6 @@ public abstract class TableModelComparator implements Comparator {
|
||||
* @param obj Row object that was passed into Comparator.
|
||||
* @param column the column to retrieve
|
||||
*/
|
||||
public abstract Object getValueForColumn(Object obj, int column);
|
||||
public abstract Comparable<?> getValueForColumn(Object obj, int column);
|
||||
|
||||
}
|
||||
|
@ -297,7 +297,7 @@ public class ObjectReader {
|
||||
return getProperties(oop);
|
||||
}
|
||||
|
||||
Class clz = readClass(kls);
|
||||
Class<?> clz = readClass(kls);
|
||||
try {
|
||||
result = clz.getDeclaredConstructor().newInstance();
|
||||
} catch (Exception ex) {
|
||||
|
Loading…
Reference in New Issue
Block a user