8240242: improve the javadoc for Lookup::dropLookupModes w.r.t. dropping UNCONDITIONAL

Reviewed-by: chegar, rriggs
This commit is contained in:
Mandy Chung 2020-03-12 11:56:49 -07:00
parent d5d6dc0caa
commit e9494f2155

View File

@ -740,11 +740,11 @@ public class MethodHandles {
* The table below shows the access modes of a {@code Lookup} produced by * The table below shows the access modes of a {@code Lookup} produced by
* any of the following factory or transformation methods: * any of the following factory or transformation methods:
* <ul> * <ul>
* <li>{@link #lookup() MethodHandles.lookup()}</li> * <li>{@link #lookup() MethodHandles::lookup}</li>
* <li>{@link #publicLookup() MethodHandles.publicLookup()}</li> * <li>{@link #publicLookup() MethodHandles::publicLookup}</li>
* <li>{@link #privateLookupIn(Class, Lookup) MethodHandles.privateLookupIn}</li> * <li>{@link #privateLookupIn(Class, Lookup) MethodHandles::privateLookupIn}</li>
* <li>{@link Lookup#in}</li> * <li>{@link Lookup#in Lookup::in}</li>
* <li>{@link Lookup#dropLookupMode(int)}</li> * <li>{@link Lookup#dropLookupMode(int) Lookup::dropLookupMode}</li>
* </ul> * </ul>
* *
* <table class="striped"> * <table class="striped">
@ -1524,14 +1524,22 @@ public class MethodHandles {
* Creates a lookup on the same lookup class which this lookup object * Creates a lookup on the same lookup class which this lookup object
* finds members, but with a lookup mode that has lost the given lookup mode. * finds members, but with a lookup mode that has lost the given lookup mode.
* The lookup mode to drop is one of {@link #PUBLIC PUBLIC}, {@link #MODULE * The lookup mode to drop is one of {@link #PUBLIC PUBLIC}, {@link #MODULE
* MODULE}, {@link #PACKAGE PACKAGE}, {@link #PROTECTED PROTECTED} or {@link #PRIVATE PRIVATE}. * MODULE}, {@link #PACKAGE PACKAGE}, {@link #PROTECTED PROTECTED},
* {@link #PROTECTED PROTECTED} is always * {@link #PRIVATE PRIVATE}, or {@link #UNCONDITIONAL UNCONDITIONAL}.
* dropped and so the resulting lookup mode will never have this access capability. *
* When dropping {@code PACKAGE} then the resulting lookup will not have {@code PACKAGE} * <p> If this lookup is a {@linkplain MethodHandles#publicLookup() public lookup},
* or {@code PRIVATE} access. When dropping {@code MODULE} then the resulting lookup will * this lookup has {@code UNCONDITIONAL} mode set and it has no other mode set.
* not have {@code MODULE}, {@code PACKAGE}, or {@code PRIVATE} access. If {@code PUBLIC} * When dropping {@code UNCONDITIONAL} on a public lookup then the resulting
* is dropped then the resulting lookup has no access. If {@code UNCONDITIONAL} * lookup has no access.
* is dropped then the resulting lookup has no access. *
* <p> If this lookup is not a public lookup, then the following applies
* regardless of its {@linkplain #lookupModes() lookup modes}.
* {@link #PROTECTED PROTECTED} is always dropped and so the resulting lookup
* mode will never have this access capability. When dropping {@code PACKAGE}
* then the resulting lookup will not have {@code PACKAGE} or {@code PRIVATE}
* access. When dropping {@code MODULE} then the resulting lookup will not
* have {@code MODULE}, {@code PACKAGE}, or {@code PRIVATE} access.
* When dropping {@code PUBLIC} then the resulting lookup has no access.
* *
* @apiNote * @apiNote
* A lookup with {@code PACKAGE} but not {@code PRIVATE} mode can safely * A lookup with {@code PACKAGE} but not {@code PRIVATE} mode can safely