use of org.checkerframework.common.reflection.qual.MethodVal in project checker-framework by typetools.
the class Location method getCurrentCity.
String getCurrentCity() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
@MethodVal(className = "NullnessReflectionExampleTest", methodName = "getCurrentLocation", params = 0) Method toLowerCase = getClass().getMethod("getCurrentLocation");
Location currentLocation = (Location) toLowerCase.invoke(this);
return currentLocation.nameOfCity();
}
use of org.checkerframework.common.reflection.qual.MethodVal in project checker-framework by typetools.
the class MethodValInferenceTest method testGetMethodParamLen.
public void testGetMethodParamLen(Class<?> @ArrayLen(2) [] classArray2, Class<?>[] classArrayUnknown) throws Exception {
@StringVal("someMethod") String str = "someMethod";
@ClassVal("java.lang.Object") Class<?> c = Object.class;
@MethodVal(className = "java.lang.Object", methodName = "getA", params = 0) Method m1 = c.getMethod("getA", new Class[] {});
@MethodVal(className = "java.lang.Object", methodName = "getA", params = 0) Method m2 = c.getMethod("getA", (Class[]) null);
@MethodVal(className = "java.lang.Object", methodName = "someMethod", params = 1) Method m3 = c.getMethod("someMethod", new Class[] { Integer.class });
@MethodVal(className = "java.lang.Object", methodName = "equals", params = 1) Method m4 = c.getMethod("equals", Object.class);
@MethodVal(className = "java.lang.Object", methodName = "someMethod", params = 1) Method m5 = c.getMethod(str, int.class);
@MethodVal(className = "java.lang.Object", methodName = "getB", params = 0) Method m6 = c.getMethod("getB", new Class[0]);
@MethodVal(className = "java.lang.Object", methodName = "someMethod", params = 1) Method m7 = c.getMethod(str, new Class[] { int.class });
@MethodVal(className = "java.lang.Object", methodName = "someMethod", params = 2) Method m8 = c.getMethod(str, new Class[] { Integer.class, Integer.class });
@MethodVal(className = "java.lang.Object", methodName = "someMethod", params = 2) Method m10 = c.getMethod(str, int.class, int.class);
@MethodVal(className = "java.lang.Object", methodName = "someMethod", params = 2) Method m11 = c.getMethod(str, classArray2);
@MethodVal(className = "java.lang.Object", methodName = "someMethod", params = -1) Method m12 = c.getMethod(str, classArrayUnknown);
}
use of org.checkerframework.common.reflection.qual.MethodVal in project checker-framework by typetools.
the class MethodValInferenceTest method testGetMethodMultiClassAndMethodNames.
public void testGetMethodMultiClassAndMethodNames(@ClassVal({ "java.lang.Object", "java.lang.String" }) Class<?> twoClasses, @ClassVal({ "java.lang.Object" }) Class<?> oneClass, @StringVal({ "method1" }) String oneName, @StringVal({ "method1", "method2" }) String twoNames, Class<?> @ArrayLen(2) [] classArray2, Class<?>[] classArrayUnknown) throws Exception {
@MethodVal(className = { "java.lang.Object" }, methodName = { "method1" }, params = -1) Method m1 = oneClass.getMethod(oneName, classArrayUnknown);
@MethodVal(className = { "java.lang.Object", "java.lang.Object" }, methodName = { "method1", "method2" }, params = { -1, -1 }) Method m2 = oneClass.getMethod(twoNames, classArrayUnknown);
@MethodVal(className = { "java.lang.Object", "java.lang.String" }, methodName = { "method1", "method1" }, params = { -1, -1 }) Method m3 = twoClasses.getMethod(oneName, classArrayUnknown);
@MethodVal(className = { "java.lang.Object", "java.lang.String", "java.lang.Object", "java.lang.String" }, methodName = { "method1", "method2", "method2", "method1" }, params = { -1, -1, -1, -1 }) Method m4 = twoClasses.getMethod(twoNames, classArrayUnknown);
}
use of org.checkerframework.common.reflection.qual.MethodVal in project checker-framework by typetools.
the class MethodValLUBTest method inferedlubTest.
void inferedlubTest() throws Exception {
Class<MethodValInferenceTest> c = MethodValInferenceTest.class;
Method m;
if (flag) {
m = c.getMethod("getA", new Class[0]);
} else {
m = c.getMethod("getB", new Class[0]);
}
@MethodVal(className = { "MethodValInferenceTest", "MethodValInferenceTest" }, methodName = { "getA", "getB" }, params = { 0, 0 }) Method lub = m;
}