}
catch (NotFoundException e) {}
- if (isIntf || Modifier.isAbstract(mod))
- try {
- CtClass[] ifs = clazz.getInterfaces();
- int size = ifs.length;
- for (int i = 0; i < size; ++i) {
- Method r = lookupMethod(ifs[i], methodName,
- argTypes, argDims, argClassNames,
- onlyExact);
+ try {
+ CtClass[] ifs = clazz.getInterfaces();
+ int size = ifs.length;
+ for (int i = 0; i < size; ++i) {
+ Method r = lookupMethod(ifs[i], methodName,
+ argTypes, argDims, argClassNames,
+ onlyExact);
+ if (r != null)
+ return r;
+ }
+
+ if (isIntf) {
+ // finally search java.lang.Object.
+ CtClass pclazz = clazz.getSuperclass();
+ if (pclazz != null) {
+ Method r = lookupMethod(pclazz, methodName, argTypes,
+ argDims, argClassNames, onlyExact);
if (r != null)
return r;
}
-
- if (isIntf) {
- // finally search java.lang.Object.
- CtClass pclazz = clazz.getSuperclass();
- if (pclazz != null) {
- Method r = lookupMethod(pclazz, methodName, argTypes,
- argDims, argClassNames, onlyExact);
- if (r != null)
- return r;
- }
- }
}
- catch (NotFoundException e) {}
+ }
+ catch (NotFoundException e) {}
return maybe;
}
Object obj = make(cc.getName());
assertEquals(10, invoke(obj, "run"));
}
+
+ public void testJIRA246() throws Exception {
+ CtClass ctClass = sloader.makeClass("test5.JIRA246Test");
+ ctClass.addInterface(sloader.get(test5.JIRA246.Test.class.getName()));
+ String methodBody = "public void test() { defaultMethod(); }";
+ CtMethod ctMethod = CtMethod.make(methodBody, ctClass);
+ ctClass.addMethod(ctMethod);
+ }
+
+ public void testJIRA246b() throws Exception {
+ CtClass ctClass = sloader.get(test5.JIRA246.A.class.getName());
+ String src = "public void id() { get(); }";
+ CtMethod make = CtNewMethod.make(src, ctClass);
+ }
}