Program: 19987
Project: 19987
Buggy source:
/** 
 * Suoritt�� s�ikeen.
 */
@Override public void run(){
  weaponManager=new WeaponManager();
  weaponManager.initialize(GameActivity.activeMode);
  hud=new Hud(context,weaponManager);
  gameMode=new SurvivalMode(gameActivity,dm,context,weaponManager);
  touchManager=new TouchManager(dm,surface,context,hud,weaponManager);
  allLoaded=true;
  waveStartTime=android.os.SystemClock.uptimeMillis();
  lastMovementUpdate=waveStartTime;
  lastAiUpdateStateOne=waveStartTime;
  lastAiUpdateStateTwo=waveStartTime;
  lastAiUpdateStateThree=waveStartTime;
  lastAiUpdateStateFour=waveStartTime;
  lastCooldownUpdate=waveStartTime;
  lastGameModeUpdate=waveStartTime;
  lastCollisionUpdate=waveStartTime;
  while (running) {
    long currentTime=android.os.SystemClock.uptimeMillis();
    if (currentTime - lastMovementUpdate >= 10) {
      lastMovementUpdate=currentTime;
      for (int i=wrapper.enemies.size() - 1; i >= 0; --i) {
        if (wrapper.enemyStates.get(i) == Wrapper.FULL_ACTIVITY || wrapper.enemyStates.get(i) == Wrapper.ANIMATION_AND_MOVEMENT) {
          wrapper.enemies.get(i).updateMovement(currentTime);
        }
      }
      for (int i=wrapper.projectiles.size() - 1; i >= 0; --i) {
        if (wrapper.projectileStates.get(i) == Wrapper.FULL_ACTIVITY || wrapper.projectileStates.get(i) == Wrapper.ANIMATION_AND_MOVEMENT) {
          wrapper.projectiles.get(i).updateMovement(currentTime);
        }
      }
    }
    if (currentTime - waveStartTime >= 3000) {
      updateSpeedUp=2;
    }
    if (wrapper.player != null) {
      if (currentTime - lastAiUpdateStateOne >= (400 / updateSpeedUp)) {
        lastAiUpdateStateOne=currentTime;
        for (        int i : wrapper.priorityOneEnemies) {
          if (wrapper.enemyStates.get(i) == Wrapper.FULL_ACTIVITY) {
            wrapper.enemies.get(i).ai.handleAi();
          }
        }
        for (        int i : wrapper.priorityOneProjectiles) {
          if (wrapper.projectileStates.get(i) == Wrapper.FULL_ACTIVITY) {
            if (wrapper.projectiles.get(i).ai != null) {
              if (wrapper.projectiles.get(i).ai.active) {
                wrapper.projectiles.get(i).ai.handleAi();
              }
            }
          }
        }
      }
      if (currentTime - lastAiUpdateStateTwo >= (200 / updateSpeedUp)) {
        lastAiUpdateStateTwo=currentTime;
        for (        int i : wrapper.priorityTwoEnemies) {
          if (wrapper.enemyStates.get(i) == Wrapper.FULL_ACTIVITY) {
            wrapper.enemies.get(i).ai.handleAi();
          }
        }
        for (        int i : wrapper.priorityTwoProjectiles) {
          if (wrapper.projectileStates.get(i) == Wrapper.FULL_ACTIVITY) {
            if (wrapper.projectiles.get(i).ai.active) {
              wrapper.projectiles.get(i).ai.handleAi();
            }
          }
        }
      }
      if (currentTime - lastAiUpdateStateThree >= (100 / updateSpeedUp)) {
        lastAiUpdateStateThree=currentTime;
        for (        int i : wrapper.priorityThreeEnemies) {
          if (wrapper.enemyStates.get(i) == Wrapper.FULL_ACTIVITY) {
            wrapper.enemies.get(i).ai.handleAi();
          }
        }
        for (        int i : wrapper.priorityThreeProjectiles) {
          if (wrapper.projectileStates.get(i) == Wrapper.FULL_ACTIVITY) {
            if (wrapper.projectiles.get(i).ai.active) {
              wrapper.projectiles.get(i).ai.handleAi();
            }
          }
        }
      }
      if (currentTime - lastAiUpdateStateFour >= (50 / updateSpeedUp)) {
        lastAiUpdateStateFour=currentTime;
        for (        int i : wrapper.priorityFourEnemies) {
          if (wrapper.enemyStates.get(i) == Wrapper.FULL_ACTIVITY) {
            wrapper.enemies.get(i).ai.handleAi();
          }
        }
        for (        int i : wrapper.priorityFourProjectiles) {
          if (wrapper.projectileStates.get(i) == Wrapper.FULL_ACTIVITY) {
            if (wrapper.projectiles.get(i).ai.active) {
              wrapper.projectiles.get(i).ai.handleAi();
            }
          }
        }
      }
    }
    if (currentTime - lastCollisionUpdate >= 50) {
      lastCollisionUpdate=currentTime;
      for (int i=wrapper.projectiles.size() - 1; i >= 0; --i) {
        if (wrapper.projectileStates.get(i) == Wrapper.FULL_ACTIVITY) {
          wrapper.projectiles.get(i).checkCollision();
        }
      }
      for (int i=wrapper.enemies.size() - 1; i >= 0; --i) {
        if (wrapper.enemyStates.get(i) == Wrapper.FULL_ACTIVITY) {
        }
      }
    }
    if (currentTime - lastCooldownUpdate >= 100) {
      lastCooldownUpdate=currentTime;
      gameMode.weaponManager.updateCooldowns();
    }
    if (currentTime - lastGameModeUpdate >= 1000) {
      if (SurvivalMode.enemiesLeft == 0) {
        waveStartTime=android.os.SystemClock.uptimeMillis();
        updateSpeedUp=1;
        gameMode.startWave();
      }
    }
    try {
      Thread.sleep(20);
    }
 catch (    InterruptedException e) {
      e.printStackTrace();
    }
  }
}

