public void setField ( Object instance , String fieldname , boolean isStatic , Object newValue ) throws IllegalAccessException { FieldReaderWriter fieldReaderWriter = locateField ( fieldname ) ; if ( isStatic && ! fieldReaderWriter . isStatic ( ) ) { throw new IncompatibleClassChangeError ( "Expected static field " + fieldReaderWriter . theField . getDeclaringTypeName ( ) + "." + fieldReaderWriter . theField . getName ( ) ) ; } else if ( ! isStatic && fieldReaderWriter . isStatic ( ) ) { throw new IncompatibleClassChangeError ( "Expected non-static field " + fieldReaderWriter . theField . getDeclaringTypeName ( ) + "." + fieldReaderWriter . theField . getName ( ) ) ; } if ( fieldReaderWriter . isStatic ( ) ) { fieldReaderWriter . setStaticFieldValue ( getClazz ( ) , newValue , null ) ; } else { fieldReaderWriter . setValue ( instance , newValue , null ) ; } }
Attempt to set the value of a field on an instance to the specified value .