src/java.base/share/classes/sun/invoke/util/VerifyAccess.java
changeset 47722 ce6ff74192fc
parent 47216 71c04702a3d5
child 50735 2f2af62dfac7
equal deleted inserted replaced
47721:d2b306a70bf1 47722:ce6ff74192fc
   330         if (class1.getClassLoader() != class2.getClassLoader())
   330         if (class1.getClassLoader() != class2.getClassLoader())
   331             return false;
   331             return false;
   332         return Objects.equals(class1.getPackageName(), class2.getPackageName());
   332         return Objects.equals(class1.getPackageName(), class2.getPackageName());
   333     }
   333     }
   334 
   334 
   335     /** Return the package name for this class.
       
   336      */
       
   337     public static String getPackageName(Class<?> cls) {
       
   338         assert (!cls.isArray());
       
   339         String name = cls.getName();
       
   340         int dot = name.lastIndexOf('.');
       
   341         if (dot < 0) return "";
       
   342         return name.substring(0, dot);
       
   343     }
       
   344 
       
   345     /**
   335     /**
   346      * Test if two classes are defined as part of the same package member (top-level class).
   336      * Test if two classes are defined as part of the same package member (top-level class).
   347      * If this is true, they can share private access with each other.
   337      * If this is true, they can share private access with each other.
   348      * @param class1 a class
   338      * @param class1 a class
   349      * @param class2 another class
   339      * @param class2 another class