Program: 11920
Project: 11920
Buggy source:
/** 
 * Registers the specified classpath variable in the workspace   and adds a classpath entry to the   {@link #getClasspathEntries() classpath entry list}. The variable is bound to the first runtime library JAR file in the list of runtime libraries of the specified plugin. When   {@link #generate generate} is called and it needs to generate the  {@link #getMethod method} to invoke,it will call  {@link #initialize initialize} which will add the classpath entries to the  {@link #getProjectName project} created to hold and compile the emitted template.<p> This method must be called <b>before</b> {@link #initialize initialize} or {@link #generate generate}are called. <p> The specified plugin ID must be the ID of an existing plugin. The referenced plugin must have at least one  runtime library JAR file in its plugin descriptor. If the plugin descriptor's list of runtime libraries contains more than one JAR file,  the classpath variable will be bound to the <b>first</b> library in the list.
 * @param variableName name of the classpath variable
 * @param pluginID the ID of an existing plugin 
 */
public void addVariable(String variableName,String pluginID) throws JETException {
  try {
    Bundle bundle=Platform.getBundle(pluginID);
    String requires=(String)bundle.getHeaders().get(Constants.BUNDLE_CLASSPATH);
    ManifestElement[] elements=ManifestElement.parseHeader(Constants.BUNDLE_CLASSPATH,requires);
    for (int i=0; i < elements.length; ++i) {
      ManifestElement element=elements[i];
      try {
        IPath path=null;
        URL url=Platform.inDevelopmentMode() ? null : bundle.getEntry(element.getValue());
        if (url == null) {
          URL classpathURL=bundle.getEntry("String_Node_Str");
          if (classpathURL == null) {
            url=bundle.getEntry(element.getValue());
          }
 else {
            DocumentBuilderFactory documentBuilderFactory=DocumentBuilderFactory.newInstance();
            documentBuilderFactory.setNamespaceAware(true);
            documentBuilderFactory.setValidating(false);
            try {
              DocumentBuilder documentBuilder=documentBuilderFactory.newDocumentBuilder();
              Document document=documentBuilder.parse(new InputSource(classpathURL.toString()));
              for (Node child=document.getDocumentElement().getFirstChild(); child != null; child=child.getNextSibling()) {
                if (child.getNodeType() == Node.ELEMENT_NODE) {
                  Element classpathEntryElement=(Element)child;
                  if ("String_Node_Str".equals(classpathEntryElement.getNodeName()) && "String_Node_Str".equals(classpathEntryElement.getAttribute("String_Node_Str"))) {
                    URI uri=URI.createURI(classpathEntryElement.getAttribute("String_Node_Str")).resolve(URI.createURI(classpathURL.toString()));
                    IWorkspace workspace=ResourcesPlugin.getWorkspace();
                    IProject project=workspace.getRoot().getProject(getProjectName());
                    if (!project.exists()) {
                      project.create(new NullProgressMonitor());
                    }
                    if (!project.isOpen()) {
                      project.open(new NullProgressMonitor());
                    }
                    IFolder folder=project.getFolder("String_Node_Str" + pluginID);
                    if (!folder.exists()) {
                      folder.createLink(new Path(CommonPlugin.asLocalURI(uri).toFileString()).removeTrailingSeparator(),IResource.ALLOW_MISSING_LOCAL,new NullProgressMonitor());
                    }
                    folder.refreshLocal(IResource.DEPTH_INFINITE,new NullProgressMonitor());
                    path=folder.getFullPath();
                    break;
                  }
                }
              }
            }
 catch (            Exception exception) {
              CodeGenPlugin.INSTANCE.log(exception);
            }
          }
        }
 else {
          path=new Path(Platform.asLocalURL(url).getFile());
        }
        if (path != null && !path.equals(JavaCore.getClasspathVariable(variableName))) {
          JavaCore.setClasspathVariable(variableName,path,null);
        }
      }
 catch (      MalformedURLException exception) {
        throw new JETException(exception);
      }
catch (      JavaModelException exception) {
        throw new JETException(exception);
      }
catch (      IOException exception) {
        throw new JETException(exception);
      }
      break;
    }
  }
 catch (  BundleException exception) {
    throw new JETException(exception);
  }
  IClasspathEntry entry=JavaCore.newVariableEntry(new Path(variableName),null,null);
  getClasspathEntries().add(entry);
}

