Example #1
0
  @Override
  public void visitCode(Code obj) {
    Method m = getMethod();
    if (m.getReturnType() == Type.VOID) {
      return;
    }

    stack.resetForMethodEntry(this);
    ifBlocks.clear();
    activeUnconditional = null;

    CodeException[] ces = obj.getExceptionTable();
    if (CollectionUtils.isEmpty(ces)) {
      catchPCs = null;
    } else {
      catchPCs = new BitSet();
      for (CodeException ce : ces) {
        catchPCs.set(ce.getHandlerPC());
      }
    }
    gotoBranchPCs.clear();
    casePositions.clear();
    lookingForResetOp = false;

    try {
      super.visitCode(obj);
    } catch (StopOpcodeParsingException e) {
      // reported an issue, so get out
    }
  }
Example #2
0
  /** Returns the exceptions of the method. */
  protected ExceptionHandler[] loadExceptions(Method m) {
    Code c = m.getCode();

    if (c == null) {
      return null;
    }

    CodeException[] ce = c.getExceptionTable();

    if (ce.length == 0) {
      return null;
    }

    int length = ce.length;
    ExceptionHandler[] eh = new ExceptionHandler[length];

    ConstantPool cp = m.getConstantPool();

    for (int i = 0; i < length; i++) {
      int ct = ce[i].getCatchType();
      eh[i] =
          new ExceptionHandler(
              ((ct == 0)
                  ? null
                  : cp.getConstantString(ct, Constants.CONSTANT_Class).replace('/', '.')),
              ce[i].getStartPC(),
              ce[i].getEndPC(),
              ce[i].getHandlerPC());
    }

    return eh;
  }