use of org.objectweb.asm.Type in project cglib by cglib.
the class Enhancer method emitCommonNewInstance.
private void emitCommonNewInstance(CodeEmitter e) {
Type thisType = getThisType(e);
e.new_instance(thisType);
e.dup();
e.invoke_constructor(thisType);
e.aconst_null();
e.invoke_static(thisType, SET_THREAD_CALLBACKS);
e.return_value();
e.end_method();
}
use of org.objectweb.asm.Type in project cglib by cglib.
the class Enhancer method emitNewInstanceMultiarg.
private void emitNewInstanceMultiarg(ClassEmitter ce, List constructors) {
final CodeEmitter e = ce.begin_method(Constants.ACC_PUBLIC, MULTIARG_NEW_INSTANCE, null);
final Type thisType = getThisType(e);
e.load_arg(2);
e.invoke_static(thisType, SET_THREAD_CALLBACKS);
e.new_instance(thisType);
e.dup();
e.load_arg(0);
EmitUtils.constructor_switch(e, constructors, new ObjectSwitchCallback() {
public void processCase(Object key, Label end) {
MethodInfo constructor = (MethodInfo) key;
Type[] types = constructor.getSignature().getArgumentTypes();
for (int i = 0; i < types.length; i++) {
e.load_arg(1);
e.push(i);
e.aaload();
e.unbox(types[i]);
}
e.invoke_constructor(thisType, constructor.getSignature());
e.goTo(end);
}
public void processDefault() {
e.throw_exception(ILLEGAL_ARGUMENT_EXCEPTION, "Constructor not found");
}
});
e.aconst_null();
e.invoke_static(thisType, SET_THREAD_CALLBACKS);
e.return_value();
e.end_method();
}
use of org.objectweb.asm.Type in project cglib by cglib.
the class Enhancer method emitNewInstanceCallbacks.
private void emitNewInstanceCallbacks(ClassEmitter ce) {
CodeEmitter e = ce.begin_method(Constants.ACC_PUBLIC, NEW_INSTANCE, null);
Type thisType = getThisType(e);
e.load_arg(0);
e.invoke_static(thisType, SET_THREAD_CALLBACKS);
emitCommonNewInstance(e);
}
use of org.objectweb.asm.Type in project cglib by cglib.
the class FieldProviderTransformer method initFieldProvider.
private void initFieldProvider(String[] names) {
CodeEmitter e = getStaticHook();
EmitUtils.push_object(e, names);
e.putstatic(getClassType(), FIELD_NAMES, Constants.TYPE_STRING_ARRAY);
e.push(names.length);
e.newarray(Constants.TYPE_CLASS);
e.dup();
for (int i = 0; i < names.length; i++) {
e.dup();
e.push(i);
Type type = (Type) fields.get(names[i]);
EmitUtils.load_class(e, type);
e.aastore();
}
e.putstatic(getClassType(), FIELD_TYPES, Constants.TYPE_CLASS_ARRAY);
}
use of org.objectweb.asm.Type in project cglib by cglib.
the class InterceptFieldTransformer method begin_method.
public CodeEmitter begin_method(int access, Signature sig, Type[] exceptions) {
return new CodeEmitter(super.begin_method(access, sig, exceptions)) {
public void visitFieldInsn(int opcode, String owner, String name, String desc) {
Type towner = TypeUtils.fromInternalName(owner);
switch(opcode) {
case Constants.GETFIELD:
if (filter.acceptRead(towner, name)) {
helper(towner, readMethodSig(name, desc));
return;
}
break;
case Constants.PUTFIELD:
if (filter.acceptWrite(towner, name)) {
helper(towner, writeMethodSig(name, desc));
return;
}
break;
}
super.visitFieldInsn(opcode, owner, name, desc);
}
private void helper(Type owner, Signature sig) {
invoke_virtual(owner, sig);
}
};
}
Aggregations