On 8/22/2022 11:57 AM, Alan Bateman wrote:
On 22/08/2022 18:13, Kasper Nielsen wrote:
Hi,
I understand that the methods are behaving as specified.
However, I still think that
int.class.getPackageName() = "java.lang"
int.class.describeConstable().get().packageName() = ""
is surprising behavior. And should probably as a minimum be
documented on ClassDesc::packageName.
A named module is a set of named packages and it just wouldn't work
for a class in a named module to say that it's in the unnamed package.
As I recall, the original proposal for getPackageName was that it
return null when the class is for an array or primitive class but that
turned out to be a usability issue. The proposal was refined to what
is specified now.
ClassDesc is a nominal descriptor so it's more like parsing a string
to get the package name. I don't disagree that the packageName method
could link to isArray and componentType when the descriptor is for an
array type, or isPrimitive to test if the descriptor is for a
primitive type.
I agree it would be fine to add apiNote/@see/@link tags, etc. , but
don't think any behavior change is justified.
-Joe