MCPcopy Create free account
hub / github.com/cinit/TMoe / findField

Method findField

app/src/main/java/cc/ioctl/tmoe/util/Reflex.java:1010–1029  ·  view source on GitHub ↗
(Class<?> clazz, Class<?> type, String name)

Source from the content-addressed store, hash-verified

1008 }
1009
1010 public static Field findField(Class<?> clazz, Class<?> type, String name) throws NoSuchFieldException {
1011 if (clazz == null) {
1012 throw new NullPointerException("clazz == null");
1013 }
1014 if (name == null) {
1015 throw new NullPointerException("name == null");
1016 }
1017 Class<?> clz = clazz;
1018 do {
1019 for (Field field : clz.getDeclaredFields()) {
1020 if ((type == null || field.getType().equals(type)) && field.getName().equals(name)) {
1021 field.setAccessible(true);
1022 return field;
1023 }
1024 }
1025 } while ((clz = clz.getSuperclass()) != null);
1026 String errMsg = type == null ? ("field '" + name + "' not found in " + clazz.getName())
1027 : ("field '" + name + "' of type " + type.getName() + " not found in " + clazz.getName());
1028 throw new NoSuchFieldException(errMsg);
1029 }
1030
1031 public static Method findMethodByTypes_1(Class<?> clazz, Class returnType, Class... argt)
1032 throws NoSuchMethodException {

Callers 13

getStaticObjectMethod · 0.95
getInstanceObjectMethod · 0.95
setInstanceObjectMethod · 0.95
setStaticObjectMethod · 0.95
hasFieldMethod · 0.95
initOnceMethod · 0.80
initOnceMethod · 0.80
initOnceMethod · 0.80
initOnceMethod · 0.80
initializeMethod · 0.80
initializeMethod · 0.80

Calls 1

equalsMethod · 0.45

Tested by

no test coverage detected