Search in sources :

Example 81 with Method

use of java.lang.reflect.Method in project afterburner by stephanenicolas.

the class AfterBurnerTest method assertHasFooMethodWithReturnValue.

private void assertHasFooMethodWithReturnValue(CtClass clazz, boolean returnValue) throws Exception {
    CtMethod fooMethod = clazz.getDeclaredMethod("foo");
    assertNotNull(fooMethod);
    // we also need to check if code has been copied
    Method realFooMethod = targetInstance.getClass().getMethod("foo");
    assertEquals(returnValue, realFooMethod.invoke(targetInstance));
}
Also used : CtMethod(javassist.CtMethod) SimpleInsertableMethod(com.github.stephanenicolas.afterburner.inserts.SimpleInsertableMethod) CtNewMethod(javassist.CtNewMethod) InsertableMethod(com.github.stephanenicolas.afterburner.inserts.InsertableMethod) Method(java.lang.reflect.Method) CtMethod(javassist.CtMethod)

Example 82 with Method

use of java.lang.reflect.Method in project Rutgers-Course-Tracker by tevjef.

the class StringPicker method setCurrent.

public void setCurrent(final int current) {
    String methodName = isUnderHoneyComb() ? "setCurrent" : "setValue";
    try {
        Method method = mClazz.getMethod(methodName, int.class);
        method.invoke(mInstance, current);
    } catch (final Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : Method(java.lang.reflect.Method)

Example 83 with Method

use of java.lang.reflect.Method in project Rutgers-Course-Tracker by tevjef.

the class StringPicker method init.

private void init(final Context context, final AttributeSet attrs) {
    try {
        Class<?> clazz = context.getClassLoader().loadClass(PICKER_CLASS);
        Constructor<?> constructor = clazz.getConstructor(Context.class, AttributeSet.class);
        mInstance = constructor.newInstance(context, attrs);
        mClazz = mInstance.getClass();
        String methodName = "setDescendantFocusability";
        Method method = mClazz.getMethod(methodName, int.class);
        method.invoke(mInstance, NumberPicker.FOCUS_BLOCK_DESCENDANTS);
    } catch (final Exception e) {
        throw new RuntimeException(e);
    }
    initAttributes(context, attrs);
    if (mDividerColor != 0) {
        setDivider(mDividerColor);
    }
    setDividerHeight(mDividerHeight);
    addView((View) mInstance);
    setOrientation(VERTICAL);
}
Also used : Method(java.lang.reflect.Method)

Example 84 with Method

use of java.lang.reflect.Method in project saga by timurstrekalov.

the class CoverageGeneratorFactory method newInstance.

public static CoverageGenerator newInstance(final String baseDir, final File outputDir) {
    final CoverageGenerator delegate = new DefaultCoverageGenerator();
    delegate.getConfig().setBaseDir(baseDir);
    delegate.getConfig().setOutputDir(outputDir);
    return Reflection.newProxy(CoverageGenerator.class, new InvocationHandler() {

        @Override
        public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
            if (method.getName().startsWith("set")) {
                logger.debug("{}({})", method.getName(), Arrays.toString(args));
            }
            return method.invoke(delegate, args);
        }
    });
}
Also used : Method(java.lang.reflect.Method) InvocationHandler(java.lang.reflect.InvocationHandler)

Example 85 with Method

use of java.lang.reflect.Method in project Float-Bar by tianzhijiexian.

the class Util method doInStatusBar.

private static void doInStatusBar(Context mContext, String methodName) {
    try {
        Object service = mContext.getSystemService("statusbar");
        Class<?> statusBarManager = Class.forName("android.app.StatusBarManager");
        Method expand = statusBarManager.getMethod(methodName);
        expand.invoke(service);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Method(java.lang.reflect.Method)

Aggregations

Method (java.lang.reflect.Method)8797 Test (org.junit.Test)1772 InvocationTargetException (java.lang.reflect.InvocationTargetException)1084 ArrayList (java.util.ArrayList)665 Field (java.lang.reflect.Field)611 IOException (java.io.IOException)549 HashMap (java.util.HashMap)352 Map (java.util.Map)290 List (java.util.List)275 PropertyDescriptor (java.beans.PropertyDescriptor)253 Annotation (java.lang.annotation.Annotation)212 Type (java.lang.reflect.Type)202 HashSet (java.util.HashSet)199 File (java.io.File)173 IndexedPropertyDescriptor (java.beans.IndexedPropertyDescriptor)170 BeanInfo (java.beans.BeanInfo)166 ParameterizedType (java.lang.reflect.ParameterizedType)132 Constructor (java.lang.reflect.Constructor)131 SimpleBeanInfo (java.beans.SimpleBeanInfo)128 FakeFox01BeanInfo (org.apache.harmony.beans.tests.support.mock.FakeFox01BeanInfo)128