smallrye / jandex

Java Annotation Indexer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add option to index methods that call specified methods

FroMage opened this issue · comments

We're going to need to be able to ask Jandex for methods that call specified methods. It would be nice if we could tell Jandex to index all calls to Foo.bar() (which could be a list of methods) so that later we can query this and do bytecode modification or compile-time validation only for the methods where those call are located.

While indexing, Jandex could look at the bytecode and record methods that call the set of specified methods we're after. Then we can query Jandex for all methods calling those methods.

Hm, this could increase the size of the generated index significantly and also slow down the generation. But it could be useful.

Well, it's an opt-in, right? If you don't want to find method calls, the index does not grow. If you do need to find method calls it's not so slow to walk the bytecode while you walk the methods, and it only grows the index size for those matching methods.

Plus we're already indexing anyway. If we do a second pass on the consuming end just to find where those methods are called it's essentially a second indexing pass.

The problem is that some indexes could be pregenerated. So you would have to reindex everything to get consistent results.

Well yes, but the same could be said of incomplete indexes because new classes appeared.

I realise now that this can't work properly because it would index stuff based on who asks for it. I'll open a better issue.