Package javassist

Examples of javassist.CtClass.addConstructor()


      {
         CtConstructor conTemplate = superInvocation.getDeclaredConstructors()[i];
         CtConstructor icon = CtNewConstructor.make(conTemplate.getParameterTypes(),
                  conTemplate.getExceptionTypes(),
                  invocation);
         invocation.addConstructor(icon);
      }
  
      return invocation;
   }
  
View Full Code Here


            break;
         }
      }
      CtConstructor icon = CtNewConstructor.make(template.getParameterTypes(),
            template.getExceptionTypes(), invocation);
      invocation.addConstructor(icon);
  
      ////////////////
      //Add typed fields
      addArgumentFieldsAndAccessors(pool, invocation, con.getParameterTypes(), false);
     
View Full Code Here

            clazz, className, conInvocation);
     
      CtConstructor template = conInvocation.getDeclaredConstructors()[0];
      CtConstructor icon = CtNewConstructor.make(template.getParameterTypes(),
            template.getExceptionTypes(), invocation);
      invocation.addConstructor(icon);

      ////////////////
      //Add typed fields
      CtClass[] params = con.getParameterTypes();
      addArgumentFieldsAndAccessors(pool, invocation, params, false);
View Full Code Here

            ClassPool pool = ClassPool.getDefault();
            CtClass cc = pool.makeClass(className);

            cc.addInterface(resolveCtClass(Serializable.class));
            cc.addField(new CtField(resolveCtClass(Map.class), "theMap", cc));
            cc.addConstructor(generateConstructor(className, cc));

            for (Entry<String, Class<?>> entry : properties.entrySet()) {

                // add getter
                cc.addMethod(generateGetter(cc, entry.getKey(), entry.getValue()));
View Full Code Here

        field.setModifiers(syntheticModifier);
        javassistClass.addField(field);
        CtConstructor ctor = new CtConstructor(new CtClass[]{CtClass.intType}, javassistClass);
        ctor.setModifiers(syntheticModifier);
        ctor.setBody("{super();}");
        javassistClass.addConstructor(ctor);

        long javassistSerialVerUid = JavassistHelper.calculateSerialVerUid(javassistClass);

        Class javaClassGenerated = javassistClass.toClass();
        long javaSerialVerUid = ObjectStreamClass.lookup(javaClassGenerated).getSerialVersionUID();
View Full Code Here

        wrapperName = "com.webobjects.kvc." + wrapperName;
      }
      CtClass wrapper = ctPool.makeClass(wrapperName, ctAccessor);
      CtConstructor c = new CtConstructor(new CtClass[0], wrapper);
      c.setBody("super(" + targetCtClass.getName() +".class, \"" + key + "\");");
      wrapper.addConstructor(c);
      return wrapper;
    } catch (Exception e) {
      throw new NSForwardException(e);
    }
  }
View Full Code Here

                    break;
                }
            }
            if (!hasDefaultConstructor && !ctClass.isInterface()) {
                CtConstructor defaultConstructor = CtNewConstructor.make("public " + ctClass.getSimpleName() + "() {}", ctClass);
                ctClass.addConstructor(defaultConstructor);
            }
        } catch (Exception e) {
            Logger.error(e, "Error in PropertiesEnhancer");
            throw new UnexpectedException("Error in PropertiesEnhancer", e);
        }
View Full Code Here

                    break;
                }
            }
            if (!hasDefaultConstructor) {
                CtConstructor defaultConstructor = CtNewConstructor.defaultConstructor(ctClass);
                ctClass.addConstructor(defaultConstructor);
            }
        } catch (Exception e) {
            Logger.error(e, "Error in PropertiesEnhancer");
            throw new UnexpectedException("Error in PropertiesEnhancer", e);
        }
View Full Code Here

    cc.addInterface(classPool.get(MethodProxy.class.getName()));
    cc.addField(CtField.make("private Method method;", cc));
   
    CtConstructor constructor = new CtConstructor(new CtClass[]{classPool.get(Method.class.getName())}, cc);
    constructor.setBody("{this.method = (Method)$1;}");
    cc.addConstructor(constructor);
   
    cc.addMethod(CtMethod.make("public Method method(){return method;}", cc));
    cc.addMethod(CtMethod.make(createInvokeMethodCode(method), cc));
   
    MethodProxy ret = (MethodProxy) cc.toClass().getConstructor(Method.class).newInstance(method);
View Full Code Here

    cc.addInterface(classPool.get(FieldProxy.class.getName()));
    cc.addField(CtField.make("private Field field;", cc));
   
    CtConstructor constructor = new CtConstructor(new CtClass[]{classPool.get(Field.class.getName())}, cc);
    constructor.setBody("{this.field = (Field)$1;}");
    cc.addConstructor(constructor);
   
    cc.addMethod(CtMethod.make("public Field field(){return field;}", cc));
    cc.addMethod(CtMethod.make(createFieldGetterMethodCode(field), cc));
    cc.addMethod(CtMethod.make(createFieldSetterMethodCode(field), cc));
   
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.