summaryrefslogtreecommitdiff
path: root/libjava/testsuite/libjava.lang/TestProxy.java
blob: ea2e1f04a93ee9f8fcd622261d56ae0170fdd75a (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
import java.lang.reflect.*;
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 ();
    }
  }
}