Package javassist

Examples of javassist.CtField$ParamInitializer


          }

          if (size == 3 && words[2].equals(";")) {
            // 增加属性域
            clazz
                .addField(new CtField(classPool.get(words[0]), words[1], clazz));
            continue;
          } else if (size == 1) {
            addMethod(clazz, words[0], null, in);
            continue;
          } else if (size == 3
View Full Code Here


      ClassPool classes1Pool = ClassPool.getDefault();
      //ClassPool classes1Pool = new ClassPool(defaultPool);
      CtClass info = classes1Pool.makeClass("org.jboss.test.scoped.interfaces.dto.SimpleResponseDTO");
      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;
      info.addField(serialVersion, CtField.Initializer.constant(serialVerionUID));

      info.writeFile(libDir.getAbsolutePath());
View Full Code Here

      ClassPool classes1Pool = ClassPool.getDefault();
      //ClassPool classes1Pool = new ClassPool(defaultPool);
      CtClass info = classes1Pool.makeClass("org.jboss.test.scoped.interfaces.dto.SimpleResponseDTO");
      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);
      long serialVerionUID = 2L;
      info.addField(serialVersion, CtField.Initializer.constant(serialVerionUID));

      info.writeFile(libDir.getAbsolutePath());
View Full Code Here

        continue;
      }

      // Update the "description" field of the annotation
      try {
        CtField ctField = aCtClazz.getField(field.getName());
        AnnotationsAttribute annoAttr = (AnnotationsAttribute) ctField.getFieldInfo().getAttribute(
                AnnotationsAttribute.visibleTag);

        // Locate and update annotation
        if (annoAttr != null) {
          Annotation[] annotations = annoAttr.getAnnotations();

          // Update existing annotation
          for (Annotation a : annotations) {
            if (a.getTypeName().equals(
                    org.apache.uima.fit.descriptor.ConfigurationParameter.class.getName())
                    || a.getTypeName().equals(
                            org.apache.uima.fit.descriptor.ExternalResource.class.getName())
                    || a.getTypeName().equals("org.uimafit.descriptor.ConfigurationParameter")
                    || a.getTypeName().equals("org.uimafit.descriptor.ExternalResource")) {
              if (a.getMemberValue("description") == null) {
                a.addMemberValue("description", new StringMemberValue(pdesc, aCtClazz
                        .getClassFile().getConstPool()));
                getLog().info("Enhanced description of " + type + " [" + pname + "]");
                // Replace updated annotation
                annoAttr.addAnnotation(a);
              } else {
                // Extract configuration parameter information from the uimaFIT annotation
                // We only want to override if the description is not set yet.
                getLog().info("Not overwriting description of " + type + " [" + pname + "] ");
              }
            }
          }
        }

        // Replace annotations
        ctField.getFieldInfo().addAttribute(annoAttr);
      } catch (NotFoundException e) {
        throw new MojoExecutionException("Field [" + field.getName() + "] not found in byte code: "
                + ExceptionUtils.getRootCauseMessage(e), e);
      }
    }
View Full Code Here

   * @param attribute
   * @throws CannotCompileException
   */
  protected void generateAttribute(CtClass proxyClass, Attribute attribute) throws CannotCompileException
  {
    CtField field = CtField.make(attribute.toJava14String(), proxyClass);
    proxyClass.addField(field);
  }
View Full Code Here

      cl = pool.makeClass(new ByteArrayInputStream(b));
      if (cl.isInterface() == false) {

        String pattern1 = "private static org.slf4j.Logger {};";
        String loggerDefinition = format(pattern1, _LOG);
        CtField field = CtField.make(loggerDefinition, cl);

        String pattern2 = "org.slf4j.LoggerFactory.getLogger({}.class);";
        String replace = name.replace('/', '.');
        String getLogger = format(pattern2, replace);
View Full Code Here

        return annotations;
    }

    private List<Annotation> findAnnotationsForField(String fieldName)
    {
        CtField field = findDeclaredCtField(fieldName);

        return extractAnnotations(field);
    }
View Full Code Here

    private CtClass getFieldCtType(String fieldName)
    {
        try
        {
            CtField field = _ctClass.getDeclaredField(fieldName);

            return field.getType();
        }
        catch (NotFoundException ex)
        {
            throw new RuntimeException(ex);
        }
View Full Code Here

        try
        {
            CtClass ctType = convertNameToCtType(type);

            CtField field = new CtField(ctType, fieldName, _ctClass);
            field.setModifiers(modifiers);

            _ctClass.addField(field);
        }
        catch (NotFoundException ex)
        {
View Full Code Here

        {
            for (String fieldName : _removedFieldNames)
            {
                try
                {
                    CtField field = _ctClass.getDeclaredField(fieldName);
                    _ctClass.removeField(field);
                }
                catch (NotFoundException ex)
                {
                    throw new RuntimeException(ex);
View Full Code Here

TOP

Related Classes of javassist.CtField$ParamInitializer

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.