Unverified 提交 85d035f6 authored 作者: Noel Grandin's avatar Noel Grandin 提交者: GitHub

Merge pull request #814 from katzyn/java_specification

Method.isVarArgs() is available on all supported platforms
...@@ -301,29 +301,6 @@ public class FunctionAlias extends SchemaObjectBase { ...@@ -301,29 +301,6 @@ public class FunctionAlias extends SchemaObjectBase {
return source; return source;
} }
/**
* Checks if the given method takes a variable number of arguments. For Java
* 1.4 and older, false is returned. Example:
* <pre>
* public static double mean(double... values)
* </pre>
*
* @param m the method to test
* @return true if the method takes a variable number of arguments.
*/
static boolean isVarArgs(Method m) {
if ("1.5".compareTo(SysProperties.JAVA_SPECIFICATION_VERSION) > 0) {
return false;
}
try {
Method isVarArgs = m.getClass().getMethod("isVarArgs");
Boolean result = (Boolean) isVarArgs.invoke(m);
return result.booleanValue();
} catch (Exception e) {
return false;
}
}
/** /**
* Should the return value ResultSet be buffered in a local temporary file? * Should the return value ResultSet be buffered in a local temporary file?
* *
...@@ -361,7 +338,7 @@ public class FunctionAlias extends SchemaObjectBase { ...@@ -361,7 +338,7 @@ public class FunctionAlias extends SchemaObjectBase {
} }
if (paramCount > 0) { if (paramCount > 0) {
Class<?> lastArg = paramClasses[paramClasses.length - 1]; Class<?> lastArg = paramClasses[paramClasses.length - 1];
if (lastArg.isArray() && FunctionAlias.isVarArgs(method)) { if (lastArg.isArray() && method.isVarArgs()) {
varArgs = true; varArgs = true;
varArgClass = lastArg.getComponentType(); varArgClass = lastArg.getComponentType();
} }
......
...@@ -58,10 +58,10 @@ public class SysProperties { ...@@ -58,10 +58,10 @@ public class SysProperties {
/** /**
* System property <code>java.specification.version</code>.<br /> * System property <code>java.specification.version</code>.<br />
* It is set by the system. Examples: 1.4, 1.5, 1.6. * It is set by the system. Examples: 0.9 (on Android), 1.7, 1.8, 9, 10.
*/ */
public static final String JAVA_SPECIFICATION_VERSION = public static final String JAVA_SPECIFICATION_VERSION =
Utils.getProperty("java.specification.version", "1.4"); Utils.getProperty("java.specification.version", "1.7");
/** /**
* System property <code>line.separator</code> (default: \n).<br /> * System property <code>line.separator</code> (default: \n).<br />
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论