public static Signature getSignature(Member member) { if (member instanceof Method) { return new Signature(member.getName(), Type.getMethodDescriptor((Method)member)); } else if (member instanceof Constructor) { Type[] types = TypeUtils.getTypes(((Constructor)member).getParameterTypes()); return new Signature(Constants.CONSTRUCTOR_NAME, Type.getMethodDescriptor(Type.VOID_TYPE, types)); } else { throw new IllegalArgumentException("Cannot get signature of a field"); } }
public AddInitTransformer(Method method) { info = ReflectUtils.getMethodInfo(method); Type[] types = info.getSignature().getArgumentTypes(); if (types.length != 1 || !types[0].equals(Constants.TYPE_OBJECT) || !info.getSignature().getReturnType().equals(Type.VOID_TYPE)) { throw new IllegalArgumentException(method + " illegal signature"); } }
public CodeEmitter begin_method(int access, Signature sig, Type[] exceptions) { final CodeEmitter emitter = super.begin_method(access, sig, exceptions); if (sig.getName().equals(Constants.CONSTRUCTOR_NAME)) { return new CodeEmitter(emitter) { public void visitInsn(int opcode) { if (opcode == Constants.RETURN) { load_this(); invoke(info); } super.visitInsn(opcode); } }; } return emitter; }
public static Object newInstance(Class type) { return newInstance(type, Constants.EMPTY_CLASS_ARRAY, null); }