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

35
LINES

< > BotCompany Repo | #1022098 // callOpt_withVarargs

JavaX fragment (include)

1  
sO callOpt_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.findMethod(method, args);
9  
    if (me == null) {
10  
      // TODO: varargs
11  
      null;
12  
    }
13  
    if ((me.getModifiers() & Modifier.STATIC) == 0)
14  
      null;
15  
    ret invokeMethod(me, null, args);
16  
  } else {
17  
    Class c = o.getClass();
18  
    _MethodCache cache = callOpt_getCache(c);
19  
20  
    Method me = cache.findMethod(method, args);
21  
    if (me != null)
22  
      ret invokeMethod(me, o, args);
23  
      
24  
    // try varargs
25  
    L<Method> methods = cache.cache.get(method);
26  
    if (methods != null) methodSearch: for (Method m : methods) {
27  
      continue unless m.isVarArgs();
28  
      O[] newArgs = massageArgsForVarArgsCall(m, args);
29  
      if (newArgs != null)
30  
        ret invokeMethod(m, o, newArgs);
31  
    }
32  
    
33  
    null;
34  
  }
35  
}

Author comment

Began life as a copy of #1022095

download  show line numbers  debug dex  old transpilations   

Travelled to 16 computer(s): bhatertpkbcr, cfunsshuasjs, ekrmjmnbrukm, elmgxqgtpvxh, gjtlkbvenryc, ishqpsrjomds, lnbujpyubztb, mowyntqkapby, mqqgnosmbjvj, podlckwnjdmb, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, whxojlpjdney, wnsclhtenguj

No comments. add comment

Snippet ID: #1022098
Snippet name: callOpt_withVarargs
Eternal ID of this version: #1022098/1
Text MD5: df9bc875767eab04030346c78187c1ef
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-03-07 20:22:47
Source code size: 952 bytes / 35 lines
Pitched / IR pitched: No / No
Views / Downloads: 272 / 597
Referenced in: [show references]