Program: 111553
Project: 111553
Buggy source:
synchronized public void writeKeyEvent(KeyEvent ev){
  if (ev.getID() != KeyEvent.KEY_PRESSED && !ev.isActionKey())   return;
  int keysym;
  if (!ev.isActionKey()) {
    vlog.debug("String_Node_Str" + ev.getKeyChar());
    if (ev.getKeyChar() < 32) {
      if ((ev.getModifiers() & KeyEvent.CTRL_MASK) != 0) {
        if ((ev.getModifiers() & KeyEvent.SHIFT_MASK) != 0) {
          keysym=ev.getKeyChar() + 64;
          if (keysym == -1)           return;
        }
 else {
          keysym=ev.getKeyChar() + 96;
          if (keysym == 127)           keysym=95;
        }
      }
 else {
switch (ev.getKeyCode()) {
case KeyEvent.VK_BACK_SPACE:
          keysym=Keysyms.BackSpace;
        break;
case KeyEvent.VK_TAB:
      keysym=Keysyms.Tab;
    break;
case KeyEvent.VK_ENTER:
  keysym=Keysyms.Return;
break;
case KeyEvent.VK_ESCAPE:
keysym=Keysyms.Escape;
break;
default :
return;
}
}
}
 else if (ev.getKeyChar() == 127) {
keysym=Keysyms.Delete;
}
 else {
keysym=UnicodeToKeysym.translate(ev.getKeyChar());
if (keysym == -1) return;
}
}
 else {
vlog.debug("String_Node_Str" + ev.getKeyCode());
switch (ev.getKeyCode()) {
case KeyEvent.VK_HOME:
keysym=Keysyms.Home;
break;
case KeyEvent.VK_END:
keysym=Keysyms.End;
break;
case KeyEvent.VK_PAGE_UP:
keysym=Keysyms.Page_Up;
break;
case KeyEvent.VK_PAGE_DOWN:
keysym=Keysyms.Page_Down;
break;
case KeyEvent.VK_UP:
keysym=Keysyms.Up;
break;
case KeyEvent.VK_DOWN:
keysym=Keysyms.Down;
break;
case KeyEvent.VK_LEFT:
keysym=Keysyms.Left;
break;
case KeyEvent.VK_RIGHT:
keysym=Keysyms.Right;
break;
case KeyEvent.VK_F1:
keysym=Keysyms.F1;
break;
case KeyEvent.VK_F2:
keysym=Keysyms.F2;
break;
case KeyEvent.VK_F3:
keysym=Keysyms.F3;
break;
case KeyEvent.VK_F4:
keysym=Keysyms.F4;
break;
case KeyEvent.VK_F5:
keysym=Keysyms.F5;
break;
case KeyEvent.VK_F6:
keysym=Keysyms.F6;
break;
case KeyEvent.VK_F7:
keysym=Keysyms.F7;
break;
case KeyEvent.VK_F8:
keysym=Keysyms.F8;
break;
case KeyEvent.VK_F9:
keysym=Keysyms.F9;
break;
case KeyEvent.VK_F10:
keysym=Keysyms.F10;
break;
case KeyEvent.VK_F11:
keysym=Keysyms.F11;
break;
case KeyEvent.VK_F12:
keysym=Keysyms.F12;
break;
case KeyEvent.VK_PRINTSCREEN:
keysym=Keysyms.Print;
break;
case KeyEvent.VK_PAUSE:
keysym=Keysyms.Pause;
break;
case KeyEvent.VK_INSERT:
keysym=Keysyms.Insert;
break;
default :
return;
}
}
writeModifiers(ev.getModifiers());
writeKeyEvent(keysym,true);
writeKeyEvent(keysym,false);
writeModifiers(0);
}

