private static Object getFieldValue( Field f, Object obj, boolean useMethodHandles )
		throws IllegalArgumentException
	{
		checkValidField( f );

		if( useMethodHandles && obj instanceof StyleableLookupProvider ) {
			// use method handles to access protected fields in JRE in modular applications
			try {
				MethodHandles.Lookup lookup = ((StyleableLookupProvider)obj).getLookupForStyling();
				return lookup.unreflectGetter( f ).invoke( obj );
			} catch( Throwable ex ) {
				throw newFieldAccessFailed( f, ex );
			}
		}

		try {
			f.setAccessible( true );
			return f.get( obj );
		} catch( IllegalAccessException ex ) {
			throw newFieldAccessFailed( f, ex );
		}
	}
Applies the given value to a field of the given object.

@param obj the object
@param fieldName the name of the field
@param key the key (only used for error reporting)
@param value the new value
@return the old value of the field
@throws UnknownStyleException if object does not have a field with given name
@throws IllegalArgumentException if value type does not fit to expected type
flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatStylingSupport.java