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

35
LINES

< > BotCompany Repo | #1022098 // callOpt_withVarargs

JavaX fragment (include)

sO callOpt_withVarargs(O o, S method, O... args) ctex {
  if (o == null) null;
  
  if (o instanceof Class) {
    Class c = (Class) o;
    _MethodCache cache = callOpt_getCache(c);
    
    Method me = cache.findMethod(method, args);
    if (me == null) {
      // TODO: varargs
      null;
    }
    if ((me.getModifiers() & Modifier.STATIC) == 0)
      null;
    ret invokeMethod(me, null, args);
  } else {
    Class c = o.getClass();
    _MethodCache cache = callOpt_getCache(c);

    Method me = cache.findMethod(method, args);
    if (me != null)
      ret invokeMethod(me, o, args);
      
    // try varargs
    L<Method> methods = cache.cache.get(method);
    if (methods != null) methodSearch: for (Method m : methods) {
      continue unless m.isVarArgs();
      O[] newArgs = massageArgsForVarArgsCall(m, args);
      if (newArgs != null)
        ret invokeMethod(m, o, newArgs);
    }
    
    null;
  }
}

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: 268 / 592
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)