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

Method getFieldValue

src/bsh/Reflect.java:266–279  ·  view source on GitHub ↗
(Class clas, Object object, String fieldName, boolean staticOnly)

Source from the content-addressed store, hash-verified

264
265
266 private static Object getFieldValue(Class clas, Object object, String fieldName, boolean staticOnly) throws UtilEvalError, ReflectError {
267 try {
268 Field f = resolveExpectedJavaField(clas, fieldName, staticOnly);
269
270 Object value = f.get(object);
271 Class returnType = f.getType();
272 return Primitive.wrap(value, returnType);
273
274 } catch (NullPointerException e) { // shouldn't happen
275 throw new ReflectError("???" + fieldName + " is not a static field.");
276 } catch (IllegalAccessException e) {
277 throw new ReflectError("Can't access field: " + fieldName);
278 }
279 }
280
281 /*
282 Note: this method and resolveExpectedJavaField should be rewritten

Callers 2

getStaticFieldValueMethod · 0.95
getObjectFieldValueMethod · 0.95

Calls 4

wrapMethod · 0.95
getMethod · 0.65
getTypeMethod · 0.45

Tested by

no test coverage detected