Skip to content

Ambiguous behavior for ClassNameGenerator::generateClassName #28517

Closed
@bclozel

Description

@bclozel

ClassNameGenerator has two variants for the generateClassName feature. One that takes a target Class<?> and another that takes a target String. I'm a bit confused by the concept of a target here and I think we should explain that a bit more in the javadocs.

These methods also have different behavior:

ClassName first = this.generator.generateClassName(java.io.InputStream.class, "bytes");
// will result in java.io.InputStream__Bytes

ClassName first = this.generator.generateClassName("java.io.InputStream", "bytes");
// will result in __.JavaIoInputStream__Bytes

Even if the difference of behavior is intended, the name and docs are very similar. Also, a common use case for the ClassNameGenerator is about generating sources in a specific package to work around visibility issues. The second variant can make this case more difficult to achieve.

As a side note, this class is also referring to the now defunct @see GeneratedClassName.

cc @philwebb @snicoll

Metadata

Metadata

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)theme: aotAn issue related to Ahead-of-time processingtype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions