JDK14 spec query : MethodHandles:dropLookupMode(int)
mandy.chung at oracle.com
Fri Feb 28 20:48:49 UTC 2020
I see the confusion and we should improve the documentation. I have
created JDK-8240242 to improve the javadoc.
I also recommend to check out the Access modes section added in 14 that
gives detail examples on the lookup object resulting from Lookup::in and
On 2/28/20 6:02 AM, Andrew Leonard wrote:
> Thanks for your thoughts Chris,
> I see what you mean... about strictly..
> I'll see if anyone else has any thoughts, then raise a "doc bug" to have
> the wording improved...
> Andrew Leonard
> Java Runtimes Development
> IBM Hursley
> IBM United Kingdom Ltd
> internet email: andrew_m_leonard at uk.ibm.com
> From: Chris Hegarty <chris.hegarty at oracle.com>
> To: Andrew Leonard <andrew_m_leonard at uk.ibm.com>
> Cc: jdk-dev at openjdk.java.net
> Date: 28/02/2020 13:06
> Subject: [EXTERNAL] Re: JDK14 spec query :
>> On 28 Feb 2020, at 12:55, Andrew Leonard <andrew_m_leonard at uk.ibm.com>
>> I'm hoping to get some clarification please on understanding the updated
>> JDK14 spec for MethodHandles:dropLookupMode(int) :
>> the following two testcases seem inconsistent with the spec, but do pass
>> currently with the RI:
>> lookup = fullPowerLookup.dropLookupMode(UNCONDITIONAL);
>> assertTrue(lookup.lookupClass() == lc);
>> assertTrue(lookup.lookupModes() ==
>> (PUBLIC|MODULE|PACKAGE|PRIVATE)); <---
>> jdk14 spec has changed to say:
>> If UNCONDITIONAL is dropped then the resulting lookup has no access.
>> expected); <-------
>> jdk14 spec states:
>> If PUBLIC is dropped then the resulting lookup has no access
>> Which is correct the code/testcase or the jdk14 spec ?
> I had the same observation recently when reading the updated Java 14
> version of this spec. The wording is not strictly incorrect, but could
> benefit from a little clarification.
> The reason I say that it is not _strictly_ incorrect is that it says
> "is dropped". For a lookup mode to actually be dropped then it must
> first be held by the lookup. In your examples the lookup does not hold
> the access mode that is passed to be dropped, so the mode is not
> actually dropped, hence a _no access_ lookup is not returned.
> I think that the implementation is behaving as desired, but I do think
> that the spec wording could be improved a little ( since I had similar
> initial confusion about this point, just as you had ).
> Unless stated otherwise above:
> IBM United Kingdom Limited - Registered in England and Wales with number
> Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU
More information about the jdk-dev