MCPcopy Index your code
hub / github.com/evernat/dead-code-detector / getJavaMethods

Method getJavaMethods

src/main/java/dcd/DcdHelper.java:62–97  ·  view source on GitHub ↗
(String asmClassName)

Source from the content-addressed store, hash-verified

60 }
61
62 static Set<String> getJavaMethods(String asmClassName) {
63 Class<?> clazz;
64 try {
65 // TODO serait-il plus performant de lire classe Java et super-classes avec Class.getResourceAsStream puis de parser avec ASM ?
66 clazz = Class.forName(Type.getObjectType(asmClassName).getClassName());
67 } catch (final Throwable t) { // NOPMD
68 final String msg = "[DCD] Can not load "
69 + Type.getObjectType(asmClassName).getClassName();
70 log(msg);
71 return Collections.emptySet();
72 }
73 final Set<Class<?>> classes = new HashSet<>();
74 while (clazz != null) {
75 classes.add(clazz);
76 if ((clazz.getModifiers() & Modifier.ABSTRACT) != 0) {
77 for (final Class<?> clazz2 : clazz.getInterfaces()) {
78 classes.add(clazz2);
79 classes.addAll(Arrays.asList(clazz2.getInterfaces()));
80 }
81 }
82 clazz = clazz.getSuperclass();
83 }
84 final Set<String> methods = new HashSet<>();
85 for (final Class<?> clazz2 : classes) {
86 for (final Method method : clazz2.getDeclaredMethods()) {
87 if ((method.getModifiers() & VISIBILITY_PUBLIC_OR_PROTECTED) != 0) {
88 final String methodKey = DcdHelper.getMethodKey(method.getName(),
89 Type.getMethodDescriptor(method));
90 if (!methods.contains(methodKey)) {
91 methods.add(methodKey);
92 }
93 }
94 }
95 }
96 return methods;
97 }
98
99 static String getMethodKey(String name, String desc) {
100 return name + METHOD_SEPARATOR + desc;

Callers 1

getJavaMethodsMethod · 0.95

Calls 2

logMethod · 0.95
getMethodKeyMethod · 0.95

Tested by

no test coverage detected