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

42
LINES

< > BotCompany Repo | #1022095 - call_withVarargs

JavaX fragment (include)

1  
static O call_withVarargs(O o, S method, O... args) ctex {
2  
  if (o == null) null;
3  
  
4  
  if (o instanceof Class) {
5  
    Class c = (Class) o;
6  
    _MethodCache cache = callOpt_getCache(c);
7  
    
8  
    Method me = cache.findStaticMethod(method, args);
9  
    if (me != null)
10  
      ret invokeMethod(me, null, args);
11  
      
12  
    // try varargs
13  
    L<Method> methods = cache.cache.get(method);
14  
    if (methods != null) methodSearch: for (Method m : methods) {
15  
      continue unless m.isVarArgs();
16  
      continue unless isStaticMethod(m);
17  
      O[] newArgs = massageArgsForVarArgsCall(m, args);
18  
      if (newArgs != null)
19  
        ret invokeMethod(m, null, newArgs);
20  
    }
21  
    
22  
    fail("Method " + c.getName() + "." + method + "(" + joinWithComma(classNames(args)) + ") not found");
23  
  } else {
24  
    Class c = o.getClass();
25  
    _MethodCache cache = callOpt_getCache(c);
26  
27  
    Method me = cache.findMethod(method, args);
28  
    if (me != null)
29  
      ret invokeMethod(me, o, args);
30  
      
31  
    // try varargs
32  
    L<Method> methods = cache.cache.get(method);
33  
    if (methods != null) methodSearch: for (Method m : methods) {
34  
      continue unless m.isVarArgs();
35  
      O[] newArgs = massageArgsForVarArgsCall(m, args);
36  
      if (newArgs != null)
37  
        ret invokeMethod(m, o, newArgs);
38  
    }
39  
    
40  
    fail("Method " + c.getName() + "." + method + "(" + joinWithComma(classNames(args)) + ") not found");
41  
  }
42  
}

Author comment

Began life as a copy of #1018503

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: #1022095
Snippet name: call_withVarargs
Eternal ID of this version: #1022095/12
Text MD5: 4eb20415f882beb89d9da0e379e32d06
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-12-12 00:19:57
Source code size: 1422 bytes / 42 lines
Pitched / IR pitched: No / No
Views / Downloads: 204 / 247
Version history: 11 change(s)
Referenced in: [show references]