Package javassist

Examples of javassist.CtBehavior


      return;
    }
    for (CtBehavior ctBehavior : ctClass.getDeclaredConstructors()) {
      removeInitializers(ctBehavior, ctField);
    }
    CtBehavior ctBehavior = ctClass.getClassInitializer();
    if (ctBehavior != null) {
      removeInitializers(ctBehavior, ctField);
    }
    ctClass.removeField(ctField);
  }
View Full Code Here


    ctField.setModifiers(oldField.getModifiers());
    ctClass.addField(ctField);
    Set<CtBehavior> allBehaviours = new HashSet<CtBehavior>();
    Collections.addAll(allBehaviours, ctClass.getDeclaredConstructors());
    Collections.addAll(allBehaviours, ctClass.getDeclaredMethods());
    CtBehavior initialiser = ctClass.getClassInitializer();
    if (initialiser != null) {
      allBehaviours.add(initialiser);
    }
    final boolean remove = attributes.containsKey("remove");
    for (CtBehavior ctBehavior : allBehaviours) {
View Full Code Here

      emptyConstructor = false
  )
  public void replaceInitializer(final Object o, Map<String, String> attributes) throws CannotCompileException, NotFoundException {
    final String field = attributes.get("field");
    CtClass ctClass = o instanceof CtClass ? (CtClass) o : null;
    CtBehavior ctBehavior = null;
    if (ctClass == null) {
      ctBehavior = (CtBehavior) o;
      ctClass = ctBehavior.getDeclaringClass();
    }
    String ctFieldClass = attributes.get("fieldClass");
    if (ctFieldClass != null) {
      if (ctClass == o) {
        PatchLog.warning("Must set methods to run on if using fieldClass.");
        return;
      }
      ctClass = classPool.get(ctFieldClass);
    }
    final CtField ctField = ctClass.getDeclaredField(field);
    String code = attributes.get("code");
    String clazz = attributes.get("class");
    if (code == null && clazz == null) {
      throw new NullPointerException("Must give code or class");
    }
    final String newInitialiser = code == null ? "$_ = new " + clazz + "();" : code;
    Set<CtBehavior> allBehaviours = new HashSet<CtBehavior>();
    if (ctBehavior == null) {
      Collections.addAll(allBehaviours, ctClass.getDeclaredConstructors());
      CtBehavior initialiser = ctClass.getClassInitializer();
      if (initialiser != null) {
        allBehaviours.add(initialiser);
      }
    } else {
      allBehaviours.add(ctBehavior);
View Full Code Here

      if ("^all^".equals(methods)) {
        patchDescriptor.set("silent", "true");
        List<CtBehavior> ctBehaviors = new ArrayList<CtBehavior>();
        Collections.addAll(ctBehaviors, ctClass.getDeclaredMethods());
        Collections.addAll(ctBehaviors, ctClass.getDeclaredConstructors());
        CtBehavior initializer = ctClass.getClassInitializer();
        if (initializer != null) {
          ctBehaviors.add(initializer);
        }
        for (CtBehavior ctBehavior : ctBehaviors) {
          run(ctBehavior, attributes, patchClassInstance);
View Full Code Here

TOP

Related Classes of javassist.CtBehavior

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.