Program: 66685
Project: 66685
Buggy source:
private List<ProcedureMethod> reflectMethods(SqlName sqlName) throws SQLException, PublisherException {
  String schema=sqlName.getSchemaName();
  String type=sqlName.getTypeName();
  ArrayList<ProcedureMethod> methodl=new ArrayList<ProcedureMethod>();
  MethodInfo[] minfo=getMethodInfo(schema,type);
  for (int minfoi=0; minfoi < minfo.length; minfoi++) {
    String methodName=minfo[minfoi].methodName;
    String methodType=minfo[minfoi].methodType;
    String methodNo=minfo[minfoi].methodNo;
    int results=minfo[minfoi].results;
    int parameters=minfo[minfoi].parameters;
    boolean preApproved=true;
    if (m_methodFilter != null) {
      preApproved=m_methodFilter.acceptMethod(new ProcedureMethod(methodName,null,-1,null,null,null,null,null,0),true);
    }
    if (!preApproved) {
      continue;
    }
    int modifiers;
    modifiers=PublisherModifier.PUBLIC;
    if (methodType.equals("String_Node_Str")) {
      modifiers=modifiers ^ PublisherModifier.MAP;
    }
 else     if (methodType.equals("String_Node_Str")) {
      modifiers=modifiers ^ PublisherModifier.ORDER;
    }
    TypeClass returnType=null;
    ResultInfo resultInfo=null;
    if (results > 0) {
      resultInfo=getResultInfo(schema,type,methodName,methodNo);
      if (resultInfo != null) {
        try {
          String resultTypeOwner=resultInfo.resultTypeOwner;
          String resultTypeName=resultInfo.resultTypeName;
          String resultTypeSubname=resultInfo.resultTypeSubname;
          String resultTypeMod=resultInfo.resultTypeMod;
          boolean ncharFormOfUse=resultInfo.ncharFormOfUse;
          String resultMethodName=resultInfo.methodName;
          String resultMethodNo=resultInfo.methodNo;
          int sequence=resultInfo.sequence;
          returnType=m_reflector.addPlsqlDBType(resultTypeOwner,resultTypeName,resultTypeSubname,resultTypeMod,ncharFormOfUse,type,resultMethodName,resultMethodNo,sequence,this);
        }
 catch (        SQLException e) {
          e.printStackTrace();
        }
      }
    }
    int paramCount=parameters;
    List<TypeClass> paramTypes_v=new ArrayList<TypeClass>();
    List<String> paramNames_v=new ArrayList<String>();
    List<Integer> paramModes_v=new ArrayList<Integer>();
    List<Boolean> paramNCharFormOfUse_v=new ArrayList<Boolean>();
    int firstNoDefault=-1;
    boolean[] paramDefaults=new boolean[paramCount];
    if (paramCount > 0) {
      ParamInfo[] pinfo=null;
      pinfo=getParamInfo(schema,type,methodName,methodNo);
      String[] paramTypeOwner=new String[paramCount];
      String[] paramName=new String[paramCount];
      String[] paramTypeName=new String[paramCount];
      String[] paramTypeSubname=new String[paramCount];
      String[] paramTypeMod=new String[paramCount];
      String[] paramMode=new String[paramCount];
      boolean[] mcharFormOfUse=new boolean[paramCount];
      String[] paramMethodName=new String[paramCount];
      String[] paramMethodNo=new String[paramCount];
      int[] sequence=new int[paramCount];
      int[] objectId=new int[paramCount];
      for (int i=pinfo.length - 1; i >= 0; i--) {
        paramTypeOwner[i]=pinfo[i].paramTypeOwner;
        paramName[i]=pinfo[i].paramName;
        paramTypeName[i]=pinfo[i].paramTypeName;
        paramTypeSubname[i]=pinfo[i].paramTypeSubname;
        paramTypeMod[i]=pinfo[i].paramTypeMod;
        paramMode[i]=pinfo[i].paramMode;
        mcharFormOfUse[i]=pinfo[i].ncharFormOfUse;
        paramMethodName[i]=pinfo[i].methodName;
        paramMethodNo[i]=pinfo[i].methodNo;
        sequence[i]=pinfo[i].sequence;
        objectId[i]=pinfo[i].objectId;
      }
      paramDefaults=new boolean[pinfo.length];
      for (int i=pinfo.length - 1; i >= 0; i--) {
        paramDefaults[i]=hasDefault(objectId[i],paramMethodName[i],sequence[i],paramMethodNo[i]);
      }
      for (int i=pinfo.length - 1; i >= 0; i--) {
        if (!paramDefaults[i]) {
          firstNoDefault=i;
          break;
        }
      }
      for (int i=0; i < paramCount && paramMethodName[i] != null; i++) {
        try {
          paramNames_v.add(paramName[i]);
          String mode=paramMode[i];
          paramModes_v.add(new Integer((mode == null) ? ProcedureMethod.INOUT : (mode.equals("String_Node_Str") ? ProcedureMethod.IN : (mode.equals("String_Node_Str") ? ProcedureMethod.OUT : ProcedureMethod.INOUT))));
          paramTypes_v.add(m_reflector.addPlsqlDBType(paramTypeOwner[i],paramTypeName[i],paramTypeSubname[i],paramTypeMod[i],mcharFormOfUse[i],type,paramMethodName[i],paramMethodNo[i],sequence[i],this));
          paramNCharFormOfUse_v.add(new Boolean(mcharFormOfUse[i]));
        }
 catch (        SQLException e) {
          e.printStackTrace();
        }
      }
    }
    int len=paramTypes_v.size();
    if (len != paramCount) {
      System.err.println("String_Node_Str" + methodName + "String_Node_Str"+ paramCount+ "String_Node_Str"+ len);
    }
    TypeClass[] paramTypes=new TypeClass[len];
    String[] paramNames=new String[len];
    int[] paramModes=new int[len];
    boolean[] paramNCharFormOfUse=new boolean[len];
    for (int i=0; i < len; i++) {
      paramTypes[i]=(TypeClass)(paramTypes_v.get(i));
      paramNames[i]=paramNames_v.get(i);
      paramModes[i]=paramModes_v.get(i).intValue();
      paramNCharFormOfUse[i]=paramNCharFormOfUse_v.get(i).booleanValue();
    }
    paramTypes=generateDefaultArgsHolderParamTypes(paramTypes,paramDefaults,paramNCharFormOfUse);
    ProcedureMethod method=null;
    for (int paramLen=firstNoDefault + 1; paramLen <= paramCount; paramLen++) {
      if (this instanceof SqlPackageType && returnType != null && resultInfo != null && returnType.equals(SqlReflector.REF_CURSOR_TYPE)) {
        method=new PlsqlCursorMethod(type,methodName,methodNo,modifiers,resultInfo.sequence,paramTypes,paramNames,paramModes,paramDefaults,paramLen,false,m_reflector);
      }
 else       if (this instanceof SqlPackageType) {
        method=new PlsqlMethod(methodName,methodNo,modifiers,returnType,paramTypes,paramNames,paramModes,paramDefaults,paramLen);
      }
 else {
        method=new ProcedureMethod(methodName,methodNo,modifiers,returnType,paramTypes,paramNames,paramModes,paramDefaults,paramLen);
      }
      if (acceptMethod(method,false)) {
        methodl.add(method);
        if (returnType != null && resultInfo != null && returnType.equals(SqlReflector.REF_CURSOR_TYPE)) {
          method=new PlsqlCursorMethod(type,methodName,methodNo,modifiers,resultInfo.sequence,paramTypes,paramNames,paramModes,paramDefaults,paramLen,true,m_reflector);
          if (((PlsqlCursorMethod)method).getReturnColCount() != 0) {
            methodl.add(method);
          }
        }
      }
    }
  }
  Collections.sort(methodl);
  return methodl;
}

