开发者

Java Reflection : internals of java.lang.reflect.Field.getDouble(object)

开发者 https://www.devze.com 2023-03-26 08:50 出处:网络
Does anyone know if Field.getDouble(Object) boxes and unboxes a double internally? Th开发者_开发技巧anks,

Does anyone know if Field.getDouble(Object) boxes and unboxes a double internally?

Th开发者_开发技巧anks, RB


If you use Field.getDouble() on a double field, there is no auto boxing/unboxing. This method existed long before this was available.


Per the Sun/Oracle Reflection API tutorial:

When using reflection, type checking only occurs at runtime so there is no opportunity to box the value. ...To eliminate this exception, the problematic line should be replaced by the following invocation of Field.set(Object obj, Object value): f.set(ft, new Integer(43));

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号