@Override
  public Object evaluate(DeferredObject[] arguments) throws HiveException {
    
    // Try to find the class
    // Skip class loading if the class name didn't change
    boolean classNameChanged = false;
    
    Object newClassName = arguments[0].get();
    
    // We compare class name/method name using ObjectInspectorUtils.compare(...), to avoid
    // any object conversion (which may cause object creation) in most cases, when the class
    // name/method name is constant Java String, or constant Text (StringWritable).
    if (className == null || ObjectInspectorUtils.compare(className, classNameOI, newClassName,
        inputClassNameOI) != 0) {
      className = ObjectInspectorUtils.copyToStandardObject(newClassName, inputClassNameOI);
      String classNameString = classNameOI.getPrimitiveJavaObject(className);
      try {
        c = JavaUtils.loadClass(classNameString);
      } catch (ClassNotFoundException ex) {
        throw new HiveException(String.format("UDFReflect evaluate error while loading class %s", classNameString), ex);
      }
      try {
        o = null;
        o = ReflectionUtils.newInstance(c, null);
      } catch (Exception e) {
        if (e.getCause() instanceof NoSuchMethodException){
          // still could be okay while using a static method of a class that hasn't got a default/parameterless constructor
          LOG.trace("ignoring NoSuchMethodException while instantiating class", e);
        }else{
          throw new HiveException(String.format("UDFReflect evaluate error while instantiating class %s", classNameString), e);
        }
      }
      classNameChanged = true;
    }
    
    // Try to find the method
    // Skip method finding if the method name didn't change, and class name didn't change.
    Object newMethodName = arguments[1].get();

    if (methodName == null || ObjectInspectorUtils.compare(methodName, methodNameOI, newMethodName,
        inputMethodNameOI) != 0 || classNameChanged) {
      methodName = ObjectInspectorUtils.copyToStandardObject(newMethodName, inputMethodNameOI);
      String methodNameString = methodNameOI.getPrimitiveJavaObject(methodName);
      try {
        m = findMethod(c, methodNameString, String.class, false);
      } catch (Exception e) {
        throw new HiveException("UDFReflect getMethod ", e);
      }
    }
    
    Object[] parameterJavaValues = setupParameters(arguments, 2);

    try {
      return String.valueOf(m.invoke(o, parameterJavaValues));
    } catch (Exception e1) {
      System.err.println("UDFReflect evaluate " + e1 + " method = " + m + " args = " +
          Arrays.asList(parameterJavaValues));
    }
    return null;
  }
A simple generic udf to call java static functions via reflection.
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFReflect.java