Package org.aspectj.apache.bcel.generic

Examples of org.aspectj.apache.bcel.generic.MethodGen$BranchTarget


        Method[] methods = jc.getMethods(); // Method no "method_no" exists, we
        // ran Pass3a before on it!

        try {

            MethodGen mg = new MethodGen(methods[method_no],
                    jc.getClassName(),
                    constantPoolGen);

            icv.setMethodGen(mg);

            // //////////// DFA BEGINS HERE ////////////////
            if (!(mg.isAbstract() || mg.isNative())) { // IF mg HAS CODE (See
                // pass 2)

                ControlFlowGraph cfg = new ControlFlowGraph(mg);

                // Build the initial frame situation for this method.
                Frame f = new Frame(mg.getMaxLocals(), mg.getMaxStack());
                if (!mg.isStatic()) {
                    if (mg.getName().equals(Constants.CONSTRUCTOR_NAME)) {
                        Frame._this = new UninitializedObjectType(new ObjectType(jc.getClassName()));
                        f.getLocals().set(0, Frame._this);
                    } else {
                        Frame._this = null;
                        f.getLocals().set(0, new ObjectType(jc.getClassName()));
                    }
                }
                Type[] argtypes = mg.getArgumentTypes();
                int twoslotoffset = 0;
                for (int j = 0; j < argtypes.length; j++) {
                    if (argtypes[j] == Type.SHORT || argtypes[j] == Type.BYTE
                            || argtypes[j] == Type.CHAR
                            || argtypes[j] == Type.BOOLEAN)
                    {
                        argtypes[j] = Type.INT;
                    }
                    f.getLocals().set(twoslotoffset + j
                            + (mg.isStatic() ? 0 : 1),
                            argtypes[j]);
                    if (argtypes[j].getSize() == 2) {
                        twoslotoffset++;
                        f.getLocals().set(twoslotoffset + j
                                + (mg.isStatic() ? 0 : 1),
                                Type.UNKNOWN);
                    }
                }
                circulationPump(cfg, cfg.contextOf(mg.getInstructionList()
                        .getStart()), f, icv, ev);
            }
        } catch (VerifierConstraintViolatedException ce) {
            ce.extendMessage("Constraint violated in method '"
                    + methods[method_no] + "':\n", "");
View Full Code Here


            }
            worthRetrying.removeAll(forRemoval);
          }
          if (annotationsToAdd != null) {
            Method oldMethod = mg.getMethod();
            MethodGen myGen = new MethodGen(oldMethod, clazz.getClassName(), clazz.getConstantPool(), false);
            for (AnnotationGen a : annotationsToAdd) {
              myGen.addAnnotation(a);
            }
            Method newMethod = myGen.getMethod();
            members.set(memberCounter, new LazyMethodGen(newMethod, clazz));
          }

        }
      }
View Full Code Here

  private void initialize() {
    if (returnType != null) {
      return;
    }

    MethodGen gen = new MethodGen(savedMethod, enclosingClass.getName(), enclosingClass.getConstantPool(), true);

    this.returnType = gen.getReturnType();
    this.argumentTypes = gen.getArgumentTypes();
    this.declaredExceptions = gen.getExceptions();
    this.attributes = gen.getAttributes();
    // this.annotations = gen.getAnnotations();
    this.maxLocals = gen.getMaxLocals();

    // this.returnType = BcelWorld.makeBcelType(memberView.getReturnType());
    // this.argumentTypes =
    // BcelWorld.makeBcelTypes(memberView.getParameterTypes());
    //
    // this.declaredExceptions =
    // UnresolvedType.getNames(memberView.getExceptions());
    // //gen.getExceptions();
    // this.attributes = new Attribute[0]; //gen.getAttributes();
    // this.maxLocals = savedMethod.getCode().getMaxLocals();

    if (gen.isAbstract() || gen.isNative()) {
      body = null;
    } else {
      // body = new InstructionList(savedMethod.getCode().getCode());
      body = gen.getInstructionList();
      unpackHandlers(gen);
      ensureAllLineNumberSetup();
      highestLineNumber = gen.getHighestlinenumber();
    }
    assertGoodBody();
  }
