/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class Main {
    public static void main(String[] args) throws Exception {
        Interface i = (Interface) Proxy.newProxyInstance(Main.class.getClassLoader(),
                                                         new Class<?>[] { Interface.class },
                                                         new Handler());
        i.foo();
    }
}

interface Interface {
    void foo();
}

class Handler implements InvocationHandler {
    public Object invoke(Object proxy, Method method, Object[] args) {
        System.out.println("Method: " + method);
        return null;
    }
}
