gpt4 book ai didi

java - 为什么 google-collections AbstractMultimap 类对成员变量使用 transient 关键字?

转载 作者:行者123 更新时间:2023-12-01 18:45:21 25 4
gpt4 key购买 nike

https://code.google.com/p/google-collections/source/browse/trunk/src/com/google/common/collect/AbstractMultimap.java?r=117

AbstractMultimap 实现了可序列化。

在我看来,实际数据保存在map和totalSize变量中。

但这两个变量都是用 transient 关键字声明的。

这个事实意味着没有序列化,对吗?

private transient Map<K, Collection<V>> map;
private transient int totalSize;

最佳答案

This fact means that there's no serialization right?

没有。

这意味着这些字段没有通过默认序列化机制进行序列化。状态实际上是在子类的 writeObject() 方法中序列化的。

关于java - 为什么 google-collections AbstractMultimap 类对成员变量使用 transient 关键字?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17984503/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com