Eliminate TypeMarkers for simple and one level parameterized types - #3035
Draft
atrocities wants to merge 1 commit into
Draft
Eliminate TypeMarkers for simple and one level parameterized types#3035atrocities wants to merge 1 commit into
atrocities wants to merge 1 commit into
Conversation
Add 5 factory methods to TypeMarker and an implementation of ParameterizedType for simple types and the 4 base parameterized types that conjure generates. This reduces the need for most TypeMarkers, while also being reasonably readable, and type safe, so that no casting of TypeMarkers is needed by the caller. TypeMarkers are still produced for parameterized types that have more than one level of parameterization. In practice, this comprises a vanishingly small number of types.
Generate changelog in
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before this PR
Anon TypeMarker implementations were created for all types that need to be serialized/deserialized. This results in pollution of jars at rest, and meta/symbol/class space at runtime.
The reason for this is because of the erasure of the parameterized type arguments for generic types, which makes it not possible to express something like List.class as an argument to a factory method. The workaround was to capture this type information in a subclass instead. While this approach was not strictly required for simple, non parameterized types, it was chosen due to uniformity.
After this PR
Add 5 factory methods to TypeMarker and an implementation of ParameterizedType for simple types and the 4 base parameterized types that conjure generates. This reduces the need for most TypeMarkers, while also being reasonably readable, and type safe, so that no casting of TypeMarkers is needed by the caller.
TypeMarkers are still produced for parameterized types that have more than one level of parameterization. In practice, this comprises a vanishingly small number of types. While conjure-java does not generate any parameterized classes outside of Set, List, Map, and Optional, it's possible that more types may be added in the future, for which anon TypeMarkers will be generated for those types unless this collection of factory methods is also updated.
Possible downsides?
This only applies to the Undertow side. Changes to Dialogue will need to be made separately.