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   

Travelled to 10 computer(s): bhatertpkbcr, cfunsshuasjs, ishqpsrjomds, lnbujpyubztb, mqqgnosmbjvj, podlckwnjdmb, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, whxojlpjdney

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

Formerly at http://tinybrain.de/1022098 & http://1022098.tinybrain.de