-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProxyClass.java
More file actions
38 lines (33 loc) · 856 Bytes
/
Copy pathProxyClass.java
File metadata and controls
38 lines (33 loc) · 856 Bytes
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
37
38
package Misc;
//Import required libraries
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.List;
// demoInvocationHandler class
class demoInvocationHandler implements InvocationHandler {
@Override
public Object invoke(Object proxy, Method method,
Object[] args) throws Throwable
{
return null;
}
}
// demoInterface
interface demoInterface {
}
// Driver code
public class ProxyClass {
public static void main(String[] args)
{
// Object created
InvocationHandler h = new demoInvocationHandler();
// ProxyClass objects stored in list
List proxyClass = (List)Proxy.newProxyInstance(
ProxyClass.class.getClassLoader(),
new Class[] { List.class },
new demoInvocationHandler());
System.out.println(
Proxy.getInvocationHandler(proxyClass));
}
}