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));
}
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);
}
}
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);
}
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);
}
});
}
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();
}
}
Aggregations