View Full Code Here

      return savedMethod; // ??? this relies on gentle treatment of
      // constant pool
    }

    try {
      MethodGen gen = pack();
      savedMethod = gen.getMethod();
      return savedMethod;
    } catch (ClassGenException e) {
      enclosingClass
          .getBcelObjectType()
          .getResolvedTypeX()
          .getWorld()
          .showMessage(
              IMessage.ERROR,
              WeaverMessages.format(WeaverMessages.PROBLEM_GENERATING_METHOD, this.getClassName(), this.getName(),
                  e.getMessage()),
              this.getMemberView() == null ? null : this.getMemberView().getSourceLocation(), null);
      // throw e; PR 70201.... let the normal problem reporting
      // infrastructure deal with this rather than crashing.
      body = null;
      MethodGen gen = pack();
      return gen.getMethod();
    }
  }
View Full Code Here

    int flags = getAccessFlags();
    if (enclosingClass.getWorld().isJoinpointSynchronizationEnabled()
        && enclosingClass.getWorld().areSynchronizationPointcutsInUse()) {
      flags = getAccessFlagsWithoutSynchronized();
    }
    MethodGen gen = new MethodGen(flags, getReturnType(), getArgumentTypes(), null, // getArgumentNames(),
        getName(), getEnclosingClass().getName(), new InstructionList(), getEnclosingClass().getConstantPool());
    for (int i = 0, len = declaredExceptions.length; i < len; i++) {
      gen.addException(declaredExceptions[i]);
    }

    for (Attribute attr : attributes) {
      gen.addAttribute(attr);
    }

    if (newAnnotations != null) {
      for (AnnotationAJ element : newAnnotations) {
        gen.addAnnotation(new AnnotationGen(((BcelAnnotation) element).getBcelAnnotation(), gen.getConstantPool(), true));
      }
    }

    if (newParameterAnnotations != null) {
      for (int i = 0; i < newParameterAnnotations.length; i++) {
        AnnotationAJ[] annos = newParameterAnnotations[i];
        for (int j = 0; j < annos.length; j++) {
          gen.addParameterAnnotation(i,
              new AnnotationGen(((BcelAnnotation) annos[j]).getBcelAnnotation(), gen.getConstantPool(), true));
        }
      }
    }

    if (memberView != null && memberView.getAnnotations() != null && memberView.getAnnotations().length != 0) {
      AnnotationAJ[] ans = memberView.getAnnotations();
      for (int i = 0, len = ans.length; i < len; i++) {
        AnnotationGen a = ((BcelAnnotation) ans[i]).getBcelAnnotation();
        gen.addAnnotation(new AnnotationGen(a, gen.getConstantPool(), true));
      }
    }

    if (isSynthetic) {
      if (enclosingClass.getWorld().isInJava5Mode()) {
        gen.setModifiers(gen.getModifiers() | ACC_SYNTHETIC);
      }
      // belt and braces, do the attribute even on Java 5 in addition to
      // the modifier flag
      ConstantPool cpg = gen.getConstantPool();
      int index = cpg.addUtf8("Synthetic");
      gen.addAttribute(new Synthetic(index, 0, new byte[0], cpg));
    }

    if (hasBody()) {
      if (this.enclosingClass.getWorld().shouldFastPackMethods()) {
        if (isAdviceMethod() || getName().equals("<clinit>")) {
          packBody(gen);
        } else {
          optimizedPackBody(gen);
        }
      } else {
        packBody(gen);
      }
      gen.setMaxLocals();
      gen.setMaxStack();
    } else {
      gen.setInstructionList(null);
    }
    return gen;
  }
