Program: 169332
Project: 169332
Buggy source:
/** 
 * Take a guess at the device type.
 */
private void guessType(){
  int joystickCharacteristic=0;
  int digitiserCharacteristic=0;
  int gamepadCharacteristic=0;
  int miscCharacteristic=0;
  int mouseCharacteristic=0;
  int supportedButtons[]=new int[numButtons];
  getSupportedButtons(supportedButtons);
  for (int i=0; i < numButtons; i++) {
switch (supportedButtons[i]) {
case NativeDefinitions.BTN_TRIGGER:
case NativeDefinitions.BTN_THUMB:
case NativeDefinitions.BTN_THUMB2:
case NativeDefinitions.BTN_TOP:
case NativeDefinitions.BTN_TOP2:
case NativeDefinitions.BTN_PINKIE:
case NativeDefinitions.BTN_BASE:
case NativeDefinitions.BTN_BASE2:
case NativeDefinitions.BTN_BASE3:
case NativeDefinitions.BTN_BASE4:
case NativeDefinitions.BTN_BASE5:
case NativeDefinitions.BTN_BASE6:
case NativeDefinitions.BTN_DEAD:
      joystickCharacteristic++;
    break;
case NativeDefinitions.BTN_A:
case NativeDefinitions.BTN_B:
case NativeDefinitions.BTN_C:
case NativeDefinitions.BTN_X:
case NativeDefinitions.BTN_Y:
case NativeDefinitions.BTN_Z:
case NativeDefinitions.BTN_TL:
case NativeDefinitions.BTN_TR:
case NativeDefinitions.BTN_TL2:
case NativeDefinitions.BTN_TR2:
case NativeDefinitions.BTN_SELECT:
case NativeDefinitions.BTN_MODE:
case NativeDefinitions.BTN_THUMBL:
case NativeDefinitions.BTN_THUMBR:
  gamepadCharacteristic++;
break;
case NativeDefinitions.BTN_0:
case NativeDefinitions.BTN_1:
case NativeDefinitions.BTN_2:
case NativeDefinitions.BTN_3:
case NativeDefinitions.BTN_4:
case NativeDefinitions.BTN_5:
case NativeDefinitions.BTN_6:
case NativeDefinitions.BTN_7:
case NativeDefinitions.BTN_8:
case NativeDefinitions.BTN_9:
miscCharacteristic++;
break;
case NativeDefinitions.BTN_LEFT:
case NativeDefinitions.BTN_RIGHT:
case NativeDefinitions.BTN_MIDDLE:
case NativeDefinitions.BTN_SIDE:
case NativeDefinitions.BTN_EXTRA:
case NativeDefinitions.BTN_FORWARD:
case NativeDefinitions.BTN_BACK:
mouseCharacteristic++;
break;
case NativeDefinitions.BTN_TOOL_PEN:
case NativeDefinitions.BTN_TOOL_RUBBER:
case NativeDefinitions.BTN_TOOL_BRUSH:
case NativeDefinitions.BTN_TOOL_PENCIL:
case NativeDefinitions.BTN_TOOL_AIRBRUSH:
case NativeDefinitions.BTN_TOOL_FINGER:
case NativeDefinitions.BTN_TOOL_MOUSE:
case NativeDefinitions.BTN_TOOL_LENS:
case NativeDefinitions.BTN_TOUCH:
case NativeDefinitions.BTN_STYLUS:
case NativeDefinitions.BTN_STYLUS2:
digitiserCharacteristic++;
break;
default :
}
}
if ((joystickCharacteristic >= digitiserCharacteristic) && (joystickCharacteristic >= gamepadCharacteristic) && (joystickCharacteristic >= miscCharacteristic)&& (joystickCharacteristic >= mouseCharacteristic)) {
typeGuess=Type.STICK;
}
 else if ((gamepadCharacteristic >= digitiserCharacteristic) && (gamepadCharacteristic >= joystickCharacteristic) && (gamepadCharacteristic >= miscCharacteristic)&& (gamepadCharacteristic >= mouseCharacteristic)) {
typeGuess=Type.GAMEPAD;
}
 else if ((digitiserCharacteristic >= gamepadCharacteristic) && (digitiserCharacteristic >= joystickCharacteristic) && (digitiserCharacteristic >= miscCharacteristic)&& (digitiserCharacteristic >= mouseCharacteristic)) {
typeGuess=Type.TRACKPAD;
}
 else if ((miscCharacteristic >= gamepadCharacteristic) && (miscCharacteristic >= joystickCharacteristic) && (miscCharacteristic >= miscCharacteristic)&& (miscCharacteristic >= mouseCharacteristic)) {
typeGuess=Type.STICK;
}
 else if ((mouseCharacteristic >= digitiserCharacteristic) && (mouseCharacteristic >= joystickCharacteristic) && (mouseCharacteristic >= miscCharacteristic)&& (mouseCharacteristic >= gamepadCharacteristic)) {
typeGuess=Type.MOUSE;
}
}

Fixed version (ground truth):
/** 
 * Take a guess at the device type.
 */
