ProxyTest.java: New test.
2007-04-03 Andrew Haley <aph@redhat.com> * testsuite/libjava.lang/ProxyTest.java: New test. From-SVN: r123466
This commit is contained in:
committed by
Andrew Haley
parent
81e864cb18
commit
83ff0d10ed
@@ -0,0 +1,37 @@
|
||||
import java.lang.reflect.*;
|
||||
|
||||
interface Twas
|
||||
{
|
||||
Object brillig();
|
||||
}
|
||||
|
||||
interface Slithy
|
||||
{
|
||||
void toves(int gyre);
|
||||
}
|
||||
|
||||
public class ProxyTest
|
||||
{
|
||||
static class MyInvocationHandler implements InvocationHandler
|
||||
{
|
||||
public Object invoke(Object proxy, Method method, Object[] args)
|
||||
{
|
||||
System.out.println (method.getDeclaringClass());
|
||||
System.out.println (args == null
|
||||
? args
|
||||
: args.getClass().getName());
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] argv)
|
||||
throws InstantiationException, IllegalAccessException
|
||||
{
|
||||
Twas wabe
|
||||
= (Twas)Proxy.newProxyInstance(ProxyTest.class.getClassLoader(),
|
||||
new Class[] { Slithy.class, Twas.class },
|
||||
new MyInvocationHandler());
|
||||
wabe.brillig();
|
||||
((Slithy)wabe).toves(2);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user