MCPcopy
hub / github.com/razerdp/BasePopup / invoke

Method invoke

app/src/main/java/razerdp/demo/utils/joor/Reflect.java:652–681  ·  view source on GitHub ↗
(Object proxy, Method method, Object[] args)

Source from the content-addressed store, hash-verified

650 final boolean isMap = (object instanceof Map);
651 final InvocationHandler handler = new InvocationHandler() {
652 @Override
653 @SuppressWarnings("null")
654 public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
655 String name = method.getName();
656
657 // Actual method name matches always come first
658 try {
659 return on(type, object).call(name, args).get();
660 }
661
662 // [#14] Emulate POJO behaviour on wrapped map objects
663 catch (ReflectException e) {
664 if (isMap) {
665 Map<String, Object> map = (Map<String, Object>) object;
666 int length = (args == null ? 0 : args.length);
667
668 if (length == 0 && name.startsWith("get")) {
669 return map.get(property(name.substring(3)));
670 } else if (length == 0 && name.startsWith("is")) {
671 return map.get(property(name.substring(2)));
672 } else if (length == 1 && name.startsWith("set")) {
673 map.put(property(name.substring(3)), args[0]);
674 return null;
675 }
676 }
677
678
679 throw e;
680 }
681 }
682 };
683
684 return (P) Proxy.newProxyInstance(proxyType.getClassLoader(), new Class[]{proxyType}, handler);

Callers 15

applyConfigSettingMethod · 0.80
objectFieldOffsetMethod · 0.80
getObjectMethod · 0.80
putObjectMethod · 0.80
arrayBaseOffsetMethod · 0.80
addressSizeMethod · 0.80
getIntMethod · 0.80
getLongMethod · 0.80
getObjectVolatileMethod · 0.80
putObjectVolatileMethod · 0.80
allocateInstanceMethod · 0.80
getStoragePathMethod · 0.80

Calls 6

onMethod · 0.95
propertyMethod · 0.95
callMethod · 0.80
putMethod · 0.80
getNameMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected