Here you can find the source of setField(T object, Field field, ResourceBundle bundle)
private static <T> void setField(T object, Field field, ResourceBundle bundle) throws IllegalAccessException
//package com.java2s; /******************************************************************************* * Copyright (c) 2007, 2013 EclipseSource and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors:/*from w w w . j a va2s . com*/ * EclipseSource - initial API and implementation ******************************************************************************/ import java.lang.reflect.*; import java.util.MissingResourceException; import java.util.ResourceBundle; public class Main { private static <T> void setField(T object, Field field, ResourceBundle bundle) throws IllegalAccessException { try { String value = bundle.getString(field.getName()); if (value != null) { field.setAccessible(true); field.set(object, value); } } catch (MissingResourceException mre) { field.setAccessible(true); field.set(object, ""); throw mre; } } }