RFR: JDK-8216558: Lookup.unreflectSetter(Field) fails to throw IllegalAccessException for final fields

Adam Farley8 adam.farley at uk.ibm.com
Wed Jan 23 16:33:00 UTC 2019


Hi Mandy,

Food for thought:

- From John's email, it looked like he was advocating a clarification 
change to the spec (which requires no CSR).

- A test case is attached to the bug. It displays "current behaviour", but 
doesn't show a clear "pass" or "fail", because at the start of this there 
appeared to be disagreement over what the correct behaviour was.

- Good idea on the new line. I'll add it to the webrev shortly.

- As for the comments, I think I see what John was going for, but I don't 
understand his first change. This seems to be the opposite of what we're 
trying for here.

+     * In the case of a field setter function on a {@code final} field,
+     * finality enforcement is treated as a kind of access control,
+     * and the lookup will fail, except in special cases of
+     * {@link Lookup#unreflectSetter Lookup.unreflectSetter}.

Perhaps he means it will still fail, but for the reasons we've discussed 
rather than anything connected to access control?

Best Regards

Adam Farley 
IBM Runtimes


Mandy Chung <mandy.chung at oracle.com> wrote on 16/01/2019 23:52:03:

> From: Mandy Chung <mandy.chung at oracle.com>
> To: Adam Farley8 <adam.farley at uk.ibm.com>
> Cc: core-libs-dev <core-libs-dev at openjdk.java.net>
> Date: 16/01/2019 23:54
> Subject: Re: RFR: JDK-8216558: Lookup.unreflectSetter(Field) fails 
> to throw IllegalAccessException for final fields
> 
> Hi Adam,

> On 1/14/19 9:10 AM, Adam Farley8 wrote:
> As for the CSR process, I'm unfamiliar with it. I've modified the 
> comment for the unreflectSetter method in the webrev. Do let me know if 
> more needs to be done.
> 
> The CSR process is straight-forward.  CSR FAQ [1] may help you get 
started. 
> 
> As for the fix, John has suggested the spec wording for this issue. 
> It's fine with the unreflectField method to have the explicit check 
> and throw field.makeAccessException(...).   The exception message 
> could match the proposed spec wording like:
>      if(isSetter && field.isStatic() && field.isFinal())
>          throw field.makeAccessException("static final field has no 
> write access", this);
> 
> You have a very long line and the throw statement can start in the 
> next line.  
> 
> In addition, please include a test case for this change.
> 
> Thanks
> Mandy
> [1] https://wiki.openjdk.java.net/display/csr/CSR+FAQs 
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