Program: 83190
Project: 83190
Buggy source:
/** 
 * Create a legal Java method call that will result in a JSNI invocation.
 * @param method
 * @param expectedHeaderLines
 * @param expectedBodyLines
 * @return a String of the Java code to call a JSNI method, usingJavaScriptHost.invokeNative
 */
private String genNonNativeVersionOfJsniMethod(JMethod method,int expectedHeaderLines,int expectedBodyLines){
  StringBuffer sb=new StringBuffer();
  for (int i=0; i < expectedHeaderLines; ++i) {
    sb.append('\n');
  }
  String methodDecl=method.getReadableDeclaration(false,true,false,false,false);
  sb.append(methodDecl + "String_Node_Str");
  JType returnType=method.getReturnType();
  boolean isJavaScriptObject=isJavaScriptObject(returnType);
  JPrimitiveType primType;
  if (isJavaScriptObject) {
    String returnTypeName=returnType.getQualifiedSourceName();
    sb.append("String_Node_Str" + returnTypeName + "String_Node_Str"+ Jsni.JAVASCRIPTHOST_NAME+ "String_Node_Str");
  }
 else   if (null != (primType=returnType.isPrimitive())) {
    char[] primTypeSuffix=primType.getSimpleSourceName().toCharArray();
    primTypeSuffix[0]=Character.toUpperCase(primTypeSuffix[0]);
    String invokeMethodName="String_Node_Str" + String.valueOf(primTypeSuffix);
    if (primType != JPrimitiveType.VOID) {
      sb.append("String_Node_Str");
    }
    sb.append(Jsni.JAVASCRIPTHOST_NAME);
    sb.append("String_Node_Str");
    sb.append(invokeMethodName);
  }
 else   if (returnType == coreTypes.javaLangString) {
    sb.append("String_Node_Str");
    sb.append(Jsni.JAVASCRIPTHOST_NAME);
    sb.append("String_Node_Str");
  }
 else {
    String returnTypeName=returnType.getQualifiedSourceName();
    sb.append("String_Node_Str");
    sb.append(returnTypeName);
    sb.append("String_Node_Str");
    sb.append(Jsni.JAVASCRIPTHOST_NAME);
    sb.append("String_Node_Str");
  }
  sb.append("String_Node_Str");
  String jsniSig=Jsni.getJsniSignature(method);
  sb.append(jsniSig);
  if (method.isStatic()) {
    sb.append("String_Node_Str");
  }
 else {
    sb.append("String_Node_Str");
  }
  if (isJavaScriptObject) {
    String returnTypeName=returnType.getQualifiedSourceName();
    sb.append(returnTypeName);
    sb.append("String_Node_Str");
  }
  sb.append(Jsni.buildTypeList(method));
  sb.append(',');
  sb.append(Jsni.buildArgList(method));
  sb.append("String_Node_Str");
  for (int i=0; i < expectedBodyLines; ++i) {
    sb.append('\n');
  }
  return sb.toString();
}

Fixed version (ground truth):
/** 
 * Create a legal Java method call that will result in a JSNI invocation.
 * @param method
 * @param expectedHeaderLines
 * @param expectedBodyLines
 * @return a String of the Java code to call a JSNI method, usingJavaScriptHost.invokeNative
 */
private String genNonNativeVersionOfJsniMethod(JMethod method,int expectedHeaderLines,int expectedBodyLines){
  StringBuffer sb=new StringBuffer();
  for (int i=0; i < expectedHeaderLines; ++i) {
    sb.append('\n');
  }
  String methodDecl=method.getReadableDeclaration(false,true,false,false,false);
  sb.append(methodDecl + "String_Node_Str");
  sb.append("String_Node_Str");
  JType returnType=method.getReturnType();
  boolean isJavaScriptObject=isJavaScriptObject(returnType);
  JPrimitiveType primType;
  if (isJavaScriptObject) {
    String returnTypeName=returnType.getQualifiedSourceName();
    sb.append("String_Node_Str" + returnTypeName + "String_Node_Str"+ Jsni.JAVASCRIPTHOST_NAME+ "String_Node_Str");
  }
 else   if (null != (primType=returnType.isPrimitive())) {
    char[] primTypeSuffix=primType.getSimpleSourceName().toCharArray();
    primTypeSuffix[0]=Character.toUpperCase(primTypeSuffix[0]);
    String invokeMethodName="String_Node_Str" + String.valueOf(primTypeSuffix);
    if (primType != JPrimitiveType.VOID) {
      sb.append("String_Node_Str");
    }
    sb.append(Jsni.JAVASCRIPTHOST_NAME);
    sb.append("String_Node_Str");
    sb.append(invokeMethodName);
  }
 else   if (returnType == coreTypes.javaLangString) {
    sb.append("String_Node_Str");
    sb.append(Jsni.JAVASCRIPTHOST_NAME);
    sb.append("String_Node_Str");
  }
 else {
    String returnTypeName=returnType.getQualifiedSourceName();
    sb.append("String_Node_Str");
    sb.append(returnTypeName);
    sb.append("String_Node_Str");
    sb.append(Jsni.JAVASCRIPTHOST_NAME);
    sb.append("String_Node_Str");
  }
  sb.append("String_Node_Str");
  String jsniSig=Jsni.getJsniSignature(method);
  sb.append(jsniSig);
  if (method.isStatic()) {
    sb.append("String_Node_Str");
  }
 else {
    sb.append("String_Node_Str");
  }
  if (isJavaScriptObject) {
    String returnTypeName=returnType.getQualifiedSourceName();
    sb.append(returnTypeName);
    sb.append("String_Node_Str");
  }
  sb.append(Jsni.buildTypeList(method));
  sb.append(',');
  sb.append(Jsni.buildArgList(method));
  sb.append("String_Node_Str");
  sb.append("String_Node_Str");
  sb.append("String_Node_Str");
  JType[] throwTypes=method.getThrows();
  for (int i=0; i < throwTypes.length; ++i) {
    String typeName=throwTypes[i].getQualifiedSourceName();
    sb.append("String_Node_Str" + typeName + "String_Node_Str"+ typeName+ "String_Node_Str");
  }
  sb.append("String_Node_Str");
  sb.append("String_Node_Str");
  sb.append("String_Node_Str");
  for (int i=0; i < expectedBodyLines; ++i) {
    sb.append('\n');
  }
  return sb.toString();
}