Package javassist

Examples of javassist.CtConstructor


            // add target object field to class
            CtField field = new CtField( target, "m_dynTarget", clas );
            clas.addField( field );

            // add public default constructor method to class
            CtConstructor cons = new CtConstructor( NO_ARGS, clas );
            cons.setBody( "m_dynTarget = new " + tClasName + "();" );
            clas.addConstructor( cons );

            // add public <code>createCopy</code> method
            CtMethod ctMeth = new CtMethod( ctIDynProxy, "createCopy", NO_ARGS, clas );
            ctMeth.setBody( "return new " + proxyName + "();" );
View Full Code Here


    }

    protected void buildConstructor() throws CannotCompileException,
      NotFoundException {
  // Constructor(Class targetClass, Template[] templates)
  CtConstructor newCtCons = CtNewConstructor.make(
    new CtClass[] {
      director.getCtClass(Class.class.getName()),
      director.getCtClass(Template.class.getName() + "[]")
    }, new CtClass[0], tmplCtClass);
  tmplCtClass.addConstructor(newCtCons);
View Full Code Here

    }

    protected void buildConstructor() throws CannotCompileException,
      NotFoundException {
  // Constructor(Class targetClass, Template[] templates)
  CtConstructor newCtCons = CtNewConstructor.make(
    new CtClass[] {
      director.getCtClass(Class.class.getName()),
      director.getCtClass(Template.class.getName() + "[]")
    },
    new CtClass[0], tmplCtClass);
View Full Code Here

        CtClass[] ctParameters = toCtClasses(parameterTypes);
        CtClass[] ctExceptions = toCtClasses(exceptions);

        try
        {
            CtConstructor constructor = new CtConstructor(ctParameters, getCtClass());
            constructor.setExceptionTypes(ctExceptions);
            constructor.setBody(body);

            getCtClass().addConstructor(constructor);
        }
        catch (Exception ex)
        {
View Full Code Here

        method.setBody("return \"unreachable\";");

        ctClass.addMethod(method);

        CtConstructor constructor = new CtConstructor(new CtClass[0], ctClass);

        constructor.setBody("return $0;");

        constructor.setModifiers(Modifier.PROTECTED);

        ctClass.addConstructor(constructor);

        ctClass.writeFile(classesDir.getAbsolutePath());
    }
View Full Code Here

        CtClass[] ctParameters = convertClasses(parameterTypes);
        CtClass[] ctExceptions = convertClasses(exceptions);

        try
        {
            CtConstructor constructor = new CtConstructor(ctParameters, getCtClass());
            constructor.setExceptionTypes(ctExceptions);
            constructor.setBody(body);

            getCtClass().addConstructor(constructor);

            _constructors.add(new AddedConstructor(parameterTypes, exceptions, body));
        }
View Full Code Here

        try
        {
            // And have a public constructor.

            CtConstructor ctor = ctClass.getConstructor("()V");

            if (!Modifier.isPublic(ctor.getModifiers())) return;
        }
        catch (NotFoundException ex)
        {
            return;
        }
View Full Code Here

        CtClass[] ctParameters = convertClasses(parameterTypes);
        CtClass[] ctExceptions = convertClasses(exceptions);

        try
        {
            CtConstructor constructor = new CtConstructor(ctParameters, getCtClass());
            constructor.setExceptionTypes(ctExceptions);
            constructor.setBody(body);

            getCtClass().addConstructor(constructor);

            _constructors.add(new AddedConstructor(parameterTypes, exceptions, body));
        }
View Full Code Here

   /**
    * Currently only method joinpoints need serialization and thus a default ctor
    */
   private void createDefaultConstructor(CtConstructor superCtor, CtClass clazz) throws CannotCompileException
   {
      CtConstructor ctor = CtNewConstructor.defaultConstructor(clazz);
      clazz.addConstructor(ctor);
   }
View Full Code Here

            }
         }
                 
         body.append("}");

         CtConstructor ctor = CtNewConstructor.make(paramTypes, superCtor.getExceptionTypes(), body.toString(), clazz);
         ctor.setModifiers(superCtor.getModifiers());
         clazz.addConstructor(ctor);
      }
      catch (CannotCompileException e)
      {
         // AutoGenerated
View Full Code Here

TOP

Related Classes of javassist.CtConstructor

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.