Package javassist

Examples of javassist.CtMethod$LongConstParameter


            }

            final CtMethod[] existingMethods = ctClass.getDeclaredMethods();
            for (int ctr = 0; ctr < existingMethods.length; ctr++)
            {
                final CtMethod method = existingMethods[ctr];
                if (!Modifier.isStatic(method.getModifiers()))
                {
                    final CtClass returnType = method.getReturnType();
                    String methodBody;
                    if (returnType.equals(CtClass.voidType))
                    {
                        methodBody =
                            "{" + contructArgumentString(method) + "scriptWrapper.invoke(\"" + method.getName() +
                            "\", arguments);}";
                    }
                    else
                    {
                        if (returnType.isPrimitive())
                        {
                            methodBody =
                                "{" + contructArgumentString(method) + " return ((" + getWrapperTypeName(returnType) +
                                ")scriptWrapper.invoke(\"" + method.getName() + "\", arguments))." +
                                returnType.getName() + "Value();}";
                        }
                        else
                        {
                            methodBody =
                                "{" + contructArgumentString(method) + " return (" + method.getReturnType().getName() +
                                ")scriptWrapper.invoke(\"" + method.getName() + "\", arguments);}";
                        }
                    }
                    method.setBody(methodBody);
                }
            }

            final File directory = getClassOutputDirectory(existingClass);
View Full Code Here


            int methodNum = analysisMethods.length;

            for (int ctr = 0; ctr < methodNum; ctr++)
            {
                CtMethod method = analysisMethods[ctr];
                String methodName = method.getName();

                if (methodName.startsWith(INA_PREFIX))
                {
                    // add the new overriden "inA" methods
                    this.methods.put(method, this.getInAMethodBody(method));
                }
                else if (methodName.startsWith(OUTA_PREFIX))
                {
                    // add the new overriden "outA" methods
                    this.methods.put(method, this.getOutAMethodBody(method));
                }
                else if (methodName.startsWith(CASE_PREFIX))
                {
                    // add the new overridden "case" methods
                    this.methods.put(method, this.getCaseMethodBody(method));
                }
            }

            //now add all the methods to the class
            Iterator allMethods = this.methods.keySet().iterator();
            while (allMethods.hasNext())
            {
                CtMethod method = (CtMethod)allMethods.next();
                CtMethod newMethod = new CtMethod(method, ctTranslatorClass, null);
                String methodBody = (String)this.methods.get(method);
                newMethod.setBody(methodBody);
                ctTranslatorClass.addMethod(newMethod);
            }

        }
        this.writeAdaptedClass();
View Full Code Here

            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 + "();" );
            clas.addMethod( ctMeth );

            // add public <code>setDynTarget</code> method
            ctMeth = new CtMethod( CtClass.voidType, "setDynTarget", new CtClass[] { _pool.get( "java.lang.Object" ) },
                                   clas );
            ctMeth.setBody( "m_dynTarget = (" + tClasName + ")$1;" );
            clas.addMethod( ctMeth );

            // add public <code>invokeDynMethod</code> method
            ctMeth = buildMethodAccessor( clas, targetMtd, types, realTypes, isConstructor );
            clas.addMethod( ctMeth );
View Full Code Here

  };
  CtClass[] exceptTypes = new CtClass[] {
    director.getCtClass(IOException.class.getName())
  };
  LOG.debug("compiling write method body: %s", new Object[] { mbody });
  CtMethod newCtMethod = CtNewMethod.make(mod, returnType, mname, paramTypes, exceptTypes, mbody, tmplCtClass);
  tmplCtClass.addMethod(newCtMethod);
  LOG.debug("finished generating write method in template class %s",
    new Object[] { tmplCtClass.getName() });
    }
View Full Code Here

  };
  CtClass[] exceptTypes = new CtClass[] {
    director.getCtClass(MessageTypeException.class.getName())
  };
  LOG.debug("compiling read method body: %s", new Object[] { mbody });
  CtMethod newCtMethod = CtNewMethod.make(mod, returnType, mname, paramTypes, exceptTypes, mbody, tmplCtClass);
  tmplCtClass.addMethod(newCtMethod);
  LOG.debug("finished generating read method in template class %s",
    new Object[] { tmplCtClass.getName() });
    }
