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

ObjectReference.setValue() calls ReferenceType.validateFieldSet(), which does:

    void validateFieldSet(Field field) {
        validateFieldAccess(field);
        if (field.isFinal()) {
            throw new IllegalArgumentException("Cannot set value of final 
field");
        }
    }

This code has been in place since the file was introduced on 2007-12-01. If 
there is a version that predates it, I don't know where to look. I'm not sure 
of the history relative to JDK 1.2 and the introduction of JPDA.

Yes, what is being proposed makes the JDI and JDWP specs out of sync, but the 
implementations have always been out of sync. The proposed spec change is just 
clarifying what the implementation already does. However, Eclipse does allow 
the user to set a non-static final field, but only after clicking through a 
warning dialog.

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

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

Reply via email to