Program: 80021
Project: 80021
Buggy source:
protected void resolveMethodCall(String javaClassName,boolean staticMethod) throws StandardException {
  if (routineInfo == null && !internalCall) {
    if ((getCompilerContext().getReliability() & CompilerContext.INTERNAL_SQL_ILLEGAL) != 0) {
      throw StandardException.newException(SQLState.LANG_SYNTAX_ERROR,javaClassName + (staticMethod ? "String_Node_Str" : "String_Node_Str") + methodName);
    }
  }
  int count=signature.length;
  ClassInspector classInspector=getClassFactory().getClassInspector();
  String[] parmTypeNames;
  String[] primParmTypeNames=null;
  boolean[] isParam=getIsParam();
  boolean hasDynamicResultSets=hasVarargs() ? false : (routineInfo != null) && (count != 0) && (count != methodParms.length);
  int signatureOffset=methodName.indexOf('(');
  if (signatureOffset != -1) {
    parmTypeNames=parseValidateSignature(methodName,signatureOffset,hasDynamicResultSets);
    methodName=methodName.substring(0,signatureOffset);
    hasDynamicResultSets=false;
  }
 else {
    parmTypeNames=getObjectSignature();
  }
  if (hasVarargs()) {
    parmTypeNames[count - 1]=parmTypeNames[count - 1] + "String_Node_Str";
  }
  try {
    method=classInspector.findPublicMethod(javaClassName,methodName,parmTypeNames,null,isParam,staticMethod,hasDynamicResultSets,hasVarargs());
    if (signatureOffset == -1 && routineInfo == null) {
      if (method == null) {
        primParmTypeNames=getPrimitiveSignature(false);
        method=classInspector.findPublicMethod(javaClassName,methodName,parmTypeNames,primParmTypeNames,isParam,staticMethod,hasDynamicResultSets,hasVarargs());
      }
    }
  }
 catch (  ClassNotFoundException e) {
    method=null;
  }
  if (method == null) {
    throwNoMethodFound(javaClassName,parmTypeNames,primParmTypeNames);
  }
  String typeName=classInspector.getType(method);
  actualMethodReturnType=typeName;
  if (routineInfo == null) {
    if (typeName.equals("String_Node_Str")) {
      if (!forCallStatement)       throw StandardException.newException(SQLState.LANG_VOID_METHOD_CALL);
    }
  }
 else {
    String promoteName=null;
    TypeDescriptorImpl returnType=(TypeDescriptorImpl)routineInfo.getReturnType();
    String requiredType;
    if (returnType == null) {
      requiredType="String_Node_Str";
    }
 else {
      TypeId returnTypeId=TypeId.getBuiltInTypeId(returnType.getJDBCTypeId());
      if (returnType.isRowMultiSet() && (routineInfo.getParameterStyle() == RoutineAliasInfo.PS_DERBY_JDBC_RESULT_SET)) {
        requiredType=ResultSet.class.getName();
      }
 else       if (returnType.getTypeId().userType()) {
        requiredType=((UserDefinedTypeIdImpl)returnType.getTypeId()).getClassName();
      }
 else {
        requiredType=returnTypeId.getCorrespondingJavaTypeName();
        if (!requiredType.equals(typeName)) {
switch (returnType.getJDBCTypeId()) {
case java.sql.Types.BOOLEAN:
case java.sql.Types.SMALLINT:
case java.sql.Types.INTEGER:
case java.sql.Types.BIGINT:
case java.sql.Types.REAL:
case java.sql.Types.DOUBLE:
            TypeCompiler tc=getTypeCompiler(returnTypeId);
          requiredType=tc.getCorrespondingPrimitiveTypeName();
        if (!routineInfo.calledOnNullInput() && routineInfo.getParameterCount() != 0) {
          promoteName=returnTypeId.getCorrespondingJavaTypeName();
        }
      break;
  }
}
}
}
boolean foundCorrectType;
if (ResultSet.class.getName().equals(requiredType)) {
try {
Class actualType=classInspector.getClass(typeName);
foundCorrectType=ResultSet.class.isAssignableFrom(actualType);
}
 catch (ClassNotFoundException cnfe) {
foundCorrectType=false;
}
}
 else {
foundCorrectType=requiredType.equals(typeName);
}
if (!foundCorrectType) {
throwNoMethodFound(requiredType + "String_Node_Str" + javaClassName,parmTypeNames,primParmTypeNames);
}
if (promoteName != null) typeName=promoteName;
if (routineInfo.getReturnType() != null) setCollationType(routineInfo.getReturnType().getCollationType());
}
setJavaTypeName(typeName);
methodParameterTypes=classInspector.getParameterTypes(method);
for (int i=0; i < methodParameterTypes.length; i++) {
String methodParameter=methodParameterTypes[i];
if (routineInfo != null) {
if (i < routineInfo.getParameterCount()) {
int parameterMode=routineInfo.getParameterModes()[i];
switch (parameterMode) {
case JDBC30Translation.PARAMETER_MODE_IN:
  break;
case JDBC30Translation.PARAMETER_MODE_IN_OUT:
methodParameter=methodParameter.substring(0,methodParameter.length() - 2);
break;
case JDBC30Translation.PARAMETER_MODE_OUT:
continue;
}
}
}
if (ClassInspector.primitiveType(methodParameter)) methodParms[i].castToPrimitive(true);
}
if (someParametersAreNull()) {
setNullParameterInfo(methodParameterTypes);
}
DataTypeDescriptor dts=DataTypeDescriptor.getSQLDataTypeDescriptor(typeName);
if (getCompilerContext().getReturnParameterFlag()) {
getCompilerContext().getParameterTypes()[0]=dts;
}
}