View Full Code Here

      info.addInterface(classes1Pool.get("java.io.Serializable"));
      CtClass s = classes1Pool.get("java.lang.String");
      CtField firstName = new CtField(s, "firstName", info);
      firstName.setModifiers(Modifier.PRIVATE);
      info.addField(firstName);
      CtMethod getFirstName = CtNewMethod.getter("getFirstName", firstName);
      getFirstName.setModifiers(Modifier.PUBLIC);
      info.addMethod(getFirstName);
      CtMethod setFirstName = CtNewMethod.setter("setFirstName", firstName);
      setFirstName.setModifiers(Modifier.PUBLIC);
      info.addMethod(setFirstName);
      CtClass s2 = classes1Pool.get("java.lang.String");
      CtField lastName = new CtField(s2, "lastName", info);
      lastName.setModifiers(Modifier.PRIVATE);
      info.addField(lastName);
      CtMethod getLastName = CtNewMethod.getter("getLastName", lastName);
      getLastName.setModifiers(Modifier.PUBLIC);
      info.addMethod(getLastName);
      CtMethod setLastName = CtNewMethod.setter("setLastName", lastName);
      setLastName.setModifiers(Modifier.PUBLIC);
      info.addMethod(setLastName);
      //CtClass s3 = classes1Pool.get("java.lang.Long");
      CtField serialVersion = new CtField(CtClass.longType, "serialVersionUID", info);
      serialVersion.setModifiers(Modifier.PUBLIC | Modifier.STATIC | Modifier.FINAL);
      long serialVerionUID = 1L;
View Full Code Here

      info.addInterface(classes1Pool.get("java.io.Serializable"));
      CtClass s = classes1Pool.get("java.lang.String");
      CtField firstName = new CtField(s, "firstName", info);
      firstName.setModifiers(Modifier.PRIVATE);
      info.addField(firstName);
      CtMethod getFirstName = CtNewMethod.getter("getFirstName", firstName);
      getFirstName.setModifiers(Modifier.PUBLIC);
      info.addMethod(getFirstName);
      CtMethod setFirstName = CtNewMethod.setter("setFirstName", firstName);
      setFirstName.setModifiers(Modifier.PUBLIC);
      info.addMethod(setFirstName);
      CtClass s2 = classes1Pool.get("java.lang.String");
      CtField lastName = new CtField(s2, "lastName", info);
      lastName.setModifiers(Modifier.PRIVATE);
      info.addField(lastName);
      CtMethod getLastName = CtNewMethod.getter("getLastName", lastName);
      getLastName.setModifiers(Modifier.PUBLIC);
      info.addMethod(getLastName);
      CtMethod setLastName = CtNewMethod.setter("setLastName", lastName);
      setLastName.setModifiers(Modifier.PUBLIC);
      info.addMethod(setLastName);
      //CtClass s3 = classes1Pool.get("java.lang.Long");
      //CtField serialVersion = new CtField(s3, "serialVersionUID", info);
      CtField serialVersion = new CtField(CtClass.longType, "serialVersionUID", info);
      serialVersion.setModifiers(Modifier.PUBLIC | Modifier.STATIC | Modifier.FINAL);
View Full Code Here

        CtClass ctReturnType = toCtClass(ms.getReturnType());

        CtClass[] ctParameters = toCtClasses(ms.getParameterTypes());
        CtClass[] ctExceptions = toCtClasses(ms.getExceptionTypes());

        CtMethod method = new CtMethod(ctReturnType, ms.getName(), ctParameters, getCtClass());

        try
        {
            method.setModifiers(modifiers);
            method.setBody(body);
            method.setExceptionTypes(ctExceptions);

            getCtClass().addMethod(method);
        }
        catch (Exception ex)
        {
View Full Code Here

        CtClass ctClass = pool.makeClass(CLASS);

        ctClass.addInterface(pool.get(ReloadableService.class.getName()));

        CtMethod method = new CtMethod(pool.get("java.lang.String"), "getStatus", null, ctClass);

        method.setBody(String.format("return \"%s\";", status));

        ctClass.addMethod(method);

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

        CtClass ctClass = pool.makeClass(CLASS);

        ctClass.addInterface(pool.get(ReloadableService.class.getName()));

        CtMethod method = new CtMethod(pool.get("java.lang.String"), "getStatus", null, ctClass);

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

        ctClass.addMethod(method);

        CtConstructor constructor = new CtConstructor(new CtClass[0], ctClass);
View Full Code Here

TOP

Related Classes of javassist.CtMethod$LongConstParameter

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.