Search in sources :

Example 1 with FieldVisitor

use of org.objectweb.asm.FieldVisitor in project MinecraftForge by MinecraftForge.

the class FMLRemappingAdapter method visitField.

@Override
public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) {
    FMLDeobfuscatingRemapper remapper = FMLDeobfuscatingRemapper.INSTANCE;
    FieldVisitor fv = cv.visitField(access, remapper.mapMemberFieldName(className, name, desc), remapper.mapDesc(desc), remapper.mapSignature(signature, true), remapper.mapValue(value));
    return createRemappingFieldAdapter(fv);
}
Also used : FieldVisitor(org.objectweb.asm.FieldVisitor)

Example 2 with FieldVisitor

use of org.objectweb.asm.FieldVisitor in project neo4j by neo4j.

the class ClassByteCodeWriter method field.

@Override
public void field(FieldReference field, Expression value) {
    //keep track of all static field->value, and initiate in <clinit> in done
    if (Modifier.isStatic(field.modifiers()) && value != null) {
        staticFields.put(field, value);
    }
    FieldVisitor fieldVisitor = classVisitor.visitField(field.modifiers(), field.name(), typeName(field.type()), signature(field.type()), null);
    fieldVisitor.visitEnd();
}
Also used : FieldVisitor(org.objectweb.asm.FieldVisitor)

Example 3 with FieldVisitor

use of org.objectweb.asm.FieldVisitor in project gradle by gradle.

the class ApiMemberSelector method visitEnd.

@Override
public void visitEnd() {
    super.visitEnd();
    apiMemberAdapter.visit(classMember.getVersion(), classMember.getAccess(), classMember.getName(), classMember.getSignature(), classMember.getSuperName(), classMember.getInterfaces());
    visitAnnotationMembers(classMember.getAnnotations());
    for (MethodMember method : methods) {
        MethodVisitor mv = apiMemberAdapter.visitMethod(method.getAccess(), method.getName(), method.getTypeDesc(), method.getSignature(), method.getExceptions().toArray(new String[0]));
        visitAnnotationMembers(mv, method.getAnnotations());
        visitAnnotationMembers(mv, method.getParameterAnnotations());
        mv.visitEnd();
    }
    for (FieldMember field : fields) {
        FieldVisitor fieldVisitor = apiMemberAdapter.visitField(field.getAccess(), field.getName(), field.getTypeDesc(), field.getSignature(), field.getValue());
        visitAnnotationMembers(fieldVisitor, field.getAnnotations());
        fieldVisitor.visitEnd();
    }
    for (InnerClassMember innerClass : innerClasses) {
        apiMemberAdapter.visitInnerClass(innerClass.getName(), innerClass.getOuterName(), innerClass.getInnerName(), innerClass.getAccess());
    }
    apiMemberAdapter.visitEnd();
}
Also used : FieldVisitor(org.objectweb.asm.FieldVisitor) MethodVisitor(org.objectweb.asm.MethodVisitor)

Example 4 with FieldVisitor

use of org.objectweb.asm.FieldVisitor in project felix by apache.

the class ClassManipulator method addIMField.

/**
 * Add the instance manager field (__im).
 */
private void addIMField() {
    FieldVisitor fv = super.visitField(0, IM_FIELD, "Lorg/apache/felix/ipojo/InstanceManager;", null, null);
    fv.visitEnd();
}
Also used : FieldVisitor(org.objectweb.asm.FieldVisitor)

Example 5 with FieldVisitor

use of org.objectweb.asm.FieldVisitor in project felix by apache.

the class ClassManipulator method visitField.

/**
 * Visit a Field.
 * This field access is replaced by an invocation to the getter method or to the setter method.
 * (except for static field).
 * Inject the getter and the setter method for this field.
 * @see org.objectweb.asm.ClassVisitor#visitField(int, java.lang.String, java.lang.String, java.lang.String, java.lang.Object)
 * @param access : access modifier
 * @param name : name of the field
 * @param desc : description of the field
 * @param signature : signature of the field
 * @param value : value of the field
 * @return FieldVisitor : null
 */
public FieldVisitor visitField(final int access, final String name, final String desc, final String signature, final Object value) {
    if ((access & ACC_STATIC) == 0) {
        FieldVisitor flag = cv.visitField(Opcodes.ACC_PRIVATE, FIELD_FLAG_PREFIX + name, "Z", null, null);
        flag.visitEnd();
        Type type = Type.getType(desc);
        if (type.getSort() == Type.ARRAY) {
            String gDesc = "()" + desc;
            createArrayGetter(name, gDesc);
            // Generates setter method
            String sDesc = "(" + desc + ")V";
            createArraySetter(name, sDesc);
        } else {
            // Generate the getter method
            String gDesc = "()" + desc;
            createSimpleGetter(name, gDesc, type);
            // Generates setter method
            String sDesc = "(" + desc + ")V";
            createSimpleSetter(name, sDesc, type);
        }
    }
    return cv.visitField(access, name, desc, signature, value);
}
Also used : Type(org.objectweb.asm.Type) FieldVisitor(org.objectweb.asm.FieldVisitor)

Aggregations

FieldVisitor (org.objectweb.asm.FieldVisitor)90 MethodVisitor (org.objectweb.asm.MethodVisitor)59 Label (org.objectweb.asm.Label)33 ClassWriter (org.objectweb.asm.ClassWriter)28 AnnotationVisitor (org.objectweb.asm.AnnotationVisitor)9 ClassReader (org.objectweb.asm.ClassReader)8 Type (org.objectweb.asm.Type)7 Method (java.lang.reflect.Method)6 ClassVisitor (org.objectweb.asm.ClassVisitor)6 IOException (java.io.IOException)4 GeneratorAdapter (org.objectweb.asm.commons.GeneratorAdapter)4 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 LitString (lucee.transformer.expression.literal.LitString)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 File (java.io.File)2 FileOutputStream (java.io.FileOutputStream)2 PrintWriter (java.io.PrintWriter)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 URL (java.net.URL)2