Package net.sf.cglib.core

Examples of net.sf.cglib.core.MethodInfo


/* 104 */     e.load_arg(1);
/* 105 */     e.checkcast(Constants.TYPE_STRING);
/* 106 */     EmitUtils.string_switch(e, getNames(getters), 1, new ObjectSwitchCallback(getters, e) {
/*     */       public void processCase(Object key, Label end) {
/* 108 */         PropertyDescriptor pd = (PropertyDescriptor)this.val$getters.get(key);
/* 109 */         MethodInfo method = ReflectUtils.getMethodInfo(pd.getReadMethod());
/* 110 */         this.val$e.invoke(method);
/* 111 */         this.val$e.box(method.getSignature().getReturnType());
/* 112 */         this.val$e.return_value();
/*     */       }
/*     */       public void processDefault() {
/* 115 */         this.val$e.aconst_null();
/* 116 */         this.val$e.return_value();
View Full Code Here


/*     */       public void processCase(Object key, Label end) {
/* 130 */         PropertyDescriptor pd = (PropertyDescriptor)this.val$setters.get(key);
/* 131 */         if (pd.getReadMethod() == null) {
/* 132 */           this.val$e.aconst_null();
/*     */         } else {
/* 134 */           MethodInfo read = ReflectUtils.getMethodInfo(pd.getReadMethod());
/* 135 */           this.val$e.dup();
/* 136 */           this.val$e.invoke(read);
/* 137 */           this.val$e.box(read.getSignature().getReturnType());
/*     */         }
/* 139 */         this.val$e.swap();
/* 140 */         this.val$e.load_arg(2);
/* 141 */         MethodInfo write = ReflectUtils.getMethodInfo(pd.getWriteMethod());
/* 142 */         this.val$e.unbox(write.getSignature().getArgumentTypes()[0]);
/* 143 */         this.val$e.invoke(write);
/* 144 */         this.val$e.return_value();
/*     */       }
/*     */
/*     */       public void processDefault()
View Full Code Here

/*  91 */       PropertyDescriptor[] descriptors = ReflectUtils.getBeanProperties(this.target);
/*  92 */       Method[] getters = ReflectUtils.getPropertyMethods(descriptors, true, false);
/*  93 */       Method[] setters = ReflectUtils.getPropertyMethods(descriptors, false, true);
/*     */
/*  95 */       for (int i = 0; i < getters.length; i++) {
/*  96 */         MethodInfo getter = ReflectUtils.getMethodInfo(getters[i]);
/*  97 */         e = EmitUtils.begin_method(ce, getter, 1);
/*  98 */         e.load_this();
/*  99 */         e.getfield("CGLIB$RWBean");
/* 100 */         e.invoke(getter);
/* 101 */         e.return_value();
/* 102 */         e.end_method();
/*     */       }
/*     */
/* 105 */       for (int i = 0; i < setters.length; i++) {
/* 106 */         MethodInfo setter = ReflectUtils.getMethodInfo(setters[i]);
/* 107 */         e = EmitUtils.begin_method(ce, setter, 1);
/* 108 */         e.throw_exception(ImmutableBean.ILLEGAL_STATE_EXCEPTION, "Bean is immutable");
/* 109 */         e.end_method();
/*     */       }
/*     */
View Full Code Here

/* 202 */       Method method = this.targetClass.getMethod(this.methodName, proxy.getParameterTypes());
/* 203 */       if (!proxy.getReturnType().isAssignableFrom(method.getReturnType())) {
/* 204 */         throw new IllegalArgumentException("incompatible return types");
/*     */       }
/*     */
/* 207 */       MethodInfo methodInfo = ReflectUtils.getMethodInfo(method);
/*     */
/* 209 */       boolean isStatic = TypeUtils.isStatic(methodInfo.getModifiers());
/* 210 */       if ((this.target == null ^ isStatic)) {
/* 211 */         throw new IllegalArgumentException("Static method " + (isStatic ? "not " : "") + "expected");
/*     */       }
/*     */
/* 214 */       ClassEmitter ce = new ClassEmitter(v);
/*     */
/* 216 */       ce.begin_class(46, 1, getClassName(), METHOD_DELEGATE, new Type[] { Type.getType(this.iface) }, "<generated>");
/*     */
/* 222 */       ce.declare_field(26, "eqMethod", Constants.TYPE_STRING, null, null);
/* 223 */       EmitUtils.null_constructor(ce);
/*     */
/* 226 */       MethodInfo proxied = ReflectUtils.getMethodInfo(this.iface.getDeclaredMethods()[0]);
/* 227 */       CodeEmitter e = EmitUtils.begin_method(ce, proxied, 1);
/* 228 */       e.load_this();
/* 229 */       e.super_getfield("target", Constants.TYPE_OBJECT);
/* 230 */       e.checkcast(methodInfo.getClassInfo().getType());
/* 231 */       e.load_args();
View Full Code Here

/* 60 */     Set unique = new HashSet();
/* 61 */     for (int i = 0; i < classes.length; i++) {
/* 62 */       Method[] methods = getMethods(classes[i]);
/* 63 */       for (int j = 0; j < methods.length; j++) {
/* 64 */         if (unique.add(MethodWrapper.create(methods[j]))) {
/* 65 */           MethodInfo method = ReflectUtils.getMethodInfo(methods[j]);
/* 66 */           e = EmitUtils.begin_method(this, method, 1);
/* 67 */           e.load_this();
/* 68 */           e.getfield("CGLIB$DELEGATES");
/* 69 */           e.aaload(route != null ? route[i] : i);
/* 70 */           e.checkcast(method.getClassInfo().getType());
/* 71 */           e.load_args();
/* 72 */           e.invoke(method);
/* 73 */           e.return_value();
/* 74 */           e.end_method();
/*    */         }
View Full Code Here

/* 40 */     this.proxyRef = proxyRef;
/*    */   }
/*    */
/*    */   public void generate(ClassEmitter ce, CallbackGenerator.Context context, List methods) {
/* 44 */     for (Iterator it = methods.iterator(); it.hasNext(); ) {
/* 45 */       MethodInfo method = (MethodInfo)it.next();
/* 46 */       if (!TypeUtils.isProtected(method.getModifiers())) {
/* 47 */         CodeEmitter e = context.beginMethod(ce, method);
/* 48 */         context.emitCallback(e, context.getIndex(method));
/* 49 */         if (this.proxyRef) {
/* 50 */           e.load_this();
/* 51 */           e.invoke_interface(PROXY_REF_DISPATCHER, PROXY_REF_LOAD_OBJECT);
/*    */         } else {
/* 53 */           e.invoke_interface(DISPATCHER, LOAD_OBJECT);
/*    */         }
/* 55 */         e.checkcast(method.getClassInfo().getType());
/* 56 */         e.load_args();
/* 57 */         e.invoke(method);
/* 58 */         e.return_value();
/* 59 */         e.end_method();
/*    */       }
View Full Code Here

/*  92 */       setNamePrefix(MulticastDelegate.class.getName());
/*  93 */       return (MulticastDelegate)super.create(this.iface.getName());
/*     */     }
/*     */
/*     */     public void generateClass(ClassVisitor cv) {
/*  97 */       MethodInfo method = ReflectUtils.getMethodInfo(ReflectUtils.findInterfaceMethod(this.iface));
/*     */
/*  99 */       ClassEmitter ce = new ClassEmitter(cv);
/* 100 */       ce.begin_class(46, 1, getClassName(), MULTICAST_DELEGATE, new Type[] { Type.getType(this.iface) }, "<generated>");
/*     */
/* 106 */       EmitUtils.null_constructor(ce);
View Full Code Here

/*     */   }
/*     */
/*     */   public void generate(ClassEmitter ce, CallbackGenerator.Context context, List methods) {
/*  73 */     Map sigMap = new HashMap();
/*  74 */     for (Iterator it = methods.iterator(); it.hasNext(); ) {
/*  75 */       MethodInfo method = (MethodInfo)it.next();
/*  76 */       Signature impl = context.getImplSignature(method);
/*     */
/*  78 */       String methodField = getMethodField(impl);
/*  79 */       String methodProxyField = getMethodProxyField(impl);
/*     */
/*  81 */       sigMap.put(method.getSignature().toString(), methodProxyField);
/*  82 */       ce.declare_field(26, methodField, METHOD, null, null);
/*  83 */       ce.declare_field(26, methodProxyField, METHOD_PROXY, null, null);
/*  84 */       ce.declare_field(26, "CGLIB$emptyArgs", Constants.TYPE_OBJECT_ARRAY, null, null);
/*     */
/*  88 */       CodeEmitter e = ce.begin_method(16, impl, method.getExceptionTypes(), null);
/*     */
/*  92 */       if (TypeUtils.isAbstract(method.getModifiers())) {
/*  93 */         e.throw_exception(ABSTRACT_METHOD_ERROR, method.toString() + " is abstract");
/*     */       } else {
/*  95 */         e.load_this();
/*  96 */         e.load_args();
/*  97 */         e.super_invoke(method.getSignature());
/*     */       }
/*  99 */       e.return_value();
/* 100 */       e.end_method();
/*     */
/* 103 */       e = context.beginMethod(ce, method);
/* 104 */       Label nullInterceptor = e.make_label();
/* 105 */       context.emitCallback(e, context.getIndex(method));
/* 106 */       e.dup();
/* 107 */       e.ifnull(nullInterceptor);
/*     */
/* 109 */       e.load_this();
/* 110 */       e.getfield(methodField);
/*     */
/* 112 */       if (method.getSignature().getArgumentTypes().length == 0)
/* 113 */         e.getfield("CGLIB$emptyArgs");
/*     */       else {
/* 115 */         e.create_arg_array();
/*     */       }
/*     */
/* 118 */       e.getfield(methodProxyField);
/* 119 */       e.invoke_interface(METHOD_INTERCEPTOR, INTERCEPT);
/* 120 */       e.unbox_or_zero(method.getSignature().getReturnType());
/* 121 */       e.return_value();
/*     */
/* 123 */       e.mark(nullInterceptor);
/* 124 */       e.load_this();
/* 125 */       e.load_args();
/* 126 */       e.super_invoke(method.getSignature());
/* 127 */       e.return_value();
/* 128 */       e.end_method();
/*     */     }
/* 130 */     generateFindProxy(ce, sigMap);
/*     */   }
View Full Code Here

/* 151 */     e.newarray();
/* 152 */     e.putfield("CGLIB$emptyArgs");
/*     */
/* 154 */     for (Iterator it = methods.iterator(); it.hasNext(); ) {
/* 155 */       e.dup();
/* 156 */       MethodInfo method = (MethodInfo)it.next();
/* 157 */       Signature impl = context.getImplSignature(method);
/* 158 */       EmitUtils.load_method(e, method);
/* 159 */       e.dup();
/* 160 */       e.putfield(getMethodField(impl));
/*     */
/* 162 */       Signature sig = method.getSignature();
/* 163 */       e.invoke_virtual(METHOD, GET_DECLARING_CLASS);
/* 164 */       e.load_local(thisclass);
/* 165 */       e.push(sig.getDescriptor());
/* 166 */       e.push(sig.getName());
/* 167 */       e.push(impl.getName());
View Full Code Here

/* 165 */     List info = CollectionUtils.transform(members, MethodInfoTransformer.getInstance());
/* 166 */     Label illegalArg = e.make_label();
/* 167 */     Block block = e.begin_block();
/* 168 */     e.process_switch(getIntRange(info.size()), new ProcessSwitchCallback(info, e, arg, illegalArg) {
/*     */       public void processCase(int key, Label end) {
/* 170 */         MethodInfo method = (MethodInfo)this.val$info.get(key);
/* 171 */         Type[] types = method.getSignature().getArgumentTypes();
/* 172 */         for (int i = 0; i < types.length; i++) {
/* 173 */           this.val$e.load_arg(this.val$arg);
/* 174 */           this.val$e.aaload(i);
/* 175 */           this.val$e.unbox(types[i]);
/*     */         }
/* 177 */         this.val$e.invoke(method);
/* 178 */         if (!TypeUtils.isConstructor(method)) {
/* 179 */           this.val$e.box(method.getSignature().getReturnType());
/*     */         }
/* 181 */         this.val$e.return_value();
/*     */       }
/*     */       public void processDefault() {
/* 184 */         this.val$e.goTo(this.val$illegalArg);
View Full Code Here

TOP

Related Classes of net.sf.cglib.core.MethodInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.