<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<p>Hello,<br>
</p>
<p>The method Class.getPackage is behaving as specified:</p>
<p>
<blockquote type="cite">public Package getPackage()<br>
Gets the package of this class.<br>
<br>
If this class represents an array type, a primitive type or
void, this method returns null.</blockquote>
</p>
<p>as is Class.getPackageName():</p>
<p>
<blockquote type="cite">If this class represents an array type
then this method returns the package name of the element type.
If this class represents a primitive type or void then the
package name "<code>java.lang</code>" is returned.</blockquote>
</p>
<p>and ClassDesc.packageName is as well.</p>
<p>Class.getPackage has been doing what it been doing since about
JDK 1.2 so due to behavioral compatibility, there would have to be
a much stronger case for altering its behavior at this point.<br>
</p>
<p>-Joe<br>
</p>
<div class="moz-cite-prefix">On 8/22/2022 2:17 AM, Kasper Nielsen
wrote:<br>
</div>
<blockquote type="cite" cite="mid:CAPs6150rFoZmCQOmY21-04+zyFwzH=9=cLtM4yHYsXTUgEDyng@mail.gmail.com">
<pre class="moz-quote-pre" wrap="">Hi,
I was playing around with java.lang.constant and found an inconsistency between
ClassDesc::packageName and Class::getPackageName as outlined in the table below.
Specifically dealing with primitive and array types.
Class ClassDesc::packageName Class::getPackage Class::getPackageName
---------- ---------------------- ----------------- ---------------------
int "" null "java.lang"
int[] "" null "java.lang"
Integer "java.lang" java.lang "java.lang"
Integer[] "" null "java.lang"
I was originally going to submit a patch for ClassDesc. But I now think
Class::getPackageName is the one that I need to patch. Thoughts?
Thanks,
Kasper
</pre>
</blockquote>
</body>
</html>