Program: 96221
Project: 96221
Buggy source:
/** 
 * Linux/Unix/Solaris use X11 + AWT to add an AWT window to a spot in the notification panel. UNFORTUNATELY, AWT components are heavyweight, and DO NOT support transparency -- so one gets a "grey" box as the background of the icon. Spectacularly enough, because this uses X11, it works on any X backend -- regardless of GtkStatusIcon or AppIndicator support. This actually provides **more** support than GtkStatusIcons or AppIndicators, since this will ALWAYS work. Additionally, the size of the tray is hard-coded to be 24. The down side, is that there is a "grey" box -- so hack around this issue by getting the color of a pixel in the notification area 1 off the corner, and setting that as the background. It would be better to take a screenshot of the space BEHIND the tray icon, but we can't do that because there is no way to get the info BEFORE the AWT is added to the notification area. See comments below for more details. http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6453521 http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6267936 http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/tip/src/solaris/classes/sun/awt/X11/XTrayIconPeer.java http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/tip/src/solaris/classes/sun/awt/X11/XSystemTrayPeer.java
 */
public static void fixLinux(int trayIconSize){
  if (isOracleVM()) {
    return;
  }
  if (isSwingTrayLoaded()) {
    throw new RuntimeException("String_Node_Str");
  }
  try {
    ClassPool pool=ClassPool.getDefault();
    CtField ctField;
    String className="String_Node_Str";
    byte[] eFrameBytes;
    byte[] trayIconBytes;
    byte[] trayPeerBytes;
{
      CtClass trayIconClass=pool.get(className);
      CtClass eFrameClass=null;
      CtClass trayPeerClass;
      CtClass[] nestedClasses=trayIconClass.getNestedClasses();
      for (      CtClass nestedClass : nestedClasses) {
        String name=nestedClass.getName();
        if (name.equals(className + "String_Node_Str")) {
          eFrameClass=nestedClass;
        }
      }
      if (eFrameClass == null) {
        throw new RuntimeException("String_Node_Str");
      }
      ctField=new CtField(pool.get("String_Node_Str"),"String_Node_Str",trayIconClass);
      ctField.setModifiers(Modifier.STATIC);
      trayIconClass.addField(ctField);
      ctField=new CtField(pool.get("String_Node_Str"),"String_Node_Str",trayIconClass);
      ctField.setModifiers(Modifier.STATIC);
      trayIconClass.addField(ctField);
      trayPeerClass=pool.get("String_Node_Str");
      CtConstructor constructor=trayIconClass.getDeclaredConstructors()[0];
      CtMethod method1=trayIconClass.getDeclaredMethod("String_Node_Str");
      CtMethod method2=trayPeerClass.getDeclaredMethod("String_Node_Str");
      CtBehavior methodInfos[]=new CtBehavior[]{constructor,method1,method2};
      fixTraySize(methodInfos,24,trayIconSize);
      constructor.getMethodInfo().rebuildStackMapForME(trayIconClass.getClassPool());
      method1.getMethodInfo().rebuildStackMapForME(trayIconClass.getClassPool());
      method2.getMethodInfo().rebuildStackMapForME(trayPeerClass.getClassPool());
      trayIconBytes=trayIconClass.toBytecode();
      trayPeerBytes=trayPeerClass.toBytecode();
      CtMethod methodVisible=CtNewMethod.make("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str" + className + "String_Node_Str"+ className+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ className+ "String_Node_Str"+ className+ "String_Node_Str"+ "String_Node_Str"+ className+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",eFrameClass);
      eFrameClass.addMethod(methodVisible);
      methodVisible.getMethodInfo().rebuildStackMapForME(eFrameClass.getClassPool());
      eFrameBytes=eFrameClass.toBytecode();
    }
    BootStrapClassLoader.defineClass(trayIconBytes);
    BootStrapClassLoader.defineClass(trayPeerBytes);
    BootStrapClassLoader.defineClass(eFrameBytes);
    if (SystemTray.DEBUG) {
      logger.debug("String_Node_Str");
    }
  }
 catch (  Exception e) {
    logger.error("String_Node_Str",e);
  }
}

Fixed version (ground truth):
/** 
 * Linux/Unix/Solaris use X11 + AWT to add an AWT window to a spot in the notification panel. UNFORTUNATELY, AWT components are heavyweight, and DO NOT support transparency -- so one gets a "grey" box as the background of the icon. Spectacularly enough, because this uses X11, it works on any X backend -- regardless of GtkStatusIcon or AppIndicator support. This actually provides **more** support than GtkStatusIcons or AppIndicators, since this will ALWAYS work. Additionally, the size of the tray is hard-coded to be 24. The down side, is that there is a "grey" box -- so hack around this issue by getting the color of a pixel in the notification area 1 off the corner, and setting that as the background. It would be better to take a screenshot of the space BEHIND the tray icon, but we can't do that because there is no way to get the info BEFORE the AWT is added to the notification area. See comments below for more details. http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6453521 http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6267936 http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/tip/src/solaris/classes/sun/awt/X11/XTrayIconPeer.java http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/tip/src/solaris/classes/sun/awt/X11/XSystemTrayPeer.java
 */
public static void fixLinux(int trayIconSize){
  if (isOracleVM()) {
    return;
  }
  if (isSwingTrayLoaded()) {
    throw new RuntimeException("String_Node_Str");
  }
  try {
    ClassPool pool=ClassPool.getDefault();
    CtField ctField;
    String className="String_Node_Str";
    byte[] eFrameBytes;
    byte[] trayIconBytes;
    byte[] trayPeerBytes;
{
      CtClass trayIconClass=pool.get(className);
      CtClass eFrameClass=null;
      CtClass trayPeerClass;
      CtClass[] nestedClasses=trayIconClass.getNestedClasses();
      for (      CtClass nestedClass : nestedClasses) {
        String name=nestedClass.getName();
        if (name.equals(className + "String_Node_Str")) {
          eFrameClass=nestedClass;
        }
      }
      if (eFrameClass == null) {
        throw new RuntimeException("String_Node_Str");
      }
      ctField=new CtField(pool.get("String_Node_Str"),"String_Node_Str",trayIconClass);
      ctField.setModifiers(Modifier.STATIC);
      trayIconClass.addField(ctField);
      ctField=new CtField(pool.get("String_Node_Str"),"String_Node_Str",trayIconClass);
      ctField.setModifiers(Modifier.STATIC);
      trayIconClass.addField(ctField);
      trayPeerClass=pool.get("String_Node_Str");
      CtConstructor constructor=trayIconClass.getDeclaredConstructors()[0];
      CtMethod method1=trayIconClass.getDeclaredMethod("String_Node_Str");
      CtMethod method2=trayPeerClass.getDeclaredMethod("String_Node_Str");
      CtBehavior methodInfos[]=new CtBehavior[]{constructor,method1,method2};
      fixTraySize(methodInfos,24,trayIconSize);
      constructor.getMethodInfo().rebuildStackMapForME(trayIconClass.getClassPool());
      method1.getMethodInfo().rebuildStackMapForME(trayIconClass.getClassPool());
      method2.getMethodInfo().rebuildStackMapForME(trayPeerClass.getClassPool());
      trayIconBytes=trayIconClass.toBytecode();
      trayPeerBytes=trayPeerClass.toBytecode();
      CtMethod methodVisible=CtNewMethod.make("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str" + className + "String_Node_Str"+ className+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ className+ "String_Node_Str"+ className+ "String_Node_Str"+ "String_Node_Str"+ className+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",eFrameClass);
      eFrameClass.addMethod(methodVisible);
      methodVisible.getMethodInfo().rebuildStackMapForME(eFrameClass.getClassPool());
      eFrameBytes=eFrameClass.toBytecode();
    }
    BootStrapClassLoader.defineClass(trayIconBytes);
    BootStrapClassLoader.defineClass(trayPeerBytes);
    BootStrapClassLoader.defineClass(eFrameBytes);
    if (SystemTray.DEBUG) {
      logger.debug("String_Node_Str");
    }
  }
 catch (  Exception e) {
    logger.error("String_Node_Str",e);
  }
}