兼容原始类型数组无法强转为Object[]的问题,
java内原始类型数组转化为对象数组会特别麻烦,所以本方法穷举出所有的原始类型数组进行强转
351266
public static Object[] toObjectArray(Object array) {
        //fixme 以下写法太丑陋，其实可以简单实现
        if (!array.getClass().isArray()) {
            throw new IllegalArgumentException("入参必须是数组");
        }
        if (int[].class.isInstance(array)) {
            int[] intArr = int[].class.cast(array);
            Integer[] objArr = new Integer[intArr.length];
            for (int i = 0; i < intArr.length; i++) {
                objArr[i] = intArr[i];
            }
            return objArr;
        }
        if (long[].class.isInstance(array)) {
            long[] longArr = long[].class.cast(array);
            Long[] objArr = new Long[longArr.length];
            for (int i = 0; i < longArr.length; i++) {
                objArr[i] = longArr[i];
            }
            return objArr;
        }
        if (short[].class.isInstance(array)) {
            short[] arr = short[].class.cast(array);
            Short[] objArr = new Short[arr.length];
            for (int i = 0; i < arr.length; i++) {
                objArr[i] = arr[i];
            }
            return objArr;
        }
        if (float[].class.isInstance(array)) {
            float[] arr = float[].class.cast(array);
            Float[] objArr = new Float[arr.length];
            for (int i = 0; i < arr.length; i++) {
                objArr[i] = arr[i];
            }
            return objArr;
        }
        if (double[].class.isInstance(array)) {
            double[] arr = double[].class.cast(array);
            Double[] objArr = new Double[arr.length];
            for (int i = 0; i < arr.length; i++) {
                objArr[i] = arr[i];
            }
            return objArr;
        }
        if (char[].class.isInstance(array)) {
            char[] arr = char[].class.cast(array);
            Character[] objArr = new Character[arr.length];
            for (int i = 0; i < arr.length; i++) {
                objArr[i] = arr[i];
            }
            return objArr;
        }
        if (byte[].class.isInstance(array)) {
            byte[] arr = byte[].class.cast(array);
            Byte[] objArr = new Byte[arr.length];
            for (int i = 0; i < arr.length; i++) {
                objArr[i] = arr[i];
            }
            return objArr;
        }
        if (boolean[].class.isInstance(array)) {
            boolean[] arr = boolean[].class.cast(array);
            Boolean[] objArr = new Boolean[arr.length];
            for (int i = 0; i < arr.length; i++) {
                objArr[i] = arr[i];
            }
            return objArr;
        }
        return Object[].class.cast(array);
    }
256422
function (forms, serializeArray) {
            // 名值键值对序列化,数组元素名字前不加 []
            return querystring.stringify(FormSerializer.getFormData(forms), undefined, undefined, serializeArray || false);
        }
677467
private static String[] fmtObjectToStrArray(Object object) {
        if (object == null) {
            return null;
        }
        if (object instanceof String[]) {
            return (String[]) object;
        }
        if (object instanceof Collection) {
            Collection c = (Collection) object;
            return (String[]) c.toArray(new String[c.size()]);
        }
        return null;
    }
1276066
function _object2array(input) {

		var index,
			subindex = 0,
			result = [];

		if (typeof input !== 'object' || !input)

			return input;

		for (index in input) {

			if (subindex++ !== Number(index))

				return input;

			result.push(input[index]);

		}

		return result;

	}
742774
protected void invoke(Object pObject) throws APPErrorException {
        try {
            Method method =tgtools.util.ReflectionUtil.findMethod(mService.getClass(),getMethodName(),getModelClass());
            method.invoke(mService,pObject);
        }catch (Exception ex)
        {
            throw new APPErrorException("执行方法错误；原因："+ex.getCause().getMessage(),ex);
        }
    }
1087195
@Override public Object invokeMethod(final String name, final Object arguments) {
    if (GantState.dryRun) {
      if (GantState.verbosity > GantState.SILENT) {
        final StringBuilder sb = new StringBuilder();
        int padding = 9 - name.length();
        if (padding < 0) { padding = 0; }
        sb.append("         ".substring(0, padding) + '[' + name + "] ");
        final Object[] args = (Object[]) arguments;
        if (args[0] instanceof Map<?,?>) {
          //////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Eclipse and IntelliJ IDEA warn that (Map) is not a proper cast but using the
          // cast (Map<?,?>) causes a type check error due to the capture algorithm.
          //
          //  TODO : Fix this rather than use a SuppressWarnings.
          //////////////////////////////////////////////////////////////////////////////////////////////////////////
          @SuppressWarnings({ "unchecked", "rawtypes" } ) final Iterator<Map.Entry<?,?>> i =((Map) args[0]).entrySet().iterator();
          while (i.hasNext()) {
            final Map.Entry<?,?> e = i.next();
            sb.append(e.getKey() + " : '" + e.getValue() + '\'');
            if (i.hasNext()) { sb.append(", "); }
          }
          sb.append('\n');
          getProject().log(sb.toString());
          if (args.length == 2) {((Closure<?>) args[1]).call(); }
        }
        else if (args[0] instanceof Closure) { ((Closure<?>) args[0]).call(); }
        else { throw new RuntimeException("Unexpected type of parameter to method " + name); }
      }
      return null;
    }
    return super.invokeMethod(name, arguments);
  }
321717
protected void assertArrayHasLengthAndAllElementsNotNull(final Object[] array, final Integer length) throws ArgumentCountException, ArgumentNullException {

		if (array.length != length) {
			throw ArgumentCountException.notEqual(array.length, length);
		}

		for (final Object element : array) {

			if (element == null) {
				throw new ArgumentNullException();
			}
		}
	}
