On Mon, 21 Nov 2022 22:58:54 GMT, Alex Menkov <amen...@openjdk.org> wrote:

> com.sun.jdi.ObjectReference::setValue spec says that final static fields 
> cannot be modified, but openjdk implementation throws 
> IllegalArgumentException for any final fields (static or instance).
> 
> The fix updates the spec to prohibit any final field modification
> CSR: JDK-8281652

I think this one is going to require more investigation as I can't immediately 
tell if this is a spec or implementation issue.

I checked the JDWP spec and the ClassReference/SetValues has "Final fields 
cannot be set" in its spec, so this means that static finals can't be set. 
ObjectReference/SetValues command doesn't have this, so JDWP allows a tool to 
set final fields. So if the change proposed in this PR goes ahead it means that 
JDI and JDWP specs won't be aligned (which is okay, it just needs to be fully 
understood).

Maybe start by digging into the history of ReferenceTypeImpl to see if the spec 
vs. implementation discrepancy dates goes back to JDK 1.2 (when JPDA was added) 
or it crept in at some other time.  Maybe also dig into bug reports to see if 
there has been any complaints about the current behavior.

If the outcome is that spec is changed as proposed then it will require the 
description for IllegalArgumentException to be expanded. If the outcome is to 
allow for changing of some final fields then the spec may need to be updated to 
take account of "non-modifiable final field", as in final fields in hidden 
classes and records. In both cases, the JDWP spec will need to looked at it too.

-------------

PR: https://git.openjdk.org/jdk/pull/11279

Reply via email to