Skip to content

Commit

Permalink
Merge pull request eclipse-openj9#352 from pdbain-ibm/getpackage
Browse files Browse the repository at this point in the history
Class.getPackage() return null for array and primitve classes
  • Loading branch information
keithc-ca authored Oct 17, 2017
2 parents a82451c + 047cbca commit 48484fe
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions jcl/src/java.base/share/classes/java/lang/Class.java
Original file line number Diff line number Diff line change
Expand Up @@ -1784,9 +1784,10 @@ private static String getNonArrayClassPackageName(Class<?> clz) {
/**
* Answers the name of the package to which the receiver belongs.
* For example, Object.class.getPackageName() returns "java.lang".
* Returns null if this class represents an array type, a primitive type or void
* Returns "java.lang" if this class represents a primitive type or void,
* and the element type's package name in the case of an array type.
*
* @return the receiver's package name.
* @return String the receiver's package name
*
* @see #getPackage
*/
Expand Down Expand Up @@ -2159,14 +2160,17 @@ public String toGenericString() {

/**
* Returns the Package of which this class is a member.
* A class has a Package iff it was loaded from a SecureClassLoader
*
* @return Package the Package of which this class is a member or null
* A class has a Package iff it was loaded from a SecureClassLoader.
*
* @return Package the Package of which this class is a member
* or null in the case of primitive or array types
*/
public Package getPackage() {
if (isArray() || isPrimitive()) {
return null;
}
String packageName = getPackageName();
if (packageName == null) {
if (null == packageName) {
return null;
} else {
/*[IF Sidecar19-SE]*/
Expand Down

0 comments on commit 48484fe

Please sign in to comment.