DefaultMXBeanMappingFactory.java 文件源码

java
阅读 26 收藏 0 点赞 0 评论 0

项目:openjdk-jdk10 作者:
@Override
final Object fromNonNullOpenValue(Object openValue)
        throws InvalidObjectException {
    final Object[] openArray = (Object[]) openValue;
    final Collection<Object> valueCollection;
    try {
        @SuppressWarnings("deprecation")
        Collection<?> tmp = collectionClass.newInstance();
        valueCollection = cast(tmp);
    } catch (Exception e) {
        throw invalidObjectException("Cannot create collection", e);
    }
    for (Object o : openArray) {
        Object value = elementMapping.fromOpenValue(o);
        if (!valueCollection.add(value)) {
            final String msg =
                "Could not add " + o + " to " +
                collectionClass.getName() +
                " (duplicate set element?)";
            throw new InvalidObjectException(msg);
        }
    }
    return valueCollection;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号