Package javassist

Examples of javassist.CtField$IntInitializer


        // fields
        List fieldList = new ArrayList();
        CtField[] fields = javaClass.getDeclaredFields();
        for (int i = 0; i < fields.length; i++) {
            CtField field = fields[i];
            fieldList.add(createFieldMetaData(field));
        }
        classMetaData.setFields(fieldList);

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

            + TransformationUtil.DELIMITER
            + ctConstructor.getDeclaringClass().getName().replace('.', '_');
        boolean hasField = false;
        CtField[] fields = ctClass.getDeclaredFields();
        for (int i = 0; i < fields.length; i++) {
            CtField field = fields[i];
            if (field.getName().equals(fieldName)) {
                hasField = true;
                break;
            }
        }
        if (!hasField) {
            CtField field = new CtField(ctClass.getClassPool().get("java.lang.Class"), fieldName, ctClass);
            field.setModifiers(Modifier.STATIC | Modifier.PRIVATE | Modifier.FINAL);
            ctClass.addField(field, "java.lang.Class#forName(\""
                + ctConstructor.getDeclaringClass().getName().replace('/', '.')
                + "\")");
        }
        return fieldName;
View Full Code Here

            // fields.
            CtField[] fields = clazz.getDeclaredFields();
            Arrays.sort(fields, new Comparator() {
                public int compare(Object o1, Object o2) {
                    CtField field1 = (CtField) o1;
                    CtField field2 = (CtField) o2;
                    return field1.getName().compareTo(field2.getName());
                }
            });
            for (int i = 0; i < fields.length; i++) {
                CtField field = (CtField) fields[i];
                int mods = field.getModifiers();
                if (((mods & Modifier.PRIVATE) == 0) || ((mods & (Modifier.STATIC | Modifier.TRANSIENT)) == 0)) {
                    out.writeUTF(field.getName());
                    out.writeInt(mods & filterFieldModifiers());
                    out.writeUTF(field.getFieldInfo2().getDescriptor());
                }
            }

            // static initializer.
            if (classFile.getStaticInitializer() != null) {
View Full Code Here

        return Descriptor.toJavaName(Descriptor.toJvmName(name));
    }

    public static void setSerialVersionUID(CtClass clazz, long serialVerUid) throws CannotCompileException {
        // add field with default value.
        CtField field = new CtField(CtClass.longType, "serialVersionUID", clazz);
        field.setModifiers(Modifier.PRIVATE | Modifier.STATIC | Modifier.FINAL);
        clazz.addField(field, serialVerUid + "L");
    }
View Full Code Here

    public static void addAspectManagerField(
        final CtClass ctClass,
        final SystemDefinition definition,
        final Context context) throws NotFoundException, CannotCompileException {
        if (!hasField(ctClass, TransformationUtil.ASPECT_MANAGER_FIELD)) {
            CtField field = new CtField(
                ctClass.getClassPool().get(TransformationUtil.ASPECT_MANAGER_CLASS),
                TransformationUtil.ASPECT_MANAGER_FIELD,
                ctClass);
            field.setModifiers(Modifier.STATIC | Modifier.PRIVATE | Modifier.FINAL);
            StringBuffer body = new StringBuffer();
            body.append(TransformationUtil.SYSTEM_LOADER_CLASS);
            body.append("#getSystem(");
            body.append(TransformationUtil.STATIC_CLASS_FIELD);
            body.append('.');
View Full Code Here

     * @param ctClass the class
     */
    public static void addStaticClassField(final CtClass ctClass, final Context context) throws NotFoundException,
            CannotCompileException {
        if (!hasField(ctClass, TransformationUtil.STATIC_CLASS_FIELD)) {
            CtField field = new CtField(
                ctClass.getClassPool().get("java.lang.Class"),
                TransformationUtil.STATIC_CLASS_FIELD,
                ctClass);
            field.setModifiers(Modifier.STATIC | Modifier.PRIVATE | Modifier.FINAL);
            ctClass.addField(field, "java.lang.Class#forName(\"" + ctClass.getName().replace('/', '.') + "\")");
            context.markAsAdvised();
        }
    }
View Full Code Here

    public static void addJoinPointManagerField(
        final CtClass ctClass,
        final SystemDefinition definition,
        final Context context) throws NotFoundException, CannotCompileException {
        if (!hasField(ctClass, TransformationUtil.JOIN_POINT_MANAGER_FIELD)) {
            CtField field = new CtField(
                ctClass.getClassPool().get(TransformationUtil.JOIN_POINT_MANAGER_CLASS),
                TransformationUtil.JOIN_POINT_MANAGER_FIELD,
                ctClass);
            field.setModifiers(Modifier.STATIC | Modifier.PRIVATE);
            StringBuffer body = new StringBuffer();
            body.append(TransformationUtil.JOIN_POINT_MANAGER_CLASS);
            body.append('#');
            body.append(TransformationUtil.GET_JOIN_POINT_MANAGER);
            body.append('(');
View Full Code Here

            + TransformationUtil.DELIMITER
            + ctMethod.getDeclaringClass().getName().replace('.', '_');
        boolean hasField = false;
        CtField[] fields = ctClass.getDeclaredFields();
        for (int i = 0; i < fields.length; i++) {
            CtField field = fields[i];
            if (field.getName().equals(fieldName)) {
                hasField = true;
                break;
            }
        }
        if (!hasField) {
            CtField field = new CtField(ctClass.getClassPool().get("java.lang.Class"), fieldName, ctClass);
            field.setModifiers(Modifier.STATIC | Modifier.PRIVATE | Modifier.FINAL);
            ctClass.addField(field, "java.lang.Class#forName(\""
                + ctMethod.getDeclaringClass().getName().replace('/', '.')
                + "\")");
        }
        return fieldName;
View Full Code Here

    }

    protected void atFieldAssign(Expr expr, int op, ASTree left, ASTree right)
        throws CompileError
    {
        CtField f = fieldAccess(left);
        atFieldRead(f);
        int fType = exprType;
        int fDim = arrayDim;
        String cname = className;
        right.accept(this);
View Full Code Here

TOP

Related Classes of javassist.CtField$IntInitializer

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.