Program: 74631
Project: 74631
Buggy source:
/** 
 * Attempts to open the default web browser to the given URL. <p> We use the following strategy to find URLs that may be inside jar files: <br> If the string does not start with "http": see if it is a file. <br> If the file cannot be found, look it up in the classpath. <br> If the file can be found in the classpath then use the found file instead of the given URL. <br>If the file cannot be found in the classpath, then pass the original given URL to the browser. <p>If the ptolemy.ptII.browser property is set, then its value is used as the value of the browser. <br>To always use Internet Explorer, one might invoke Ptolemy with:  <pre> java -classpath $PTII -Dptolemy.ptII.browser=c:\\Program\ Files\\Internet\ Explorer\\iexplore.exe ptolemy.vergil.VergilApplication </pre> <p>To always use Firefox: <pre> java -classpath $PTII -Dptolemy.ptII.browser=c:\\Program\ Files\\Mozilla\ Firefox\\firefox ptolemy.vergil.VergilApplication </pre> <p>To preserve your browser choice set the ptolemy.ptII.browser property in <code>$PTII/lib/ptII.properties</code>.  Note that each time <code>$PTII/bin/configure</code> is run, <code>$PTII/lib/ptII.properties.in</code> is read and  <code>$PTII/lib/ptII.properties</code> is overwritten, so you may want to add your changes to  <code>$PTII/lib/ptII.properties.in</code>.
 * @param url The URL to open.It is best if the first argument is an absolute URL as opposed to a relative URL.
 * @exception IOException If the web browser could not be located ordoes not run
 */
public static void openURL(String url) throws IOException {
  if (!loadedWithoutErrors) {
    throw new IOException("String_Node_Str" + errorMessage);
  }
  if (!url.startsWith("String_Node_Str")) {
    File urlFile=null;
    try {
      urlFile=new File(url);
    }
 catch (    Exception ex) {
    }
    if ((urlFile == null) || !urlFile.exists()) {
      String refClassName="String_Node_Str";
      try {
        Class refClass=Class.forName(refClassName);
        URL entryURL=refClass.getClassLoader().getResource(url);
        if ((entryURL != null) && !url.startsWith("String_Node_Str")) {
          System.out.println("String_Node_Str" + "String_Node_Str" + url + "String_Node_Str"+ entryURL+ "String_Node_Str");
          url=entryURL.toString();
        }
 else {
          if (url.startsWith("String_Node_Str")) {
            String old=url;
            String temporaryURL=JNLPUtilities.saveJarURLInClassPath(url);
            if (temporaryURL != null) {
              url=temporaryURL;
            }
 else {
              url=JNLPUtilities.saveJarURLAsTempFile(url,"String_Node_Str",null,null);
              delayExit=true;
            }
            System.out.println("String_Node_Str" + "String_Node_Str" + old + "String_Node_Str"+ url+ "String_Node_Str");
          }
        }
      }
 catch (      ClassNotFoundException ex) {
        System.err.println("String_Node_Str" + "String_Node_Str" + refClassName);
      }
    }
  }
  if (!StringUtilities.getProperty("String_Node_Str").equals("String_Node_Str")) {
    Runtime.getRuntime().exec(new String[]{"String_Node_Str" + StringUtilities.getProperty("String_Node_Str") + "String_Node_Str",url});
    return;
  }
  Object browser=locateBrowser();
  if (browser == null) {
    throw new IOException("String_Node_Str" + errorMessage);
  }
  int exitCode=0;
  String errorMessage="String_Node_Str";
  String args[];
switch (jvm) {
case MRJ_2_0:
    errorMessage="String_Node_Str" + url + "String_Node_Str";
  Object aeDesc=null;
try {
  aeDesc=aeDescConstructor.newInstance(new Object[]{url});
  putParameter.invoke(browser,new Object[]{keyDirectObject,aeDesc});
  sendNoReply.invoke(browser,new Object[]{});
}
 catch (InvocationTargetException ite) {
  throw new IOException("String_Node_Str" + "String_Node_Str" + ite.getMessage());
}
catch (IllegalAccessException iae) {
  throw new IOException("String_Node_Str" + "String_Node_Str" + iae.getMessage());
}
catch (InstantiationException ie) {
  throw new IOException("String_Node_Str" + "String_Node_Str" + ie.getMessage());
}
 finally {
  aeDesc=null;
  browser=null;
}
break;
case MRJ_2_1:
args=new String[]{(String)browser,url};
errorMessage="String_Node_Str" + args[0] + "String_Node_Str"+ args[1];
Runtime.getRuntime().exec(args);
break;
case MRJ_3_0:
errorMessage="String_Node_Str" + url + "String_Node_Str";
int[] instance=new int[1];
int result=ICStart(instance,0);
if (result == 0) {
int[] selectionStart=new int[]{0};
byte[] urlBytes=url.getBytes();
int[] selectionEnd=new int[]{urlBytes.length};
result=ICLaunchURL(instance[0],new byte[]{0},urlBytes,urlBytes.length,selectionStart,selectionEnd);
if (result == 0) {
ICStop(instance);
}
 else {
throw new IOException("String_Node_Str" + result);
}
}
 else {
throw new IOException("String_Node_Str" + "String_Node_Str" + result);
}
break;
case MRJ_3_1:
errorMessage="String_Node_Str" + url + "String_Node_Str";
try {
openURL.invoke(null,new Object[]{url});
}
 catch (InvocationTargetException ite) {
throw new IOException("String_Node_Str" + "String_Node_Str" + url + "String_Node_Str"+ ite.getMessage());
}
catch (IllegalAccessException iae) {
throw new IOException("String_Node_Str" + "String_Node_Str" + url + "String_Node_Str"+ iae.getMessage());
}
break;
case WINDOWS_NT:
case WINDOWS_9x:
args=new String[]{(String)browser,FIRST_WINDOWS_PARAMETER,SECOND_WINDOWS_PARAMETER,THIRD_WINDOWS_PARAMETER,'"' + url + '"'};
Process process=Runtime.getRuntime().exec(args);
errorMessage="String_Node_Str" + args[0] + "String_Node_Str"+ args[1]+ "String_Node_Str"+ args[2]+ "String_Node_Str"+ args[3]+ "String_Node_Str"+ args[4]+ "String_Node_Str"+ "String_Node_Str";
try {
exitCode=process.waitFor();
process.exitValue();
}
 catch (InterruptedException ie) {
throw new IOException("String_Node_Str" + "String_Node_Str" + ie.getMessage());
}
break;
case OTHER:
args=new String[]{(String)browser,NETSCAPE_REMOTE_PARAMETER,NETSCAPE_OPEN_PARAMETER_START + url + NETSCAPE_OPEN_PARAMETER_END};
process=Runtime.getRuntime().exec(args);
errorMessage="String_Node_Str" + args[0] + "String_Node_Str"+ args[1]+ "String_Node_Str"+ args[2];
try {
exitCode=process.waitFor();
if (exitCode != 0) {
Runtime.getRuntime().exec(new String[]{(String)browser,url});
}
}
 catch (InterruptedException ie) {
throw new IOException("String_Node_Str" + "String_Node_Str" + ie.getMessage());
}
break;
default :
Runtime.getRuntime().exec(new String[]{"String_Node_Str" + (String)browser + "String_Node_Str",url});
break;
}
if (exitCode != 0) {
throw new IOException("String_Node_Str" + exitCode + "String_Node_Str"+ "String_Node_Str"+ url+ "String_Node_Str"+ browser+ "String_Node_Str"+ errorMessage);
}
}

