All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.powermock.modules.agent.DefinalizingClassVisitor Maven / Gradle / Ivy

There is a newer version: 2.0.9
Show newest version
package org.powermock.modules.agent;

import net.bytebuddy.jar.asm.ClassVisitor;
import net.bytebuddy.jar.asm.MethodVisitor;
import net.bytebuddy.jar.asm.Opcodes;

class DefinalizingClassVisitor extends ClassVisitor {

    public DefinalizingClassVisitor(ClassVisitor classVisitor) {
        super(Opcodes.ASM5, classVisitor);
    }

    @Override
    public void visit(final int version, final int access, final String name, final String signature, final String superName,
            final String[] interfaces) {
        final int accessModifiersWithFinalRemoved = removeFinal(access);
        super.visit(version, accessModifiersWithFinalRemoved, name, signature, superName, interfaces);
    }

    @Override
    public MethodVisitor visitMethod(int access, final String name, final String desc, final String signature,
                                     final String[] exceptions) {
        return super.visitMethod(removeFinal(access), name, desc, signature, exceptions);
    }

    @Override
    public void visitInnerClass(String name, String outerName, String innerName, int access) {
        super.visitInnerClass(name, outerName, innerName, removeFinal(access));
    }

    private int removeFinal(int access) {
        return access & ~Opcodes.ACC_FINAL;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy