Skip to content

Commit 64215cb

Browse files
committed
Refactor
1 parent 1b1c607 commit 64215cb

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

retrolambda/src/main/java/net/orfjackal/retrolambda/lambdas/BackportLambdaInvocations.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2013-2016 Esko Luontola and other Retrolambda contributors
1+
// Copyright © 2013-2017 Esko Luontola and other Retrolambda contributors
22
// This software is released under the Apache License 2.0.
33
// The license text is at http://www.apache.org/licenses/LICENSE-2.0
44

@@ -104,13 +104,7 @@ private boolean isOwnedMethodVisible(Handle implMethod) {
104104
}
105105

106106
private boolean isNonOwnedMethodVisible(Handle implMethod) {
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-
113-
if (classPackage.equals(implPackage)) {
107+
if (getPackage(className).equals(getPackage(implMethod.getOwner()))) {
114108
return true; // All method visibilities in the same package will be visible.
115109
}
116110

@@ -126,6 +120,11 @@ private boolean isNonOwnedMethodVisible(Handle implMethod) {
126120
return true;
127121
}
128122

123+
private static String getPackage(String className) {
124+
int lastSlash = className.lastIndexOf('/');
125+
return lastSlash == -1 ? "" : className.substring(0, lastSlash);
126+
}
127+
129128
private String getLambdaAccessMethodDesc(Handle implMethod) {
130129
if (implMethod.getTag() == H_INVOKESTATIC) {
131130
// static method call -> keep as-is

0 commit comments

Comments
 (0)