Fixed version (ground truth):
protected void resolveMethodCall(String javaClassName,boolean staticMethod) throws StandardException {
  if (routineInfo == null && !internalCall) {
    if ((getCompilerContext().getReliability() & CompilerContext.INTERNAL_SQL_ILLEGAL) != 0) {
      throw StandardException.newException(SQLState.LANG_SYNTAX_ERROR,javaClassName + (staticMethod ? "String_Node_Str" : "String_Node_Str") + methodName);
    }
  }
  int count=signature.length;
  ClassInspector classInspector=getClassFactory().getClassInspector();
  String[] parmTypeNames;
  String[] primParmTypeNames=null;
  boolean[] isParam=getIsParam();
  boolean hasDynamicResultSets=hasVarargs() ? false : (routineInfo != null) && (count != 0) && (count != methodParms.length);
  int signatureOffset=methodName.indexOf('(');
  if (signatureOffset != -1) {
    parmTypeNames=parseValidateSignature(methodName,signatureOffset,hasDynamicResultSets);
    methodName=methodName.substring(0,signatureOffset);
    hasDynamicResultSets=false;
  }
 else {
    parmTypeNames=getObjectSignature();
  }
  if (hasVarargs()) {
    parmTypeNames[count - 1]=parmTypeNames[count - 1] + "String_Node_Str";
  }
  try {
    method=classInspector.findPublicMethod(javaClassName,methodName,parmTypeNames,null,isParam,staticMethod,hasDynamicResultSets,hasVarargs());
    if (signatureOffset == -1 && routineInfo == null) {
      if (method == null) {
        primParmTypeNames=getPrimitiveSignature(false);
        method=classInspector.findPublicMethod(javaClassName,methodName,parmTypeNames,primParmTypeNames,isParam,staticMethod,hasDynamicResultSets,hasVarargs());
      }
    }
  }
 catch (  ClassNotFoundException e) {
    method=null;
  }
  if (method == null) {
    throwNoMethodFound(javaClassName,parmTypeNames,primParmTypeNames);
  }
  String typeName=classInspector.getType(method);
  actualMethodReturnType=typeName;
  if (routineInfo == null) {
    if (typeName.equals("String_Node_Str")) {
      if (!forCallStatement)       throw StandardException.newException(SQLState.LANG_VOID_METHOD_CALL);
    }
  }
 else {
    String promoteName=null;
    TypeDescriptorImpl returnType=(TypeDescriptorImpl)routineInfo.getReturnType();
    String requiredType;
    if (returnType == null) {
      requiredType="String_Node_Str";
    }
 else {
      TypeId returnTypeId=TypeId.getBuiltInTypeId(returnType.getJDBCTypeId());
      if (returnType.isRowMultiSet() && (routineInfo.getParameterStyle() == RoutineAliasInfo.PS_DERBY_JDBC_RESULT_SET)) {
        requiredType=ResultSet.class.getName();
      }
 else       if (returnType.getTypeId().userType()) {
        requiredType=((UserDefinedTypeIdImpl)returnType.getTypeId()).getClassName();
      }
 else {
        requiredType=returnTypeId.getCorrespondingJavaTypeName();
        if (!requiredType.equals(typeName)) {
switch (returnType.getJDBCTypeId()) {
case java.sql.Types.BOOLEAN:
case java.sql.Types.SMALLINT:
case java.sql.Types.INTEGER:
case java.sql.Types.BIGINT:
case java.sql.Types.REAL:
case java.sql.Types.DOUBLE:
            TypeCompiler tc=getTypeCompiler(returnTypeId);
          requiredType=tc.getCorrespondingPrimitiveTypeName();
        if (!routineInfo.calledOnNullInput() && routineInfo.getParameterCount() != 0) {
          promoteName=returnTypeId.getCorrespondingJavaTypeName();
        }
      break;
  }
}
}
}
boolean foundCorrectType;
if (ResultSet.class.getName().equals(requiredType)) {
try {
Class actualType=classInspector.getClass(typeName);
foundCorrectType=ResultSet.class.isAssignableFrom(actualType);
}
 catch (ClassNotFoundException cnfe) {
foundCorrectType=false;
}
}
 else {
foundCorrectType=requiredType.equals(typeName);
}
if (!foundCorrectType) {
throwNoMethodFound(requiredType + "String_Node_Str" + javaClassName,parmTypeNames,primParmTypeNames);
}
if (promoteName != null) typeName=promoteName;
if (routineInfo.getReturnType() != null) setCollationType(routineInfo.getReturnType().getCollationType());
}
setJavaTypeName(typeName);
methodParameterTypes=classInspector.getParameterTypes(method);
String methodParameter=null;
for (int i=0; i < methodParameterTypes.length; i++) {
methodParameter=methodParameterTypes[i];
if (routineInfo != null) {
if (i < routineInfo.getParameterCount()) {
int parameterMode=routineInfo.getParameterModes()[getRoutineArgIdx(i)];
switch (parameterMode) {
case JDBC30Translation.PARAMETER_MODE_IN:
  break;
case JDBC30Translation.PARAMETER_MODE_IN_OUT:
methodParameter=stripOneArrayLevel(methodParameter);
break;
case JDBC30Translation.PARAMETER_MODE_OUT:
continue;
}
}
}
if (hasVarargs() && (i >= getFirstVarargIdx())) {
methodParameter=stripOneArrayLevel(methodParameter);
}
if (ClassInspector.primitiveType(methodParameter)) {
if (i < methodParms.length) {
methodParms[i].castToPrimitive(true);
}
}
}
if (hasVarargs()) {
int firstVarargIdx=getFirstVarargIdx();
int trailingVarargCount=methodParms.length - firstVarargIdx;
for (int i=1; i < trailingVarargCount; i++) {
if (ClassInspector.primitiveType(methodParameter)) {
methodParms[i + firstVarargIdx].castToPrimitive(true);
}
}
}
if (someParametersAreNull()) {
setNullParameterInfo(methodParameterTypes);
}
DataTypeDescriptor dts=DataTypeDescriptor.getSQLDataTypeDescriptor(typeName);
if (getCompilerContext().getReturnParameterFlag()) {
getCompilerContext().getParameterTypes()[0]=dts;
}
}