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

20
LINES

< > BotCompany Repo | #1002796 - findMethodNamed

JavaX fragment (include)

// This is a bit rough... finds static and non-static methods.

static Method findMethodNamed(O obj, String method) {
  if (obj == null) ret null;
  if (obj instanceof Class)
    ret findMethodNamed((Class) obj, method);
  ret findMethodNamed(obj.getClass(), method);
}

static Method findMethodNamed(Class c, String method) {
  while (c != null) {
    for (Method m : c.getDeclaredMethods())
      if (m.getName().equals(method)) {
        makeAccessible(m);
        ret m;
      }
    c = c.getSuperclass();
  }
  ret null;
}

Author comment

Began life as a copy of #1002180

download  show line numbers  debug dex   

Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz

No comments. add comment

Snippet ID: #1002796
Snippet name: findMethodNamed
Eternal ID of this version: #1002796/2
Text MD5: d4456f240c65b97cb6aeebb8a79bfd7f
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-08-31 14:49:46
Source code size: 546 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 441 / 464
Version history: 1 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1002796 & http://1002796.tinybrain.de