|
12 | 12 | import java.util.HashSet; |
13 | 13 | import java.util.List; |
14 | 14 | import java.util.Map; |
| 15 | +import java.util.Set; |
15 | 16 |
|
16 | 17 | import com.telerik.metadata.TreeNode.FieldInfo; |
17 | 18 | import com.telerik.metadata.TreeNode.MethodInfo; |
|
22 | 23 | import com.telerik.metadata.desc.MethodDescriptor; |
23 | 24 | import com.telerik.metadata.desc.TypeDescriptor; |
24 | 25 | import com.telerik.metadata.dx.DexFile; |
| 26 | +import com.telerik.metadata.parsing.ClassParser; |
25 | 27 |
|
26 | 28 | public class Builder { |
27 | 29 | private static class MethodNameComparator implements Comparator<MethodDescriptor> { |
@@ -250,33 +252,14 @@ private static void getFieldsFromImplementedInterfaces(ClassDescriptor clazz, Tr |
250 | 252 | } |
251 | 253 |
|
252 | 254 | private static MethodDescriptor[] getDefaultMethodsFromImplementedInterfaces(ClassDescriptor clazz, MethodDescriptor[] originalClassMethodDescriptors) { |
253 | | - HashSet<MethodDescriptor> defaultMethods = getAllDefaultMethodsFromImplementedInterfaces(clazz); |
254 | | - HashSet<MethodDescriptor> classMethods = new HashSet<MethodDescriptor>(Arrays.asList(originalClassMethodDescriptors)); |
255 | | - defaultMethods.removeAll(classMethods); |
256 | | - |
257 | | - return defaultMethods.toArray(new MethodDescriptor[0]); |
258 | | - } |
259 | | - |
260 | | - private static HashSet<MethodDescriptor> getAllDefaultMethodsFromImplementedInterfaces(ClassDescriptor clazz) { |
261 | | - return getAllDefaultMethodsFromImplementedInterfacesRecursively(clazz, new HashSet<MethodDescriptor>()); |
262 | | - } |
263 | | - |
264 | | - private static HashSet<MethodDescriptor> getAllDefaultMethodsFromImplementedInterfacesRecursively(ClassDescriptor clazz, HashSet<MethodDescriptor> collectedDefaultMethods) { |
265 | | - String[] implementedInterfacesNames = clazz.getInterfaceNames(); |
266 | | - |
267 | | - for (String implementedInterfaceName : implementedInterfacesNames) { |
268 | | - ClassDescriptor interfaceClass = ClassRepo.findClass(implementedInterfaceName); |
| 255 | + ClassParser parser = ClassParser.forClassDescriptor(clazz); |
269 | 256 |
|
270 | | - for (MethodDescriptor md : interfaceClass.getMethods()) { |
271 | | - if (!md.isStatic() && !md.isAbstract()) { |
272 | | - collectedDefaultMethods.add(md); |
273 | | - } |
274 | | - } |
| 257 | + Set<MethodDescriptor> defaultMethods = parser.getAllDefaultMethodsFromImplementedInterfaces(); |
| 258 | + Set<MethodDescriptor> classMethods = new HashSet<MethodDescriptor>(Arrays.asList(originalClassMethodDescriptors)); |
275 | 259 |
|
276 | | - collectedDefaultMethods.addAll(getAllDefaultMethodsFromImplementedInterfacesRecursively(interfaceClass, new HashSet<MethodDescriptor>())); |
277 | | - } |
| 260 | + defaultMethods.removeAll(classMethods); |
278 | 261 |
|
279 | | - return collectedDefaultMethods; |
| 262 | + return defaultMethods.toArray(new MethodDescriptor[0]); |
280 | 263 | } |
281 | 264 |
|
282 | 265 | private static TreeNode getOrCreateNode(TreeNode root, TypeDescriptor type) |
|
0 commit comments