File tree 2 files changed +25
-2
lines changed
end-to-end-tests/src/test/java
retrolambda/src/main/java/net/orfjackal/retrolambda/lambdas 2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change
1
+ // Copyright © 2013-2016 Esko Luontola and other Retrolambda contributors
2
+ // This software is released under the Apache License 2.0.
3
+ // The license text is at http://www.apache.org/licenses/LICENSE-2.0
4
+
5
+ import org .junit .Test ;
6
+
7
+ public final class DefaultPackageTest {
8
+ @ Test
9
+ public void method_reference_to_sibling_class () {
10
+ SiblingClass sibling = new SiblingClass ();
11
+ Runnable lambda = sibling ::method ;
12
+ lambda .run ();
13
+ }
14
+ }
15
+
16
+ class SiblingClass {
17
+ void method () {
18
+ }
19
+ }
Original file line number Diff line number Diff line change @@ -104,8 +104,12 @@ private boolean isOwnedMethodVisible(Handle implMethod) {
104
104
}
105
105
106
106
private boolean isNonOwnedMethodVisible (Handle implMethod ) {
107
- String classPackage = className .substring (0 , className .lastIndexOf ('/' ));
108
- String implPackage = implMethod .getOwner ().substring (0 , implMethod .getOwner ().lastIndexOf ('/' ));
107
+ int classNameLastSlash = className .lastIndexOf ('/' );
108
+ String classPackage = classNameLastSlash == -1 ? "" : className .substring (0 , classNameLastSlash );
109
+
110
+ int implMethodLastSlash = implMethod .getOwner ().lastIndexOf ('/' );
111
+ String implPackage = implMethodLastSlash == -1 ? "" : implMethod .getOwner ().substring (0 , implMethodLastSlash );
112
+
109
113
if (classPackage .equals (implPackage )) {
110
114
return true ; // All method visibilities in the same package will be visible.
111
115
}
You can’t perform that action at this time.
0 commit comments