File tree 3 files changed +70
-1
lines changed
junit-platform-commons/src/main
java/org/junit/platform/commons/util
java9/org/junit/platform/commons/util
3 files changed +70
-1
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2015-2024 the original author or authors.
3
+ *
4
+ * All rights reserved. This program and the accompanying materials are
5
+ * made available under the terms of the Eclipse Public License v2.0 which
6
+ * accompanies this distribution and is available at
7
+ *
8
+ * https://www.eclipse.org/legal/epl-v20.html
9
+ */
10
+
11
+ package org .junit .platform .commons .util ;
12
+
13
+ import static org .junit .platform .commons .util .PackageUtils .DEFAULT_PACKAGE_NAME ;
14
+
15
+ /**
16
+ * Collection of utilities for working with package names.
17
+ *
18
+ * <h2>DISCLAIMER</h2>
19
+ *
20
+ * <p>These utilities are intended solely for usage within the JUnit framework
21
+ * itself. <strong>Any usage by external parties is not supported.</strong>
22
+ * Use at your own risk!
23
+ *
24
+ * @since 1.11.3
25
+ */
26
+ class PackageNameUtils {
27
+
28
+ static String getPackageName (Class <?> clazz ) {
29
+ Package p = clazz .getPackage ();
30
+ if (p != null ) {
31
+ return p .getName ();
32
+ }
33
+ String className = clazz .getName ();
34
+ int index = className .lastIndexOf ('.' );
35
+ return index == -1 ? DEFAULT_PACKAGE_NAME : className .substring (0 , index );
36
+ }
37
+
38
+ }
Original file line number Diff line number Diff line change @@ -1903,7 +1903,8 @@ private static boolean isPackagePrivate(Member member) {
1903
1903
}
1904
1904
1905
1905
private static boolean declaredInSamePackage (Method m1 , Method m2 ) {
1906
- return m1 .getDeclaringClass ().getPackage ().getName ().equals (m2 .getDeclaringClass ().getPackage ().getName ());
1906
+ return PackageNameUtils .getPackageName (m1 .getDeclaringClass ()).equals (
1907
+ PackageNameUtils .getPackageName (m2 .getDeclaringClass ()));
1907
1908
}
1908
1909
1909
1910
/**
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2015-2024 the original author or authors.
3
+ *
4
+ * All rights reserved. This program and the accompanying materials are
5
+ * made available under the terms of the Eclipse Public License v2.0 which
6
+ * accompanies this distribution and is available at
7
+ *
8
+ * https://www.eclipse.org/legal/epl-v20.html
9
+ */
10
+
11
+ package org .junit .platform .commons .util ;
12
+
13
+ /**
14
+ * Collection of utilities for working with package names.
15
+ *
16
+ * <h2>DISCLAIMER</h2>
17
+ *
18
+ * <p>These utilities are intended solely for usage within the JUnit framework
19
+ * itself. <strong>Any usage by external parties is not supported.</strong>
20
+ * Use at your own risk!
21
+ *
22
+ * @since 1.11.3
23
+ */
24
+ class PackageNameUtils {
25
+
26
+ static String getPackageName (Class <?> clazz ) {
27
+ return clazz .getPackageName ();
28
+ }
29
+
30
+ }
You can’t perform that action at this time.
0 commit comments