Fixed version (ground truth):
/** 
 * Attempts to open the default web browser to the given URL. <p> We use the following strategy to find URLs that may be inside jar files: <br> If the string does not start with "http": see if it is a file. <br> If the file cannot be found, look it up in the classpath. <br> If the file can be found in the classpath then use the found file instead of the given URL. <br>If the file cannot be found in the classpath, then pass the original given URL to the browser. <p>If the ptolemy.ptII.browser property is set, then its value is used as the value of the browser. <br>To always use Internet Explorer, one might invoke Ptolemy with:  <pre> java -classpath $PTII -Dptolemy.ptII.browser=c:\\Program\ Files\\Internet\ Explorer\\iexplore.exe ptolemy.vergil.VergilApplication </pre> <p>To always use Firefox: <pre> java -classpath $PTII -Dptolemy.ptII.browser=c:\\Program\ Files\\Mozilla\ Firefox\\firefox ptolemy.vergil.VergilApplication </pre> <p>To preserve your browser choice set the ptolemy.ptII.browser property in <code>$PTII/lib/ptII.properties</code>.  Note that each time <code>$PTII/bin/configure</code> is run, <code>$PTII/lib/ptII.properties.in</code> is read and  <code>$PTII/lib/ptII.properties</code> is overwritten, so you may want to add your changes to  <code>$PTII/lib/ptII.properties.in</code>.
 * @param url The URL to open.It is best if the first argument is an absolute URL as opposed to a relative URL.
 * @exception IOException If the web browser could not be located ordoes not run
 */
