-
Bug
-
Resolution: Fixed
-
P3
-
5.0
-
b51
-
x86
-
windows_xp
FULL PRODUCT VERSION :
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
ObjectReference.setValue(Field, Value) throws an IllegalArgumentException when the field is final. Whether or not the field is static, the message for the exception is "Cannot set value of static final field".
From the Java 1.4.2 sources (I assume 1.5.0 is much the same),
in file j2se\src\share\classes\com\sun\tools\jdi\ReferenceTypeImpl.java
I see:
void validateFieldSet(Field field) {
validateFieldAccess(field);
if (field.isFinal()) {
throw new IllegalArgumentException("Cannot set value of static
final field");
}
}
This is called from ObjectReferenceImpl.setValue(Field, Value)
or ClassTypeImpl.setValue(Field, Value), and can
clearly be called with a non-static field argument,
but the error message says "static", whether or not
the field is static. This should either just say
"Cannot set value of final field", or say
"static" only when field.isStatic() is true.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Inside of debugger code, call ObjectReference.setValue(Field, Value) for a non-static final field, such as Integer.value.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Expect an IllegalArgumentException with the message "Cannot set value of final field" only for static & final fields.
ACTUAL -
Get an IllegalArgumentException with the message "Cannot set value of static final field" for non-static & final fields.
REPRODUCIBILITY :
This bug can be reproduced always.
###@###.### 2005-2-22 04:54:42 GMT
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
ObjectReference.setValue(Field, Value) throws an IllegalArgumentException when the field is final. Whether or not the field is static, the message for the exception is "Cannot set value of static final field".
From the Java 1.4.2 sources (I assume 1.5.0 is much the same),
in file j2se\src\share\classes\com\sun\tools\jdi\ReferenceTypeImpl.java
I see:
void validateFieldSet(Field field) {
validateFieldAccess(field);
if (field.isFinal()) {
throw new IllegalArgumentException("Cannot set value of static
final field");
}
}
This is called from ObjectReferenceImpl.setValue(Field, Value)
or ClassTypeImpl.setValue(Field, Value), and can
clearly be called with a non-static field argument,
but the error message says "static", whether or not
the field is static. This should either just say
"Cannot set value of final field", or say
"static" only when field.isStatic() is true.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Inside of debugger code, call ObjectReference.setValue(Field, Value) for a non-static final field, such as Integer.value.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Expect an IllegalArgumentException with the message "Cannot set value of final field" only for static & final fields.
ACTUAL -
Get an IllegalArgumentException with the message "Cannot set value of static final field" for non-static & final fields.
REPRODUCIBILITY :
This bug can be reproduced always.
###@###.### 2005-2-22 04:54:42 GMT