Package org.jpox.enhancer.asm.method

Source Code of org.jpox.enhancer.asm.method.JdoGetInheritedFieldCount

/**********************************************************************
Copyright (c) 2007 Andy Jefferson and others. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Contributors:
    ...
**********************************************************************/
package org.jpox.enhancer.asm.method;

import org.jpox.enhancer.ClassEnhancer;
import org.jpox.enhancer.asm.ASMClassMethod;
import org.jpox.metadata.ClassMetaData;
import org.objectweb.asm.Opcodes;

/**
* Method to generate the method "__jdoGetInheritedFieldCount" using ASM.
* @version $Revision: 1.2 $
*/
public class JdoGetInheritedFieldCount extends ASMClassMethod
{
    public static JdoGetInheritedFieldCount getInstance(ClassEnhancer enhancer)
    {
        return new JdoGetInheritedFieldCount(enhancer, ClassEnhancer.MN_JdoGetInheritedFieldCount,
            Opcodes.ACC_PROTECTED | Opcodes.ACC_STATIC,
            int.class, null, null);
    }

    /**
     * Constructor.
     * @param enhancer ClassEnhancer
     * @param name Name of method
     * @param access Access type
     * @param returnType Return type
     * @param argTypes Argument types
     * @param argNames Argument names
     */
    public JdoGetInheritedFieldCount(ClassEnhancer enhancer, String name, int access,
        Object returnType, Object[] argTypes, String[] argNames)
    {
        super(enhancer, name, access, returnType, argTypes, argNames);
    }

    /**
     * Method to add the contents of the class method.
     */
    public void execute()
    {
        ClassMetaData cmd = enhancer.getClassMetaData();
        String persistenceCapableSuperclass = cmd.getPersistenceCapableSuperclass();

        visitor.visitCode();

        if (persistenceCapableSuperclass != null && persistenceCapableSuperclass.length() > 0)
        {
            visitor.visitMethodInsn(Opcodes.INVOKESTATIC, persistenceCapableSuperclass.replace('.', '/'),
                ClassEnhancer.MN_JdoGetManagedFieldCount, "()I");
            visitor.visitInsn(Opcodes.IRETURN);
            visitor.visitMaxs(1, 0);
        }
        else
        {
            visitor.visitInsn(Opcodes.ICONST_0);
            visitor.visitInsn(Opcodes.IRETURN);
            visitor.visitMaxs(1, 0);
        }

        visitor.visitEnd();
    }
}
TOP

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

TOP
Copyright © 2018 www.massapi.com. 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.