Program: 51065
Project: 51065
Buggy source:
/** 
 * Creates a new udf instance from the given udf class.
 * @param udfClass the class to create new instance for
 * @param functionName Function name, or null
 * @return an instance of UserDefinedFunction
 */
public static UserDefinedFunction createUdf(Class<? extends UserDefinedFunction> udfClass,String functionName){
  UserDefinedFunction udf;
  String className=udfClass.getName();
  String functionNameOrEmpty=functionName == null ? "String_Node_Str" : functionName;
  Constructor<?> constructor;
  Object[] args={};
  try {
    constructor=udfClass.getConstructor(String.class);
    if (Modifier.isPublic(constructor.getModifiers())) {
      args=new Object[]{functionName};
    }
 else {
      constructor=null;
    }
  }
 catch (  NoSuchMethodException e) {
    constructor=null;
  }
  if (constructor == null) {
    try {
      constructor=udfClass.getConstructor();
      if (Modifier.isPublic(constructor.getModifiers())) {
        args=new Object[]{};
      }
 else {
        constructor=null;
      }
    }
 catch (    NoSuchMethodException e) {
      constructor=null;
    }
  }
  if (constructor == null) {
    throw MondrianResource.instance().UdfClassWrongIface.ex(functionNameOrEmpty,className,UserDefinedFunction.class.getName());
  }
  try {
    udf=(UserDefinedFunction)constructor.newInstance(args);
  }
 catch (  InstantiationException e) {
    throw MondrianResource.instance().UdfClassWrongIface.ex(functionNameOrEmpty,className,UserDefinedFunction.class.getName());
  }
catch (  IllegalAccessException e) {
    throw MondrianResource.instance().UdfClassWrongIface.ex(functionName,className,UserDefinedFunction.class.getName());
  }
catch (  ClassCastException e) {
    throw MondrianResource.instance().UdfClassWrongIface.ex(functionNameOrEmpty,className,UserDefinedFunction.class.getName());
  }
catch (  InvocationTargetException e) {
    throw MondrianResource.instance().UdfClassWrongIface.ex(functionName,className,UserDefinedFunction.class.getName());
  }
  return udf;
}

Fixed version (ground truth):
/** 
 * Creates a new udf instance from the given udf class.
 * @param udfClass the class to create new instance for
 * @param functionName Function name, or null
 * @return an instance of UserDefinedFunction
 */
public static UserDefinedFunction createUdf(Class<? extends UserDefinedFunction> udfClass,String functionName){
  UserDefinedFunction udf;
  String className=udfClass.getName();
  String functionNameOrEmpty=functionName == null ? "String_Node_Str" : functionName;
  Constructor<?> constructor;
  Object[] args={};
  if (!Modifier.isPublic(udfClass.getModifiers()) || (udfClass.getEnclosingClass() != null && !Modifier.isStatic(udfClass.getModifiers()))) {
    throw MondrianResource.instance().UdfClassMustBePublicAndStatic.ex(functionName,className);
  }
  try {
    constructor=udfClass.getConstructor(String.class);
    if (Modifier.isPublic(constructor.getModifiers())) {
      args=new Object[]{functionName};
    }
 else {
      constructor=null;
    }
  }
 catch (  NoSuchMethodException e) {
    constructor=null;
  }
  if (constructor == null) {
    try {
      constructor=udfClass.getConstructor();
      if (Modifier.isPublic(constructor.getModifiers())) {
        args=new Object[]{};
      }
 else {
        constructor=null;
      }
    }
 catch (    NoSuchMethodException e) {
      constructor=null;
    }
  }
  if (constructor == null) {
    throw MondrianResource.instance().UdfClassWrongIface.ex(functionNameOrEmpty,className,UserDefinedFunction.class.getName());
  }
  try {
    udf=(UserDefinedFunction)constructor.newInstance(args);
  }
 catch (  InstantiationException e) {
    throw MondrianResource.instance().UdfClassWrongIface.ex(functionNameOrEmpty,className,UserDefinedFunction.class.getName());
  }
catch (  IllegalAccessException e) {
    throw MondrianResource.instance().UdfClassWrongIface.ex(functionName,className,UserDefinedFunction.class.getName());
  }
catch (  ClassCastException e) {
    throw MondrianResource.instance().UdfClassWrongIface.ex(functionNameOrEmpty,className,UserDefinedFunction.class.getName());
  }
catch (  InvocationTargetException e) {
    throw MondrianResource.instance().UdfClassWrongIface.ex(functionName,className,UserDefinedFunction.class.getName());
  }
  return udf;
}