如何在不强制转换的情况下从状态的合同状态形式获取数据?

How to get data from Contract State form of a state, without casting?

有没有办法从 ContractState 形式的状态数据中检索数据,而无需强制转换?我尝试像下面给出的那样使用反射,但它没有给出值(我猜它正在返回状态字段“status”的元数据)。

historyForId is of type : ArrayList<Map<String,ContractState>>
val temp2 = historyForId.first().get("contractStateData")!!.javaClass.getDeclaredField("status")

添加在 Corda ledger slack 上找到的答案。发现该字段的“isAccessible”被设置为false。通过将“isAccessible”显式指定为 true 解决了该问题。