Fixed version (ground truth):
/** 
 * Suoritt�� s�ikeen.
 */
@Override public void run(){
  weaponManager=new WeaponManager();
  weaponManager.initialize(GameActivity.activeMode);
  hud=new Hud(context,weaponManager);
  gameMode=new SurvivalMode(gameActivity,dm,context,weaponManager);
  touchManager=new TouchManager(dm,surface,context,hud,weaponManager);
  allLoaded=true;
  waveStartTime=android.os.SystemClock.uptimeMillis();
  lastMovementUpdate=waveStartTime;
  lastAiUpdateStateOne=waveStartTime;
  lastAiUpdateStateTwo=waveStartTime;
  lastAiUpdateStateThree=waveStartTime;
  lastAiUpdateStateFour=waveStartTime;
  lastCooldownUpdate=waveStartTime;
  lastGameModeUpdate=waveStartTime;
  lastCollisionUpdate=waveStartTime;
  while (running) {
    long currentTime=android.os.SystemClock.uptimeMillis();
    if (currentTime - lastMovementUpdate >= 10) {
      lastMovementUpdate=currentTime;
      for (int i=wrapper.enemies.size() - 1; i >= 0; --i) {
        if (wrapper.enemyStates.get(i) == Wrapper.FULL_ACTIVITY || wrapper.enemyStates.get(i) == Wrapper.ANIMATION_AND_MOVEMENT) {
          wrapper.enemies.get(i).updateMovement(currentTime);
        }
      }
      for (int i=wrapper.projectiles.size() - 1; i >= 0; --i) {
        if (wrapper.projectileStates.get(i) == Wrapper.FULL_ACTIVITY || wrapper.projectileStates.get(i) == Wrapper.ANIMATION_AND_MOVEMENT) {
          wrapper.projectiles.get(i).updateMovement(currentTime);
        }
      }
    }
    if (currentTime - waveStartTime >= 3000) {
      updateSpeedUp=2;
    }
    if (wrapper.player != null) {
      if (currentTime - lastAiUpdateStateOne >= (400 / updateSpeedUp)) {
        lastAiUpdateStateOne=currentTime;
        for (        int i : wrapper.priorityOneEnemies) {
          if (wrapper.enemyStates.get(i) == Wrapper.FULL_ACTIVITY) {
            wrapper.enemies.get(i).ai.handleAi();
          }
        }
        for (        int i : wrapper.priorityOneProjectiles) {
          if (wrapper.projectileStates.get(i) == Wrapper.FULL_ACTIVITY) {
            if (wrapper.projectiles.get(i).ai != null) {
              if (wrapper.projectiles.get(i).ai.active) {
                wrapper.projectiles.get(i).ai.handleAi();
              }
            }
          }
        }
      }
      if (currentTime - lastAiUpdateStateTwo >= (200 / updateSpeedUp)) {
        lastAiUpdateStateTwo=currentTime;
        for (        int i : wrapper.priorityTwoEnemies) {
          if (wrapper.enemyStates.get(i) == Wrapper.FULL_ACTIVITY) {
            wrapper.enemies.get(i).ai.handleAi();
          }
        }
        for (        int i : wrapper.priorityTwoProjectiles) {
          if (wrapper.projectileStates.get(i) == Wrapper.FULL_ACTIVITY) {
            if (wrapper.projectiles.get(i).ai.active) {
              wrapper.projectiles.get(i).ai.handleAi();
            }
          }
        }
      }
      if (currentTime - lastAiUpdateStateThree >= (100 / updateSpeedUp)) {
        lastAiUpdateStateThree=currentTime;
        for (        int i : wrapper.priorityThreeEnemies) {
          if (wrapper.enemyStates.get(i) == Wrapper.FULL_ACTIVITY) {
            wrapper.enemies.get(i).ai.handleAi();
          }
        }
        for (        int i : wrapper.priorityThreeProjectiles) {
          if (wrapper.projectileStates.get(i) == Wrapper.FULL_ACTIVITY) {
            if (wrapper.projectiles.get(i).ai.active) {
              wrapper.projectiles.get(i).ai.handleAi();
            }
          }
        }
      }
      if (currentTime - lastAiUpdateStateFour >= (50 / updateSpeedUp)) {
        lastAiUpdateStateFour=currentTime;
        for (        int i : wrapper.priorityFourEnemies) {
          if (wrapper.enemyStates.get(i) == Wrapper.FULL_ACTIVITY) {
            wrapper.enemies.get(i).ai.handleAi();
          }
        }
        for (        int i : wrapper.priorityFourProjectiles) {
          if (wrapper.projectileStates.get(i) == Wrapper.FULL_ACTIVITY) {
            if (wrapper.projectiles.get(i).ai.active) {
              wrapper.projectiles.get(i).ai.handleAi();
            }
          }
        }
      }
    }
    if (currentTime - lastCollisionUpdate >= 50) {
      lastCollisionUpdate=currentTime;
      for (int i=wrapper.projectiles.size() - 1; i >= 0; --i) {
        if (wrapper.projectileStates.get(i) == Wrapper.FULL_ACTIVITY) {
          wrapper.projectiles.get(i).checkCollision();
        }
      }
      for (int i=wrapper.enemies.size() - 1; i >= 0; --i) {
        if (wrapper.enemyStates.get(i) == Wrapper.FULL_ACTIVITY) {
        }
      }
    }
    if (currentTime - lastCooldownUpdate >= 100) {
      lastCooldownUpdate=currentTime;
      gameMode.weaponManager.updateCooldowns();
      hud.updateCooldowns();
    }
    if (currentTime - lastGameModeUpdate >= 1000) {
      if (SurvivalMode.enemiesLeft == 0) {
        waveStartTime=android.os.SystemClock.uptimeMillis();
        updateSpeedUp=1;
        gameMode.startWave();
      }
    }
    try {
      Thread.sleep(20);
    }
 catch (    InterruptedException e) {
      e.printStackTrace();
    }
  }
}