View Full Code Here

        Method[] methods = jc.getMethods(); // Method no "method_no" exists, we
        // ran Pass3a before on it!

        try {

            MethodGen mg = new MethodGen(methods[method_no],
                    jc.getClassName(),
                    constantPoolGen);

            icv.setMethodGen(mg);

            // //////////// DFA BEGINS HERE ////////////////
            if (!(mg.isAbstract() || mg.isNative())) { // IF mg HAS CODE (See
                // pass 2)

                ControlFlowGraph cfg = new ControlFlowGraph(mg);

                // Build the initial frame situation for this method.
                Frame f = new Frame(mg.getMaxLocals(), mg.getMaxStack());
                if (!mg.isStatic()) {
                    if (mg.getName().equals(Constants.CONSTRUCTOR_NAME)) {
                        Frame._this = new UninitializedObjectType(new ObjectType(jc.getClassName()));
                        f.getLocals().set(0, Frame._this);
                    } else {
                        Frame._this = null;
                        f.getLocals().set(0, new ObjectType(jc.getClassName()));
                    }
                }
                Type[] argtypes = mg.getArgumentTypes();
                int twoslotoffset = 0;
                for (int j = 0; j < argtypes.length; j++) {
                    if (argtypes[j] == Type.SHORT || argtypes[j] == Type.BYTE
                            || argtypes[j] == Type.CHAR
                            || argtypes[j] == Type.BOOLEAN)
                    {
                        argtypes[j] = Type.INT;
                    }
                    f.getLocals().set(twoslotoffset + j
                            + (mg.isStatic() ? 0 : 1),
                            argtypes[j]);
                    if (argtypes[j].getSize() == 2) {
                        twoslotoffset++;
                        f.getLocals().set(twoslotoffset + j
                                + (mg.isStatic() ? 0 : 1),
                                Type.UNKNOWN);
                    }
                }
                circulationPump(cfg, cfg.contextOf(mg.getInstructionList()
                        .getStart()), f, icv, ev);
            }
        } catch (VerifierConstraintViolatedException ce) {
            ce.extendMessage("Constraint violated in method '"
                    + methods[method_no] + "':\n", "");
View Full Code Here

            }
            worthRetrying.removeAll(forRemoval);
          }
          if (annotationsToAdd != null) {
            Method oldMethod = mg.getMethod();
            MethodGen myGen = new MethodGen(oldMethod, clazz.getClassName(), clazz.getConstantPool(), false);
            for (AnnotationGen a : annotationsToAdd) {
              myGen.addAnnotation(a);
            }
            Method newMethod = myGen.getMethod();
            members.set(memberCounter, new LazyMethodGen(newMethod, clazz));
          }

        }
      }
View Full Code Here

  private void initialize() {
    if (returnType != null) {
      return;
    }
    MethodGen gen = new MethodGen(savedMethod, enclosingClass.getName(), enclosingClass.getConstantPool(), true);

    this.returnType = gen.getReturnType();
    this.argumentTypes = gen.getArgumentTypes();
    this.declaredExceptions = gen.getExceptions();
    this.attributes = gen.getAttributes();
    // this.annotations = gen.getAnnotations();
    this.maxLocals = gen.getMaxLocals();

    // this.returnType = BcelWorld.makeBcelType(memberView.getReturnType());
    // this.argumentTypes =
    // BcelWorld.makeBcelTypes(memberView.getParameterTypes());
    //
    // this.declaredExceptions =
    // UnresolvedType.getNames(memberView.getExceptions());
    // //gen.getExceptions();
    // this.attributes = new Attribute[0]; //gen.getAttributes();
    // this.maxLocals = savedMethod.getCode().getMaxLocals();

    if (gen.isAbstract() || gen.isNative()) {
      body = null;
    } else {
      // body = new InstructionList(savedMethod.getCode().getCode());
      body = gen.getInstructionList();
      unpackHandlers(gen);
      ensureAllLineNumberSetup();
      highestLineNumber = gen.getHighestlinenumber();
    }
    assertGoodBody();
  }
