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

18
LINES

< > BotCompany Repo | #1034786 // massageArgsForVarArgsCall backup

JavaX fragment (include)

1  
static O[] massageArgsForVarArgsCall(Executable m, O[] args) {
2  
  Class<?>[] types = m.getParameterTypes();
3  
  int n = types.length-1, nArgs = args.length;
4  
  if (nArgs < n) null;
5  
  for i to n:
6  
    if (!argumentCompatibleWithType(args[i], types[i]))
7  
      null;
8  
  Class varArgType = types[n].getComponentType();
9  
  for (int i = n; i < nArgs; i++)
10  
    if (!argumentCompatibleWithType(args[i], varArgType))
11  
      null;
12  
  O[] newArgs = new O[n+1];
13  
  arraycopy(args, 0, newArgs, 0, n);
14  
  O[] varArgs = arrayOfType(varArgType, nArgs-n);
15  
  arraycopy(args, n, varArgs, 0, nArgs-n);
16  
  newArgs[n] = varArgs;
17  
  ret newArgs;
18  
}

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: 66 / 82
Referenced in: [show references]