8205623: Replace use of Class::getPackage with Class::getPackageName
authormchung
Mon, 25 Jun 2018 22:28:04 -0700
changeset 50783 0ed32e0d98e1
parent 50782 e92d48cf94f9
child 50784 57f5cba78093
8205623: Replace use of Class::getPackage with Class::getPackageName Reviewed-by: jjg, erikj
src/java.base/share/classes/jdk/internal/reflect/ReflectionFactory.java
src/java.base/share/classes/sun/util/resources/BreakIteratorResourceBundle.java
src/java.xml/share/classes/javax/xml/catalog/CatalogMessages.java
--- a/src/java.base/share/classes/jdk/internal/reflect/ReflectionFactory.java	Mon Jun 25 22:27:09 2018 -0700
+++ b/src/java.base/share/classes/jdk/internal/reflect/ReflectionFactory.java	Mon Jun 25 22:28:04 2018 -0700
@@ -675,8 +675,14 @@
      * @returns true if the two classes are in the same classloader and package
      */
     private static boolean packageEquals(Class<?> cl1, Class<?> cl2) {
+        assert !cl1.isArray() && !cl2.isArray();
+
+        if (cl1 == cl2) {
+            return true;
+        }
+
         return cl1.getClassLoader() == cl2.getClassLoader() &&
-                Objects.equals(cl1.getPackage(), cl2.getPackage());
+                Objects.equals(cl1.getPackageName(), cl2.getPackageName());
     }
 
 }
--- a/src/java.base/share/classes/sun/util/resources/BreakIteratorResourceBundle.java	Mon Jun 25 22:27:09 2018 -0700
+++ b/src/java.base/share/classes/sun/util/resources/BreakIteratorResourceBundle.java	Mon Jun 25 22:28:04 2018 -0700
@@ -69,7 +69,7 @@
         if (!info.containsKey(key)) {
             return null;
         }
-        String path = getClass().getPackage().getName().replace('.', '/')
+        String path = getClass().getPackageName().replace('.', '/')
                       + '/' + info.getString(key);
         byte[] data;
         try (InputStream is = getResourceAsStream(path)) {
--- a/src/java.xml/share/classes/javax/xml/catalog/CatalogMessages.java	Mon Jun 25 22:27:09 2018 -0700
+++ b/src/java.xml/share/classes/javax/xml/catalog/CatalogMessages.java	Mon Jun 25 22:28:04 2018 -0700
@@ -53,7 +53,7 @@
     public static final String ERR_CREATING_URI = "FailedCreatingURI";
     public static final String ERR_OTHER = "OtherError";
 
-    static final String bundleName = CatalogMessages.class.getPackage().getName() + ".CatalogMessages";
+    static final String bundleName = CatalogMessages.class.getPackageName() + ".CatalogMessages";
     static ResourceBundle resourceBundle;
 
     /**