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

13
LINES

< > BotCompany Repo | #1035539 // preciseGetOrCallMethod_sentinel

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

Libraryless. Click here for Pure Java version (9290L/51K).

sO preciseGetOrCallMethod_sentinel(O object, S name, O sentinel) {
  if (object == null) null;
  
  // could optimize more for sure
  if (canCallWithVarargs(object, name))
    ret call(object, name);
    
  Field f = getField(object, name);
  if (f != null)
    ret fieldGet(f, object);
  
  ret sentinel;
}

Author comment

Began life as a copy of #1035088

download  show line numbers  debug dex  old transpilations   

Travelled to 2 computer(s): elmgxqgtpvxh, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1035539
Snippet name: preciseGetOrCallMethod_sentinel
Eternal ID of this version: #1035539/3
Text MD5: 86ce0f4e5f47f538865a33e2303d865f
Transpilation MD5: f96a241060ed51f1d77232642405a1ef
Author: stefan
Category: javax / reflection
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-06-10 23:55:20
Source code size: 319 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 131 / 188
Version history: 2 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)