natField.cc (getAddr): Allow setting of final field when it is accessible.

* java/lang/reflect/natField.cc (getAddr): Allow setting of final
	field when it is accessible.

From-SVN: r114896
This commit is contained in:
Tom Tromey 2006-06-22 16:59:15 +00:00 committed by Tom Tromey
parent 746907b225
commit 6d82bb8521
2 changed files with 9 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2006-06-22 Tom Tromey <tromey@redhat.com>
* java/lang/reflect/natField.cc (getAddr): Allow setting of final
field when it is accessible.
2006-06-21 Bryce McKinlay <mckinlay@redhat.com> 2006-06-21 Bryce McKinlay <mckinlay@redhat.com>
* include/win32-threads.h (_Jv_ThreadDesc_t): New typedef. * include/win32-threads.h (_Jv_ThreadDesc_t): New typedef.

View File

@ -72,6 +72,10 @@ getAddr (java::lang::reflect::Field* field, jclass caller, jobject obj,
// Setting a final field is usually not allowed. // Setting a final field is usually not allowed.
if (checkFinal if (checkFinal
// As of 1.5, you can set a non-static final field if it is
// accessible.
&& (! field->isAccessible()
|| (field->getModifiers() & java::lang::reflect::Modifier::STATIC))
&& (field->getModifiers() & java::lang::reflect::Modifier::FINAL)) && (field->getModifiers() & java::lang::reflect::Modifier::FINAL))
throw new java::lang::IllegalAccessException(JvNewStringUTF throw new java::lang::IllegalAccessException(JvNewStringUTF
("Field is final")); ("Field is final"));