public static void openURL(String url) throws IOException {
  if (!loadedWithoutErrors) {
    throw new IOException("String_Node_Str" + errorMessage);
  }
  if (!url.startsWith("String_Node_Str")) {
    File urlFile=null;
    try {
      urlFile=new File(url);
    }
 catch (    Exception ex) {
    }
    if ((urlFile == null) || !urlFile.exists()) {
      String refClassName="String_Node_Str";
      try {
        Class refClass=Class.forName(refClassName);
        URL entryURL=refClass.getClassLoader().getResource(url);
        if ((entryURL != null) && !url.startsWith("String_Node_Str")) {
          System.out.println("String_Node_Str" + "String_Node_Str" + url + "String_Node_Str"+ entryURL+ "String_Node_Str");
          url=entryURL.toString();
        }
 else {
          if (url.startsWith("String_Node_Str")) {
            String old=url;
            String temporaryURL=JNLPUtilities.saveJarURLInClassPath(url);
            if (temporaryURL != null) {
              url=temporaryURL;
            }
 else {
              url=JNLPUtilities.saveJarURLAsTempFile(url,"String_Node_Str",null,null);
              delayExit=true;
            }
            System.out.println("String_Node_Str" + "String_Node_Str" + old + "String_Node_Str"+ url+ "String_Node_Str");
          }
        }
      }
 catch (      ClassNotFoundException ex) {
        System.err.println("String_Node_Str" + "String_Node_Str" + refClassName);
      }
    }
  }
  if (!StringUtilities.getProperty("String_Node_Str").equals("String_Node_Str")) {
    Runtime.getRuntime().exec(new String[]{"String_Node_Str" + StringUtilities.getProperty("String_Node_Str") + "String_Node_Str",url});
    return;
  }
  Object browser=locateBrowser();
  if (browser == null) {
    throw new IOException("String_Node_Str" + errorMessage);
  }
  String errorMessage="String_Node_Str";
  String args[];
switch (jvm) {
case MRJ_2_0:
    errorMessage="String_Node_Str" + url + "String_Node_Str";
  Object aeDesc=null;
try {
  aeDesc=aeDescConstructor.newInstance(new Object[]{url});
  putParameter.invoke(browser,new Object[]{keyDirectObject,aeDesc});
  sendNoReply.invoke(browser,new Object[]{});
}
 catch (InvocationTargetException ite) {
  throw new IOException("String_Node_Str" + "String_Node_Str" + ite.getMessage());
}
catch (IllegalAccessException iae) {
  throw new IOException("String_Node_Str" + "String_Node_Str" + iae.getMessage());
}
catch (InstantiationException ie) {
  throw new IOException("String_Node_Str" + "String_Node_Str" + ie.getMessage());
}
 finally {
  aeDesc=null;
  browser=null;
}
break;
case MRJ_2_1:
args=new String[]{(String)browser,url};
errorMessage="String_Node_Str" + args[0] + "String_Node_Str"+ args[1];
Runtime.getRuntime().exec(args);
break;
case MRJ_3_0:
errorMessage="String_Node_Str" + url + "String_Node_Str";
int[] instance=new int[1];
int result=ICStart(instance,0);
if (result == 0) {
int[] selectionStart=new int[]{0};
byte[] urlBytes=url.getBytes();
int[] selectionEnd=new int[]{urlBytes.length};
result=ICLaunchURL(instance[0],new byte[]{0},urlBytes,urlBytes.length,selectionStart,selectionEnd);
if (result == 0) {
ICStop(instance);
}
 else {
throw new IOException("String_Node_Str" + result);
}
}
 else {
throw new IOException("String_Node_Str" + "String_Node_Str" + result);
}
break;
case MRJ_3_1:
errorMessage="String_Node_Str" + url + "String_Node_Str";
try {
openURL.invoke(null,new Object[]{url});
}
 catch (InvocationTargetException ite) {
throw new IOException("String_Node_Str" + "String_Node_Str" + url + "String_Node_Str"+ ite.getMessage());
}
catch (IllegalAccessException iae) {
throw new IOException("String_Node_Str" + "String_Node_Str" + url + "String_Node_Str"+ iae.getMessage());
}
break;
case WINDOWS_NT:
case WINDOWS_9x:
args=new String[]{(String)browser,FIRST_WINDOWS_PARAMETER,SECOND_WINDOWS_PARAMETER,THIRD_WINDOWS_PARAMETER,'"' + url + '"'};
Process process=Runtime.getRuntime().exec(args);
errorMessage="String_Node_Str" + args[0] + "String_Node_Str"+ args[1]+ "String_Node_Str"+ args[2]+ "String_Node_Str"+ args[3]+ "String_Node_Str"+ args[4]+ "String_Node_Str"+ "String_Node_Str";
int exitCode=0;
try {
exitCode=process.waitFor();
process.exitValue();
}
 catch (InterruptedException ie) {
throw new IOException("String_Node_Str" + "String_Node_Str" + ie.getMessage());
}
if (exitCode != 0) {
throw new IOException("String_Node_Str" + exitCode + "String_Node_Str"+ "String_Node_Str"+ url+ "String_Node_Str"+ browser+ "String_Node_Str"+ errorMessage);
}
break;
case OTHER:
args=new String[]{(String)browser,NETSCAPE_REMOTE_PARAMETER,NETSCAPE_OPEN_PARAMETER_START + url + NETSCAPE_OPEN_PARAMETER_END};
process=Runtime.getRuntime().exec(args);
errorMessage="String_Node_Str" + args[0] + "String_Node_Str"+ args[1]+ "String_Node_Str"+ args[2];
try {
if (process.waitFor() != 0) {
Runtime.getRuntime().exec(new String[]{(String)browser,url});
}
}
 catch (InterruptedException ie) {
throw new IOException("String_Node_Str" + "String_Node_Str" + ie.getMessage());
}
break;
default :
Runtime.getRuntime().exec(new String[]{"String_Node_Str" + (String)browser + "String_Node_Str",url});
break;
}
}