370874
public static void main(String... args) throws Exception {

        String string = "SELECT :expr1, #($expr2.class),"
                + " WHERE #if(:expr3) {e = $expr3} #else {e IS NULL}"
                + "#for(variant in $expr4.bytes) { AND c = :variant}" // NL
                + " {AND d = :expr-5}? {AND f = $expr6}?" // NL
                + " BY #!(:expr7) ASC";

        // 在输入中查找  PREFIX 字符
        Matcher matcher = PATTERN_KEYWORD.matcher(string);

        int position = 0;

        while (matcher.find(position)) {

            System.out.println("===============================");
            System.out.println("group 0: " + matcher.group(0));
            System.out.println("group 1: " + matcher.group(1));
            System.out.println("group 2: " + matcher.group(2));
            System.out.println("group 3: " + matcher.group(3));

            position = matcher.end();
        }

        // 在循环表达式中查找
        matcher = PATTERN_IN.matcher("variant in :expr5");

        if (matcher.matches()) {

            System.out.println("===============================");
            System.out.println("group 0: " + matcher.group(0));
            System.out.println("group 1: " + matcher.group(1));
            System.out.println("group 2: " + matcher.group(2));
        }

        // 编译下列语句
        ExqlPattern pattern = new ExqlCompiler(string).compile();

        ExqlContext context = new ExqlContextImpl();

        HashMap<String, Object> map = new HashMap<String, Object>();

        map.put("expr1", "expr1");
        map.put("expr2", "expr2");
        map.put("expr3", "expr3");
        map.put("expr4", "expr4");
        map.put("expr5", "expr5");
        // map.put("expr6", "expr6");
        map.put("expr7", "expr7");

        pattern.execute(context, map, map);
        System.out.println(context.flushOut());
        System.out.println(Arrays.toString(context.getArgs()));
    }
902791
Object[] getNewRowData(Session session) {

        Object[] data = new Object[getColumnCount()];
        int      i;

        if (hasDefaultValues) {
            for (i = 0; i < getColumnCount(); i++) {
                Expression def = colDefaults[i];

                if (def != null) {
                    data[i] = def.getValue(session, colTypes[i]);
                }
            }
        }

        return data;
    }
468795
public int getArrayLength() throws ReflectorException  {
		
		if(object == null) {
			logger.error("object is null: did you specify it using the 'inspect()' method?");
			throw new ReflectorException("object is null: did you specify it using the 'inspect()' method?");
		}
		
		int length = 0;
		if(object.getClass().isArray()) {
			length = Array.getLength(object);
		} else if (object instanceof List<?>){
			length = ((List<?>)object).size();
		} else {
			throw new ReflectorException("object is not an array or a list");
		}
		return length;
	}
903791
function objectFromPairs(array) {
  return Array.isArray(array) && array.reduce((a, v) => (a[v[0]] = v[1], a), {});
}
1299145
function(object) {
		var methods = Array.prototype.slice.call(arguments).slice(1);
		if (!methods.length) {
			methods = gui.Object.ownmethods(object).filter(function(name) {
				return name[0] !== "_"; // exclude private methods
			});
		}
		methods.forEach(function(name) {
			object[name] = object[name].bind(object);
		});
		return object;
	}
1166038
@Override
    public byte[] serialize(Object obj) throws IOException {
		KryoHolder kryoHolder = null;
		if (obj == null)
			throw new RuntimeException("obj can not be null");
		try {
			kryoHolder = KryoPoolImpl.getInstance().get();
			kryoHolder.output.clear(); // clear Output -->每次调用的时候 重置
			kryoHolder.kryo.writeClassAndObject(kryoHolder.output, obj);
			return kryoHolder.output.toBytes();// 无法避免拷贝 ~~~
		} catch (RuntimeException e) {
			throw new RuntimeException(e);
		} finally {
			if (kryoHolder != null) {
				KryoPoolImpl.getInstance().offer(kryoHolder);
			}
			// obj = null; //GC
		}
    }
95034
function () {
    var pattern = /\{(\d+)\}/g;
    //safer way to convert a pseudo array to an object array
    var args = Array.prototype.slice.call(arguments);
    var s = args.shift();
    return s.replace(pattern, function(c, d) {
      var replacement = args[d] ;
      if (lib.isNull(replacement)) {
        replacement = "";
      }
      return replacement;
    });
  }
22107
private static String dumpArrayString(Object[] arguments) {
    StringBuilder argBuf = new StringBuilder("[");
    for (int i = 0; i < arguments.length; i++) {
      if (i > 0) {
        argBuf.append(", ");
      }
      argBuf.append(DefaultGroovyMethods.dump(arguments[i]));
    }
    argBuf.append("]");
    return argBuf.toString();
  }
191236
function( object, method ) {
		var args = Array.prototype.slice.call(arguments, 2);
		return function() {
			var args2 = [this].concat(args, $.makeArray(arguments));
			return method.apply(object, args2);
		};
	}
674832
function formalizeWrap(wrap) {
    const result = {before: '', after: ''};

    if ((typeof wrap === 'string' && wrap.length > 0) || typeof wrap === 'number') {
        result.before = result.after = wrap;
    } else if (Array.isArray(wrap) && wrap.length > 0) {
        result.before = [].slice.call(wrap, 0, 1)[0];
        result.after = wrap.length > 1 ? [].slice.call(wrap, 1, 2)[0] : result.before;
    } else if (_.isPlainObject(wrap)) {
        let i = 0;

        // crappy method getting the value of the first and second item in object
        for (let el in wrap) {
            if (!wrap.hasOwnProperty(el)) {
                continue;
            }

            if (i < 2) {
                result.before = wrap[el];
            }

            i++;
        }

        // set value of after to the value of before if after is empty
        result.after = result.after.length < 1 ? result.before : result.after;
    }

    return result;
}