1 | static Method findStaticMethod(Class c, String method, Object... args) { |
2 | Class _c = c; |
3 | while (c != null) { |
4 | for (Method m : c.getDeclaredMethods()) { |
5 | if (!m.getName().equals(method)) |
6 | continue; |
7 | |
8 | if ((m.getModifiers() & Modifier.STATIC) == 0 || !findStaticMethod_checkArgs(m, args)) |
9 | continue; |
10 | |
11 | return m; |
12 | } |
13 | c = c.getSuperclass(); |
14 | } |
15 | return null; |
16 | } |
17 | |
18 | static boolean findStaticMethod_checkArgs(Method m, Object[] args) { |
19 | Class<?>[] types = m.getParameterTypes(); |
20 | if (types.length != args.length) |
21 | return false; |
22 | for (int i = 0; i < types.length; i++) |
23 | if (!(args[i] == null || isInstanceX(types[i], args[i]))) |
24 | return false; |
25 | return true; |
26 | } |
Began life as a copy of #1001199
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1001255 |
Snippet name: | findStaticMethod |
Eternal ID of this version: | #1001255/2 |
Text MD5: | 4f11d775fe72a4e99360bb75d9e5d018 |
Author: | stefan |
Category: | |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-04-05 11:26:02 |
Source code size: | 730 bytes / 26 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 769 / 976 |
Version history: | 1 change(s) |
Referenced in: | [show references] |