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

23
LINES

< > BotCompany Repo | #1034768 // callWithoutVarargs

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

Libraryless. Click here for Pure Java version (5264L/29K).

sO callWithoutVarargs(O o, S methodName, 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);
      
    fail("Method " + c.getName() + "." + methodName + "(" + joinWithComma(classNames(args)) + ") not found");
  } else {
    Class c = o.getClass();
    _MethodCache cache = callOpt_getCache(c);

    Method me = cache.findMethod(methodName, args);
    if (me != null)
      ret invokeMethod(me, o, args);
      
    fail("Method " + c.getName() + "." + methodName + "(" + joinWithComma(classNames(args)) + ") not found");
  }
}

Author comment

Began life as a copy of #1022095

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1034768
Snippet name: callWithoutVarargs
Eternal ID of this version: #1034768/1
Text MD5: 9fd59a287afc7535a0f5f55e3035fb5e
Transpilation MD5: 4949684b0d8886e450accb8cdf7496c5
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-08 06:48:15
Source code size: 763 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 117 / 173
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)