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).

1  
sO callWithVarargs_sentinel(O o, S methodName, O methodNotFoundSentinel, O... args) ctex {
2  
  if (o == null) null;
3  
  
4  
  if (o instanceof Class) {
5  
    Class c = (Class) o;
6  
    _MethodCache cache = callOpt_getCache(c);
7  
    
8  
    Method me = cache.findStaticMethod(methodName, args);
9  
    if (me != null)
10  
      ret invokeMethod(me, null, args);
11  
      
12  
    // try varargs
13  
    L<Method> methods = cache.cache.get(methodName);
14  
    if (methods != null) methodSearch: for (Method m : methods) {
15  
      continue unless m.isVarArgs();
16  
      continue unless isStaticMethod(m);
17  
      O[] newArgs = massageArgsForVarArgsCall(m, args);
18  
      if (newArgs != null)
19  
        ret invokeMethod(m, null, newArgs);
20  
    }
21  
    
22  
    methodNotFoundSentinel;
23  
  } else {
24  
    Class c = o.getClass();
25  
    _MethodCache cache = callOpt_getCache(c);
26  
27  
    Method me = cache.findMethod(methodName, args);
28  
    if (me != null)
29  
      ret invokeMethod(me, o, args);
30  
      
31  
    // try varargs
32  
    L<Method> methods = cache.cache.get(methodName);
33  
    if (methods != null) methodSearch: for (Method m : methods) {
34  
      continue unless m.isVarArgs();
35  
      O[] newArgs = massageArgsForVarArgsCall(m, args);
36  
      if (newArgs != null)
37  
        ret invokeMethod(m, o, newArgs);
38  
    }
39  
    
40  
    methodNotFoundSentinel;
41  
  }
42  
}

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