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

18
LINES

< > BotCompany Repo | #1022097 - massageArgsForVarArgsCall - TODO: optimize for case where there is a single O... parameter

JavaX fragment (include)

static O[] massageArgsForVarArgsCall(Method 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;
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1022097
Snippet name: massageArgsForVarArgsCall - TODO: optimize for case where there is a single O... parameter
Eternal ID of this version: #1022097/2
Text MD5: 4bb171c2fb80c969e9d513b8844eaacf
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-04-06 19:40:47
Source code size: 624 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 155 / 178
Version history: 1 change(s)
Referenced in: [show references]