MCPcopy Create free account
hub / github.com/java-native-access/jna / concatenateVarArgs

Method concatenateVarArgs

src/com/sun/jna/Function.java:770–798  ·  view source on GitHub ↗

Concatenate varargs with normal args to obtain a simple argument array.

(Object[] inArgs)

Source from the content-addressed store, hash-verified

768 * array.
769 */
770 static Object[] concatenateVarArgs(Object[] inArgs) {
771 // If the final argument is an array of something other than
772 // primitives, Structure, or String, treat it as varargs and
773 // concatenate the previous arguments with the varargs elements.
774 if (inArgs != null && inArgs.length > 0) {
775 Object lastArg = inArgs[inArgs.length-1];
776 Class<?> argType = lastArg != null ? lastArg.getClass() : null;
777 if (argType != null && argType.isArray()) {
778 Object[] varArgs = (Object[])lastArg;
779 // Promote float varargs to double (https://github.com/java-native-access/jna/issues/463).
780 for (int i=0; i < varArgs.length; i++) {
781 if (varArgs[i] instanceof Float) {
782 varArgs[i] = (double)(Float)varArgs[i];
783 }
784 }
785 Object[] fullArgs = new Object[inArgs.length+varArgs.length];
786 System.arraycopy(inArgs, 0, fullArgs, 0, inArgs.length-1);
787 System.arraycopy(varArgs, 0, fullArgs, inArgs.length-1, varArgs.length);
788 // For convenience, always append a NULL argument to the end
789 // of varargs, whether the called API requires it or not. If
790 // it is not needed, it will be ignored, but if it *is*
791 // required, it avoids forcing the Java client to always
792 // explicitly add it.
793 fullArgs[fullArgs.length-1] = null;
794 inArgs = fullArgs;
795 }
796 }
797 return inArgs;
798 }
799
800 /** Varargs are only supported on 1.5+. */
801 static boolean isVarArgs(Method m) {

Callers 2

invokeMethod · 0.95
invokeMethod · 0.95

Calls 1

isArrayMethod · 0.80

Tested by

no test coverage detected