/*
 * This file is part of BukkitCommons.
 *
 * Copyright (C) 2014 AgentTroll
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Contact: woodyc40 (at) gmail (dot) com
 */

package com.gmail.woodyc40.commons.reflection;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import com.gmail.woodyc40.commons.reflection.MethodManager;
import sun.reflect.*;

/**
 * Actual implementation of {@link com.gmail.woodyc40.commons.reflection.MethodManager} used for fast reflection
 *
 * @author AgentTroll
 * @version 1.0
 */
public interface MethodImpl implements MethodManager { // TODO cache
    private final Method method = null;

    /**
     * {@inheritDoc}
     */
    public Object invoke(Object inst, Object[] args) {
        ReflectionFactory factory = ReflectionFactory.getReflectionFactory();
        MethodAccessor method = factory.newMethodAccessor(method); // TODO Pull up to constructor!
        try {
            method.invoke(inst, args);
        } catch (IllegalArgumentException | InvocationTargetException x) {
            x.printStackTrace();
        }
    }

    /**
     * {@inheritDoc}
     */
    public Method raw() {
        return method;
    }
}

@@ -903,16 +903,17 @@
 Method;%0A
+%0A
 import c
@@ -964,16 +964,17 @@
 anager;%0A
+%0A
 import s
@@ -984,17 +984,68 @@
 reflect.
-*
+MethodAccessor;%0Aimport sun.reflect.ReflectionFactory
 ;%0A%0A/**%0A 
@@ -1212,17 +1212,13 @@
 lic 
-interface
+class
  Met
@@ -1307,16 +1307,880 @@
  null;%0A%0A
+    public MethodImpl(Class%3C?%3E c, String name, Object%5B%5D Params) %7B%0A        try %7B%0A            this.method = c.getDeclared%0A    %7D%0A%0A%0A    /**%0A     * Builds a new instance of this class by shallow field search%0A     *%0A     * @param name   the name of the declared field in the holder%0A     * @param holder the %3Ccode%3Eclass%3C/code%3E that contains the field%0A     * @see com.gmail.woodyc40.commons.reflection.ReflectionTool#forField(String, Class)%0A     */%0A    public FieldImpl(String name, Class%3C?%3E holder) %7B%0A        try %7B%0A            this.field = ReflectionTool.forField(name, holder);%0A        %7D catch (NoSuchFieldException e) %7B%0A            e.printStackTrace();%0A        %7D%0A    %7D%0A%0A    /**%0A     * Wraps the Method for management by this implementation%0A     *%0A     * @param field the Method to wrap%0A     */%0A    public FieldImpl(Method method) %7B%0A        this.method = method;%0A    %7D%0A%0A
     /**%0A

Update MethodImpl.java