JDK14 spec query : MethodHandles:dropLookupMode(int)

Mandy Chung mandy.chung at oracle.com
Mon Mar 9 16:37:10 UTC 2020


I have bcc'ed jdk-dev and add core-libs-dev mailing list where this 
thread should be discussed.

The spec says:

"When dropping|PACKAGE|then the resulting lookup will not 
have|PACKAGE|or|PRIVATE|access.When dropping|MODULE|then the resulting 
lookup will not have|MODULE|,|PACKAGE|, or|PRIVATE|access. If|PUBLIC|is 
dropped then the resulting lookup has no access."

@throws IAE if modeToDrop is a valid mode.

I found the spec is quite clear that there is no condition to require 
the modeToDrop must exist.

Mandy
[1] https://bugs.openjdk.java.net/browse/JDK-8226916

On 3/9/20 3:06 AM, Andrew Leonard wrote:
> Thank you Mandy for raising the bug, I have one more query please, we 
> may want to add to the bug that I am not sure about:
> *testDropLookupMode*() in 
> test/jdk/java/lang/invoke/modules/m3/jdk/test/ModuleAccessTest.java:
>
>  public void testDropLookupMode() throws Exception {
>        Lookup lookup = MethodHandles.privateLookupIn(m5.type1, m4.lookup);
>        assertTrue((lookup.lookupModes() & MODULE) == 0); <--- MODULE 
> doesn't exist
>        ...
>        Lookup lookup3 = lookup.dropLookupMode(MODULE);
> ---> assertTrue(lookup3.lookupModes() == (lookup.lookupModes() & 
> ~(PROTECTED|PRIVATE|PACKAGE)));
>
>
> Based on the expected result above, does it mean PRIVATE, PACKAGE 
> should be dropped whether
> or not MODULE exists in the access mode (PROTECTED is dropped by 
> default) ?
> If so, the document should be updated to explicitly clarify the 
> exception case?
>
> Thanks,
> Andrew
>
> Andrew Leonard
> Java Runtimes Development
> IBM Hursley
> IBM United Kingdom Ltd
> internet email: andrew_m_leonard at uk.ibm.com
>
> Unless stated otherwise above:
> IBM United Kingdom Limited - Registered in England and Wales with 
> number 741598.
> Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU



More information about the core-libs-dev mailing list