use of java.lang.reflect.Proxy in project VirtualApp by asLody.
the class ProviderHook method createProxy.
public static IInterface createProxy(boolean external, String authority, IInterface provider) {
if (provider instanceof Proxy && Proxy.getInvocationHandler(provider) instanceof ProviderHook) {
return provider;
}
ProviderHook.HookFetcher fetcher = ProviderHook.fetchHook(authority);
if (fetcher != null) {
ProviderHook hook = fetcher.fetch(external, provider);
IInterface proxyProvider = ProviderHook.createProxy(provider, hook);
if (proxyProvider != null) {
provider = proxyProvider;
}
}
return provider;
}
use of java.lang.reflect.Proxy in project core by asyncj.
the class ActorManager method unblockResult.
public void unblockResult(Object actor1) {
Proxy proxy = (Proxy) getReference(actor1);
((MethodHandler) Proxy.getInvocationHandler(proxy)).unblockResult();
}
use of java.lang.reflect.Proxy in project robovm by robovm.
the class ProxyTest method test_isProxyClassLjava_lang_Class.
/**
* java.lang.reflect.Proxy#isProxyClass(java.lang.Class)
*/
public void test_isProxyClassLjava_lang_Class() {
Class proxy = Proxy.getProxyClass(Support_Proxy_I1.class.getClassLoader(), new Class[] { Support_Proxy_I1.class });
class Fake extends Proxy {
Fake() {
super(null);
}
}
Proxy fake = new Proxy(new InvocationHandler() {
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
return null;
}
}) {
};
assertTrue("Does not believe its a Proxy class ", Proxy.isProxyClass(proxy));
assertTrue("Proxy subclasses do not count ", !Proxy.isProxyClass(Fake.class));
assertTrue("Is not a runtime generated Proxy class ", !Proxy.isProxyClass(fake.getClass()));
boolean thrown = false;
try {
Proxy.isProxyClass(null);
} catch (NullPointerException ex) {
thrown = true;
}
assertTrue("NPE not thrown.", thrown);
}
use of java.lang.reflect.Proxy in project intellij-community by JetBrains.
the class BaseGradleProjectResolverExtension method printToolingProxyDiagnosticInfo.
private static void printToolingProxyDiagnosticInfo(@Nullable Object obj) {
if (!LOG.isDebugEnabled() || obj == null)
return;
LOG.debug(String.format("obj: %s", obj));
final Class<?> aClass = obj.getClass();
LOG.debug(String.format("obj class: %s", aClass));
LOG.debug(String.format("classloader: %s", aClass.getClassLoader()));
for (Method m : aClass.getDeclaredMethods()) {
LOG.debug(String.format("obj m: %s", m));
}
if (obj instanceof Proxy) {
try {
final Field hField = ReflectionUtil.findField(obj.getClass(), null, "h");
hField.setAccessible(true);
final Object h = hField.get(obj);
final Field delegateField = ReflectionUtil.findField(h.getClass(), null, "delegate");
delegateField.setAccessible(true);
final Object delegate = delegateField.get(h);
LOG.debug(String.format("delegate: %s", delegate));
LOG.debug(String.format("delegate class: %s", delegate.getClass()));
LOG.debug(String.format("delegate classloader: %s", delegate.getClass().getClassLoader()));
for (Method m : delegate.getClass().getDeclaredMethods()) {
LOG.debug(String.format("delegate m: %s", m));
}
} catch (NoSuchFieldException | IllegalAccessException e) {
LOG.debug(e);
}
}
}
use of java.lang.reflect.Proxy in project jdk8u_jdk by JetBrains.
the class MBeanServerInvocationHandler method doLocally.
private Object doLocally(Object proxy, Method method, Object[] args) {
final String methodName = method.getName();
if (methodName.equals("equals")) {
if (this == args[0]) {
return true;
}
if (!(args[0] instanceof Proxy)) {
return false;
}
final InvocationHandler ihandler = Proxy.getInvocationHandler(args[0]);
if (ihandler == null || !(ihandler instanceof MBeanServerInvocationHandler)) {
return false;
}
final MBeanServerInvocationHandler handler = (MBeanServerInvocationHandler) ihandler;
return connection.equals(handler.connection) && objectName.equals(handler.objectName) && proxy.getClass().equals(args[0].getClass());
} else if (methodName.equals("toString")) {
return (isMXBean() ? "MX" : "M") + "BeanProxy(" + connection + "[" + objectName + "])";
} else if (methodName.equals("hashCode")) {
return objectName.hashCode() + connection.hashCode();
} else if (methodName.equals("finalize")) {
// ignore the finalizer invocation via proxy
return null;
}
throw new RuntimeException("Unexpected method name: " + methodName);
}
Aggregations