}
}
private static ObjectId newObjectId(SoftReference obj)
{
ObjectId id = null;
Object object = obj.get();
if (object.getClass().isArray())
id = new ArrayId();
else
{
for (Class myClass = object.getClass(); myClass != null;
myClass = myClass.getSuperclass())
{
Class clz = (Class) idList.get(myClass);
if (clz != null)
{
try
{
id = (ObjectId) clz.newInstance();
synchronized (idLock)
{
id.setId(++lastId);
}
id.setReference(obj);
return id;
}
catch (InstantiationException e)
{
throw new RuntimeException("cannot create new ID", e);
}
catch (IllegalAccessException e)
{
throw new RuntimeException("illegal access of ID", e);
}
}
}
id = new ObjectId();
}
synchronized (idLock)
{
id.setId(++lastId);
}
id.setReference(obj);
return id;
}