Package javassist

Examples of javassist.CtConstructor


                        // filter caller methods
                        if (methodFilterCaller(where)) {
                            return;
                        }
                        CtConstructor ctConstructor = newExpr.getConstructor();
                        String calleeClassName = newExpr.getClassName();

                        // filter callee classes
                        if (!definition.inIncludePackage(calleeClassName)) {
                            return;
                        }

                        // filter the constructors
                        if (constructorFilter(ctConstructor)) {
                            return;
                        }

                        // create the caller method info
                        MemberInfo withinMethodInfo = null;
                        if (where instanceof CtMethod) {
                            withinMethodInfo = JavassistMethodInfo.getMethodInfo((CtMethod) where, context.getLoader());
                        } else if (where instanceof CtConstructor) {
                            withinMethodInfo = JavassistConstructorInfo.getConstructorInfo(
                                (CtConstructor) where,
                                context.getLoader());
                        }

                        // create the constructor info
                        CtConstructor constructor = newExpr.getConstructor();
                        ConstructorInfo calleeSideConstructorInfo = JavassistConstructorInfo.getConstructorInfo(
                            constructor,
                            context.getLoader());
                        ExpressionContext ctx = new ExpressionContext(
                            PointcutType.CALL,
View Full Code Here


            // constructors.
            CtConstructor[] constructors = clazz.getDeclaredConstructors();
            Arrays.sort(constructors, new Comparator() {
                public int compare(Object o1, Object o2) {
                    CtConstructor c1 = (CtConstructor) o1;
                    CtConstructor c2 = (CtConstructor) o2;
                    return c1.getMethodInfo2().getDescriptor().compareTo(c2.getMethodInfo2().getDescriptor());
                }
            });
            for (int i = 0; i < constructors.length; i++) {
                CtConstructor constructor = constructors[i];
                int mods = constructor.getModifiers();
                if ((mods & Modifier.PRIVATE) == 0) {
                    out.writeUTF("<init>");
                    out.writeInt(mods & filterConstructorModifiers());
                    out.writeUTF(constructor.getMethodInfo2().getDescriptor().replace('/', '.'));
                }
            }

            // methods.
            CtMethod[] methods = clazz.getDeclaredMethods();
View Full Code Here

            CtConstructor[] constructors = m_class.getDeclaredConstructors();

            for (int i = 0; i < constructors.length; i++) {

                CtConstructor constructor = constructors[i];

                m_constructors.put(JavassistConstructorInfo.calculateHash(constructor), new JavassistConstructorInfo(

                    constructor,

                    this,

                    loader,

                    m_attributeExtractor));

            }

            if (m_class.getClassInitializer() != null) {

                CtConstructor constructor = m_class.getClassInitializer();

                m_constructors.put(JavassistConstructorInfo.calculateHash(constructor), new JavassistConstructorInfo(

                    constructor,
View Full Code Here

                    loader,
                    m_attributeExtractor));
            }
            CtConstructor[] constructors = m_class.getDeclaredConstructors();
            for (int i = 0; i < constructors.length; i++) {
                CtConstructor constructor = constructors[i];
                m_constructors.put(JavassistConstructorInfo.calculateHash(constructor), new JavassistConstructorInfo(
                    constructor,
                    this,
                    loader,
                    m_attributeExtractor));
            }
            if (m_class.getClassInitializer() != null) {
                CtConstructor constructor = m_class.getClassInitializer();
                m_constructors.put(JavassistConstructorInfo.calculateHash(constructor), new JavassistConstructorInfo(
                    constructor,
                    this,
                    loader,
                    m_attributeExtractor));
View Full Code Here

            return EMPTY_OBJECT_ARRAY;
        }
        List attributes = new ArrayList();
        CtConstructor[] constructors = m_ctClass.getDeclaredConstructors();
        for (int i = 0; i < constructors.length; i++) {
            CtConstructor constructor = constructors[i];
            if (Arrays.equals(constructorParamTypes, DescriptorUtil.getParameters(constructors[i].getSignature()))) {
                for (Iterator it = constructor.getMethodInfo().getAttributes().iterator(); it.hasNext();) {
                    retrieveCustomAttributes((AttributeInfo) it.next(), attributes);
                }
            }
        }
        return attributes.toArray(new Object[attributes.size()]);
View Full Code Here

        int syntheticModifier = Constants.ACC_SYNTHETIC | Modifier.PUBLIC;
        javassistClass.addMethod(CtNewMethod.make(syntheticModifier, CtClass.intType, "syntheticDo", new CtClass[]{}, new CtClass[]{}, "{return 0;}", javassistClass));
        CtField field = new CtField(CtClass.intType, "syntheticField", javassistClass);
        field.setModifiers(syntheticModifier);
        javassistClass.addField(field);
        CtConstructor ctor = new CtConstructor(new CtClass[]{CtClass.intType}, javassistClass);
        ctor.setModifiers(syntheticModifier);
        ctor.setBody("{super();}");
        javassistClass.addConstructor(ctor);

        long javassistSerialVerUid = JavassistHelper.calculateSerialVerUid(javassistClass);

        Class javaClassGenerated = javassistClass.toClass();
View Full Code Here

        CtBehavior[] cb = thisClass.getDeclaredBehaviors();
        for (int i = cb.length - 1; i >= 0; --i)
            if (cb[i].getMethodInfo2() == mi)
                return cb[i];

        CtConstructor init = thisClass.getClassInitializer();
        if (init != null && init.getMethodInfo2() == mi)
            return init;

        /* getDeclaredBehaviors() returns a list of methods/constructors.
         * Although the list is cached in a CtClass object, it might be
         * recreated for some reason.  Thus, the member name and the signature
View Full Code Here

        CtClass[] ctParameters = toCtClasses(parameterTypes);
        CtClass[] ctExceptions = toCtClasses(exceptions);

        try
        {
            CtConstructor constructor = new CtConstructor(ctParameters, getCtClass());
            constructor.setExceptionTypes(ctExceptions);
            constructor.setBody(body);

            getCtClass().addConstructor(constructor);
        }
        catch (Exception ex)
        {
View Full Code Here

        int lineNumber = 0;

        try
        {
            CtConstructor ctConstructor = ctClass.getConstructor(descripton.toString());

            lineNumber = ctConstructor.getMethodInfo().getLineNumber(0);

            String sourceFile = ctConstructor.getDeclaringClass().getClassFile2().getSourceFile();

            builder.append(String.format(" (at %s:%d)", sourceFile, lineNumber));
        }
        catch (Exception ex)
        {
View Full Code Here

        CtClass[] ctParameters = convertClasses(parameterTypes);
        CtClass[] ctExceptions = convertClasses(exceptions);

        try
        {
            CtConstructor constructor = new CtConstructor(ctParameters, _ctClass);
            constructor.setExceptionTypes(ctExceptions);
            constructor.setBody(body);

            _ctClass.addConstructor(constructor);
        }
        catch (Exception ex)
        {
View Full Code Here

TOP

Related Classes of javassist.CtConstructor

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.