smallrye / jandex

Java Annotation Indexer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

allow navigating from `ClassInfo` to its member classes

Ladicek opened this issue · comments

For a class, the InnerClasses bytecode attribute contains (among others) names of all its member classes. They can be recognized by outer_class_info_index being != 0. If that outer_class_info_index points to the "current" class, we know it is "our" member class. The name of the member class can be found using inner_name_index.

Names (as in, DotNames) of all member classes could be stored in the ClassInfo and serialized. That would allow, in addition to current navigation from a class to its enclosing class, also navigating from a class to its member classes.

Open questions:

  1. If I have a bunch of classes like this

    class A {
      class B {
        class C {
        }
      }
    }

    What should A's set of member classes contain? Only B, or B and C? I'd say just B. If you want C, you should navigate to it from B.

  2. Member class names in bytecode are stored in a simple form. So if I have a class com.example.A which has a member class B, we know its name is B. Do we want to return a full name of com.example.A$B? I'd say yes, it's actually pretty simple to create a componentized name of this form.

  3. What about local classes and anonymous classes? I'd say we can just ignore them, at least for now.

Done in #185.