equal
deleted
inserted
replaced
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 |