MockObjectReference (Object o, Class<?> type, final MockVirtualMachine virtualMachine) { if (o instanceof String || type != null && String.class.isAssignableFrom(type)) { return new MockStringReference(virtualMachine, (String)o); } if (o instanceof Thread || type != null && Thread.class.isAssignableFrom(type)) { return new MockThreadReference(virtualMachine, (Thread)o); } if (o instanceof ClassLoader || type != null && ClassLoader.class.isAssignableFrom(type)) { return new MockClassLoaderReference(virtualMachine, (ClassLoader)o); } if (o instanceof Object[] || type != null && type.isArray()) { return new MockArrayReference(virtualMachine, o, type == null ? o.getClass() : type); } return new MockObjectReference(virtualMachine, o); }