Program: 185980
Project: 185980
Buggy source:
private void doInitialize(BundleContext context) throws BundleException {
  SpecifiedVersion specifiedVersion=findSysPropVersion();
  if (specifiedVersion == SpecifiedVersion.UNSPECIFIED) {
    specifiedVersion=getVersionFromPrefenences(context);
  }
  System.out.println("String_Node_Str" + specifiedVersion.toReadableVersionString());
  Bundle[] bundles=Platform.getBundles(GROOVY_PLUGIN_ID,null);
  if (bundles == null || bundles.length == 0) {
    System.out.println("String_Node_Str");
    bundles=new Bundle[0];
  }
  allVersions=new Version[bundles.length];
  allSpecifiedVersions=new SpecifiedVersion[bundles.length];
  if (specifiedVersion != SpecifiedVersion.UNSPECIFIED) {
    boolean found=false;
    for (int i=0; i < bundles.length; i++) {
      Bundle bundle=bundles[i];
      allVersions[i]=bundle.getVersion();
      allSpecifiedVersions[i]=SpecifiedVersion.findVersion(bundle.getVersion());
      if (allSpecifiedVersions[i] == specifiedVersion && !found) {
        activeIndex=i;
        found=true;
      }
    }
    if (found && activeIndex > 0) {
      for (int i=0; i < bundles.length; i++) {
        if (i != activeIndex) {
          Bundle bundle=bundles[i];
          bundle.uninstall();
        }
      }
      PackageAdmin pkgAdmin=context.getService(context.getServiceReference(org.osgi.service.packageadmin.PackageAdmin.class));
      try {
        Method method=pkgAdmin.getClass().getMethod("String_Node_Str",Bundle[].class,boolean.class,FrameworkListener[].class);
        if (method == null) {
          pkgAdmin.refreshPackages(bundles);
        }
 else {
          method.setAccessible(true);
          method.invoke(pkgAdmin,bundles,true,null);
        }
      }
 catch (      Exception e) {
        pkgAdmin.refreshPackages(bundles);
      }
    }
 else {
      if (!found) {
        System.out.println("String_Node_Str" + allVersions[0] + "String_Node_Str");
      }
    }
  }
 else {
    for (int i=0; i < bundles.length; i++) {
      Bundle bundle=bundles[i];
      allVersions[i]=bundle.getVersion();
      allSpecifiedVersions[i]=SpecifiedVersion.findVersion(bundle.getVersion());
    }
  }
}

Fixed version (ground truth):
private void doInitialize(BundleContext context) throws BundleException {
  SpecifiedVersion specifiedVersion=findSysPropVersion();
  if (specifiedVersion == SpecifiedVersion.UNSPECIFIED) {
    specifiedVersion=getVersionFromPrefenences(context);
  }
  System.out.println("String_Node_Str" + specifiedVersion.toReadableVersionString());
  Bundle[] bundles=Platform.getBundles(GROOVY_PLUGIN_ID,null);
  if (bundles == null || bundles.length == 0) {
    System.out.println("String_Node_Str");
    bundles=new Bundle[0];
  }
  allVersions=new Version[bundles.length];
  allSpecifiedVersions=new SpecifiedVersion[bundles.length];
  if (specifiedVersion != SpecifiedVersion.UNSPECIFIED) {
    boolean found=false;
    for (int i=0; i < bundles.length; i++) {
      Bundle bundle=bundles[i];
      allVersions[i]=bundle.getVersion();
      allSpecifiedVersions[i]=SpecifiedVersion.findVersion(bundle.getVersion());
      if (allSpecifiedVersions[i] == specifiedVersion && !found) {
        activeIndex=i;
        found=true;
      }
    }
    if (found) {
      for (int i=0; i < bundles.length; i++) {
        if (i != activeIndex) {
          Bundle bundle=bundles[i];
          bundle.uninstall();
        }
      }
      PackageAdmin pkgAdmin=context.getService(context.getServiceReference(org.osgi.service.packageadmin.PackageAdmin.class));
      try {
        Method method=pkgAdmin.getClass().getMethod("String_Node_Str",Bundle[].class,boolean.class,FrameworkListener[].class);
        if (method == null) {
          pkgAdmin.refreshPackages(bundles);
        }
 else {
          method.setAccessible(true);
          method.invoke(pkgAdmin,bundles,true,null);
        }
      }
 catch (      Exception e) {
        pkgAdmin.refreshPackages(bundles);
      }
    }
 else {
      if (!found) {
        System.out.println("String_Node_Str" + allVersions[0] + "String_Node_Str");
      }
    }
  }
 else {
    for (int i=0; i < bundles.length; i++) {
      Bundle bundle=bundles[i];
      allVersions[i]=bundle.getVersion();
      allSpecifiedVersions[i]=SpecifiedVersion.findVersion(bundle.getVersion());
    }
  }
}