Skip to content

Eliminate TypeMarkers for simple and one level parameterized types - #3035

Draft
atrocities wants to merge 1 commit into
developfrom
yzhou/remove_most_typemarkers
Draft

Eliminate TypeMarkers for simple and one level parameterized types#3035
atrocities wants to merge 1 commit into
developfrom
yzhou/remove_most_typemarkers

Conversation

@atrocities

@atrocities atrocities commented Aug 26, 2026

Copy link
Copy Markdown

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.

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.
@changelog-app

changelog-app Bot commented Aug 26, 2026

Copy link
Copy Markdown

Generate changelog in changelog/@unreleased

Type (Select exactly one)

  • Feature (Adding new functionality)
  • Improvement (Improving existing functionality)
  • Fix (Fixing an issue with existing functionality)
  • Break (Creating a new major version by breaking public APIs)
  • Deprecation (Removing functionality in a non-breaking way)
  • Migration (Automatically moving data/functionality to a new system)

Description

Encapsulate simple and one level paramaterized types

Check the box to generate changelog(s)

  • Generate changelog entry

@atrocities atrocities changed the title Encapsulate simple and one level paramaterized types Eliminate TypeMarkers for simple and one level parameterized types Aug 26, 2026
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.

1 participant