dimanche 9 août 2020

Java - Find all the methods returning a specific type from classloader

I am looking for a way to find all the methods from all the classes from my classloader which returns some type. For example List.

I tried to use this library - https://github.com/ronmamo/reflections

Reflections reflections = new Reflections("com",new MethodParameterScanner());

        Set<Method> methodsReturn = reflections.getMethodsReturn(List.class);
        methodsReturn
                .forEach(c -> System.out.println(c.getDeclaringClass() + "-" + c.getName()));

But failed with this exception.

org.reflections.ReflectionsException: could not get type for name com.intellij.rt.execution.CommandLineWrapper$AppData.access
    at org.reflections.ReflectionUtils.forName(ReflectionUtils.java:312)
    at org.reflections.util.Utils.getMemberFromDescriptor(Utils.java:67)
    at org.reflections.util.Utils.getMethodsFromDescriptors(Utils.java:88)

Is there any other way to do this?





Aucun commentaire:

Enregistrer un commentaire