1

I'm using ASM to collect some information about the classes in an Android project (using a gradle plugin combined with the Google Transform API). I want to find if a method is overriding a method from his superclass/interfaces. If the superclass or the interface is part of the project or the local dependencies (jars) i can compare the descriptor of the current method against all the methods defined in the superclass/interface. This is done by traversing the entire hierarchy (bottom-up). If i find a match between the descriptors i've found an overridden method.

My problem appears when i reach a superclass/interface defined in a standard library (like java.lang or android.app, etc..) because i don't known how to visit this kind of classes. If the library class is in the current classpath i can access directly from the ClassReader.

For example:

ClassReader classReader = new ClassReader("java.lang.Object");

But if the class is not in the current classpath i get (of course) java.io.IOException: Class not found. For example when i try:

ClassReader classReader = new ClassReader("android.app.Activity");

From what i know, comparing the descriptors of two methods, is the only way to determine if one is overriding of the other, so i must visit the superclass/interface somehow.

So my question is: How can i visit a superclass/interface that is defined in a standard library? (note: not the dependencies inside the android project, that, i'm already able to evaluate), or if there is another way to determine the override property.

3
  • If you have the standard lib as jar, then you can create a class reader with an InputStream. Jan 7, 2021 at 16:51
  • The problem is exactly that. I do not have the standard lib as a jar during the build in the android project, i can access the project source, the dependencies, the subprojects, everything the Transform API allow to see. But i can't access the stdlib Jan 8, 2021 at 7:31
  • 1
    The classes must be in a format, the compiler can read, i.e. in a directory or jar file, as otherwise, it would be impossible to compile the project.
    – Holger
    Jan 8, 2021 at 18:24

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.