}
if (!hasStaticInitialisation)
{
// Add a static initialisation block for the class since nothing added yet
InitClass method = InitClass.getInstance(enhancer);
method.initialise(cv);
method.execute();
method.close();
}
if (!hasDefaultConstructor)
{
// Add a default constructor
DefaultConstructor ctr = DefaultConstructor.getInstance(enhancer);
ctr.initialise(cv);
ctr.execute();
ctr.close();
}
// Add any new methods
List methods = enhancer.getMethodsList();
Iterator methodsIter = methods.iterator();
while (methodsIter.hasNext())
{
ASMClassMethod method = (ASMClassMethod)methodsIter.next();
method.initialise(cv);
method.execute();
method.close();
}
if (Serializable.class.isAssignableFrom(enhancer.cls))
{
// Class is Serializable
if (!hasSerialVersionUID)
{
// Needs "serialVersionUID" field
Long uid = null;
try
{
uid = new Long(ObjectStreamClass.lookup(enhancer.getClassEnhanced()).getSerialVersionUID());
}
catch (Throwable e)
{
JPOXLogger.ENHANCER.warn(StringUtils.getStringFromStackTrace(e));
}
ClassField cf = new ClassField(enhancer, ClassEnhancer.FN_serialVersionUID,
Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC | Opcodes.ACC_FINAL, long.class, uid);
if (JPOXLogger.ENHANCER.isDebugEnabled())
{
JPOXLogger.ENHANCER.debug(LOCALISER.msg("Enhancer.AddField",
((Class)cf.getType()).getName() + " " + cf.getName()));
}
cv.visitField(cf.getAccess(), cf.getName(), Type.getDescriptor((Class)cf.getType()), null, cf.getInitialValue());
}
if (!hasWriteObject)
{
ASMClassMethod method = WriteObject.getInstance(enhancer);
method.initialise(cv);
method.execute();
method.close();
}
}
// Add jdoGetXXX, jdoSetXXX for each of the (managed) fields/properties
AbstractMemberMetaData[] fmds = enhancer.getClassMetaData().getManagedMembers();