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
Comment From: philwebb
The String variant was added to support generation where there isn't a single class that can be linked. I think it's currently only used in BeanRegistrationsAotContribution. We should probably rename that method to make it clearer that there is no target class.
I know @snicoll was wondering about the use of the __ package in general, perhaps we can make the generated BeanRegistrations class be in the same package as the @SpringBootApplication class then we can drop the string version entirely.
The ClassNameGenerator should be removed, we dropped that class during the prototype work.
Comment From: snicoll
The second method that takes a String rather than a Class<?> has been removed in 4bd33cb6e0659df2cd0b9fa04feea8fd77e5a16d. I am going to look at the Javadoc and see if we can clarify