private void guessType(){
  int joystickCharacteristic=0;
  int digitiserCharacteristic=0;
  int gamepadCharacteristic=0;
  int miscCharacteristic=0;
  int mouseCharacteristic=0;
  int supportedButtons[]=new int[numButtons];
  getSupportedButtons(supportedButtons);
  for (int i=0; i < numButtons; i++) {
switch (supportedButtons[i]) {
case NativeDefinitions.BTN_TRIGGER:
case NativeDefinitions.BTN_THUMB:
case NativeDefinitions.BTN_THUMB2:
case NativeDefinitions.BTN_TOP:
case NativeDefinitions.BTN_TOP2:
case NativeDefinitions.BTN_PINKIE:
case NativeDefinitions.BTN_BASE:
case NativeDefinitions.BTN_BASE2:
case NativeDefinitions.BTN_BASE3:
case NativeDefinitions.BTN_BASE4:
case NativeDefinitions.BTN_BASE5:
case NativeDefinitions.BTN_BASE6:
case NativeDefinitions.BTN_DEAD:
      joystickCharacteristic++;
    break;
case NativeDefinitions.BTN_A:
case NativeDefinitions.BTN_B:
case NativeDefinitions.BTN_C:
case NativeDefinitions.BTN_X:
case NativeDefinitions.BTN_Y:
case NativeDefinitions.BTN_Z:
case NativeDefinitions.BTN_TL:
case NativeDefinitions.BTN_TR:
case NativeDefinitions.BTN_TL2:
case NativeDefinitions.BTN_TR2:
case NativeDefinitions.BTN_SELECT:
case NativeDefinitions.BTN_MODE:
case NativeDefinitions.BTN_THUMBL:
case NativeDefinitions.BTN_THUMBR:
  gamepadCharacteristic++;
break;
case NativeDefinitions.BTN_0:
case NativeDefinitions.BTN_1:
case NativeDefinitions.BTN_2:
case NativeDefinitions.BTN_3:
case NativeDefinitions.BTN_4:
case NativeDefinitions.BTN_5:
case NativeDefinitions.BTN_6:
case NativeDefinitions.BTN_7:
case NativeDefinitions.BTN_8:
case NativeDefinitions.BTN_9:
miscCharacteristic++;
break;
case NativeDefinitions.BTN_LEFT:
case NativeDefinitions.BTN_RIGHT:
case NativeDefinitions.BTN_MIDDLE:
case NativeDefinitions.BTN_SIDE:
case NativeDefinitions.BTN_EXTRA:
case NativeDefinitions.BTN_FORWARD:
case NativeDefinitions.BTN_BACK:
mouseCharacteristic++;
break;
case NativeDefinitions.BTN_TOOL_PEN:
case NativeDefinitions.BTN_TOOL_RUBBER:
case NativeDefinitions.BTN_TOOL_BRUSH:
case NativeDefinitions.BTN_TOOL_PENCIL:
case NativeDefinitions.BTN_TOOL_AIRBRUSH:
case NativeDefinitions.BTN_TOOL_FINGER:
case NativeDefinitions.BTN_TOOL_MOUSE:
case NativeDefinitions.BTN_TOOL_LENS:
case NativeDefinitions.BTN_TOUCH:
case NativeDefinitions.BTN_STYLUS:
case NativeDefinitions.BTN_STYLUS2:
digitiserCharacteristic++;
break;
default :
}
}
if ((joystickCharacteristic >= digitiserCharacteristic) && (joystickCharacteristic >= gamepadCharacteristic) && (joystickCharacteristic >= miscCharacteristic)&& (joystickCharacteristic >= mouseCharacteristic)) {
typeGuess=Type.STICK;
}
 else if ((gamepadCharacteristic >= digitiserCharacteristic) && (gamepadCharacteristic >= joystickCharacteristic) && (gamepadCharacteristic >= miscCharacteristic)&& (gamepadCharacteristic >= mouseCharacteristic)) {
typeGuess=Type.GAMEPAD;
}
 else if ((digitiserCharacteristic >= gamepadCharacteristic) && (digitiserCharacteristic >= joystickCharacteristic) && (digitiserCharacteristic >= miscCharacteristic)&& (digitiserCharacteristic >= mouseCharacteristic)) {
typeGuess=Type.TRACKPAD;
}
 else if ((miscCharacteristic >= gamepadCharacteristic) && (miscCharacteristic >= joystickCharacteristic) && (miscCharacteristic >= miscCharacteristic)&& (miscCharacteristic >= mouseCharacteristic)) {
typeGuess=Type.STICK;
}
 else if ((mouseCharacteristic >= digitiserCharacteristic) && (mouseCharacteristic >= joystickCharacteristic) && (mouseCharacteristic >= miscCharacteristic)&& (mouseCharacteristic >= gamepadCharacteristic)) {
typeGuess=Type.MOUSE;
}
if (typeGuess == Type.STICK) {
String tempName=getName().toLowerCase();
if ((tempName.indexOf("String_Node_Str") > -1) || (tempName.indexOf("String_Node_Str") > -1)) {
typeGuess=Type.GAMEPAD;
}
}
}