Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make Indexer.index() return void #172

Merged
merged 1 commit into from
Feb 11, 2022

Conversation

Ladicek
Copy link
Contributor

@Ladicek Ladicek commented Feb 11, 2022

The Indexer.index() method used to return ClassInfo, which
assumes that no whole-index post-processing is not necessarsy.
Indeed Jandex doesn't do any such post-processing at the moment,
but it seems pretty obvious that it is necessary. Thus, as a first
step, this commit changes this method to return void, so that
all Indexer callers are forced to call complete() before
being able to access any kind of indexed information.

There are 2 kinds of usages of the Indexer.index() result of
the ClassInfo type in the Jandex project itself: showing some
summary during batch indexing and creating a single-class index
for tests.

For the first use case, a method indexWithSummary is added
that returns ClassSummary. This is fine and doesn't affect future
index post-processing, because the summary contains very high-level
information (just a name and number of annotations).

For the second use case, the IndexingUtil class is added which
contains utility methods for the most common cases of creating
a single-class index.

Additionally, the IndexingUtil class has a rountrip method
that serializes the index in memory and deserializes it back.
This is used in several tests, which usually had their own
variation of this code (one even serialized the index to a file).
This commit changes all such places to use this roundtrip method.

Fixes #132

The `Indexer.index()` method used to return `ClassInfo`, which
assumes that no whole-index post-processing is not necessarsy.
Indeed Jandex doesn't do any such post-processing at the moment,
but it seems pretty obvious that it is necessary. Thus, as a first
step, this commit changes this method to return `void`, so that
all `Indexer` callers are forced to call `complete()` before
being able to access any kind of indexed information.

There are 2 kinds of usages of the `Indexer.index()` result of
the `ClassInfo` type in the Jandex project itself: showing some
summary during batch indexing and creating a single-class index
for tests.

For the first use case, a method `indexWithSummary` is added
that returns `ClassSummary`. This is fine and doesn't affect future
index post-processing, because the summary contains very high-level
information (just a name and number of annotations).

For the second use case, the `IndexingUtil` class is added which
contains utility methods for the most common cases of creating
a single-class index.

Additionally, the `IndexingUtil` class has a `rountrip` method
that serializes the index in memory and deserializes it back.
This is used in several tests, which usually had their own
variation of this code (one even serialized the index to a file).
This commit changes all such places to use this `roundtrip` method.
@Ladicek Ladicek added the breaking-change Changes that break API backwards compatibility label Feb 11, 2022
@Ladicek Ladicek added this to the 3.0.0 milestone Feb 11, 2022
@Ladicek Ladicek linked an issue Feb 11, 2022 that may be closed by this pull request
@Ladicek Ladicek merged commit 3127b09 into smallrye:smallrye Feb 11, 2022
@Ladicek Ladicek deleted the indexer-index-void branch February 11, 2022 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change Changes that break API backwards compatibility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Indexer.index() shouldn't return ClassInfo
1 participant