Fixed version (ground truth):
/** 
 * Registers the specified classpath variable in the workspace   and adds a classpath entry to the   {@link #getClasspathEntries() classpath entry list}. The variable is bound to the first runtime library JAR file in the list of runtime libraries of the specified plugin. When   {@link #generate generate} is called and it needs to generate the  {@link #getMethod method} to invoke,it will call  {@link #initialize initialize} which will add the classpath entries to the  {@link #getProjectName project} created to hold and compile the emitted template.<p> This method must be called <b>before</b> {@link #initialize initialize} or {@link #generate generate}are called. <p> The specified plugin ID must be the ID of an existing plugin. The referenced plugin must have at least one  runtime library JAR file in its plugin descriptor. If the plugin descriptor's list of runtime libraries contains more than one JAR file,  the classpath variable will be bound to the <b>first</b> library in the list.
 * @param variableName name of the classpath variable
 * @param pluginID the ID of an existing plugin 
 */
public void addVariable(String variableName,String pluginID) throws JETException {
  try {
    Bundle bundle=Platform.getBundle(pluginID);
    String requires=(String)bundle.getHeaders().get(Constants.BUNDLE_CLASSPATH);
    ManifestElement[] elements=ManifestElement.parseHeader(Constants.BUNDLE_CLASSPATH,requires);
    for (int i=0; i < elements.length; ++i) {
      ManifestElement element=elements[i];
      try {
        IPath path=null;
        URL url=Platform.inDevelopmentMode() ? null : bundle.getEntry(element.getValue());
        if (url == null) {
          URL classpathURL=bundle.getEntry("String_Node_Str");
          if (classpathURL == null) {
            url=bundle.getEntry(element.getValue());
            path=new Path(Platform.asLocalURL(url).getFile());
          }
 else {
            DocumentBuilderFactory documentBuilderFactory=DocumentBuilderFactory.newInstance();
            documentBuilderFactory.setNamespaceAware(true);
            documentBuilderFactory.setValidating(false);
            try {
              DocumentBuilder documentBuilder=documentBuilderFactory.newDocumentBuilder();
              Document document=documentBuilder.parse(new InputSource(classpathURL.toString()));
              for (Node child=document.getDocumentElement().getFirstChild(); child != null; child=child.getNextSibling()) {
                if (child.getNodeType() == Node.ELEMENT_NODE) {
                  Element classpathEntryElement=(Element)child;
                  if ("String_Node_Str".equals(classpathEntryElement.getNodeName()) && "String_Node_Str".equals(classpathEntryElement.getAttribute("String_Node_Str"))) {
                    URI uri=URI.createURI(classpathEntryElement.getAttribute("String_Node_Str")).resolve(URI.createURI(classpathURL.toString()));
                    IWorkspace workspace=ResourcesPlugin.getWorkspace();
                    IProject project=workspace.getRoot().getProject(getProjectName());
                    if (!project.exists()) {
                      project.create(new NullProgressMonitor());
                    }
                    if (!project.isOpen()) {
                      project.open(new NullProgressMonitor());
                    }
                    IFolder folder=project.getFolder("String_Node_Str" + pluginID);
                    if (!folder.exists()) {
                      folder.createLink(new Path(CommonPlugin.asLocalURI(uri).toFileString()).removeTrailingSeparator(),IResource.ALLOW_MISSING_LOCAL,new NullProgressMonitor());
                    }
                    folder.refreshLocal(IResource.DEPTH_INFINITE,new NullProgressMonitor());
                    path=folder.getFullPath();
                    break;
                  }
                }
              }
            }
 catch (            Exception exception) {
              CodeGenPlugin.INSTANCE.log(exception);
            }
          }
        }
 else {
          path=new Path(Platform.asLocalURL(url).getFile());
        }
        if (path != null && !path.equals(JavaCore.getClasspathVariable(variableName))) {
          JavaCore.setClasspathVariable(variableName,path,null);
        }
      }
 catch (      MalformedURLException exception) {
        throw new JETException(exception);
      }
catch (      JavaModelException exception) {
        throw new JETException(exception);
      }
catch (      IOException exception) {
        throw new JETException(exception);
      }
      break;
    }
  }
 catch (  BundleException exception) {
    throw new JETException(exception);
  }
  IClasspathEntry entry=JavaCore.newVariableEntry(new Path(variableName),null,null);
  getClasspathEntries().add(entry);
}