I propose that we change newObject to use concrete type of the created object as the return type.
public class VMObjectFactory {
- public static Object newObject(Class clazz, Address addr)
+ public static <T> T newObject(Class<T> clazz, Address addr)
This way we wouldn't have to duplicate the type in lines like this:
return (ZPhysicalMemoryManager)VMObjectFactory.newObject(ZPhysicalMemoryManager.class, physicalAddr);
Instead this could be written as:
return VMObjectFactory.newObject(ZPhysicalMemoryManager.class, physicalAddr);
public class VMObjectFactory {
- public static Object newObject(Class clazz, Address addr)
+ public static <T> T newObject(Class<T> clazz, Address addr)
This way we wouldn't have to duplicate the type in lines like this:
return (ZPhysicalMemoryManager)VMObjectFactory.newObject(ZPhysicalMemoryManager.class, physicalAddr);
Instead this could be written as:
return VMObjectFactory.newObject(ZPhysicalMemoryManager.class, physicalAddr);