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

12
LINES

< > BotCompany Repo | #1035088 // preciseGetOrCallMethod

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

Libraryless. Click here for Pure Java version (7538L/42K).

// TODO: better error message when neither field nor method found

sO preciseGetOrCallMethod(O object, S name) {
  if (object == null) null;
  
  // could optimize more for sure
  if (canCallWithVarargs(object, name))
    ret call(object, name);
    
  // TODO: better error message when neither field nor method found
  ret _get(object, name);
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1035088
Snippet name: preciseGetOrCallMethod
Eternal ID of this version: #1035088/3
Text MD5: e508bdc362d52de4edadc29804047423
Transpilation MD5: 06293548edaa20c640bd73299187fa09
Author: stefan
Category: javax / reflection
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-29 20:56:47
Source code size: 357 bytes / 12 lines
Pitched / IR pitched: No / No
Views / Downloads: 143 / 207
Version history: 2 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1035539 - preciseGetOrCallMethod_sentinel