Fixed version (ground truth):
private List<ProcedureMethod> reflectMethods(SqlName sqlName) throws SQLException, PublisherException {
  String schema=sqlName.getSchemaName();
  String type=sqlName.getTypeName();
  ArrayList<ProcedureMethod> methodl=new ArrayList<ProcedureMethod>();
  MethodInfo[] minfo=getMethodInfo(schema,type);
  for (int minfoi=0; minfoi < minfo.length; minfoi++) {
    String methodName=minfo[minfoi].methodName;
    String methodType=minfo[minfoi].methodType;
    String methodNo=minfo[minfoi].methodNo;
    int results=minfo[minfoi].results;
    int parameters=minfo[minfoi].parameters;
    boolean preApproved=true;
    if (m_methodFilter != null) {
      preApproved=m_methodFilter.acceptMethod(new ProcedureMethod(methodName,null,-1,null,null,null,null,null,0),true);
    }
    if (!preApproved) {
      continue;
    }
    int modifiers;
    modifiers=PublisherModifier.PUBLIC;
    if (methodType.equals("String_Node_Str")) {
      modifiers=modifiers ^ PublisherModifier.MAP;
    }
 else     if (methodType.equals("String_Node_Str")) {
      modifiers=modifiers ^ PublisherModifier.ORDER;
    }
    TypeClass returnType=null;
    ResultInfo resultInfo=null;
    if (results > 0) {
      resultInfo=getResultInfo(schema,type,methodName,methodNo);
      if (resultInfo != null) {
        try {
          String resultTypeOwner=resultInfo.resultTypeOwner;
          String resultTypeName=resultInfo.resultTypeName;
          String resultTypeSubname=resultInfo.resultTypeSubname;
          String resultTypeMod=resultInfo.resultTypeMod;
          boolean ncharFormOfUse=resultInfo.ncharFormOfUse;
          String resultMethodName=resultInfo.methodName;
          String resultMethodNo=resultInfo.methodNo;
          int sequence=resultInfo.sequence;
          returnType=m_reflector.addPlsqlDBType(resultTypeOwner,resultTypeName,resultTypeSubname,resultTypeMod,ncharFormOfUse,type,resultMethodName,resultMethodNo,sequence,this);
        }
 catch (        SQLException e) {
          e.printStackTrace();
        }
      }
    }
    int paramCount=parameters;
    List<TypeClass> paramTypes_v=new ArrayList<TypeClass>();
    List<String> paramNames_v=new ArrayList<String>();
    List<Integer> paramModes_v=new ArrayList<Integer>();
    List<Boolean> paramNCharFormOfUse_v=new ArrayList<Boolean>();
    int firstNoDefault=-1;
    boolean[] paramDefaults=new boolean[paramCount];
    if (paramCount > 0) {
      ParamInfo[] pinfo=null;
      pinfo=getParamInfo(schema,type,methodName,methodNo);
      String[] paramTypeOwner=new String[paramCount];
      String[] paramName=new String[paramCount];
      String[] paramTypeName=new String[paramCount];
      String[] paramTypeSubname=new String[paramCount];
      String[] paramTypeMod=new String[paramCount];
      String[] paramMode=new String[paramCount];
      boolean[] mcharFormOfUse=new boolean[paramCount];
      String[] paramMethodName=new String[paramCount];
      String[] paramMethodNo=new String[paramCount];
      int[] sequence=new int[paramCount];
      int[] objectId=new int[paramCount];
      for (int i=pinfo.length - 1; i >= 0; i--) {
        paramTypeOwner[i]=pinfo[i].paramTypeOwner;
        paramName[i]=pinfo[i].paramName;
        paramTypeName[i]=pinfo[i].paramTypeName;
        paramTypeSubname[i]=pinfo[i].paramTypeSubname;
        paramTypeMod[i]=pinfo[i].paramTypeMod;
        paramMode[i]=pinfo[i].paramMode;
        mcharFormOfUse[i]=pinfo[i].ncharFormOfUse;
        paramMethodName[i]=pinfo[i].methodName;
        paramMethodNo[i]=pinfo[i].methodNo;
        sequence[i]=pinfo[i].sequence;
        objectId[i]=pinfo[i].objectId;
      }
      paramDefaults=new boolean[pinfo.length];
      for (int i=pinfo.length - 1; i >= 0; i--) {
        paramDefaults[i]=hasDefault(objectId[i],paramMethodName[i],sequence[i],paramMethodNo[i]);
      }
      for (int i=pinfo.length - 1; i >= 0; i--) {
        if (!paramDefaults[i]) {
          firstNoDefault=i;
          break;
        }
      }
      for (int i=0; i < paramCount && paramMethodName[i] != null; i++) {
        try {
          paramNames_v.add(paramName[i]);
          String mode=paramMode[i];
          paramModes_v.add(Integer.valueOf((mode == null) ? ProcedureMethod.INOUT : (mode.equals("String_Node_Str") ? ProcedureMethod.IN : (mode.equals("String_Node_Str") ? ProcedureMethod.OUT : ProcedureMethod.INOUT))));
          paramTypes_v.add(m_reflector.addPlsqlDBType(paramTypeOwner[i],paramTypeName[i],paramTypeSubname[i],paramTypeMod[i],mcharFormOfUse[i],type,paramMethodName[i],paramMethodNo[i],sequence[i],this));
          paramNCharFormOfUse_v.add(Boolean.valueOf(mcharFormOfUse[i]));
        }
 catch (        SQLException e) {
          e.printStackTrace();
        }
      }
    }
    int len=paramTypes_v.size();
    if (len != paramCount) {
      System.err.println("String_Node_Str" + methodName + "String_Node_Str"+ paramCount+ "String_Node_Str"+ len);
    }
    TypeClass[] paramTypes=new TypeClass[len];
    String[] paramNames=new String[len];
    int[] paramModes=new int[len];
    boolean[] paramNCharFormOfUse=new boolean[len];
    for (int i=0; i < len; i++) {
      paramTypes[i]=(TypeClass)(paramTypes_v.get(i));
      paramNames[i]=paramNames_v.get(i);
      paramModes[i]=paramModes_v.get(i).intValue();
      paramNCharFormOfUse[i]=paramNCharFormOfUse_v.get(i).booleanValue();
    }
    paramTypes=generateDefaultArgsHolderParamTypes(paramTypes,paramDefaults,paramNCharFormOfUse);
    ProcedureMethod method=null;
    for (int paramLen=firstNoDefault + 1; paramLen <= paramCount; paramLen++) {
      if (this instanceof SqlPackageType && returnType != null && resultInfo != null && returnType.equals(SqlReflector.REF_CURSOR_TYPE)) {
        method=new PlsqlCursorMethod(type,methodName,methodNo,modifiers,resultInfo.sequence,paramTypes,paramNames,paramModes,paramDefaults,paramLen,false,m_reflector);
      }
 else       if (this instanceof SqlPackageType) {
        method=new PlsqlMethod(methodName,methodNo,modifiers,returnType,paramTypes,paramNames,paramModes,paramDefaults,paramLen);
      }
 else {
        method=new ProcedureMethod(methodName,methodNo,modifiers,returnType,paramTypes,paramNames,paramModes,paramDefaults,paramLen);
      }
      if (acceptMethod(method,false)) {
        methodl.add(method);
        if (returnType != null && resultInfo != null && returnType.equals(SqlReflector.REF_CURSOR_TYPE)) {
          method=new PlsqlCursorMethod(type,methodName,methodNo,modifiers,resultInfo.sequence,paramTypes,paramNames,paramModes,paramDefaults,paramLen,true,m_reflector);
          if (((PlsqlCursorMethod)method).getReturnColCount() != 0) {
            methodl.add(method);
          }
        }
      }
    }
  }
  Collections.sort(methodl);
  return methodl;
}