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

31
LINES

< > BotCompany Repo | #1026818 // canCallWithVarargs

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

Libraryless. Click here for Pure Java version (2162L/14K).

sbool canCallWithVarargs(O o, S method, O... args) {
  if (o == null) false;
  
  if (o instanceof Class) {
    Class c = (Class) o;
    _MethodCache cache = callOpt_getCache(c);
    
    if (cache.findStaticMethod(method, args) != null) true;

    // try varargs
    L<Method> methods = cache.cache.get(method);
    if (methods != null) methodSearch: for (Method m : methods) {
      continue unless m.isVarArgs() && isStaticMethod(m);
      if (massageArgsForVarArgsCall(m, args) != null) true;
    }
  } else {
    Class c = o.getClass();
    _MethodCache cache = callOpt_getCache(c);

    if (cache.findMethod(method, args) != null) true;
      
    // try varargs
    L<Method> methods = cache.cache.get(method);
    if (methods != null) methodSearch: for (Method m : methods) {
      continue unless m.isVarArgs();
      if (massageArgsForVarArgsCall(m, args) != null) true;
    }
  }
  
  false;
}

Author comment

Began life as a copy of #1022095

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1026818
Snippet name: canCallWithVarargs
Eternal ID of this version: #1026818/3
Text MD5: 8d9be5d790a4833f2a5451b57e8d22e4
Transpilation MD5: 4dbed4fb095a4b669ffbdf871793d885
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-01-23 22:50:20
Source code size: 934 bytes / 31 lines
Pitched / IR pitched: No / No
Views / Downloads: 169 / 221
Version history: 2 change(s)
Referenced in: [show references]