Package javassist.expr

Examples of javassist.expr.ExprEditor


            ClassInfo classInfo = JavassistClassInfo.getClassInfo(ctClass, context.getLoader());
            if (classFilter(definition, new ExpressionContext(PointcutType.CALL, classInfo, classInfo), ctClass)) {
                continue;
            }
            ctClass.instrument(
                    new ExprEditor() {
                        public void edit(MethodCall methodCall) throws CannotCompileException {
                            try {
                                CtBehavior where;
                                try {
                                    where = methodCall.where();
View Full Code Here


            ClassInfo classInfo = JavassistClassInfo.getClassInfo(ctClass, context.getLoader());
            if (classFilter(definition, new ExpressionContext(PointcutType.CALL, classInfo, classInfo), ctClass)) {
                continue;
            }
            ctClass.instrument(
                    new ExprEditor() {
                        public void edit(NewExpr newExpr) throws CannotCompileException {
                            try {
                                CtBehavior where = null;
                                try {
                                    where = newExpr.where();
View Full Code Here

        if (TransformClasses.debugInstrumentation)
            logger.trace("Instrument Agent --> Processing class initializer (static {})....");

        if (cm == null) return;

        cm.instrument(new ExprEditor() {
            public void edit(MethodCall m) throws CannotCompileException {
                try {
                    processMethodCall(m, clazz);
                } catch (Exception e) {
                    e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
View Full Code Here

    private final static void processMethodCalls(CtBehavior cm, final CtClass clazz) throws CannotCompileException {
        if (TransformClasses.debugInstrumentation)
            logger.trace("Instrument Agent --> Processing Methods ...");

        cm.instrument(new ExprEditor() {
            public void edit(MethodCall m) throws CannotCompileException {
                try {
                    processMethodCall(m, clazz);
                } catch (Exception e) {
                    e.printStackTrace();
View Full Code Here

    if (initialiser != null) {
      allBehaviours.add(initialiser);
    }
    final boolean remove = attributes.containsKey("remove");
    for (CtBehavior ctBehavior : allBehaviours) {
      ctBehavior.instrument(new ExprEditor() {
        @Override
        public void edit(FieldAccess fieldAccess) throws CannotCompileException {
          if (fieldAccess.getClassName().equals(ctClass.getName()) && fieldAccess.getFieldName().equals(field)) {
            if (fieldAccess.isReader()) {
              if (remove) {
View Full Code Here

      allBehaviours.add(ctBehavior);
    }
    final IntHolder replaced = new IntHolder();
    for (CtBehavior ctBehavior_ : allBehaviours) {
      final Map<Integer, String> newExprType = new HashMap<Integer, String>();
      ctBehavior_.instrument(new ExprEditor() {
        NewExpr lastNewExpr;
        int newPos = 0;

        @Override
        public void edit(NewExpr e) {
          lastNewExpr = null;
          newPos++;
          try {
            if (classPool.get(e.getClassName()).subtypeOf(ctField.getType())) {
              lastNewExpr = e;
            }
          } catch (NotFoundException ignored) {
          }
        }

        @Override
        public void edit(FieldAccess e) {
          NewExpr myLastNewExpr = lastNewExpr;
          lastNewExpr = null;
          if (myLastNewExpr != null && e.getFieldName().equals(field)) {
            newExprType.put(newPos, classSignatureToName(e.getSignature()));
          }
        }

        @Override
        public void edit(MethodCall e) {
          lastNewExpr = null;
        }

        @Override
        public void edit(NewArray e) {
          lastNewExpr = null;
        }

        @Override
        public void edit(Cast e) {
          lastNewExpr = null;
        }

        @Override
        public void edit(Instanceof e) {
          lastNewExpr = null;
        }

        @Override
        public void edit(Handler e) {
          lastNewExpr = null;
        }

        @Override
        public void edit(ConstructorCall e) {
          lastNewExpr = null;
        }
      });
      ctBehavior_.instrument(new ExprEditor() {
        int newPos = 0;

        @Override
        public void edit(NewExpr e) throws CannotCompileException {
          newPos++;
View Full Code Here

    } else {
      allBehaviours.add((CtBehavior) o);
    }
    final IntHolder done = new IntHolder();
    for (CtBehavior ctBehavior : allBehaviours) {
      ctBehavior.instrument(new ExprEditor() {
        @Override
        public void edit(NewExpr e) throws CannotCompileException {
          if (e.getClassName().equals(type)) {
            e.replace(newInitialiser);
            done.value++;
View Full Code Here

    if (readCode == null && writeCode == null) {
      throw new IllegalArgumentException("readCode or writeCode must be set");
    }
    final IntHolder replaced = new IntHolder();
    try {
      ctBehavior.instrument(new ExprEditor() {
        @Override
        public void edit(FieldAccess fieldAccess) throws CannotCompileException {
          String fieldName;
          try {
            fieldName = fieldAccess.getFieldName();
View Full Code Here

    final IntHolder replaced = new IntHolder();
    final int index = Integer.valueOf(index_);
    final boolean removeAfter = attributes.containsKey("removeAfter");

    try {
      ctBehavior.instrument(new ExprEditor() {
        private int currentIndex = 0;

        @Override
        public void edit(MethodCall methodCall) throws CannotCompileException {
          if ((className == null || methodCall.getClassName().equals(className)) && (method.isEmpty() || methodCall.getMethodName().equals(method)) && (index == -1 || currentIndex++ == index)) {
View Full Code Here

    final String field = attributes.get("field");
    final String threadLocalField = attributes.get("threadLocalField");
    final String type = attributes.get("type");
    String setExpression_ = attributes.get("setExpression");
    final String setExpression = setExpression_ == null ? '(' + type + ") $1" : setExpression_;
    ctClass.instrument(new ExprEditor() {
      @Override
      public void edit(FieldAccess e) throws CannotCompileException {
        if (e.getFieldName().equals(field)) {
          if (e.isReader()) {
            e.replace("{ $_ = (" + type + ") " + threadLocalField + ".get(); }");
View Full Code Here

TOP

Related Classes of javassist.expr.ExprEditor

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.