Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

18
LINES

< > BotCompany Repo | #1034786 // massageArgsForVarArgsCall backup

JavaX fragment (include)

static O[] massageArgsForVarArgsCall(Executable m, O[] args) {
  Class<?>[] types = m.getParameterTypes();
  int n = types.length-1, nArgs = args.length;
  if (nArgs < n) null;
  for i to n:
    if (!argumentCompatibleWithType(args[i], types[i]))
      null;
  Class varArgType = types[n].getComponentType();
  for (int i = n; i < nArgs; i++)
    if (!argumentCompatibleWithType(args[i], varArgType))
      null;
  O[] newArgs = new O[n+1];
  arraycopy(args, 0, newArgs, 0, n);
  O[] varArgs = arrayOfType(varArgType, nArgs-n);
  arraycopy(args, n, varArgs, 0, nArgs-n);
  newArgs[n] = varArgs;
  ret newArgs;
}

Author comment

Began life as a copy of #1022097

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1034786
Snippet name: massageArgsForVarArgsCall backup
Eternal ID of this version: #1034786/1
Text MD5: 04bf13e5cd2e5f8853e35f3645fc12ff
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-08 10:50:51
Source code size: 628 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 62 / 76
Referenced in: [show references]