private PrimitiveObjectInspectorUtils.PrimitiveTypeEntry getTypeFor(Class<?> retType)
      throws UDFArgumentException {
    PrimitiveObjectInspectorUtils.PrimitiveTypeEntry entry =
        PrimitiveObjectInspectorUtils.getTypeEntryFromPrimitiveJavaType(retType);
    if (entry == null) {
      entry = PrimitiveObjectInspectorUtils.getTypeEntryFromPrimitiveJavaClass(retType);
    }
    if (entry == null) {
      throw new UDFArgumentException("Invalid return type " + retType);
    }
    return entry;
  }
A simple generic udf to call java functions via reflection.
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFReflect2.java