Example usage for com.google.gwt.dev.shell.designtime MethodAdaptor getName

List of usage examples for com.google.gwt.dev.shell.designtime MethodAdaptor getName

Introduction

In this page you can find the example usage for com.google.gwt.dev.shell.designtime MethodAdaptor getName.

Prototype

public String getName() 

Source Link

Usage

From source file:com.google.gdt.eclipse.designer.ie.jsni.IDispatchImpl.java

License:Open Source License

protected static Variant callMethod(ClassLoader cl, DispatchIdOracle ora, Object jthis, Variant[] params,
        MethodAdaptor method) throws InstantiationException, InvocationTargetException, HResultException {
    // TODO: make sure we have enough args! It's okay if there are too many.
    Object[] javaParams = SwtOleGlue.convertVariantsToObjects(cl, method.getParameterTypes(), params,
            "Calling method '" + method.getName() + "'");
    Object result = null;// w  ww .j  av  a2s .  c om
    try {
        try {
            result = method.invoke(jthis, javaParams);
        } catch (IllegalAccessException e) {
            // should never, ever happen
            e.printStackTrace();
            throw new RuntimeException(e);
        }
    } catch (NullPointerException e) {
        /*
         * The JavaScript expected the method to be static, having forgotten an
         * instance reference (most often "this.").
         */
        StringBuffer sb = new StringBuffer();
        sb.append("Instance method '");
        sb.append(method.getName());
        sb.append("' needed a qualifying instance ");
        sb.append("(did you forget to prefix the call with 'this.'?)");
        throw new HResultException(sb.toString());
    } finally {
        for (int i = 0; i < javaParams.length; i++) {
            if (javaParams[i] instanceof OleAutomation) {
                OleAutomation tmp = (OleAutomation) javaParams[i];
                tmp.dispose();
            }
        }
    }
    return SwtOleGlue.convertObjectToVariant(cl, ora, method.getReturnType(), result);
}