3636 * type is know and the expected subclasses are within a particular
3737 * package. */
3838
39- public class VirtualBaseConstructor <T > extends InstanceConstructor {
39+ public class VirtualBaseConstructor <T > extends InstanceConstructor < T > {
4040 private TypeDataBase db ;
41- private Map <String , Class <?>> map ;
41+ private Map <String , Class <? extends T >> map ;
4242 private Type baseType ;
43- private Class unknownTypeHandler ;
43+ private Class < T > unknownTypeHandler ;
4444
45- public VirtualBaseConstructor (TypeDataBase db , Type baseType , String packageName , Class unknownTypeHandler ) {
45+ public VirtualBaseConstructor (TypeDataBase db , Type baseType , String packageName , Class < T > unknownTypeHandler ) {
4646 this .db = (HotSpotTypeDataBase )db ;
4747 map = new HashMap <>();
4848 this .baseType = baseType ;
@@ -59,10 +59,12 @@ public VirtualBaseConstructor(TypeDataBase db, Type baseType, String packageName
5959 }
6060 if (superType == baseType ) {
6161 superType = t ;
62- Class c = null ;
62+ Class <? extends T > c = null ;
6363 while (c == null && superType != null ) {
6464 try {
65- c = Class .forName (packageName + "." + superType .getName ());
65+ @ SuppressWarnings ("unchecked" )
66+ Class <? extends T > lookedUpClass = (Class <? extends T >)Class .forName (packageName + "." + superType .getName ());
67+ c = lookedUpClass ;
6668 } catch (Exception e ) {
6769 }
6870 if (c == null ) superType = superType .getSuperclass ();
@@ -80,7 +82,7 @@ public VirtualBaseConstructor(TypeDataBase db, Type baseType, String packageName
8082 class. The latter must be a subclass of
8183 sun.jvm.hotspot.runtime.VMObject. Returns false if there was
8284 already a class for this type name in the map. */
83- public boolean addMapping (String cTypeName , Class clazz ) {
85+ public boolean addMapping (String cTypeName , Class <? extends T > clazz ) {
8486 if (map .get (cTypeName ) != null ) {
8587 return false ;
8688 }
@@ -101,9 +103,9 @@ public T instantiateWrapperFor(Address addr) throws WrongTypeException {
101103
102104 Type type = db .findDynamicTypeForAddress (addr , baseType );
103105 if (type != null ) {
104- return ( T ) VMObjectFactory .newObject (( Class ) map .get (type .getName ()), addr );
106+ return VMObjectFactory .newObject (map .get (type .getName ()), addr );
105107 } else if (unknownTypeHandler != null ) {
106- return ( T ) VMObjectFactory .newObject (unknownTypeHandler , addr );
108+ return VMObjectFactory .newObject (unknownTypeHandler , addr );
107109 }
108110
109111 throw newWrongTypeException (addr );
0 commit comments