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

42
LINES

< > BotCompany Repo | #1035533 // callWithVarargs_sentinel

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (9161L/50K).

sO callWithVarargs_sentinel(O o, S methodName, O methodNotFoundSentinel, O... args) ctex {
  if (o == null) null;
  
  if (o instanceof Class) {
    Class c = (Class) o;
    _MethodCache cache = callOpt_getCache(c);
    
    Method me = cache.findStaticMethod(methodName, args);
    if (me != null)
      ret invokeMethod(me, null, args);
      
    // try varargs
    L<Method> methods = cache.cache.get(methodName);
    if (methods != null) methodSearch: for (Method m : methods) {
      continue unless m.isVarArgs();
      continue unless isStaticMethod(m);
      O[] newArgs = massageArgsForVarArgsCall(m, args);
      if (newArgs != null)
        ret invokeMethod(m, null, newArgs);
    }
    
    methodNotFoundSentinel;
  } else {
    Class c = o.getClass();
    _MethodCache cache = callOpt_getCache(c);

    Method me = cache.findMethod(methodName, args);
    if (me != null)
      ret invokeMethod(me, o, args);
      
    // try varargs
    L<Method> methods = cache.cache.get(methodName);
    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);
    }
    
    methodNotFoundSentinel;
  }
}

Author comment

Began life as a copy of #1022095

download  show line numbers  debug dex  old transpilations   

Travelled to 2 computer(s): mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1035533
Snippet name: callWithVarargs_sentinel
Eternal ID of this version: #1035533/1
Text MD5: c70da5c74eb755a7e6cbab7e74c56b6a
Transpilation MD5: bb7d81d4cfe321a6427f76b1ed8765a4
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-06-04 09:07:06
Source code size: 1314 bytes / 42 lines
Pitched / IR pitched: No / No
Views / Downloads: 58 / 83
Referenced in: [show references]