MCPcopy Index your code
hub / github.com/beanshell/beanshell / getObjectFieldValue

Method getObjectFieldValue

src/bsh/Reflect.java:210–229  ·  view source on GitHub ↗
(Object object, String fieldName)

Source from the content-addressed store, hash-verified

208 /**
209 */
210 public static Object getObjectFieldValue(Object object, String fieldName) throws UtilEvalError, ReflectError {
211 if (object instanceof This) {
212 return ((This) object).namespace.getVariable(fieldName);
213 } else if (object == Primitive.NULL) {
214 //noinspection ThrowableInstanceNeverThrown
215 throw new UtilTargetError(new NullPointerException("Attempt to access field '" + fieldName + "' on null value"));
216 } else {
217 try {
218 return getFieldValue(object.getClass(), object, fieldName, false/*onlystatic*/);
219 } catch (ReflectError e) {
220 // no field, try property acces
221
222 if (hasObjectPropertyGetter(object.getClass(), fieldName)) {
223 return getObjectProperty(object, fieldName);
224 } else {
225 throw e;
226 }
227 }
228 }
229 }
230
231
232 static LHS getLHSStaticField(Class clas, String fieldName) throws UtilEvalError, ReflectError {

Callers 3

getClassInstanceThisMethod · 0.95
doNameMethod · 0.95

Calls 5

getFieldValueMethod · 0.95
getObjectPropertyMethod · 0.95
getVariableMethod · 0.80
getClassMethod · 0.80

Tested by

no test coverage detected