Ejemplo n.º 1
0
  boolean checkGetClass() {
    if (!method.isStatic() || !(method.getType().equals("(Ljava/lang/String;)Ljava/lang/Class;")))
      return false;

    BytecodeInfo bytecode = method.getBytecode();

    Handler[] excHandlers = bytecode.getExceptionHandlers();
    if (excHandlers.length != 1 || !"java.lang.ClassNotFoundException".equals(excHandlers[0].type))
      return false;

    int excSlot = -1;
    int i = 0;
    for (Iterator iter = bytecode.getInstructions().iterator(); iter.hasNext(); i++) {
      Instruction instr = (Instruction) iter.next();
      while (instr.getOpcode() == opc_nop && iter.hasNext()) instr = (Instruction) iter.next();
      if (i == getClassOpcodes.length || instr.getOpcode() != getClassOpcodes[i]) return false;
      if (i == 0 && (instr.getLocalSlot() != 0 || excHandlers[0].start != instr)) return false;
      if (i == 2 && excHandlers[0].end != instr) return false;
      if (i == 3) {
        if (excHandlers[0].catcher != instr) return false;
        excSlot = instr.getLocalSlot();
      }
      if (i == 4 && !instr.getClazzType().equals("Ljava/lang/NoClassDefFoundError;")) return false;
      if (i == 6 && instr.getLocalSlot() != excSlot) return false;
      if (getClassRefs[i] != null && !getClassRefs[i].equals(instr.getReference())) return false;
    }
    this.kind = GETCLASS;
    return true;
  }