[Demonstration 1]

[Buggy Method]
@Override
public void onDrawFrame(GL10 gl) {
    float[] scratch = new float[16];
    GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);
    // Set the camera position (View matrix)
    Matrix.setLookAtM(mViewMatrix, 0, 0, 0, -3.0f, 0f, 0f, 0f, 0f, 1.0f, 0.0f);
    // Calculate the projection and view transformation
    Matrix.multiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mViewMatrix, 0);
    // Create a rotation transformation for the triangle
    long time = SystemClock.uptimeMillis() % 40000L;
    Matrix.setRotateM(mRotationMatrix, 0, mAngleY, 1.f, 0, 0);
    Matrix.setRotateM(mRotationMatrix2, 0, mAngleX, 0, 1.0f, 0);
    // Combine the rotation matrix with the projection and camera view
    // Note that the mMVPMatrix factor *must be first* in order
    // for the matrix multiplication product to be correct.
    Matrix.multiplyMM(scratch, 0, mRotationMatrix, 0, mRotationMatrix2, 0);
    Matrix.multiplyMM(scratch, 0, mMVPMatrix, 0, scratch, 0);
    // Draw triangle
    //triangle.draw(scratch);
    //Matrix.translateM(scratch, 0, scratch, 0, -2.0f, 0, 0);
    long currentTime = SystemClock.uptimeMillis();
    long elapsedTime = currentTime - lastSystrmTime;
    lastSystemTime = currentTime;
    cube.update((float) (elapsedTime / 1000));
    cube.draw(scratch);
}

[Buggy Hunk]
long elapsedTime = currentTime - lastSystrmTime;

[Patch]
long elapsedTime = currentTime - lastSystemTime;

[Demonstration 2]

[Buggy Method]
public boolean loadLocalPackage(String fileName, String version, String md5, List<String> appDomains, InputStream is) {
    LocalPackageLoadTask task = new LocalPackageLoadTask(fileName, version, md5, appDomains, is);
    mExecutorService.execute(task);
    return true;
}

[Buggy Hunk]
mExecutorService.execute(task);

[Patch]
task.run();

[Demonstration 3]

[Buggy Method]
@Override
public boolean computeSlots() {
    // What's the minimum number of map and reduce slots we should try to
    // launch?
    mapSlots = 0;
    reduceSlots = 0;
    // Determine how many slots we can allocate.
    int slots = mapSlotsMax + reduceSlotsMax;
    slots = (int) Math.min(slots, (cpus - containerCpus) / slotCpus);
    slots = (int) Math.min(slots, (mem - containerMem) / slotMem);
    slots = (int) Math.min(slots, (disk - containerDisk) / slotDisk);
    // Is this offer too small for even the minimum slots?
    if (slots < 1) {
        return false;
    }
    // Is the number of slots we need sufficiently small? If so, we can
    // allocate exactly the number we need.
    if (slots >= neededMapSlots + neededReduceSlots && neededMapSlots < mapSlotsMax && neededReduceSlots < reduceSlotsMax) {
        mapSlots = neededMapSlots;
        reduceSlots = neededReduceSlots;
    } else {
        // Allocate slots fairly for this resource offer.
        double mapFactor = (double) neededMapSlots / (neededMapSlots + neededReduceSlots);
        double reduceFactor = (double) neededReduceSlots / (neededMapSlots + neededReduceSlots);
        // To avoid map/reduce slot starvation, don't allow more than 50%
        // spread between map/reduce slots when we need both mappers and
        // reducers.
        if (neededMapSlots > 0 && neededReduceSlots > 0) {
            if (mapFactor < 0.25) {
                mapFactor = 0.25;
            } else if (mapFactor > 0.75) {
                mapFactor = 0.75;
            }
            if (reduceFactor < 0.25) {
                reduceFactor = 0.25;
            } else if (reduceFactor > 0.75) {
                reduceFactor = 0.75;
            }
        }
        mapSlots = Math.min(Math.min((long) Math.round(mapFactor * slots), mapSlotsMax), neededMapSlots);
        // The remaining slots are allocated for reduces.
        slots -= mapSlots;
        reduceSlots = Math.min(Math.min(slots, reduceSlotsMax), neededReduceSlots);
    }
    return true;
}

[Buggy Hunk]
mapSlots = Math.min(Math.min((long)Math.round(mapFactor * slots), mapSlotsMax), neededMapSlots);

[Patch]
mapSlots = Math.min(Math.min((long)Math.max(Math.round(mapFactor * slots), 1), mapSlotsMax), neededMapSlots);