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

Discover tables and validators in runtime using io.github.classgraph #1311

Merged
merged 3 commits into from
Jan 16, 2023

Conversation

aababilov
Copy link
Collaborator

This effectively reverts commit 7fb105e where registries of tables and validators were generated by the GtfsAnnotationProcessor. It is impossible to reliably generate a registry for multiple classes since there is an orthogonality rule for Java Annotation Processors [1]:

“The result of processing a given input is not a function of the presence or absence of other inputs (orthogonality).”

In other words, there is no way to guarantee that GtfsAnnotationProcessor receives all schema and validator classes: it may receive only a portion of them, so it cannot generate a global registry.

[1] https://docs.oracle.com/javase/7/docs/api/javax/annotation/processing/Processor.html

This effectively reverts commit 7fb105e
where registries of tables and validators were generated by the
GtfsAnnotationProcessor. It is impossible to reliably generate a
registry for multiple classes since there is an orthogonality rule for
Java Annotation Processors [1]:

“The result of processing a given input is not a function of the presence or absence of other inputs (orthogonality).”

In other words, there is no way to guarantee that GtfsAnnotationProcessor
receives all schema and validator classes: it may receive only a portion of
them, so it cannot generate a global registry.

Discovery is implemented in separate classes (ClassGraphTableDiscoverer
and ClassGraphValidatorDiscoverer), so that clients of the GTFS
Validator may implement their own ways to discover tables and
validators. io.github.classgraph is just one option, an alternative is
com.google.common.reflect.

[1] https://docs.oracle.com/javase/7/docs/api/javax/annotation/processing/Processor.html
Copy link
Collaborator

@asvechnikov2 asvechnikov2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@aababilov aababilov merged commit c45552d into MobilityData:master Jan 16, 2023
KClough pushed a commit to JarvusInnovations/gtfs-validator that referenced this pull request Jan 24, 2023
…obilityData#1311)

This effectively reverts commit 7fb105e
where registries of tables and validators were generated by the
GtfsAnnotationProcessor. It is impossible to reliably generate a
registry for multiple classes since there is an orthogonality rule for
Java Annotation Processors [1]:

“The result of processing a given input is not a function of the presence or absence of other inputs (orthogonality).”

In other words, there is no way to guarantee that GtfsAnnotationProcessor
receives all schema and validator classes: it may receive only a portion of
them, so it cannot generate a global registry.

Discovery is implemented in a separate class ClassGraphDiscovery,
so that clients of the GTFS Validator may implement their own ways
to discover tables and validators. io.github.classgraph is just one
option, an alternative is com.google.common.reflect.

[1] https://docs.oracle.com/javase/7/docs/api/javax/annotation/processing/Processor.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants