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

com.artemis.weaver.transplant.ClassMethodTransplantAdapter Maven / Gradle / Ivy

There is a newer version: 2.3.0
Show newest version
package com.artemis.weaver.transplant;

import com.artemis.Weaver;
import com.artemis.meta.ClassMetadata;
import com.artemis.meta.MethodDescriptor;
import org.objectweb.asm.*;

public class ClassMethodTransplantAdapter extends ClassVisitor implements Opcodes {
	protected final ClassReader source;
	private final ClassMethodTransplantVisitor transplanter;

	public ClassMethodTransplantAdapter(ClassReader source, ClassVisitor target, ClassMetadata meta) {
		super(ASM5, target);
		this.source = source;
		transplanter = new ClassMethodTransplantVisitor(source, this, meta);
	}

	public ClassMethodTransplantAdapter(Class source, ClassVisitor target, ClassMetadata meta) {
		this(Weaver.toClassReader(source), target, meta);
	}

	public ClassMethodTransplantAdapter addMethod(String method, String methodDesc) {
		transplanter.addMethod(new MethodDescriptor(method, methodDesc));
		return this;
	}

	@Override
	public void visitEnd() {
		source.accept(transplanter, 0);
		super.visitEnd();
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy