summaryrefslogtreecommitdiff
path: root/libjava/testsuite/libjava.lang/TestProxy.java
blob: 08e16aa33c57df8a866a5c33e0eec90cc64f48d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import java.lang.reflect.Proxy;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.net.*;

public class TestProxy
{
  public static class MyInvocationHandler implements InvocationHandler
  {
    public Object invoke (Object proxy,
			  Method method,
			  Object[] args)
      throws Throwable
    {
      System.out.println (args[0]);
      return null;
    }
  }

  public static void main (String[] args)
  {
    try {
      InvocationHandler ih = new MyInvocationHandler();
      
      SocketOptions c = (SocketOptions)
	Proxy.newProxyInstance (SocketOptions.class.getClassLoader(),
				new Class[]{SocketOptions.class},
				ih);
      
      c.getOption (555);

    } catch (Exception e) {
      e.printStackTrace ();
    }
  }
}