Search in sources :

Example 6 with Attribute

use of org.apache.bcel.classfile.Attribute in project jop by jop-devel.

the class ReplaceAtomicAnnotation method visitJavaClass.

public void visitJavaClass(JavaClass clazz) {
    super.visitJavaClass(clazz);
    Method[] methods = clazz.getMethods();
    for (int i = 0; i < methods.length; i++) {
        for (Attribute a : methods[i].getAttributes()) {
            if (a instanceof AnnotationAttribute) {
                if (((AnnotationAttribute) a).hasAtomicAnnotation()) {
                    ConstantPoolGen cpoolgen = new ConstantPoolGen(clazz.getConstantPool());
                    Method nm = transform(methods[i], clazz, cpoolgen);
                    OldMethodInfo mi = getCli().getMethodInfo(nm.getName() + nm.getSignature());
                    // set new method also in MethodInfo
                    mi.setMethod(nm);
                    methods[i] = nm;
                    clazz.setConstantPool(cpoolgen.getFinalConstantPool());
                    System.out.println("RTTM: transformed atomic method " + clazz.getClassName() + "." + nm.getName() + nm.getSignature());
                }
            }
        }
    }
}
Also used : ConstantPoolGen(org.apache.bcel.generic.ConstantPoolGen) Attribute(org.apache.bcel.classfile.Attribute) AnnotationAttribute(com.jopdesign.common.bcel.AnnotationAttribute) Method(org.apache.bcel.classfile.Method) AnnotationAttribute(com.jopdesign.common.bcel.AnnotationAttribute)

Aggregations

Attribute (org.apache.bcel.classfile.Attribute)6 AnnotationAttribute (com.jopdesign.common.bcel.AnnotationAttribute)2 ArrayList (java.util.ArrayList)2 Code (org.apache.bcel.classfile.Code)2 Constant (org.apache.bcel.classfile.Constant)2 ConstantPool (org.apache.bcel.classfile.ConstantPool)2 ConstantString (org.apache.bcel.classfile.ConstantString)2 ExceptionTable (org.apache.bcel.classfile.ExceptionTable)2 LocalVariable (org.apache.bcel.classfile.LocalVariable)2 LocalVariableTable (org.apache.bcel.classfile.LocalVariableTable)2 ConstantPoolGen (org.apache.bcel.generic.ConstantPoolGen)2 CallString (com.jopdesign.common.code.CallString)1 XMethod (edu.umd.cs.findbugs.ba.XMethod)1 Nullable (javax.annotation.Nullable)1 BootstrapMethod (org.apache.bcel.classfile.BootstrapMethod)1 BootstrapMethods (org.apache.bcel.classfile.BootstrapMethods)1 InnerClass (org.apache.bcel.classfile.InnerClass)1 InnerClasses (org.apache.bcel.classfile.InnerClasses)1 Method (org.apache.bcel.classfile.Method)1