Package org.jpox.enhancer.asm.method

Examples of org.jpox.enhancer.asm.method.InitClass


            }

            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();
View Full Code Here


    {
        if (enhancer.getClassMetaData().getPersistenceModifier() == ClassPersistenceModifier.PERSISTENCE_CAPABLE &&
            methodName.equals("<clinit>") && methodDescriptor.equals("()V") && opcode == Opcodes.RETURN)
        {
            // Add the initialise instructions to the existing block
            InitClass initMethod = InitClass.getInstance(enhancer);
            initMethod.addInitialiseInstructions(mv);

            // Add the RETURN
            mv.visitInsn(Opcodes.RETURN);
            return;
        }
View Full Code Here

TOP

Related Classes of org.jpox.enhancer.asm.method.InitClass

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.