< prev index next >
src/java.base/share/classes/java/lang/invoke/MethodHandles.java
Print this page
@@ -1393,17 +1393,11 @@
public MethodHandle findSpecial(Class<?> refc, String name, MethodType type,
Class<?> specialCaller) throws NoSuchMethodException, IllegalAccessException {
checkSpecialCaller(specialCaller, refc);
Lookup specialLookup = this.in(specialCaller);
MemberName method = specialLookup.resolveOrFail(REF_invokeSpecial, refc, name, type);
- Class<?> callerCls = findBoundCallerClass(method);
- boolean restrict = !(method.isPrivate() && Reflection.areNestMates(specialCaller, refc));
-
- if (restrict)
- return specialLookup.getDirectMethod(REF_invokeSpecial, refc, method, callerCls);
- else
- return specialLookup.getDirectMethodNoRestrictInvokeSpecial(refc, method, callerCls);
+ return specialLookup.getDirectMethod(REF_invokeSpecial, refc, method, findBoundCallerClass(method));
}
/**
* Produces a method handle giving read access to a non-static field.
* The type of the method handle will have a return type of the field's
< prev index next >