Ejemplo n.º 1
0
  private static byte[] insertGap2w(
      byte[] code, int where, int gapLength, boolean exclusive, ArrayList jumps, Pointers ptrs)
      throws BadBytecode {
    int n = jumps.size();
    if (gapLength > 0) {
      ptrs.shiftPc(where, gapLength, exclusive);
      for (int i = 0; i < n; i++) ((Branch) jumps.get(i)).shift(where, gapLength, exclusive);
    }

    boolean unstable = true;
    do {
      while (unstable) {
        unstable = false;
        for (int i = 0; i < n; i++) {
          Branch b = (Branch) jumps.get(i);
          if (b.expanded()) {
            unstable = true;
            int p = b.pos;
            int delta = b.deltaSize();
            ptrs.shiftPc(p, delta, false);
            for (int j = 0; j < n; j++) ((Branch) jumps.get(j)).shift(p, delta, false);
          }
        }
      }

      for (int i = 0; i < n; i++) {
        Branch b = (Branch) jumps.get(i);
        int diff = b.gapChanged();
        if (diff > 0) {
          unstable = true;
          int p = b.pos;
          ptrs.shiftPc(p, diff, false);
          for (int j = 0; j < n; j++) ((Branch) jumps.get(j)).shift(p, diff, false);
        }
      }
    } while (unstable);

    return makeExapndedCode(code, jumps, where, gapLength);
  }
Ejemplo n.º 2
0
 void mayCauseNPE() {
   Random rng = new Random();
   Pointers.A a = Pointers.mayReturnNull(rng.nextInt());
   // FIXME: should check for null before calling method()
   a.method();
 }
Ejemplo n.º 3
0
 void doesNotCauseNPE() {
   Pointers.A a = Pointers.mayReturnNull(10);
   a.method();
 }