Fixed version (ground truth):
synchronized public void writeKeyEvent(KeyEvent ev){
  if (ev.getID() != KeyEvent.KEY_PRESSED && !ev.isActionKey())   return;
  int keysym, keycode, currentModifiers;
  currentModifiers=ev.getModifiers();
  keycode=ev.getKeyCode();
  if (!ev.isActionKey()) {
    vlog.debug("String_Node_Str" + ev.getKeyChar());
    if (ev.getKeyChar() < 32) {
      if ((currentModifiers & KeyEvent.CTRL_MASK) != 0) {
        if ((currentModifiers & KeyEvent.SHIFT_MASK) != 0) {
          keysym=ev.getKeyChar() + 64;
          if (keysym == -1)           return;
        }
 else {
          keysym=ev.getKeyChar() + 96;
          if (keysym == 127)           keysym=95;
        }
      }
 else {
switch (keycode) {
case KeyEvent.VK_BACK_SPACE:
          keysym=Keysyms.BackSpace;
        break;
case KeyEvent.VK_TAB:
      keysym=Keysyms.Tab;
    break;
case KeyEvent.VK_ENTER:
  keysym=Keysyms.Return;
break;
case KeyEvent.VK_ESCAPE:
keysym=Keysyms.Escape;
break;
default :
return;
}
}
}
 else if (ev.getKeyChar() == 127) {
keysym=Keysyms.Delete;
}
 else {
keysym=UnicodeToKeysym.translate(ev.getKeyChar());
if (keysym == -1) return;
if ((currentModifiers & KeyEvent.CTRL_MASK) != 0 && (currentModifiers & KeyEvent.ALT_MASK) != 0 && ((keysym == 0x5c) || (keysym == 0x7c) || (keysym == 0x5b)|| (keysym == 0x5d)|| (keysym == 0x7b)|| (keysym == 0x7d)|| (keysym == 0x7e)|| (keysym == 0x40)|| (keysym == 0x20ac)|| (keysym == 0xb5)|| (keysym == 0xb2)|| (keysym == 0xb3))) currentModifiers&=(~KeyEvent.CTRL_MASK) & (~KeyEvent.ALT_MASK);
}
}
 else {
vlog.debug("String_Node_Str" + keycode);
switch (keycode) {
case KeyEvent.VK_HOME:
keysym=Keysyms.Home;
break;
case KeyEvent.VK_END:
keysym=Keysyms.End;
break;
case KeyEvent.VK_PAGE_UP:
keysym=Keysyms.Page_Up;
break;
case KeyEvent.VK_PAGE_DOWN:
keysym=Keysyms.Page_Down;
break;
case KeyEvent.VK_UP:
keysym=Keysyms.Up;
break;
case KeyEvent.VK_DOWN:
keysym=Keysyms.Down;
break;
case KeyEvent.VK_LEFT:
keysym=Keysyms.Left;
break;
case KeyEvent.VK_RIGHT:
keysym=Keysyms.Right;
break;
case KeyEvent.VK_F1:
keysym=Keysyms.F1;
break;
case KeyEvent.VK_F2:
keysym=Keysyms.F2;
break;
case KeyEvent.VK_F3:
keysym=Keysyms.F3;
break;
case KeyEvent.VK_F4:
keysym=Keysyms.F4;
break;
case KeyEvent.VK_F5:
keysym=Keysyms.F5;
break;
case KeyEvent.VK_F6:
keysym=Keysyms.F6;
break;
case KeyEvent.VK_F7:
keysym=Keysyms.F7;
break;
case KeyEvent.VK_F8:
keysym=Keysyms.F8;
break;
case KeyEvent.VK_F9:
keysym=Keysyms.F9;
break;
case KeyEvent.VK_F10:
keysym=Keysyms.F10;
break;
case KeyEvent.VK_F11:
keysym=Keysyms.F11;
break;
case KeyEvent.VK_F12:
keysym=Keysyms.F12;
break;
case KeyEvent.VK_PRINTSCREEN:
keysym=Keysyms.Print;
break;
case KeyEvent.VK_PAUSE:
keysym=Keysyms.Pause;
break;
case KeyEvent.VK_INSERT:
keysym=Keysyms.Insert;
break;
default :
return;
}
}
writeModifiers(currentModifiers);
writeKeyEvent(keysym,true);
writeKeyEvent(keysym,false);
writeModifiers(0);
}