Skip to content

AnnotationDto.setAnnotationType accepts invalid type kinds (generic/array/map/set/wildcard) #445

Done

Description

@igel-devin-ai

Summary

AnnotationDto#setAnnotationType(TypeName) accepts any TypeName subclass — including TypeNameGeneric, TypeNameArray, TypeNameMap, TypeNameSet and TypeNameWildcard. None of those can ever be valid annotation types: Java annotations cannot declare type parameters, be arrays, or be wildcards, so an AnnotationDto built with one is unrepresentable and produces broken generated source late in the pipeline instead of failing fast.

Surfaced in #429 review: the annotationType builder shortcuts made it easy to construct such invalid models.

Expected behavior

setAnnotationType (and the builder path) should reject non-plain type kinds with an IllegalArgumentException (or similar), so invalid models fail at construction time. Valid inputs: plain TypeName (incl. nested/plain class types) — the only shapes a real annotation type can have.

Scope

  • validation in AnnotationDto.setAnnotationType
  • tests for rejected kinds and accepted plain types
  • behavior change: strictly it can break callers who (accidentally) relied on the lenient behavior — call out in release notes

Related: #415, split-PR work from #429

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions