JDK14 spec query : MethodHandles:dropLookupMode(int)
Mandy Chung
mandy.chung at oracle.com
Mon Mar 9 18:55:37 UTC 2020
On 3/9/20 10:45 AM, Chris Hegarty wrote:
> Sure, I guess it somewhat depends on how you see 8240242 [1] turning
> out. 8240242 clearly describes a similar(ish) issue where dropping
> PUBLIC, when it is not currently held, has no effect, i.e. it does not
> result in “no access” - this is either a bug in the implementation, or
> a bug/clarification in the spec. If the latter, then there are some
> scenarios where the outcome of passing a mode to dropLookupMode will
> have some dependency on the actual held modes.
The confusion here is the public lookup with UNCONDITIONAL mode.
In JDK 9, a public lookup has PUBLIC and UNCONDITIONAL modes set
whereas in 14 JDK-8226916 revises public lookup objects with
only UNCONDITIONAL bit set.
Here is the spec clarification I am thinking of that may explain why the
focus is not whether MODULE bit is set or not.
@@ -1524,14 +1524,20 @@
* 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.
* The lookup mode to drop is one of {@link #PUBLIC PUBLIC},
{@link #MODULE
- * MODULE}, {@link #PACKAGE PACKAGE}, {@link #PROTECTED
PROTECTED} or {@link #PRIVATE PRIVATE}.
- * {@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. If {@code PUBLIC}
- * is dropped then the resulting lookup has no access. If
{@code UNCONDITIONAL}
- * is dropped then the resulting lookup has no access.
+ * MODULE}, {@link #PACKAGE PACKAGE}, {@link #PROTECTED PROTECTED},
+ * {@link #PRIVATE PRIVATE}, or {@code UNCONDITIONAL}.
+ * If this lookup has at least {@code PUBLIC} mode then
+ * {@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 result lookup has no
access.
+ *
+ * <p> If this lookup has {@code UNCONDITIONAL} mode, this
lookup is a
+ * {@linkplain MethodHandles#publicLookup() public lookup} and
it has no
+ * other mode set. When dropping {@code UNCONDITIONAL} on a
public lookup
+ * then the resulting lookup has has no access.
*
Is this clearer?
Mandy
More information about the core-libs-dev
mailing list