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

14
LINES

< > BotCompany Repo | #1034748 // invokeMethodWithWidening

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

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

1  
sO invokeMethodWithWidening(Method m, O o, O... args) ctex {
2  
  try {
3  
    Class<?>[] types = m.getParameterTypes();
4  
    int n = types.length;
5  
    O[] args2 = new[n];
6  
    for i to n:
7  
      args2[i] = convertPrimitiveIfNecessary(args[i], types[i]);
8  
    ret m.invoke(o, args2);
9  
  } catch (InvocationTargetException e) {
10  
    throw rethrow(getExceptionCause(e));
11  
  } catch (IllegalArgumentException e) {
12  
    throw new IllegalArgumentException(e.getMessage() + " - was calling: " + m + ", args: " + joinWithSpace(classNames(args)));
13  
  }
14  
}

Author comment

Began life as a copy of #1013187

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1034748
Snippet name: invokeMethodWithWidening
Eternal ID of this version: #1034748/2
Text MD5: aac0d0212b131b7d17daf3f4cf1a960d
Transpilation MD5: c6e5841b1efb89d2fce6879647931406
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-08 02:55:06
Source code size: 544 bytes / 14 lines
Pitched / IR pitched: No / No
Views / Downloads: 140 / 203
Version history: 1 change(s)
Referenced in: [show references]