View Full Code Here

      return savedMethod; // ??? this relies on gentle treatment of
      // constant pool
    }

    try {
      MethodGen gen = pack();
      savedMethod = gen.getMethod();
      return savedMethod;
    } catch (ClassGenException e) {
      enclosingClass
          .getBcelObjectType()
          .getResolvedTypeX()
          .getWorld()
          .showMessage(
              IMessage.ERROR,
              WeaverMessages.format(WeaverMessages.PROBLEM_GENERATING_METHOD, this.getClassName(), this.getName(),
                  e.getMessage()),
              this.getMemberView() == null ? null : this.getMemberView().getSourceLocation(), null);
      // throw e; PR 70201.... let the normal problem reporting
      // infrastructure deal with this rather than crashing.
      body = null;
      MethodGen gen = pack();
      return gen.getMethod();
    } catch (RuntimeException re) {
      if (re.getCause() instanceof ClassGenException) {
        enclosingClass
            .getBcelObjectType()
            .getResolvedTypeX()
            .getWorld()
            .showMessage(
                IMessage.ERROR,
                WeaverMessages.format(WeaverMessages.PROBLEM_GENERATING_METHOD, this.getClassName(),
                    this.getName(), re.getCause().getMessage()),
                this.getMemberView() == null ? null : this.getMemberView().getSourceLocation(), null);
        // throw e; PR 70201.... let the normal problem reporting
        // infrastructure deal with this rather than crashing.
        body = null;
        MethodGen gen = pack();
        return gen.getMethod();
      }
      throw re;
    }
  }
View Full Code Here

    int flags = getAccessFlags();
    if (enclosingClass.getWorld().isJoinpointSynchronizationEnabled()
        && enclosingClass.getWorld().areSynchronizationPointcutsInUse()) {
      flags = getAccessFlagsWithoutSynchronized();
    }
    MethodGen gen = new MethodGen(flags, getReturnType(), getArgumentTypes(), null, // getArgumentNames(),
        getName(), getEnclosingClass().getName(), new InstructionList(), getEnclosingClass().getConstantPool());
    for (int i = 0, len = declaredExceptions.length; i < len; i++) {
      gen.addException(declaredExceptions[i]);
    }

    for (Attribute attr : attributes) {
      gen.addAttribute(attr);
    }

    if (newAnnotations != null) {
      for (AnnotationAJ element : newAnnotations) {
        gen.addAnnotation(new AnnotationGen(((BcelAnnotation) element).getBcelAnnotation(), gen.getConstantPool(), true));
      }
    }

    if (newParameterAnnotations != null) {
      for (int i = 0; i < newParameterAnnotations.length; i++) {
        AnnotationAJ[] annos = newParameterAnnotations[i];
        for (int j = 0; j < annos.length; j++) {
          gen.addParameterAnnotation(i,
              new AnnotationGen(((BcelAnnotation) annos[j]).getBcelAnnotation(), gen.getConstantPool(), true));
        }
      }
    }

    if (memberView != null && memberView.getAnnotations() != null && memberView.getAnnotations().length != 0) {
      AnnotationAJ[] ans = memberView.getAnnotations();
      for (int i = 0, len = ans.length; i < len; i++) {
        AnnotationGen a = ((BcelAnnotation) ans[i]).getBcelAnnotation();
        gen.addAnnotation(new AnnotationGen(a, gen.getConstantPool(), true));
      }
    }

    if (isSynthetic) {
      if (enclosingClass.getWorld().isInJava5Mode()) {
        gen.setModifiers(gen.getModifiers() | ACC_SYNTHETIC);
      }
      // belt and braces, do the attribute even on Java 5 in addition to
      // the modifier flag
      ConstantPool cpg = gen.getConstantPool();
      int index = cpg.addUtf8("Synthetic");
      gen.addAttribute(new Synthetic(index, 0, new byte[0], cpg));
    }

    if (hasBody()) {
      if (this.enclosingClass.getWorld().shouldFastPackMethods()) {
        if (isAdviceMethod() || getName().equals("<clinit>")) {
          packBody(gen);
        } else {
          optimizedPackBody(gen);
        }
      } else {
        packBody(gen);
      }
      gen.setMaxLocals();
      gen.setMaxStack();
    } else {
      gen.setInstructionList(null);
    }
    return gen;
  }
View Full Code Here

TOP

Related Classes of org.aspectj.apache.bcel.generic.MethodGen$BranchTarget

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.